difftool: Add '-x' and as an alias for '--extcmd'
This adds '-x' as a shorthand for the '--extcmd' option. Arguments to '--extcmd' can be specified separately, which was not originally possible. This also fixes the brief help text so that it mentions both '-x' and '--extcmd'. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
a9e11220c2
commit
f47f1e2ce8
@ -7,7 +7,7 @@ git-difftool - Show changes using common diff tools
|
|||||||
|
|
||||||
SYNOPSIS
|
SYNOPSIS
|
||||||
--------
|
--------
|
||||||
'git difftool' [--tool=<tool>] [-y|--no-prompt|--prompt] [<'git diff' options>]
|
'git difftool' [<options>] <commit>{0,2} [--] [<path>...]
|
||||||
|
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
-----------
|
-----------
|
||||||
@ -58,6 +58,7 @@ is set to the name of the temporary file containing the contents
|
|||||||
of the diff post-image. `$BASE` is provided for compatibility
|
of the diff post-image. `$BASE` is provided for compatibility
|
||||||
with custom merge tool commands and has the same value as `$LOCAL`.
|
with custom merge tool commands and has the same value as `$LOCAL`.
|
||||||
|
|
||||||
|
-x <command>::
|
||||||
--extcmd=<command>::
|
--extcmd=<command>::
|
||||||
Specify a custom command for viewing diffs.
|
Specify a custom command for viewing diffs.
|
||||||
'git-difftool' ignores the configured defaults and runs
|
'git-difftool' ignores the configured defaults and runs
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env perl
|
#!/usr/bin/env perl
|
||||||
# Copyright (c) 2009 David Aguilar
|
# Copyright (c) 2009, 2010 David Aguilar
|
||||||
#
|
#
|
||||||
# This is a wrapper around the GIT_EXTERNAL_DIFF-compatible
|
# This is a wrapper around the GIT_EXTERNAL_DIFF-compatible
|
||||||
# git-difftool--helper script.
|
# git-difftool--helper script.
|
||||||
@ -23,8 +23,9 @@ my $DIR = abs_path(dirname($0));
|
|||||||
sub usage
|
sub usage
|
||||||
{
|
{
|
||||||
print << 'USAGE';
|
print << 'USAGE';
|
||||||
usage: git difftool [-g|--gui] [-t|--tool=<tool>] [-y|--no-prompt]
|
usage: git difftool [-t|--tool=<tool>] [-x|--extcmd=<cmd>]
|
||||||
["git diff" options]
|
[-y|--no-prompt] [-g|--gui]
|
||||||
|
['git diff' options]
|
||||||
USAGE
|
USAGE
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
@ -62,14 +63,20 @@ sub generate_command
|
|||||||
$skip_next = 1;
|
$skip_next = 1;
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
if ($arg =~ /^--extcmd=/) {
|
|
||||||
$ENV{GIT_DIFFTOOL_EXTCMD} = substr($arg, 9);
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
if ($arg =~ /^--tool=/) {
|
if ($arg =~ /^--tool=/) {
|
||||||
$ENV{GIT_DIFF_TOOL} = substr($arg, 7);
|
$ENV{GIT_DIFF_TOOL} = substr($arg, 7);
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
if ($arg eq '-x' || $arg eq '--extcmd') {
|
||||||
|
usage() if $#ARGV <= $idx;
|
||||||
|
$ENV{GIT_DIFFTOOL_EXTCMD} = $ARGV[$idx + 1];
|
||||||
|
$skip_next = 1;
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
if ($arg =~ /^--extcmd=/) {
|
||||||
|
$ENV{GIT_DIFFTOOL_EXTCMD} = substr($arg, 9);
|
||||||
|
next;
|
||||||
|
}
|
||||||
if ($arg eq '-g' || $arg eq '--gui') {
|
if ($arg eq '-g' || $arg eq '--gui') {
|
||||||
my $tool = Git::command_oneline('config',
|
my $tool = Git::command_oneline('config',
|
||||||
'diff.guitool');
|
'diff.guitool');
|
||||||
|
@ -225,8 +225,16 @@ test_expect_success 'difftool.<tool>.path' '
|
|||||||
test_expect_success 'difftool --extcmd=cat' '
|
test_expect_success 'difftool --extcmd=cat' '
|
||||||
diff=$(git difftool --no-prompt --extcmd=cat branch) &&
|
diff=$(git difftool --no-prompt --extcmd=cat branch) &&
|
||||||
test "$diff" = branch"$LF"master
|
test "$diff" = branch"$LF"master
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'difftool --extcmd cat' '
|
||||||
|
diff=$(git difftool --no-prompt --extcmd cat branch) &&
|
||||||
|
test "$diff" = branch"$LF"master
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'difftool -x cat' '
|
||||||
|
diff=$(git difftool --no-prompt -x cat branch) &&
|
||||||
|
test "$diff" = branch"$LF"master
|
||||||
|
|
||||||
|
|
||||||
'
|
'
|
||||||
|
Loading…
Reference in New Issue
Block a user