bug-patch
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-patch] [request] Add option -I <regexp> for matching context


From: Urs Thuermann
Subject: [bug-patch] [request] Add option -I <regexp> for matching context
Date: 12 Nov 2009 09:00:08 +0100
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

When applying diffs generated by CVS or SVN I sometimes (in one
current project quite often) have the problem that the context of the
patch contains keywords like $Id$ which cause patch to not find the
position to apply the patch.  This happens if the line containing $Id$
directly precedes or succeeds the changed lines.  Then, with 3 lines
of context the default fuzz of 2 means that one line of context must
match, which it doesn't.  For example

janus:test$ svn cat -r1 foo
# $Id: foo 1 2009-11-12 05:24:39Z urs $
foo
cl1
cl2
cl3
cl4
janus:test$ svn cat -r2 foo
# $Id: foo 2 2009-11-12 05:24:54Z urs $
bar
cl1
cl2
cl3
cl4
janus:test$ svn diff -c2 foo
Index: foo
===================================================================
--- foo (revision 1)
+++ foo (revision 2)
@@ -1,5 +1,5 @@
 # $Id$
-foo
+bar
 cl1
 cl2
 cl3
janus:test$ svn up -r1 foo
U    foo
Updated to revision 1.
janus:test$ svn diff -c2 foo | patch foo
patching file foo
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file foo.rej


I would like to see an option -I with an regexp argument, that,
similar to diff, considers lines in the file to be patched and lines
in the patch to be matching, if they match the regular expression.

In the example above, you could then call patch as follows

        svn diff -c2 foo | patch -I '$Id.*$' foo

to apply the patch successfully.  My current (somewhat risky)
workaround patch -F3 could then be avoided.


urs




reply via email to

[Prev in Thread] Current Thread [Next in Thread]