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

git add -p: new "quit" command at the prompt.

There's already 'd' to stop staging hunks in a file, but no explicit command to stop the interactive staging (for the current files and the remaining ones). Of course you can do 'd' and then ^C, but it would be more intuitive to allow 'quit' action. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Matthieu Moy committed Apr 10, 2009 at 16:57 UTC cbd3a01ed803778b2377e0148448f7e617bc381a
2 files changed +20 -1
Documentation/git-add.txt
+1
@@ -245,6 +245,7 @@ patch::
245
246 y - stage this hunk
247 n - do not stage this hunk
248 + q - quite, do not stage this hunk nor any of the remaining ones
249 a - stage this and all the remaining hunks in the file
250 d - do not stage this hunk nor any of the remaining hunks in the file
251 j - leave this hunk undecided, see next undecided hunk
git-add--interactive.perl
+19 -1
@@ -890,6 +890,7 @@ sub help_patch_cmd {
890 print colored $help_color, <<\EOF ;
891 y - stage this hunk
892 n - do not stage this hunk
893 +q - quit, do not stage this hunk nor any of the remaining ones
894 a - stage this and all the remaining hunks in the file
895 d - do not stage this hunk nor any of the remaining hunks in the file
896 g - select a hunk to go to
@@ -926,7 +927,7 @@ sub patch_update_cmd {
927 @mods);
928 }
929 for (@them) {
929 - patch_update_file($_->{VALUE});
930 + return 0 if patch_update_file($_->{VALUE});
931 }
932 }
933
@@ -972,6 +973,7 @@ sub display_hunks {
973 }
974
975 sub patch_update_file {
976 + my $quit = 0;
977 my ($ix, $num);
978 my $path = shift;
979 my ($head, @hunk) = parse_diff($path);
@@ -1002,6 +1004,11 @@ sub patch_update_file {
1004 $_->{USE} = 0 foreach ($mode, @hunk);
1005 last;
1006 }
1007 + elsif ($line =~ /^q/i) {
1008 + $_->{USE} = 0 foreach ($mode, @hunk);
1009 + $quit = 1;
1010 + last;
1011 + }
1012 else {
1013 help_patch_cmd('');
1014 next;
@@ -1109,6 +1116,16 @@ sub patch_update_file {
1116 }
1117 next;
1118 }
1119 + elsif ($line =~ /^q/i) {
1120 + while ($ix < $num) {
1121 + if (!defined $hunk[$ix]{USE}) {
1122 + $hunk[$ix]{USE} = 0;
1123 + }
1124 + $ix++;
1125 + }
1126 + $quit = 1;
1127 + next;
1128 + }
1129 elsif ($line =~ m|^/(.*)|) {
1130 my $regex = $1;
1131 if ($1 eq "") {
@@ -1235,6 +1252,7 @@ sub patch_update_file {
1252 }
1253
1254 print "\n";
1255 + return $quit;
1256 }
1257
1258 sub diff_cmd {