]> git.ipfire.org Git - thirdparty/git.git/commitdiff
add-patch: quit without skipping undecided hunks
authorRené Scharfe <l.s.r@web.de>
Sat, 25 Oct 2025 05:46:42 +0000 (07:46 +0200)
committerJunio C Hamano <gitster@pobox.com>
Sat, 25 Oct 2025 16:45:07 +0000 (09:45 -0700)
Option q implies d, i.e., it marks any undecided hunks towards the
bottom of the hunk array as skipped.  This is unnecessary; later code
treats undecided and skipped hunks the same: The only functions that
use UNDECIDED_HUNK and SKIP_HUNK are patch_update_file() itself (but
not after its big for loop) and its helpers get_first_undecided() and
display_hunks().

Streamline the handling of option q by quitting immediately.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
add-patch.c

index ae9a20d8f23bafa8fdd4cea015238f23f57429e8..a70def1f81fe3f10902318f78e82cf45d5e2a636 100644 (file)
@@ -1601,7 +1601,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 +1613,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,