summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruen@suse.de>2009-05-12 21:54:01 +0200
committerAndreas Gruenbacher <agruen@suse.de>2009-05-12 21:55:35 +0200
commit917aa4f4f112d79b73ffa4d5cc5e36b225a033f3 (patch)
tree0b7eb7e92f883c1d014b2317607d4ddb22052fcc
parent889d33db47d8266e5796d61d87125dd1192007cb (diff)
downloadpatch-917aa4f4f112d79b73ffa4d5cc5e36b225a033f3.tar.gz
When the file to patch is specified on the command line, apply all patches to that file
-rw-r--r--ChangeLog19
-rw-r--r--Makefile.in1
-rw-r--r--NEWS8
-rw-r--r--src/patch.c4
-rw-r--r--tests/inname39
5 files changed, 68 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 2083756..752142a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2009-05-12 Andreas Gruenbacher <agruen@suse.de>
+
+ * src/merge.c (locate_merge): Make sure to return a line number
+ bigger than last_frozen_line.
+
+ * src/patch.c (explicit_inname): New variable.
+ (get_some_switches): Set to true when the filename to patch has been
+ specified on the command line.
+ (reinitialize_almost_everything): Do not reset the input filename
+ between patches when it has been specified on the command line.
+ * tests/inname: New test case.
+ * Makefile.in: Add test case.
+
+2009-04-11 Vincent Legoll <vincent.legoll@gmail.com>
+
+ * src/patch.c (main): Always set patch_get to 0 unless PATCH_GET is
+ set.
+ * patch.man: Update accordingly.
+
2009-04-11 Andreas Gruenbacher <agruen@suse.de>
* update-version.sh, configure.ac, Makefile.in: Portability
diff --git a/Makefile.in b/Makefile.in
index 1798557..27eb598 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -188,6 +188,7 @@ TESTS = \
tests/create-delete \
tests/crlf-handling \
tests/global-reject-files \
+ tests/inname \
tests/line-numbers \
tests/merge \
tests/munged-context-format \
diff --git a/NEWS b/NEWS
index aa9451b..30829ac 100644
--- a/NEWS
+++ b/NEWS
@@ -14,12 +14,16 @@
intermediary versions.
* In the above situation, if there are rejects in more than one of those
patches, they all go into the same reject file.
-* The -r option works correctly even if there are rejects in more than
+* When the file to be patched is specified on the command line, all patches
+ are applied to that file. (Previously, the first patch was applied to the
+ file specified on the command line, and the names of additional files to
+ patch were taken from header lines in the patch file.)
+* The -r option now works correctly even if there are rejects in more than
one file. Use the - argument to discard rejects.
* Rejected hunks come out in unified diff format if the input patch was of
that format, otherwise in ordinary context diff form. Use the
--reject-format option to enforce either "context" or "unified" format.
- The "diff -p" (--show-c-function) output is preserved.
+ Timestamps and the "diff -p" (--show-c-function) output are preserved.
Changed lines in context format reject files are correctly indicated
with '!' markers as the format defines. Added and removed lines are
still marked with '+' and '-', respectively.
diff --git a/src/patch.c b/src/patch.c
index 1fd9443..79718a7 100644
--- a/src/patch.c
+++ b/src/patch.c
@@ -68,6 +68,7 @@ static bool backup_if_mismatch;
static char const *version_control;
static char const *version_control_context;
static bool remove_empty_files;
+static bool explicit_inname;
/* true if -R was specified on command line. */
static bool reverse_flag_specified;
@@ -494,7 +495,7 @@ reinitialize_almost_everything (void)
input_lines = 0;
last_frozen_line = 0;
- if (inname) {
+ if (inname && ! explicit_inname) {
free (inname);
inname = 0;
}
@@ -840,6 +841,7 @@ get_some_switches (void)
if (optind < Argc)
{
inname = savestr (Argv[optind++]);
+ explicit_inname = true;
invc = -1;
if (optind < Argc)
{
diff --git a/tests/inname b/tests/inname
new file mode 100644
index 0000000..a6d4d37
--- /dev/null
+++ b/tests/inname
@@ -0,0 +1,39 @@
+# Copyright (C) 2009 Free Software Foundation, Inc.
+#
+# Copying and distribution of this file, with or without modification,
+# in any medium, are permitted without royalty provided the copyright
+# notice and this notice are preserved.
+
+# Don't recognize hunks before a filename has been specified/seen
+
+. $srcdir/test-lib.sh
+
+require_cat
+use_local_patch
+use_tmpdir
+
+# ==============================================================
+
+cat > f.diff <<EOF
+--- a
++++ b
+@@ -1 +1 @@
+-one
++two
+--- c
++++ d
+@@ -1 +1 @@
+-two
++three
+EOF
+
+echo one > x
+
+check 'patch x < f.diff' <<EOF
+patching file x
+patching file x
+EOF
+
+check 'cat x' <<EOF
+three
+EOF