Browse Source

difftool: Fix '--gui' when diff.guitool is unconfigured

When diff.guitool is unconfigured and "--gui" is specified
git-difftool dies with the following error message:

	config diff.guitool: command returned error: 1

Catch the error so that the "--gui" flag is a no-op when
diff.guitool is unconfigured.

Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
David Aguilar 15 years ago committed by Junio C Hamano
parent
commit
42accaec01
  1. 12
      git-difftool.perl
  2. 9
      t/t7800-difftool.sh

12
git-difftool.perl

@ -78,11 +78,13 @@ sub generate_command
next; next;
} }
if ($arg eq '-g' || $arg eq '--gui') { if ($arg eq '-g' || $arg eq '--gui') {
my $tool = Git::command_oneline('config', eval {
'diff.guitool'); my $tool = Git::command_oneline('config',
if (length($tool)) { 'diff.guitool');
$ENV{GIT_DIFF_TOOL} = $tool; if (length($tool)) {
} $ENV{GIT_DIFF_TOOL} = $tool;
}
};
next; next;
} }
if ($arg eq '-y' || $arg eq '--no-prompt') { if ($arg eq '-y' || $arg eq '--no-prompt') {

9
t/t7800-difftool.sh

@ -92,6 +92,15 @@ test_expect_success 'difftool honors --gui' '
restore_test_defaults restore_test_defaults
' '


test_expect_success 'difftool --gui works without configured diff.guitool' '
git config diff.tool test-tool &&

diff=$(git difftool --no-prompt --gui branch) &&
test "$diff" = "branch" &&

restore_test_defaults
'

# Specify the diff tool using $GIT_DIFF_TOOL # Specify the diff tool using $GIT_DIFF_TOOL
test_expect_success 'GIT_DIFF_TOOL variable' ' test_expect_success 'GIT_DIFF_TOOL variable' '
git config --unset diff.tool git config --unset diff.tool

Loading…
Cancel
Save