mirror of
https://https.git.savannah.gnu.org/git/patch.git
synced 2026-01-27 01:44:34 +00:00
When applying an empty patch to a file and -o is given, copy the input file to the output file
This commit is contained in:
parent
17c16b669c
commit
19947785bf
@ -20,6 +20,10 @@
|
||||
* tests/unmodified-files: New test case.
|
||||
* Makefile.in (TESTS): Add test case.
|
||||
|
||||
* patch.c (main): New apply_empty_patch variable. When applying an
|
||||
empty patch to a file and -o is given, copy the input file to the
|
||||
output file.
|
||||
|
||||
2009-03-24 Andreas Gruenbacher <agruen@suse.de>
|
||||
|
||||
* patch.c (abort_hunk_unified, abort_hunk_context): Preserve
|
||||
|
||||
13
patch.c
13
patch.c
@ -123,6 +123,7 @@ main (int argc, char **argv)
|
||||
struct stat outst;
|
||||
char numbuf[LINENUM_LENGTH_BOUND + 1];
|
||||
bool written_to_rejname = false;
|
||||
bool apply_empty_patch = false;
|
||||
|
||||
exit_failure = 2;
|
||||
program_name = argv[0];
|
||||
@ -178,10 +179,17 @@ main (int argc, char **argv)
|
||||
/* Make sure we clean up in case of disaster. */
|
||||
set_signals (false);
|
||||
|
||||
if (inname && outfile)
|
||||
{
|
||||
apply_empty_patch = true;
|
||||
inerrno = -1;
|
||||
}
|
||||
for (
|
||||
open_patch_file (patchname);
|
||||
there_is_another_patch (! (inname || posixly_correct));
|
||||
reinitialize_almost_everything()
|
||||
there_is_another_patch (! (inname || posixly_correct))
|
||||
|| apply_empty_patch;
|
||||
reinitialize_almost_everything(),
|
||||
apply_empty_patch = false
|
||||
) { /* for each patch in patch file */
|
||||
int hunk = 0;
|
||||
int failed = 0;
|
||||
@ -343,7 +351,6 @@ main (int argc, char **argv)
|
||||
}
|
||||
|
||||
/* Finish spewing out the new file. */
|
||||
assert (hunk);
|
||||
if (! spew_output (&outstate, &outst))
|
||||
{
|
||||
say ("Skipping patch.\n");
|
||||
|
||||
@ -37,3 +37,24 @@ Status: 1
|
||||
EOF
|
||||
|
||||
ncheck 'test a -ef a.first'
|
||||
|
||||
# ==============================================================
|
||||
|
||||
# When applying an empty patch to a file with -o, copy the input file.
|
||||
|
||||
cat > a.diff <<EOF
|
||||
EOF
|
||||
|
||||
echo three > a
|
||||
|
||||
check 'patch -o b a < a.diff' <<EOF
|
||||
patching file a
|
||||
EOF
|
||||
|
||||
check 'cat b' <<EOF
|
||||
three
|
||||
EOF
|
||||
|
||||
check 'patch -b -o b a < a.diff' <<EOF
|
||||
patching file a
|
||||
EOF
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user