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" \!*'

Comments

It is in subversion!

I'm not sure if it is a new feature since you wrote this, but it's there now.

svn diff -x -w filename

or perhaps:

svn diff -x --ignore-eol-style filename

for more info:

svn help diff

Thanks...very useful

Thanks...very useful tip....I had done some minimal changes to my code and realigned the entire file. It was very difficult to see only the necessary changes since SVN was showing the entire file as a difference.

Yep, that's new

It's there in SVN 1.4 Not sure when it went in.