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

时间:2014-02-20 17:26:53

标签: shell svn diff command-line-arguments sh

我经常使用这个在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问题是否有解决方法?

2 个答案:

答案 0 :(得分:7)

Subversion不使用GNU diff来生成diff。 It has it's own implementation of 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也会在/usr/bin/diff(或您想要的任何路径)选择外部差异。

您还可以将Subversion配置为始终通过配置文件使用external diff命令。 section on using external diff and merge tools中有一个Subversion book

答案 1 :(得分:0)

您可以编写一个小shell script来执行此操作:

#!/bin/bash
diff --unified=40 <(svn cat "$1") "$1"