Skip to content

Commit d5addcf

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1d73f8e commit d5addcf

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

git-add--interactive.perl

+1
Original file line numberDiff line numberDiff line change
@@ -1152,6 +1152,7 @@ sub prompt_yesno {
11521152
while (1) {
11531153
print colored $prompt_color, $prompt;
11541154
my $line = prompt_single_character;
1155+
return undef unless defined $line;
11551156
return 0 if $line =~ /^n/i;
11561157
return 1 if $line =~ /^y/i;
11571158
}

0 commit comments

Comments
 (0)