summaryrefslogtreecommitdiff
path: root/git-add--interactive.perl
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2017-06-21 19:26:36 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-06-21 21:06:09 (GMT)
commitd5addcf522deb05d259ecbc0946584d977879565 (patch)
tree659c54abaedfddcf6e1d549a4b5af86c2f8b33b6 /git-add--interactive.perl
parent1d73f8e86d7b4d95e0b7ce53eec2a5f8114722ac (diff)
downloadgit-d5addcf522deb05d259ecbc0946584d977879565.zip
git-d5addcf522deb05d259ecbc0946584d977879565.tar.gz
git-d5addcf522deb05d259ecbc0946584d977879565.tar.bz2
add--interactive: handle EOF in prompt_yesno
The prompt_yesno function loops indefinitely waiting for a "y" or "n" response. But it doesn't handle EOF, meaning that we can end up in an infinite loop of reading EOF from stdin. One way to simulate that is with: echo e | GIT_EDITOR='echo corrupt >' git add -p Let's break out of the loop and propagate the undef to the caller. Without modifying the callers that effectively turns it into a "no" response. This is reasonable for both of the current callers, and it leaves room for any future caller to check for undef explicitly. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-add--interactive.perl')
-rwxr-xr-xgit-add--interactive.perl1
1 files changed, 1 insertions, 0 deletions
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 4e0ab5a..7c95324 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -1152,6 +1152,7 @@ sub prompt_yesno {
while (1) {
print colored $prompt_color, $prompt;
my $line = prompt_single_character;
+ return undef unless defined $line;
return 0 if $line =~ /^n/i;
return 1 if $line =~ /^y/i;
}