问题
I'm having problems trying to setup an external diff program for svn on Mac OSX Lion. I have both xxdiff and opendiff installed.
I add these lines to ~/.subversion/config:
diff-cmd = opendiff
diff3-cmd = opendiff
or
diff-cmd = /Applications/xxdiff.app/Contents/MacOS/xxdiff
diff3-cmd = /Applications/xxdiff.app/Contents/MacOS/xxdiff
But when I invoke svn, I get this error:
svn: /Users/tre11/.subversion/config:49: Option expected
How do I fix this problem?
回答1:
There aren't many diff utilities, aside from the GNU ones of course, that will take the parameters as given by svn (bbdiff is one of the few). You need to wrap the call in a shell script. It's explained in the subversion docs.
Edit
Based on your comment that the default text diff is still being run, I think there's an error in your .subversion/config file. That's consistent with your error message. The most likely cause is a space at the beginning of the diff-cmd
line. Yes, subversion's parser freaks out at spaces at the beginning of the line. I put a space at the beginning of my diff-cmd
line and got the same "Option expected" error.
回答2:
Here's an example of one I use with MacVIM
#! /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;
This is a Perl program (but you have Perl on your Mac, so it's okay).
Basically, you have to know the various parameter positions passed to your program. A quick test shows the following parameters were passed:
-u
(Unified Diff)-L
(In diff, use the following as the title of the left hand file)bludgen.pl (revision 63)
(Left hand title)-L
(In diff, use the following as the title of the right hand file)bludgen.pl (working copy)
(Right hand title).svn/text-base/bludgen.pl.svn-base
(Left hand file)bludgen.pl
(right hand file)
More information here.
来源:https://stackoverflow.com/questions/9603647/trying-to-setup-svn-external-diff-program-on-mac