mirror of
https://https.git.savannah.gnu.org/git/patch.git
synced 2026-01-27 01:44:34 +00:00
Add --follow-symlinks option for backwards compatibility
* src/common.h (follow_symlinks): New variable. * src/patch.c (longopts): Add new --follow-symlinks option. (get_some_switches): Recognize the new option. * src/util.c (stat_file): Follow symlinks if requested. * patch.man: Document the new option. * tests/symlinks: Add test case.
This commit is contained in:
parent
59609b50c5
commit
293415dbcf
@ -600,6 +600,13 @@ diff form.
|
||||
\fB\-s\fP or \fB\*=silent\fP or \fB\*=quiet\fP
|
||||
Work silently, unless an error occurs.
|
||||
.TP
|
||||
\fB\*=follow\-symlinks\fP
|
||||
When looking for input files, follow symbolic links. Replaces the symbolic
|
||||
links, instead of modifying the files the symbolic links point to. Git-style
|
||||
patches to symbolic links will no longer apply. This option exists for
|
||||
backwards compatibility with previous versions of patch; its use is
|
||||
discouraged.
|
||||
.TP
|
||||
\fB\-t\fP or \fB\*=batch\fP
|
||||
Suppress questions like
|
||||
.BR \-f ,
|
||||
|
||||
@ -111,6 +111,7 @@ XTERN bool canonicalize;
|
||||
XTERN int patch_get;
|
||||
XTERN bool set_time;
|
||||
XTERN bool set_utc;
|
||||
XTERN bool follow_symlinks;
|
||||
|
||||
enum diff
|
||||
{
|
||||
|
||||
@ -726,6 +726,7 @@ static struct option const longopts[] =
|
||||
{"quoting-style", required_argument, NULL, CHAR_MAX + 8},
|
||||
{"reject-format", required_argument, NULL, CHAR_MAX + 9},
|
||||
{"read-only", required_argument, NULL, CHAR_MAX + 10},
|
||||
{"follow-symlinks", no_argument, NULL, CHAR_MAX + 11},
|
||||
{NULL, no_argument, NULL, 0}
|
||||
};
|
||||
|
||||
@ -1017,6 +1018,9 @@ get_some_switches (void)
|
||||
else
|
||||
usage (stderr, 2);
|
||||
break;
|
||||
case CHAR_MAX + 11:
|
||||
follow_symlinks = true;
|
||||
break;
|
||||
default:
|
||||
usage (stderr, 2);
|
||||
}
|
||||
|
||||
@ -1652,5 +1652,8 @@ make_tempfile (char const **name, char letter, char const *real_name,
|
||||
|
||||
int stat_file (char const *filename, struct stat *st)
|
||||
{
|
||||
return lstat (filename, st) == 0 ? 0 : errno;
|
||||
int (*xstat)(char const *, struct stat *) =
|
||||
follow_symlinks ? stat : lstat;
|
||||
|
||||
return xstat (filename, st) == 0 ? 0 : errno;
|
||||
}
|
||||
|
||||
@ -54,6 +54,11 @@ File l is not a regular file -- refusing to patch
|
||||
1 out of 1 hunk ignored -- saving rejects to file l.rej
|
||||
Status: 1
|
||||
EOF
|
||||
|
||||
check 'patch --follow-symlinks < modify.diff || echo "Status: $?"' <<EOF
|
||||
patching file l
|
||||
EOF
|
||||
|
||||
# --------------------------------------------------------------
|
||||
|
||||
rm -f f l
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user