diff options
| author | Junio C Hamano <gitster@pobox.com> | 2025-11-03 06:49:54 -0800 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-11-03 06:49:54 -0800 |
| commit | 18a7988898889bf9c8e17ad5a305d7e529d1ec6b (patch) | |
| tree | 1a764fb833f1a33b21cf04d0408df7fcf0c833c9 /add-patch.c | |
| parent | a99f379adf116d53eb11957af5bab5214915f91d (diff) | |
| parent | e56f6dcd7b4c90192018e848d0810f091d092913 (diff) | |
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
Diffstat (limited to 'add-patch.c')
| -rw-r--r-- | add-patch.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/add-patch.c b/add-patch.c index ae9a20d8f2..173a53241e 100644 --- a/add-patch.c +++ b/add-patch.c @@ -1569,8 +1569,10 @@ static int patch_update_file(struct add_p_state *s, if (*s->s.reset_color_interactive) fputs(s->s.reset_color_interactive, stdout); fflush(stdout); - if (read_single_character(s) == EOF) + if (read_single_character(s) == EOF) { + quit = 1; break; + } if (!s->answer.len) continue; @@ -1601,7 +1603,7 @@ soft_increment: } else if (hunk->use == UNDECIDED_HUNK) { hunk->use = USE_HUNK; } - } else if (ch == 'd' || ch == 'q') { + } else if (ch == 'd') { if (file_diff->hunk_nr) { for (; hunk_index < file_diff->hunk_nr; hunk_index++) { hunk = file_diff->hunk + hunk_index; @@ -1613,10 +1615,9 @@ soft_increment: } else if (hunk->use == UNDECIDED_HUNK) { hunk->use = SKIP_HUNK; } - if (ch == 'q') { - quit = 1; - break; - } + } else if (ch == 'q') { + quit = 1; + break; } else if (s->answer.buf[0] == 'K') { if (permitted & ALLOW_GOTO_PREVIOUS_HUNK) hunk_index = dec_mod(hunk_index, |
