2014-05-09 104 views
0

我发现差异输出是奇怪的,当我设置--diff-cmd=diff为什么'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. 

颠覆将通过默认PARAMS -u外部diff程序。

➜ 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 

回答

0

颠覆将下列参数传递到外部diff命令:经由-x'. If -x is null, the -u`

  • -u或指定的用户的标志无论如何通过。
  • -L
  • 基地标题
  • -L
  • 工作副本标题
  • 基础文件
  • 工作拷贝文件

摆脱-u的唯一办法是在其他参数来传递。我写我用做我的分析,然后用VIM我DIFF Perl脚本:

#! /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;