summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruen@suse.de>2010-09-17 12:19:43 +0200
committerAndreas Gruenbacher <agruen@suse.de>2010-09-17 12:19:43 +0200
commit19aecf81082fa21b47e59a3a3b828efdd82be82f (patch)
tree05765fb3106109520a5ffd9d3e767a8d158adf1f
parentb73bec8e457560c5b9a19c303071f35c2e0fa936 (diff)
downloadpatch-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--ChangeLog7
-rw-r--r--src/inp.c12
-rw-r--r--src/patch.c19
-rw-r--r--tests/copy-rename18
-rw-r--r--tests/unmodified-files2
5 files changed, 32 insertions, 26 deletions
diff --git a/ChangeLog b/ChangeLog
index b1e1f3d..0db1863 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/src/inp.c b/src/inp.c
index bf22304..28c548d 100644
--- a/src/inp.c
+++ b/src/inp.c
@@ -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