mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
add-patch: quit on EOF
If we reach the end of the input, e.g. because the user pressed ctrl-D on Linux, there is no point in showing any more prompts, as we won't get any reply. Do the same as option 'q' would: Quit. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
13768117f5
commit
e56f6dcd7b
@@ -1569,8 +1569,10 @@ static int patch_update_file(struct add_p_state *s,
|
|||||||
if (*s->s.reset_color_interactive)
|
if (*s->s.reset_color_interactive)
|
||||||
fputs(s->s.reset_color_interactive, stdout);
|
fputs(s->s.reset_color_interactive, stdout);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
if (read_single_character(s) == EOF)
|
if (read_single_character(s) == EOF) {
|
||||||
|
quit = 1;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (!s->answer.len)
|
if (!s->answer.len)
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -1431,4 +1431,15 @@ test_expect_success 'invalid option s is rejected' '
|
|||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'EOF quits' '
|
||||||
|
echo a >file &&
|
||||||
|
echo a >file2 &&
|
||||||
|
git add file file2 &&
|
||||||
|
echo X >file &&
|
||||||
|
echo X >file2 &&
|
||||||
|
git add -p </dev/null >out &&
|
||||||
|
test_grep file out &&
|
||||||
|
test_grep ! file2 out
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|||||||
Reference in New Issue
Block a user