The output of the `diff` command is the defacto standard for displaying and distributing file differences (AKA patches) on UNIX systems. Comparing versions of source code is the usual application, but "diffs" are generally useful for comparing entities by formatting them as lines of text so that they can be compared.

However I find it very difficult to read the output from the diff command. At the terminal, the VIM editor will syntax highlight opened diff files which helps, or even a simple script can be used for this. However I find side by side comparison of files much easier to interpret, and given the current trend towards wider screens, this is quite practical. Note that to ease side by side comparison of files, it's another good reason to restrict the line lengths in your files, preferably to less than 80 characters.

Mergely

mergely provides both javascript source to integrate a side by side viewer/editor into your website/browser, and an online instance for use. One can upload local files, or even link to arbitrary URLs so that one gets a dynamic diff viewer. Below for example we show all the changes made to my l script through github, and one can click on the picture to get an up to date view in your browser (Notice the use of lhs and rhs URL parameters in the link).

Mozilla Thunderbird - Colored Diffs addon

The "Colored Diffs" addon is available for the email client I use, Thunderbird. I get a lot of email containing patches either directly from SCM systems, or from mailing lists of open source projects, so this addon helps me parse these quickly. There are useful options like highlighting whitespace so one can see whitespace damage that email clients are prone to do. By hovering over the screenshot below one can see the standard Thunderbird display without the addon.

Tkdiff

Tkdiff is actually part of the TkCVS project, and was the graphical diff tool I used mostly for the last 7 years. It has separate utilities for merging (tkmerge) and managing repositories (tkcvs), and is very functional, with interline diffs etc. However it has some problems mainly due to the poorly maintained tools it's built on, i.e. Tcl/Tk. The main problem I noticed was the very slow cold cache startup because the disk went into a seek storm. I analysed this a bit using strace, and it's because Tcl essentially does find /usr/lib/ /usr/share/ -maxdepth 2 -type f -name pkgIndex.tcl looking for packages to load, on each startup. Coincidentally I notice that Tcl/Tk 8.5 has just been released after 5 years of development. There is mention of fixing this performance issue with new support for modules as opposed to the traditional packages, but tkcvs would have to be modified to take advantage of this. Also even in Tcl/Tk 8.5 there still have been no hooks created for GTK or QT, so applications still look clunky and out of place on linux as you can see below. Note the windows and Mac ports of Tk are well integrated into the GUI in this new version of Tcl/Tk, which is surprising. [Update Aug 2008: There have now been hooks created for GTK+ and QT].

Meld

Due to the problems mentioned with Tkdiff above, I've recently switched to using Meld. It provides all the functions that TkCVS does, but in separate tabs instead of separate utilities. It uses the well maintained and elegant PyGtk toolkit, which I've used myself for applications, and so integrates well into the linux desktop at least. If you hover over the screenshot below you can switch between its repository and file comparison views, and with my version (1.1.5), there are plugins provided for the svn, cvs, bzr, mercurial, monotone and tla SCM systems. One very handy thing I noticed that Meld supports is in-place editing of the files being compared, and also very easy merging by clicking on the icons in the center bar. The most common way I use Meld is to review my local changes before committing them to the perforce and subversion SCM systems I use, and to support this I have a handy script. Note if one prefers the KDE environment rather than Gnome/GTK+ then the analogous KDiff3 utility may be more suited.

Google Code - changeset viewer

Recently Jenan Wise from google added a changeset viewer to their project hosting web interface. Coincidentally the "Colored Diffs" project mentioned above is hosted on Google Code, so you can view its latest changes as an example. The screenshot below shows the representation of a particular change, where a summary of the diff is shown, and one can drill down further to get a full side by side file comparison of the change.

Github - changeset viewer

Github has a useful interface for (re)viewing changes to a file or more generally change sets to a project. First I'll describe how I setup local forks for a project by explaining how I work with the github coreutils mirror.

This was forked to my a/c on github and then in the my standard coreutils local repo I did:

$ git remote add github git@github.com:pixelb/coreutils.git
$ git fetch github
That worked immediately since there were no new commits. I have repos and branches set like this in .git/config, which allows me to update my github-master branch periodically.
[remote "github"]
    url = git@github.com:pixelb/coreutils.git
    fetch = +refs/heads/*:refs/remotes/github/*
[branch "selinux-restorecon"]
    remote = github
    merge = refs/heads/selinux-restorecon
[branch "github-master"]
    remote = github
    merge = refs/heads/master
Now I can (force) push my branches to my github fork like:
$ git push github +selinux-restorecon
I also removed all but the master branch and my own branches from my github fork, to make it obvious which branches were the ones I wanted to make available.

With these patches now available in github we can leverage some functional and interface advantages of github for working collaboratively on change sets. github has a very nice viewer for topic branches, which you can (re)view each change. See for example:

https://github.com/pixelb/coreutils/compare/selinux-restorecon

That shows each commit specific to the branch, and one can add comments there. Also very useful is to see the combined changes on a per file basis, using:

https://github.com/pixelb/coreutils/compare/selinux-restorecon#files_bucket

One can even reference a particular diff within the set of changes directly like:

https://github.com/pixelb/coreutils/compare/selinux-restorecon#diff-8

Since Sep 2014 the github diff viewer supports side by side mode, which it calls split diffs, and improved changed word highlighting which you can see at the above link.

BTW if you want to reference that raw patch set for piping to git am without having to worry about setting up git remotes etc., just tack a ".patch" on the end of the changeset link like:

https://github.com/pixelb/coreutils/compare/selinux-restorecon.patch

Windows

For completeness I'll mention "ExamDiff" which I first used at least 10 years ago (1998), when I was still using the windows platform. It was the first side by side comparison program I used, and I've been a convert since then. Now I haven't used windows for 7 years now, so I'm not sure that this is still the best tool for the job? Considering like most windows applications, it's closed source and somewhat crippled until you pay for it, I'm not providing it any link juice. Note that the KDiff3 utility menitoned above also provides a windows installer, and wikipedia has a list of file comparison tools which lists other free and open source windows and Mac OS X options.

© Feb 13 2008