summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruen@suse.de>2010-10-05 19:21:35 +0200
committerAndreas Gruenbacher <agruen@suse.de>2010-10-05 19:21:35 +0200
commit3e234c40d29d3ccf01d288c7e56488b259199153 (patch)
tree75e88c2732d45c3413e793064777e7ab5be11c51
parent86e12910c67ce69b5e36592824c053d900031e1e (diff)
downloadpatch-3e234c40d29d3ccf01d288c7e56488b259199153.tar.gz
Only recognize quited filename in the "diff --git" format
* src/util.c: Add a maybe_quoted parameter to fetchname. * src/pch.c: Only recognize quited filename in the "diff --git" format, at least for now. * tests/quoted-filenames: Update accordingly. * NEWS: Update accordingly.
-rw-r--r--ChangeLog40
-rw-r--r--NEWS9
-rw-r--r--src/pch.c8
-rw-r--r--src/util.c6
-rw-r--r--src/util.h2
-rw-r--r--tests/quoted-filenames1
6 files changed, 39 insertions, 27 deletions
diff --git a/ChangeLog b/ChangeLog
index a560133..4c5f53f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+ * src/util.c: Add a maybe_quoted parameter to fetchname.
+ * src/pch.c: Only recognize quited filename in the "diff --git"
+ format, at least for now.
+ * tests/quoted-filenames: Update accordingly.
+ * NEWS: Update accordingly.
+
+2010-09-17 Andreas Gruenbacher <agruen@suse.de>
+
+ * 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.
+
+ * NEWS: Document that "diff --git" criss-cross renames are broken
+ still.
+ * tests/criss-cross: Test case currently expected to fail.
+
+ * tests/criss-cross: Add copy-after-modify test case.
+
+2010-09-16 Andreas Gruenbacher <agruen@suse.de>
+
* src/patch.c (open_outfile): New function.
(init_output): Split into open_outfile() and the rest.
@@ -25,21 +50,6 @@
* src/patch.c (main): Compute TMPOUTNAME with make_tempfile().
(make_temp): Remove obsolete function.
- * 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.
-
- * NEWS: Document that "diff --git" criss-cross renames are broken
- still.
- * tests/criss-cross: Test case currently expected to fail.
-
- * tests/criss-cross: Add copy-after-modify test case.
-
2010-07-27 Tim Waugh <twaugh@redhat.com>
* src/patch.c: Stops "patch --get 1" from segfaulting.
diff --git a/NEWS b/NEWS
index f46f12d..c727782 100644
--- a/NEWS
+++ b/NEWS
@@ -4,10 +4,11 @@
+ In the "diff --git" format, all the patches are relative to the original
state of the files to patch, allowing things like criss-cross renames.
GNU patch will currently fail for such patches.
-* Support for double-quoted filenames: when a filename in a context diff
- starts with a double quote, it is interpreted as a C string literal. The
- escape sequences \\, \", \a, \b, \f, \n, \r, \t, \v, and \ooo (a three-digit
- octal number between 0 and 255) are recognized.
+* Support for double-quoted filenames in the "diff --git" format: when a
+ filename in a context diff starts with a double quote, it is interpreted
+ as a C string literal. The escape sequences \\, \", \a, \b, \f, \n, \r,
+ \t, \v, and \ooo (a three-digit octal number between 0 and 255) are
+ recognized.
* Refuse to patch read-only files by default, or at least warn when patching
such files with --force or --batch.
* Refuse to apply a normal patch to a symlink. (Previous versions of patch
diff --git a/src/pch.c b/src/pch.c
index e51e73e..8e039ff 100644
--- a/src/pch.c
+++ b/src/pch.c
@@ -498,21 +498,21 @@ intuit_diff_type (bool need_header, mode_t *p_file_type)
}
if (!stars_last_line && strnEQ(s, "*** ", 4))
{
- fetchname (s+4, strippath, &p_name[OLD], &p_timestr[OLD],
+ fetchname (s+4, strippath, git_diff, &p_name[OLD], &p_timestr[OLD],
&p_timestamp[OLD]);
need_header = false;
}
else if (strnEQ(s, "+++ ", 4))
{
/* Swap with NEW below. */
- fetchname (s+4, strippath, &p_name[OLD], &p_timestr[OLD],
+ fetchname (s+4, strippath, git_diff, &p_name[OLD], &p_timestr[OLD],
&p_timestamp[OLD]);
need_header = false;
p_strip_trailing_cr = strip_trailing_cr;
}
else if (strnEQ(s, "Index:", 6))
{
- fetchname (s+6, strippath, &p_name[INDEX], (char **) 0, NULL);
+ fetchname (s+6, strippath, git_diff, &p_name[INDEX], (char **) 0, NULL);
need_header = false;
p_strip_trailing_cr = strip_trailing_cr;
}
@@ -653,7 +653,7 @@ intuit_diff_type (bool need_header, mode_t *p_file_type)
{
struct timespec timestamp;
timestamp.tv_sec = -1;
- fetchname (t+4, strippath, &p_name[NEW], &p_timestr[NEW],
+ fetchname (t+4, strippath, git_diff, &p_name[NEW], &p_timestr[NEW],
&timestamp);
need_header = false;
if (timestamp.tv_sec != -1)
diff --git a/src/util.c b/src/util.c
index c9f4801..bd2f39d 100644
--- a/src/util.c
+++ b/src/util.c
@@ -1366,8 +1366,8 @@ strip_leading_slashes (char *name, int strip_leading)
/* Make filenames more reasonable. */
void
-fetchname (char const *at, int strip_leading, char **pname, char **ptimestr,
- struct timespec *pstamp)
+fetchname (char const *at, int strip_leading, bool maybe_quoted, char **pname,
+ char **ptimestr, struct timespec *pstamp)
{
char *name;
const char *t;
@@ -1381,7 +1381,7 @@ fetchname (char const *at, int strip_leading, char **pname, char **ptimestr,
if (debug & 128)
say ("fetchname %s %d\n", at, strip_leading);
- if (*at == '"')
+ if (maybe_quoted && *at == '"')
{
name = parse_c_string (at, &t);
if (! name)
diff --git a/src/util.h b/src/util.h
index 9635351..521d098 100644
--- a/src/util.h
+++ b/src/util.h
@@ -38,7 +38,7 @@ void fatal (char const *, ...)
void pfatal (char const *, ...)
__attribute__ ((noreturn, format (printf, 1, 2)));
-void fetchname (char const *, int, char **, char **, struct timespec *);
+void fetchname (char const *, int, bool, char **, char **, struct timespec *);
char *parse_name (char const *, int, char const **);
char *savebuf (char const *, size_t);
char *savestr (char const *);
diff --git a/tests/quoted-filenames b/tests/quoted-filenames
index e10bfa8..568f628 100644
--- a/tests/quoted-filenames
+++ b/tests/quoted-filenames
@@ -18,6 +18,7 @@ use_tmpdir
# \ / : * ? " < > |
cat > d.diff <<EOF
+diff --git " \\t\\040" " \\t\\040"
--- " \\t\\040"
+++ " \\t\\040"
@@ -1 +1 @@