From: Johannes Sixt <j6t@kdbg.org>
To: David Aguilar <davvid@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>,
Sitaram Chamarty <sitaramc@gmail.com>
Subject: difftool--helper: exit when reading a prompt answer fails
Date: Sun, 26 Oct 2014 09:09:20 +0100 [thread overview]
Message-ID: <544CAC30.7000607@kdbg.org> (raw)
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>
---
Found while reviewing your latest patch.
I chose the 'foo || return' idiom for the error check, but left the
'if' for the interesting check, because I feel it is more readable
than 'test ... && return'.
-- Hannes
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 7ef36b9..aca0413 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 dc30a51..9cf5dc9 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 </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
--
2.0.0.12.gbcf935e
next reply other threads:[~2014-10-26 8:09 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-26 8:09 Johannes Sixt [this message]
2014-10-27 0:41 ` difftool--helper: exit when reading a prompt answer fails David Aguilar
2014-10-27 1:10 ` David Aguilar
2014-10-27 12:54 ` Michael J Gruber
2014-10-27 17:38 ` Junio C Hamano
2014-10-27 1:15 ` [PATCH v3 1/2] t7800-difftool: use "test_must_fail grep" instead of "! grep" David Aguilar
2014-10-27 1:15 ` [PATCH v3 2/2] difftool: add support for --trust-exit-code David Aguilar
2014-10-27 18:45 ` Junio C Hamano
2014-10-28 9:34 ` David Aguilar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=544CAC30.7000607@kdbg.org \
--to=j6t@kdbg.org \
--cc=davvid@gmail.com \
--cc=git@vger.kernel.org \
--cc=sitaramc@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).