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_DIFFTOOL_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));
21 usage
: git difftool
[--tool
=<tool
>] [--no-prompt
] ["git diff" options
]
28 $ENV{PATH
} = "$DIR:$ENV{PATH}";
30 $ENV{GIT_EXTERNAL_DIFF
} = 'git-difftool-helper';
36 return defined $ENV{COMSPEC
} ?
"$exe.exe" : $exe;
41 my @command = (exe
('git'), 'diff');
50 if ($arg eq '-t' or $arg eq '--tool') {
51 usage
() if $#ARGV <= $idx;
52 $ENV{GIT_MERGE_TOOL
} = $ARGV[$idx + 1];
56 if ($arg =~ /^--tool=/) {
57 $ENV{GIT_MERGE_TOOL
} = substr($arg, 7);
60 if ($arg eq '--no-prompt') {
61 $ENV{GIT_DIFFTOOL_NO_PROMPT
} = 'true';
64 if ($arg eq '-h' or $arg eq '--help') {
73 exec(generate_command
());