views:

188

answers:

3

I need to know if the two patches are effectively the same.

I have an old patch file and new patch file created with the unix diff command. Just diff'ing the patches reports differences due to the timestamp when the patch was created.

Is there a way (with diff?) that can reliably tell me if the two patches are effectively the same?

+3  A: 

You could apply both patches to copies of the same source file and then use diff normally to check for differences in the results.

Patches represent changes to the input files, so two patches are the same if they have the same effect on the input files. Differences in patches are directly reflected in differences of the results of those patches.

Any differences between two patches that don't result in a difference in the result of those patches are irrelevant.

sth
+7  A: 

Use interdiff from patchutils.

ephemient
Thanks ephemient. This is just the ticket.
srking
Unfortunately, after getting into it interdiff failed me. First there is no return code like diff and second it improperly generated tons of differences between two big but otherwise identical patches.
srking
Hmm. The return code is zero either way, but if the two diffs are identical there should be no output at all. Are any filenames changed between the two diffs? I tested `interdiff` just now on a few 80kB text files with roughly 20kB of changes, and it worked fine at recognizing differing diffs.
ephemient
Ah you are right. I visually checked the patches with vimdiff and the top directory name had a small change. Interdiff was being honest after all. Thanks!!
srking
You may find `filterdiff --strip=[n]` useful to remove leading components from the paths in your patches.
ephemient
A: 

You could try Beyond Compare.

It can be configured to replace strings in one or both files with something else, which it then does under the covers. The files on screen still look like they exist on disk, but the differences are according to the processed files.

With that you can configure it to change all text that has a format like a timestamp to something common in both files, and then you'll only compare everything else.

In the Windows client, to change these settings, in the toolbar there is a button with a small symbol that looks like a man, torso and head, and in the dialog that opens, there is a tab for Replacements.

Lasse V. Karlsen
Thanks, but i need an open-source tool since an unknown number of users will be executing the patch compare.
srking
Ok, but if all you need to find out is if they're same, except for the timestamps, perhaps you should just do an AWK or SED or similar on the file to transform it, so that the timestamps are equal, and then you can run any type of diff you want on the files.
Lasse V. Karlsen
Or is the patch process more like "given the original file, patch it with one of the files, then patch the same original file with the other file, then compare the results of the two patch operations", so that the actual patches might contain different data, but they end up with the same result?
Lasse V. Karlsen