2

I found diff output is strange when I set --diff-cmd=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

I thought the two commands above essentially excute as below, am I wrong?

➜  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

I get this from svn help diff

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

The subversion will pass default params -u to external diff program.

➜  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
  • Thanks for posting this. I can't understand how this output is useful for a custom diff command. Commented Jun 4, 2024 at 20:03

2 Answers 2

4

Subversion passes the following parameters to the external diff command:

  • -u or the user specified flags via -x'. If-xis null, the-u` is passed anyway.
  • -L
  • Base Title
  • -L
  • Working Copy Title
  • Base file
  • Working copy file

The only way to get rid of -u is to pass in another parameter. I wrote a Perl script I use to do my parsing and then use VIM for my diff:

#! /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;
Sign up to request clarification or add additional context in comments.

Comments

0

Diffmerge Command Line options

This doesn't answer the question but I hope will be useful background for people who land on this page, and doesn't seem to be on the official site (https://sourcegear.com/diffmerge/webhelp/chapter_clargs.html).

Mac

    SourceGear DiffMerge - Version 4.1.0 (534:eca1777d85) [intel] stable
    Copyright (C) 2003-2013 SourceGear LLC. All Rights Reserved.

    Synopsis:
    DiffMerge [options] [path1 [path2 [path3]]]

    Options:
    -h, -help, --help
    -c=STRING, -caption=STRING, --caption=STRING
    -m, -merge, --merge
    -r=PATH, -result=PATH, --result=PATH
    -ro2, --ro2
    -t1=STRING, -title1=STRING, --title1=STRING
    -t2=STRING, -title2=STRING, --title2=STRING
    -t3=STRING, -title3=STRING, --title3=STRING
    -nosplash, --nosplash

    Batch Options:
    -d=PATH, -diff=PATH, --diff=PATH
    -u, -unified, --unified

Windows

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.