mirror of
https://github.com/git/git.git
synced 2025-12-18 12:00:25 +01:00
Merge branch 'rs/add-patch-quit'
The 'q'(uit) command in "git add -p" has been improved to quit without doing any meaningless work before leaving, and giving EOF (typically control-D) to the prompt is made to behave the same way. * rs/add-patch-quit: add-patch: quit on EOF add-patch: quit without skipping undecided hunks
This commit is contained in:
@@ -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;
|
||||||
@@ -1601,7 +1603,7 @@ soft_increment:
|
|||||||
} else if (hunk->use == UNDECIDED_HUNK) {
|
} else if (hunk->use == UNDECIDED_HUNK) {
|
||||||
hunk->use = USE_HUNK;
|
hunk->use = USE_HUNK;
|
||||||
}
|
}
|
||||||
} else if (ch == 'd' || ch == 'q') {
|
} else if (ch == 'd') {
|
||||||
if (file_diff->hunk_nr) {
|
if (file_diff->hunk_nr) {
|
||||||
for (; hunk_index < file_diff->hunk_nr; hunk_index++) {
|
for (; hunk_index < file_diff->hunk_nr; hunk_index++) {
|
||||||
hunk = file_diff->hunk + hunk_index;
|
hunk = file_diff->hunk + hunk_index;
|
||||||
@@ -1613,10 +1615,9 @@ soft_increment:
|
|||||||
} else if (hunk->use == UNDECIDED_HUNK) {
|
} else if (hunk->use == UNDECIDED_HUNK) {
|
||||||
hunk->use = SKIP_HUNK;
|
hunk->use = SKIP_HUNK;
|
||||||
}
|
}
|
||||||
if (ch == 'q') {
|
} else if (ch == 'q') {
|
||||||
quit = 1;
|
quit = 1;
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
} else if (s->answer.buf[0] == 'K') {
|
} else if (s->answer.buf[0] == 'K') {
|
||||||
if (permitted & ALLOW_GOTO_PREVIOUS_HUNK)
|
if (permitted & ALLOW_GOTO_PREVIOUS_HUNK)
|
||||||
hunk_index = dec_mod(hunk_index,
|
hunk_index = dec_mod(hunk_index,
|
||||||
|
|||||||
@@ -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