diff options
author | Andreas Gruenbacher <agruen@suse.de> | 2010-09-17 12:19:43 +0200 |
---|---|---|
committer | Andreas Gruenbacher <agruen@suse.de> | 2010-09-17 12:19:43 +0200 |
commit | 19aecf81082fa21b47e59a3a3b828efdd82be82f (patch) | |
tree | 05765fb3106109520a5ffd9d3e767a8d158adf1f | |
parent | b73bec8e457560c5b9a19c303071f35c2e0fa936 (diff) | |
download | patch-19aecf81082fa21b47e59a3a3b828efdd82be82f.tar.gz |
Fix the "patching file" message for renames and copies
* src/patch.c (main): Generate the "patching file" message here. When
the input and output file name is not he same, include both names in
the message.
* src/inp.c (scan_input): Previously the "patching file" message was
generated here.
* tests/unmodified-files, tests/copy-rename: Update.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | src/inp.c | 12 | ||||
-rw-r--r-- | src/patch.c | 19 | ||||
-rw-r--r-- | tests/copy-rename | 18 | ||||
-rw-r--r-- | tests/unmodified-files | 2 |
5 files changed, 32 insertions, 26 deletions
@@ -27,6 +27,13 @@ * src/inp.c (scan_input): Remove double quotearg(). + * src/patch.c (main): Generate the "patching file" message here. When + the input and output file name is not he same, include both names in + the message. + * src/inp.c (scan_input): Previously the "patching file" message was + generated here. + * tests/unmodified-files, tests/copy-rename: Update. + 2010-07-27 Tim Waugh <twaugh@redhat.com> * src/patch.c: Stops "patch --get 1" from segfaulting. @@ -88,18 +88,6 @@ scan_input (char *filename, mode_t file_type) } plan_b(filename); } - - if (verbosity != SILENT) - { - if (verbosity == VERBOSE) - say ("Patching %s %s using Plan %s...\n", - S_ISLNK (file_type) ? "symbolic link" : "file", - quotearg (filename), using_plan_a ? "A" : "B"); - else - say ("patching %s %s\n", - S_ISLNK (file_type) ? "symbolic link" : "file", - quotearg (filename)); - } } /* Report whether a desired revision was found. */ diff --git a/src/patch.c b/src/patch.c index ebf2a26..f849589 100644 --- a/src/patch.c +++ b/src/patch.c @@ -275,9 +275,26 @@ main (int argc, char **argv) } /* find out where all the lines are */ - if (!skip_rest_of_patch) + if (!skip_rest_of_patch) { scan_input (inname, file_type); + if (verbosity != SILENT) + { + bool renamed = strcmp (inname, outname); + + say ("patching %s %s%c", + S_ISLNK (file_type) ? "symbolic link" : "file", + quotearg (outname), renamed ? ' ' : '\n'); + if (renamed) + say ("(%s from %s)\n", + pch_copy () ? "copied" : + (pch_rename () ? "renamed" : "read"), + inname); + if (verbosity == VERBOSE) + say ("Using Plan %s...\n", using_plan_a ? "A" : "B"); + } + } + /* from here on, open no standard i/o files, because malloc */ /* might misfire and we can't catch it easily */ diff --git a/tests/copy-rename b/tests/copy-rename index d8d376a..ac40f1e 100644 --- a/tests/copy-rename +++ b/tests/copy-rename @@ -28,9 +28,8 @@ copy to g +new EOF -# FIXME: the message is confusing ... check 'patch -p1 < copy.diff || echo "Status: $?"' <<EOF -patching file f +patching file g (copied from f) EOF check 'cat f' <<EOF @@ -52,9 +51,8 @@ rename to h +new EOF -# FIXME: the message is confusing ... check 'patch -p1 < rename.diff || echo "Status: $?"' <<EOF -patching file f +patching file h (renamed from f) EOF ncheck 'test ! -e f' @@ -75,9 +73,8 @@ copy from f copy to g EOF -# FIXME: the message is confusing ... check 'patch -p1 < copy.diff || echo "Status: $?"' <<EOF -patching file f +patching file g (copied from f) EOF check 'cat f' <<EOF @@ -94,9 +91,8 @@ rename from f rename to h EOF -# FIXME: the message is confusing ... check 'patch -p1 < rename.diff || echo "Status: $?"' <<EOF -patching file f +patching file h (renamed from f) EOF ncheck 'test ! -e f' @@ -111,9 +107,8 @@ EOF echo old > f rm -f g h -# FIXME: the message is confusing ... check 'patch -p1 --backup < copy.diff || echo "Status: $?"' <<EOF -patching file f +patching file g (copied from f) EOF ncheck 'test ! -e f.orig' @@ -122,9 +117,8 @@ ncheck 'cat g.orig' rm -f f.orig g.orig -# FIXME: the message is confusing ... check 'patch -p1 --backup < rename.diff || echo "Status: $?"' <<EOF -patching file f +patching file h (renamed from f) EOF check 'cat f.orig' <<EOF diff --git a/tests/unmodified-files b/tests/unmodified-files index e54777a..335787a 100644 --- a/tests/unmodified-files +++ b/tests/unmodified-files @@ -51,7 +51,7 @@ EOF echo three > a check 'patch -o b a < a.diff' <<EOF -patching file a +patching file b (read from a) EOF check 'cat b' <<EOF |