Skip to content

Commit f5ea3f2

Browse files
committed
add -p: 'q' should really quit
The "quit" command was added in 9a7a1e0 (git add -p: new "quit" command at the prompt, 2009-04-10) to allow the user to say that hunks other than what have already been chosen are undesirable, and exit the interactive loop immediately. It forgot that there may be an undecided hunk before the current one. In such a case, the interactive loop still goes back to the beginning. Clear all the USE bit for undecided hunks and exit the loop. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9d15860 commit f5ea3f2

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

git-add--interactive.perl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,14 +1366,13 @@ sub patch_update_file {
13661366
next;
13671367
}
13681368
elsif ($line =~ /^q/i) {
1369-
while ($ix < $num) {
1370-
if (!defined $hunk[$ix]{USE}) {
1371-
$hunk[$ix]{USE} = 0;
1369+
for ($i = 0; $i < $num; $i++) {
1370+
if (!defined $hunk[$i]{USE}) {
1371+
$hunk[$i]{USE} = 0;
13721372
}
1373-
$ix++;
13741373
}
13751374
$quit = 1;
1376-
next;
1375+
last;
13771376
}
13781377
elsif ($line =~ m|^/(.*)|) {
13791378
my $regex = $1;

0 commit comments

Comments
 (0)