6

Is there a diff tool that allows saving of the compare markup?

To clarify, I would like to save the actual comparison of the two files that shows the differences to send to someone for review.


EDIT

Lots of good answers here. In my case I already had a copy of Beyond Compare but didn't see the option. Thanks to John Saunders for pointing out the feature. It's "Session...Text Compare Report..." BTW.

My question was not specifically about Beyond Compare, so I am going to accept the answer that currently has the most up votes.

TWA
  • 12,756
  • 13
  • 56
  • 92

5 Answers5

14

WinMerge is free and allows you to save the differences in various formats. It works well enough for me to not bother looking elsewhere, and I like the price.

There is also a portable version if you can't, or don't want to, install it.

Rich Seller
  • 83,208
  • 23
  • 172
  • 177
  • 3
    Perhaps a few details on how to do this could be useful. Am probably missing something but in version 2.14.0.0, the only way I could see to do this was via Tools - Generate Report (which only gives the option of saving as HTML). – Steve Chambers Nov 19 '15 at 11:03
  • 1
    @SteveChambers There is actually a way to obtain something more usable. For some reason, they call it "Patch". Click on "Tool", and then on "Generare Patch", and then you'll obtain a simple, usable diff of your two files in a text format. Cf. my answer at https://stackoverflow.com/a/48878453/2657549 (Using version 2.14.0.0 as well) – Clément Feb 20 '18 at 05:31
  • [WinMerge](http://winmerge.org/downloads/source-code.php) is actually free as in "free speech". Its source code [is there](http://winmerge.org/downloads/source-code.php), and it is under [GNU General Public License](http://www.gnu.org/licenses/gpl-2.0.html). I think this is an important aspect. – Clément Feb 21 '18 at 20:59
5

You can do this with the command line diff if you're using Unix, though it sounds like you're not. Cygwin does bring a CLI diff, and Mac OS X ships with it.

$ diff <file> <other file> > mydiff.txt
Mitch Haile
  • 11,716
  • 2
  • 28
  • 25
3

Beyond Compare does this.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
  • 1
    I actually have a trial of Beyond Compare but didn't see the option at first. Just choose "Session...Text Compare Report..." and there it is. Beyond Compare FTW. :) – TWA Jul 10 '09 at 15:02
2

I use the Scintilla Text Editor (SciTE) to open a diff file generated by command line or WinMerge, and then export the RTF, and it preserves color highlighting of differences. I use this method especially when emailing short patches for review in-house, and I use Outlook, for example.

The process I used just now as an example:

# diff -U 1000 a.txt b.txt > diff.txt
# scite diff.txt
### Edit-Copy as RTF
### Paste into Outlook

http://imagebin.ca/img/nBG25am.png

WinMerge provides this functionality through the Tools->Generate Patch menu item. I use the MSYS tools on windows, so that I run GNU diff a lot, but once you get the output, I would use SciTE if you need something like the above.

maxwellb
  • 13,366
  • 2
  • 25
  • 35
1

ExamDiff does a comparison which is shown in a window. It can save a Unix-like formatted version of the differences. Also, the file-to-file comparison version of the program is free!

PTBNL
  • 6,042
  • 4
  • 28
  • 34