I have an product (say version 1) and there are some custom changes made to it (say version 1.x). I am running a diff on these versions and creating a patch file.
Now there is a later version of the product (say version 2). I wish to apply the patch created from version 1 and version 1.x onto version 2.
The difficulty here is that the line numbers will not remain constant.
I understand there might be some failed hunks as well but atleast it will save me a lot of manual effort if I can apply the patch on version 2 (by ignoring the line numbers but by referring the lines below and above).
What's the best way to go about it? Any suggestions?
Also any useful tools which can help here?
Thanks!
Gaurav
Patch will do that normally. You'll see it say something like
Hunk #1 succeeded at 6 (offset 5 lines).
when it applies a patch at a different line number from the original.
If some of the neighboring lines have changed, but there is still enough context to determine where to apply the patch, it will say with fuzz N
where N is the number of context lines that didn't match.
I was having the same problem with unified diffs. It worked using context
diffs as shown bellow:
Creating the patch:
diff -c original.file modified.file > my.patch
Applying the patch:
patch -p0 --fuzz 500 --ignore-whitespace < my.patch
After that we need to check for mismatches:
Generate a diff on the destination folder between the original and the modified files
diff -c destination.file.orig destination.file > second.patch
Compare the patch from the source folder with the patch from the destination folder. I generally do this using the midnight commander's compare files command on Linux+Mac and WinMerge on Windows.