From 25098690a0151ba29ec1c728d783366c1899624d Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Sun, 26 Oct 2014 09:09:20 +0100 Subject: [PATCH] difftool--helper: exit when reading a prompt answer fails An attempt to quit difftool by hitting Ctrl-D (EOF) at its prompt does not quit it, but is treated as if 'yes' was answered to the prompt and all following prompts, which is contrary to the user's intent. Fix the error check. Signed-off-by: Johannes Sixt Signed-off-by: Junio C Hamano --- git-difftool--helper.sh | 3 ++- t/t7800-difftool.sh | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/git-difftool--helper.sh b/git-difftool--helper.sh index 7ef36b9482..aca0413c28 100755 --- a/git-difftool--helper.sh +++ b/git-difftool--helper.sh @@ -49,7 +49,8 @@ launch_merge_tool () { else printf "Launch '%s' [Y/n]: " "$merge_tool" fi - if read ans && test "$ans" = n + read ans || return + if test "$ans" = n then return fi diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh index dc30a514bf..9cf5dc9347 100755 --- a/t/t7800-difftool.sh +++ b/t/t7800-difftool.sh @@ -301,6 +301,14 @@ test_expect_success PERL 'say no to the second file' ' ! grep br2 output ' +test_expect_success PERL 'ending prompt input with EOF' ' + git difftool -x cat branch output && + ! grep master output && + ! grep branch output && + ! grep m2 output && + ! grep br2 output +' + test_expect_success PERL 'difftool --tool-help' ' git difftool --tool-help >output && grep tool output -- 2.11.4.GIT