Skip to content

Commit 1376811

Browse files
rscharfegitster
authored andcommitted
add-patch: quit without skipping undecided hunks
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>
1 parent 4e98b73 commit 1376811

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

add-patch.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,7 +1601,7 @@ static int patch_update_file(struct add_p_state *s,
16011601
} else if (hunk->use == UNDECIDED_HUNK) {
16021602
hunk->use = USE_HUNK;
16031603
}
1604-
} else if (ch == 'd' || ch == 'q') {
1604+
} else if (ch == 'd') {
16051605
if (file_diff->hunk_nr) {
16061606
for (; hunk_index < file_diff->hunk_nr; hunk_index++) {
16071607
hunk = file_diff->hunk + hunk_index;
@@ -1613,10 +1613,9 @@ static int patch_update_file(struct add_p_state *s,
16131613
} else if (hunk->use == UNDECIDED_HUNK) {
16141614
hunk->use = SKIP_HUNK;
16151615
}
1616-
if (ch == 'q') {
1617-
quit = 1;
1618-
break;
1619-
}
1616+
} else if (ch == 'q') {
1617+
quit = 1;
1618+
break;
16201619
} else if (s->answer.buf[0] == 'K') {
16211620
if (permitted & ALLOW_GOTO_PREVIOUS_HUNK)
16221621
hunk_index = dec_mod(hunk_index,

0 commit comments

Comments
 (0)