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

标签 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 问题有解决方法吗?

最佳答案

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 toolsSubversion book .

关于shell - svn diff -x (v1.6) 不接受我的 diff 选项 --unified=40,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21915194/

相关文章:

linux - linux下如何使组内文件的权限与属主相同?

java - 无论如何在未连接时关闭 Eclipse Subversion 中的 "show history"任务?

git - 查找 source 从 git 分支的位置

git - 有没有办法将 git 或 Mercurial diff 输出通过管道传输到 GUI Diff 工具?

c - 您如何根据代码结构比较包含 C 代码的两个文件,而不仅仅是文本差异?

linux - sh trap SIGINT 失败,但 trap SIGQUIT 成功

linux - 查找具有多个文件扩展名的命令

javascript - 如何在 node.js shell 中实现制表符补全?

svn - 为什么重命名会导致文件添加而不是文件更改?

postgresql - 如何像SVN那样管理一个有分支和主干的数据库