svn小技巧——重定向svn diff

时间:2022-04-17 02:39:38

svn diff的默认输出模式比较冗长,如果遇到修改比较多的情况,有时会较难看清diff。svn本身提供了自定义diff输出的选项,可能的修改方法如下:

建立一个脚本文件(如svndiff.sh),调用vimdiff作为svn diff的配置选项,内容如下:

#!/bin/sh
DIFF="/usr/bin/vimdiff"

# Subversion provides the paths we need as the sixth and seventh parameters
LEFT=${6}
RIGHT=${7}

# diff command
${DIFF} ${LEFT} ${RIGHT}

然后修改svn配置文件~/.subversion/config,确保写入下列配置:

[helpers]
diff-cmd = /path/to/svndiff.sh

之后执行svn diff时,svn将会调用svndiff.sh脚本来操作,实际实现了vimdiff替换默认diff模式的功能。