svn diff -x(v1.6)不接受我的diff选项--unified = 40

oli*_*bre 2 svn shell diff sh command-line-arguments

我经常使用这个在Subversion 1.6.11和GNU diff 2.8.1上运行良好的命令行.

svn diff -x '--unified --ignore-space-change --ignore-all-space --ignore-eol-style --show-c-function' --no-diff-deleted my-file | vim -
Run Code Online (Sandbox Code Playgroud)

但是我想使用该diff选项增加上下文行,--unified=40但我的所有尝试都失败了:

$ svn diff -x '--unified=40' my-file
svn: Error parsing diff options: Missing parameter for the specified command line option

$ svn diff -x '--unified 40' my-file
svn: Invalid argument '40' in diff options

$ svn diff -x '--unified\=40' my-file
svn: Error parsing diff options: Bad character specified on command line

$ svn diff -x '-u 40' my-file
svn: Invalid argument '40' in diff options

$ svn diff -x '-u=40' my-file
svn: Error parsing diff options: Bad character specified on command line

$ svn diff -x '-U' my-file
svn: Error parsing diff options: Bad character specified on command line
Run Code Online (Sandbox Code Playgroud)

我还想忽略使用该diff选项--ignore-matching-lines='^[ \t]*#'但相同错误的注释行中的更改.

这个svn diff -x问题有解决方法吗?

Ben*_*ser 7

Subversion不使用GNU diff来生成diff. 它有自己的diff实现(参见链接部分的最后一段).内部差异实现只有几个选项,您可以从输出中看到svn help diff:

-x [--extensions] ARG    : Specify differencing options for external diff or
                          internal diff or blame. Default: '-u'. Options are
                          separated by spaces. Internal diff and blame take:
                            -u, --unified: Show 3 lines of unified context
                            -b, --ignore-space-change: Ignore changes in
                              amount of white space
                            -w, --ignore-all-space: Ignore all white space
                            --ignore-eol-style: Ignore changes in EOL style
                            -p, --show-c-function: Show C function name
Run Code Online (Sandbox Code Playgroud)

你可能想这样svn diff --diff-cmd=/usr/bin/diff -x '--unified=40' my-file做,Subversion也会选择外部差异/usr/bin/diff(或你想要的任何路径).

您还可以将Subversion配置为始终通过配置文件使用external diff命令.在Subversion书中有一节关于使用外部差异和合并工具.