How to view svn diff in vimdiff style in svn How to view svn diff in vimdiff style in svn unix unix

How to view svn diff in vimdiff style in svn


Edit the file $HOME/.subversion/config so it contains the line:

diff-cmd = <your favorite diff application>

Some diff apps support svn. For example, diff-cmd = meld should work fine. However, vimdiff is not one of them. The reason for that is that svn diff gives the files to be compared as 6th and 7th arguments, and not as 1st and 2nd as usual. So what most people do in this situation is this:

Create a wrapper script:

#!/bin/sh/usr/bin/vimdiff ${6} ${7}

Save it, for example, at $HOME/bin/svndiffwrap.sh

Do not forget to make it executable chmod +x $HOME/bin/svndiffwrap.sh.

Make it the svn diff command:

in $HOME/.subversion/config:

diff-cmd = /home/<username>/bin/svndiffwrap.sh

Note: Some svn clients do not support paths that uses $HOME environment variable. So it is useful to specify full path.


Found it at:http://blog.tplus1.com/index.php/2007/08/29/how-to-use-vimdiff-as-the-subversion-diff-tool/

This blog post takes the script directly from the SVN book external diff tools example:

diffwrap.sh

#!/bin/sh# Configure your favorite diff program here.DIFF="/usr/local/bin/vimdiff"# Subversion provides the paths we need as the sixth and seventh # parameters.LEFT=${6}RIGHT=${7}# Call the diff command (change the following line to make sense for# your merge program).$DIFF $LEFT $RIGHT# Return an errorcode of 0 if no differences were detected, 1 if some were.# Any other errorcode will be treated as fatal.

Note: This assumes that your vimdiff is in /usr/local/bin, for me, in Fedora, it was in /usr/bin. If you can't find it run:

$ whereis vimdiff

Then in ~/.subversion/config:

[helpers]...diff-cmd = /home/<username>/bin/diffwrap.sh


vimdiff <(svn diff)

<() is referred to as process substitution which creates a pseudo file from the output of svn diff for vimdiff to consume.

You can create a shell alias like so: alias svndiff='vimdiff <(svn diff)'

Similar answer

PS - this is the simplest solution I have yet to find; it changed my life (relatively speaking)!