Ignore whitespace in Subversion diffs

20 May, 2009 - 15:24

When you're working on a software development project where not all parties use the same code style conventions or editor setting (like tabs vs. spaces, removing trailing spaces, etc), the signal to noise ratio of a source code diff can be a bit frustrating. Luckily, most diff programs have an option to ignore whitespace changes, for example -w or --ignore-all-space in GNU diff or colordiff.

The internal diff engine of Subversion also offers this option (since version 1.4 if I'm not mistaken), but it looks a bit weird to use it:

svn diff -x -w ventrolucator.cpp

The weird thing is that the option -w is actually an argument for the -x option. So if you want extra diff customization, like adding the option -p for showing the function name in the diff, you should do

svn diff -x "-w -p" ventrolucator.cpp

or you could merge the -w and -p options to make it a bit less weird:

svn diff -x -wp ventrolucator.cpp

More info in a svn help diff near you.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • No HTML tags allowed
  • Lines and paragraphs break automatically.

More information about formatting options