Skip to content

Commit 2509869

Browse files
j6tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3c2dc76 commit 2509869

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

git-difftool--helper.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ launch_merge_tool () {
4949
else
5050
printf "Launch '%s' [Y/n]: " "$merge_tool"
5151
fi
52-
if read ans && test "$ans" = n
52+
read ans || return
53+
if test "$ans" = n
5354
then
5455
return
5556
fi

t/t7800-difftool.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,14 @@ test_expect_success PERL 'say no to the second file' '
301301
! grep br2 output
302302
'
303303

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+
304312
test_expect_success PERL 'difftool --tool-help' '
305313
git difftool --tool-help >output &&
306314
grep tool output

0 commit comments

Comments
 (0)