Skip to content

Commit

Permalink
difftool--helper: exit when reading a prompt answer fails
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Johannes Sixt authored and Junio C Hamano committed Oct 27, 2014
1 parent 3c2dc76 commit 2509869
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion git-difftool--helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions t/t7800-difftool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2509869

Please sign in to comment.