@matheusbsbs / matheus-bagliano / commits / f5ea3f2bb3
Fork 0

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 <gitster@pobox.com>

Junio C Hamano committed Apr 29, 2011 at 15:12 UTC f5ea3f2bb30bf912d0021ef6a77e772ccdb4f8fd
1 file changed +4 -5
git-add--interactive.perl
+4 -5
@@ -1366,14 +1366,13 @@ sub patch_update_file {
1366 next;
1367 }
1368 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;
1372 }
1373 - $ix++;
1373 }
1374 $quit = 1;
1376 - next;
1375 + last;
1376 }
1377 elsif ($line =~ m|^/(.*)|) {
1378 my $regex = $1;