2 # Copyright (c) 2009 David Aguilar
4 # This is a wrapper around the GIT_EXTERNAL_DIFF-compatible
5 # git-difftool-helper script. This script exports
6 # GIT_EXTERNAL_DIFF and GIT_PAGER for use by git, and
7 # GIT_NO_PROMPT and GIT_MERGE_TOOL for use by git-difftool-helper.
8 # Any arguments that are unknown to this script are forwarded to 'git diff'.
13 use File
::Basename
qw(dirname);
15 my $DIR = abs_path
(dirname
($0));
22 usage
: git difftool
[--no-prompt
] [--tool
=tool
] ["git diff" options
]
29 $ENV{PATH
} = "$DIR:$ENV{PATH}";
31 $ENV{GIT_EXTERNAL_DIFF
} = 'git-difftool-helper';
37 return defined $ENV{COMSPEC
} ?
"$exe.exe" : $exe;
42 my @command = (exe
('git'), 'diff');
51 if ($arg eq '-t' or $arg eq '--tool') {
52 usage
() if $#ARGV <= $idx;
53 $ENV{GIT_MERGE_TOOL
} = $ARGV[$idx + 1];
57 if ($arg =~ /^--tool=/) {
58 $ENV{GIT_MERGE_TOOL
} = substr($arg, 7);
61 if ($arg eq '--no-prompt') {
62 $ENV{GIT_DIFFTOOL_NO_PROMPT
} = 'true';
65 if ($arg eq '-h' or $arg eq '--help') {
74 exec(generate_command
());