rkarivuraj / coderev

Automatically exported from code.google.com/p/coderev
GNU General Public License v2.0
0 stars 0 forks source link

Auto detecting reverse patch does not always work #4

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
coderev.sh depends on patch(1) to detect reverse patch automatically,
unfortunately patch(1) does not always identify a reverse patch set, make
the logic broken and produce incorrect web pages.

Typical case happens on newly add files (for svn).

Following steps demonstrated the concept -

First, generate a diff from an empty file and a non-empty file (same as svn
diff of a newly added file) 

$ cp /etc/issue foo
$ cat foo
Red Hat Enterprise Linux Server release 5 (Tikanga)
Kernel \r on an \m

$ touch foo.0
$ diff -u foo.0 foo
--- foo.0       2010-03-12 09:54:58.000000000 +0000
+++ foo 2010-03-12 09:54:28.000000000 +0000
@@ -0,0 +1,3 @@
+Red Hat Enterprise Linux Server release 5 (Tikanga)
+Kernel \r on an \m
+
$ diff -u foo.0 foo > diff

Patch file "diff" is ready, now try dry-run patch(1), it does not report
"reverse patch"!

$ patch -p0 -i diff --dry-run
patching file foo

If I do real patching, the file will be incorrectly patched!

$ patch -p0 -i diff
patching file foo
$ cat foo
Red Hat Enterprise Linux Server release 5 (Tikanga)
Kernel \r on an \m

Red Hat Enterprise Linux Server release 5 (Tikanga)
Kernel \r on an \m

Original issue reported on code.google.com by matt...@gmail.com on 12 Mar 2010 at 10:04

GoogleCodeExporter commented 9 years ago
If we are not receiving patch set from stdin and not using "-r" option, it
then means we are working on patch set from default "<vcs> diff", in this
case "patch -R" is required, otherwise we try patch (dry-run) to detect
errors and reverse patch in advance, then do real patch.

Fixed in r39.

Original comment by matt...@gmail.com on 15 Mar 2010 at 3:56