96

I can get diffs between two revisions using something like

svn diff -r 100:200 > file.diff

But the problem is that there are many lines that show up due to change in whitespace. Is there a way to only write those lines that actually change in a significant way and not just in whitespace?

umar
  • 4,309
  • 9
  • 34
  • 47

4 Answers4

98

You can use

svn diff -r 100:200 -x -b > file.diff

If you want to ignore all whitespaces:

svn diff -x -w | less

Source

Marco Sulla
  • 15,299
  • 14
  • 65
  • 100
jrbjazz
  • 3,130
  • 22
  • 19
  • Is that new for 1.6? SVN never use to do that. I should keep more current :) – Dan McGrath Nov 16 '09 at 12:02
  • 4
    1.5.4 does it. But: --ignore-space-change, not --ignore-space-changes – ur. Nov 16 '09 at 12:04
  • @Dan McG. Do not know if is new for 1.6, but entry number 8 at http://www.akatombo.com/en/comments/ignore_whitespace_in_a_subversion_diff/ suggest that it is available since 1.4 – jrbjazz Nov 16 '09 at 12:06
  • @ur. Sure. Sorry for the typo. Corrected. – jrbjazz Nov 16 '09 at 12:06
  • Just a comment, that "-x" argument sure has confusing semantics: when used after --diff-cmd diff, "-x" means "pass the next argument to diff". When used without, it means "pass the next argument to our internal implementation of diff, which happens to have some of the same syntax as real diff". Ugh. – Steve Bennett Feb 03 '11 at 03:21
  • Is there any way to make this the default for `svn diff`, so I don't have to say `-x -b` every time? – JoelFan Apr 13 '11 at 11:41
  • 1
    Because EOL may be considered whitespace as well, adding ``-x --ignore-eol-style`` might be necessary if EOL style is different between revisions. – nedim Apr 27 '15 at 14:09
  • When you also want to suppress any newlines introduced or removed you should use an external diff program and add some options `svn diff --diff-cmd '/usr/bin/diff' -x '-u --ignore-all-space --ignore-blank-lines' path1 path2` (-u gives the unified style as does svn diff) – Giso Stallenberg Jul 31 '15 at 11:47
  • 5
    Using `svn diff -x -w` can sometimes also be useful, as it ignores more whitespace (alias for ignore-all-space) – Kendall Dec 09 '16 at 17:40
75

Use -x --ignore-space-change or -x --ignore-all-space. (See svn -h diff.)

Mansoor Siddiqui
  • 20,853
  • 10
  • 48
  • 67
ur.
  • 2,890
  • 1
  • 18
  • 21
8

Note that end-of-lines are not considered whitespace in this scenario and that has to be ignored with:

svn diff -x --ignore-eol-style [etc...]
zzxyz
  • 2,953
  • 1
  • 16
  • 31
7

You can use an alternate diff command using the --diff-cmd argument for svn diff. diff is a good utility that has plenty of features for ignoring whitespace.

For example:

svn diff --diff-cmd /usr/bin/diff -x "-w"
Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
tschaible
  • 7,635
  • 1
  • 31
  • 34