2 # Copyright (c) 2009 David Aguilar
4 # This is a wrapper around the GIT_EXTERNAL_DIFF-compatible
5 # git-difftool--helper script.
7 # This script exports GIT_EXTERNAL_DIFF and GIT_PAGER for use by git.
8 # GIT_DIFFTOOL_NO_PROMPT, GIT_DIFFTOOL_PROMPT, and GIT_DIFF_TOOL
9 # are exported for use by git-difftool--helper.
11 # Any arguments that are unknown to this script are forwarded to 'git diff'.
16 use File
::Basename
qw(dirname);
18 my $DIR = abs_path
(dirname
($0));
24 usage
: git difftool
[--tool
=<tool
>] [-y
|--no-prompt
] ["git diff" options
]
31 $ENV{PATH
} = "$DIR:$ENV{PATH}";
33 $ENV{GIT_EXTERNAL_DIFF
} = 'git-difftool--helper';
39 if ($^O
eq 'MSWin32' || $^O
eq 'msys') {
47 my @command = (exe
('git'), 'diff');
56 if ($arg eq '-t' || $arg eq '--tool') {
57 usage
() if $#ARGV <= $idx;
58 $ENV{GIT_DIFF_TOOL
} = $ARGV[$idx + 1];
62 if ($arg =~ /^--tool=/) {
63 $ENV{GIT_DIFF_TOOL
} = substr($arg, 7);
66 if ($arg eq '-y' || $arg eq '--no-prompt') {
67 $ENV{GIT_DIFFTOOL_NO_PROMPT
} = 'true';
68 delete $ENV{GIT_DIFFTOOL_PROMPT
};
71 if ($arg eq '--prompt') {
72 $ENV{GIT_DIFFTOOL_PROMPT
} = 'true';
73 delete $ENV{GIT_DIFFTOOL_NO_PROMPT
};
76 if ($arg eq '-h' || $arg eq '--help') {
85 exec(generate_command
());