为什么&s; svn diff --diff-cmd = diff'输出内部差异格式?

时间:2014-05-09 15:33:06

标签: svn diff

我设置--diff-cmd=diff时发现diff输出很奇怪。

➜  svntest  svn diff --diff-cmd=diff -x '' #The cmd `diff` cann't output this format, so strange 
Index: a.c
===================================================================
--- a.c (revision 1)
+++ a.c (working copy)
@@ -0,0 +1 @@
+teste

➜  svntest  svn diff --diff-cmd=diff -x '-i'
Index: a.c
===================================================================
0a1
> teste

我认为上面的两个命令基本上都是如下所示,我错了吗?

➜  svntest  diff   -L 'a.c(revision 1)' -L 'a.c(working copy)' '/Users/hilojack/www/svntest/.svn/pristine/da/da39a3ee5e6b4b0d3255bfef95601890afd80709.svn-base' '/Users/hilojack/www/svntest/a.c'
0a1
> teste
➜  svntest  diff  -i -L 'a.c(revision 1)' -L 'a.c(working copy)' '/Users/hilojack/www/svntest/.svn/pristine/da/da39a3ee5e6b4b0d3255bfef95601890afd80709.svn-base' '/Users/hilojack/www/svntest/a.c'
0a1
> teste

我是从svn help diff

得到的
-x [--extensions] ARG    : Default: '-u'. When Subversion is invoking an external diff program, ARG is simply passed along to the program.

subversion会将默认参数-u传递给外部差异程序。

➜  svntest  svn diff --diff-cmd=echo
Index: a.c
===================================================================
-u -L a.c   (revision 1) -L a.c (working copy) /Users/hilojack/www/svntest/.svn/pristine/da/da39a3ee5e6b4b0d3255bfef95601890afd80709.svn-base /Users/hilojack/www/svntest/a.c

1 个答案:

答案 0 :(得分:0)

Subversion将以下参数传递给外部diff命令:

    无论如何,通过-u - x -x'. If - u`传递
  • is null, the或用户指定的标记。
  • -L
  • 基本标题
  • -L
  • 工作副本标题
  • 基础文件
  • 工作副本文件

摆脱-u的唯一方法是传入另一个参数。我编写了一个用于解析的Perl脚本,然后将VIM用于我的差异:

#! /usr/bin/env perl

use strict;
use warnings;

use constant DIFF => qw(mvim -d -f);

my $parameters = $#ARGV;
my $file1 = $ARGV[$parameters - 1];
my $file2 = $ARGV[$parameters];
my $title1 = $ARGV[$parameters - 4];
my $title2 = $ARGV[$parameters - 2];

$ENV{TITLE} = "$title1  -   $title2";
system DIFF, '-c', 'let &titlestring=$TITLE', $file1, $file2;