我经常使用这个命令行,它在 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 -
但是,我想使用 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
我还想使用 diff
选项忽略注释行中的更改 --ignore-matching-lines='^[\t]*#'
但出现相同的错误.
这个 svn diff -x
问题有解决方法吗?
最佳答案
Subversion 不使用 GNU diff 来生成 diff。 It has it's own implementation of 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
你可能想要执行svn diff --diff-cmd=/usr/bin/diff -x '--unified=40' my-file
,这样 Subversion 也会选择外部 diff在 /usr/bin/diff
(或您想要的任何路径)。
您还可以通过配置文件将 Subversion 配置为始终使用外部 diff 命令。有一个section on using external diff and merge tools在 Subversion book .
关于shell - svn diff -x (v1.6) 不接受我的 diff 选项 --unified=40,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21915194/