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 <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Sixt committed
Oct 26, 2014 at 09:09 UTC
25098690a0151ba29ec1c728d783366c1899624d
2 files changed
+10
-1
git-difftool--helper.sh
+2
-1
@@ -49,7 +49,8 @@ launch_merge_tool () {
49
else
50
printf "Launch '%s' [Y/n]: " "$merge_tool"
51
fi
52
- if read ans && test "$ans" = n
52
+ read ans || return
53
+ if test "$ans" = n
54
then
55
return
56
fi
t/t7800-difftool.sh
+8
@@ -301,6 +301,14 @@ test_expect_success PERL 'say no to the second file' '
301
! grep br2 output
302
'
303
304
+test_expect_success PERL 'ending prompt input with EOF' '
305
+ git difftool -x cat branch </dev/null >output &&
306
+ ! grep master output &&
307
+ ! grep branch output &&
308
+ ! grep m2 output &&
309
+ ! grep br2 output
310
+'
311
+
312
test_expect_success PERL 'difftool --tool-help' '
313
git difftool --tool-help >output &&
314
grep tool output