git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] add -p: 'q' should really quit
@ 2011-04-29 22:34 Junio C Hamano
  0 siblings, 0 replies; only message in thread
From: Junio C Hamano @ 2011-04-29 22:34 UTC (permalink / raw)
  To: git; +Cc: Matthieu Moy

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>
---
 git-add--interactive.perl |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index a329c5a..4fb8cd0 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -1366,14 +1366,13 @@ sub patch_update_file {
 				next;
 			}
 			elsif ($line =~ /^q/i) {
-				while ($ix < $num) {
-					if (!defined $hunk[$ix]{USE}) {
-						$hunk[$ix]{USE} = 0;
+				for ($i = 0; $i < $num; $i++) {
+					if (!defined $hunk[$i]{USE}) {
+						$hunk[$i]{USE} = 0;
 					}
-					$ix++;
 				}
 				$quit = 1;
-				next;
+				last;
 			}
 			elsif ($line =~ m|^/(.*)|) {
 				my $regex = $1;
-- 
1.7.5.252.g565191

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2011-04-29 22:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-29 22:34 [PATCH] add -p: 'q' should really quit Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).