{"thread":{"id":"27227","subject":"[PATCH] add -p: 'q' should really quit","startedAt":"2011-04-29T22:34:43Z","lastAt":"2011-04-29T22:34:43Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"166781","messageId":"7vzkn8vg8s.fsf@alter.siamese.dyndns.org","threadId":"27227","inReplyTo":null,"subject":"[PATCH] add -p: 'q' should really quit","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-04-29T22:34:43Z","receivedAt":"2011-04-29T22:34:43Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The \"quit\" command was added in 9a7a1e0 (git add -p: new \"quit\" command at\nthe prompt, 2009-04-10) to allow the user to say that hunks other than\nwhat have already been chosen are undesirable, and exit the interactive\nloop immediately.  It forgot that there may be an undecided hunk before\nthe current one.  In such a case, the interactive loop still goes back to\nthe beginning.\n\nClear all the USE bit for undecided hunks and exit the loop.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n git-add--interactive.perl |    9 ++++-----\n 1 files changed, 4 insertions(+), 5 deletions(-)\n\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex a329c5a..4fb8cd0 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -1366,14 +1366,13 @@ sub patch_update_file {\n \t\t\t\tnext;\n \t\t\t}\n \t\t\telsif ($line =~ /^q/i) {\n-\t\t\t\twhile ($ix < $num) {\n-\t\t\t\t\tif (!defined $hunk[$ix]{USE}) {\n-\t\t\t\t\t\t$hunk[$ix]{USE} = 0;\n+\t\t\t\tfor ($i = 0; $i < $num; $i++) {\n+\t\t\t\t\tif (!defined $hunk[$i]{USE}) {\n+\t\t\t\t\t\t$hunk[$i]{USE} = 0;\n \t\t\t\t\t}\n-\t\t\t\t\t$ix++;\n \t\t\t\t}\n \t\t\t\t$quit = 1;\n-\t\t\t\tnext;\n+\t\t\t\tlast;\n \t\t\t}\n \t\t\telsif ($line =~ m|^/(.*)|) {\n \t\t\t\tmy $regex = $1;\n-- \n1.7.5.252.g565191\n"}]}