From: David Aguilar Date: Fri, 15 Jan 2010 22:03:43 +0000 (-0800) Subject: difftool: Add '-x' and as an alias for '--extcmd' X-Git-Tag: v1.7.0-rc0~67^2~2 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=f47f1e2ce8b4022113120b32decb4436341dc3aa;p=git.git 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 Signed-off-by: Junio C Hamano --- diff --git a/Documentation/git-difftool.txt b/Documentation/git-difftool.txt index f67d2db76..5c68cff90 100644 --- a/Documentation/git-difftool.txt +++ b/Documentation/git-difftool.txt @@ -7,7 +7,7 @@ git-difftool - Show changes using common diff tools SYNOPSIS -------- -'git difftool' [--tool=] [-y|--no-prompt|--prompt] [<'git diff' options>] +'git difftool' [] {0,2} [--] [...] 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 with custom merge tool commands and has the same value as `$LOCAL`. +-x :: --extcmd=:: Specify a custom command for viewing diffs. 'git-difftool' ignores the configured defaults and runs diff --git a/git-difftool.perl b/git-difftool.perl index f8ff24575..d975d072d 100755 --- a/git-difftool.perl +++ b/git-difftool.perl @@ -1,5 +1,5 @@ #!/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 # git-difftool--helper script. @@ -23,8 +23,9 @@ my $DIR = abs_path(dirname($0)); sub usage { print << 'USAGE'; -usage: git difftool [-g|--gui] [-t|--tool=] [-y|--no-prompt] - ["git diff" options] +usage: git difftool [-t|--tool=] [-x|--extcmd=] + [-y|--no-prompt] [-g|--gui] + ['git diff' options] USAGE exit 1; } @@ -62,14 +63,20 @@ sub generate_command $skip_next = 1; next; } - if ($arg =~ /^--extcmd=/) { - $ENV{GIT_DIFFTOOL_EXTCMD} = substr($arg, 9); - next; - } if ($arg =~ /^--tool=/) { $ENV{GIT_DIFF_TOOL} = substr($arg, 7); 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') { my $tool = Git::command_oneline('config', 'diff.guitool'); diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh index 1d9e07b0d..69e1c3415 100755 --- a/t/t7800-difftool.sh +++ b/t/t7800-difftool.sh @@ -225,8 +225,16 @@ test_expect_success 'difftool..path' ' test_expect_success 'difftool --extcmd=cat' ' diff=$(git difftool --no-prompt --extcmd=cat branch) && 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 '