Skip to content

Commit

Permalink
difftool: Fix '--gui' when diff.guitool is unconfigured
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
David Aguilar authored and Junio C Hamano committed Mar 28, 2010
1 parent bb6ad28 commit 42accae
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
12 changes: 7 additions & 5 deletions git-difftool.perl
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,13 @@ sub generate_command
next;
}
if ($arg eq '-g' || $arg eq '--gui') {
my $tool = Git::command_oneline('config',
'diff.guitool');
if (length($tool)) {
$ENV{GIT_DIFF_TOOL} = $tool;
}
eval {
my $tool = Git::command_oneline('config',
'diff.guitool');
if (length($tool)) {
$ENV{GIT_DIFF_TOOL} = $tool;
}
};
next;
}
if ($arg eq '-y' || $arg eq '--no-prompt') {
Expand Down
9 changes: 9 additions & 0 deletions t/t7800-difftool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@ test_expect_success 'difftool honors --gui' '
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
test_expect_success 'GIT_DIFF_TOOL variable' '
git config --unset diff.tool
Expand Down

0 comments on commit 42accae

Please sign in to comment.