提交 42accaec 编写于 作者: D David Aguilar 提交者: Junio C Hamano

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: NDavid Aguilar <davvid@gmail.com>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 bb6ad28c
......@@ -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') {
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册