Ignoring whitespace changes with svn diff

When using Subversion, a recent successor to the ubiquitous CVS revision control system, one may notice certain niceties of CVS are lost.

In particular, the -w flag on cvs diff.

cvs diff will display changes in the local file. Without the -r flag to specify which version is being compared, the default is to compare the local file to the currently tagged version in the repository, or the main branch HEAD if the file is not tagged.

cvs diff -w will display all non-whitespace changes. White space changes include adding or removing tabs or spaces, or changing spaces to tabs. New lines are still included in the diff.

Subversion doesn't have this shortcut. To ignore whitespace changes, you must use an external diff program with subversion:

svn diff filename --diff-cmd `which diff` -x "-w"

You can specify a different diff, such as xdiff, xxdiff, as a value to the --diff-cmd argument, but be sure to include the full path. If you want to pass more values to your diff command, include them in the -x argument value, which is passed along directly to the diff command:

svn diff -r123:126 filename --diff-cmd /path/to/diff -x "-u -w"

If you want, you can also create an alias for this. In tcsh:

alias svndiff 'svn diff --diff-cmd `which diff` -x "-w" \!*'