Using Another Diff Program

A common requirement is to do diffs which ignore whitespace, the diff built into Subversion cannot do this. GNU diff is commonly used for this purpose so if you don't have a preferred diff program already install GNU diff.

Windows

These examples assume cygwin GNU diff is installed in C:\cygwin.

First create a batch file as follows:

C:\cygwin\bin\diff.exe -wd %*

Save it in C:\svndiff.bat

Now edit C:\Documents and Settings\<yourusername>\Application Data\Subversion\config and make sure that the [helpers] line is not commented out. Uncomment the diff-cmd line and set it to point to the svndiff batch file:

[helpers]
diff-cmd = C:\svndiff.bat

Now when you type svn diff it will use GNU diff with the w and d options.

Windows and TortoiseSVN

If you have TortoiseSVN installed on windows you can use TortoiseMerge as your diff program. Put this line inside svndiff.bat:

"c:\Program Files\TortoiseSVN\bin\TortoiseMerge.exe" /base:"%6" /yours:"%7" /basename:%3 /yoursname:%5

Note: No quotes for %3 and %5 arguments!

This will run TortoiseMerge for each changed file. If there are a lot of changed files this could be more than a little irritating but it's your choice!

Linux and Unix

Linux will have have GNU diff installed as /usr/bin/diff.

Create a script ~/bin/svndiff:

#!/bin/bash
diff=/usr/bin/diff
args="-wd"
    
exec ${diff} ${args} "$@"

Make it executable:

chmod +x ~/bin/svndiff

Edit the file ~/.subversion/config and make sure that the [helpers] line is not commented out. Uncomment the diff-cmd line and set it to point to the svndiff script:

[helpers]
diff-cmd = ~/bin/svndiff

Now when you type svn diff it will use GNU diff with the w and d options.

Mon, 2005-07-18 11:19
( categories: )

TortoiseMerge parameters

It seems the parameters for TortoiseMerge.exe above are incorrect, here is my svndiff.bat.

@echo off
"c:\Program Files\TortoiseSVN\bin\TortoiseMerge.exe" /base:"%6" /mine:"%7" /basename:%3 /minename:%5

(placed in PATH and then using --diff-cmd svndiff.bat)