rediff removes comments from patch files
When using rediff <ORIGINAL> <EDITED> to correct a manually modified patch file, comment lines present in the edited patch are removed from the output patch, which makes the difference between the edited patch and the output patch far more than necessary.
It looks like only comments starting the edited patch file are kept. Comments in the middle of the patch file are removed.
The only workaround I found, for the moment, is to manually modify the output patch to add the comments back, but that's tedious and error-prone.
Could you please supply input files that demonstrate the problem?
Let's say I have a few sample C source files inside old/: a.c, b.c and c.c. See: a.zip
I copy old/ into new/ then I modify all three files, and then I issue the following:
$ diff -rpU 3 old new > diff.patch
$ cp diff.patch diff.patch.original
$ rediff diff.patch.original diff.patch > diff.patch.new
$ diff -rpU 3 diff.patch.original diff.patch.new
the output of the last command is:
--- diff.patch.original 2021-01-07 14:02:03.948383400 -0500
+++ diff.patch.new 2021-01-07 14:03:25.048376569 -0500
@@ -8,7 +8,6 @@ diff -rpU 3 old/a.c new/a.c
+ puts("three");
+ puts("four");
}
-diff -rpU 3 old/b.c new/b.c
--- old/b.c 2021-01-07 14:01:33.088385854 -0500
+++ new/b.c 2021-01-07 13:57:03.824402898 -0500
@@ -1,6 +1,11 @@
@@ -23,7 +22,6 @@ diff -rpU 3 old/b.c new/b.c
int function200() {
puts("two hundred");
puts("two hundred one");
-diff -rpU 3 old/c.c new/c.c
--- old/c.c 2021-01-07 14:01:40.232385294 -0500
+++ new/c.c 2021-01-07 13:57:31.352401585 -0500
@@ -1,3 +1,6 @@
This indicates that the comments in the middle of diff.patch were removed. Only the comments at the beginning of the file were kept.
I hope this illustrates the issue clearly.