]> git.ipfire.org Git - thirdparty/git.git/commitdiff
difftool--helper: exit when reading a prompt answer fails
authorJohannes Sixt <j6t@kdbg.org>
Sun, 26 Oct 2014 08:09:20 +0000 (09:09 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 27 Oct 2014 18:17:56 +0000 (11:17 -0700)
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 <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-difftool--helper.sh
t/t7800-difftool.sh

index 7ef36b9482ccc4111f2c888bf5ccbaa2421a5875..aca0413c2840a3097056d6d247aad9438451249e 100755 (executable)
@@ -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
index dc30a514bf681dde44dea32e671632ef6f0a47a7..9cf5dc9347971438b50e2a23cbb005758106ab5e 100755 (executable)
@@ -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 </dev/null >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