Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rediff removes comments from patch files #48

Open
koutheir opened this issue Jan 6, 2021 · 2 comments
Open

rediff removes comments from patch files #48

koutheir opened this issue Jan 6, 2021 · 2 comments

Comments

@koutheir
Copy link

koutheir commented Jan 6, 2021

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.

@twaugh
Copy link
Owner

twaugh commented Jan 7, 2021

Could you please supply input files that demonstrate the problem?

@koutheir
Copy link
Author

koutheir commented Jan 7, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants