@matheusbsbs / matheus-bagliano / commits / 9a7a1e03d5
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 9a7a1e03d5e530cdad98c41c109e3319c008ce69
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
@@ -894,6 +894,7 @@ sub help_patch_cmd {
894 print colored $help_color, <<\EOF ;
895 y - stage this hunk
896 n - do not stage this hunk
897 +q - quit, do not stage this hunk nor any of the remaining ones
898 a - stage this and all the remaining hunks in the file
899 d - do not stage this hunk nor any of the remaining hunks in the file
900 g - select a hunk to go to
@@ -930,7 +931,7 @@ sub patch_update_cmd {
931 @mods);
932 }
933 for (@them) {
933 - patch_update_file($_->{VALUE});
934 + return 0 if patch_update_file($_->{VALUE});
935 }
936 }
937
@@ -976,6 +977,7 @@ sub display_hunks {
977 }
978
979 sub patch_update_file {
980 + my $quit = 0;
981 my ($ix, $num);
982 my $path = shift;
983 my ($head, @hunk) = parse_diff($path);
@@ -1006,6 +1008,11 @@ sub patch_update_file {
1008 $_->{USE} = 0 foreach ($mode, @hunk);
1009 last;
1010 }
1011 + elsif ($line =~ /^q/i) {
1012 + $_->{USE} = 0 foreach ($mode, @hunk);
1013 + $quit = 1;
1014 + last;
1015 + }
1016 else {
1017 help_patch_cmd('');
1018 next;
@@ -1113,6 +1120,16 @@ sub patch_update_file {
1120 }
1121 next;
1122 }
1123 + elsif ($line =~ /^q/i) {
1124 + while ($ix < $num) {
1125 + if (!defined $hunk[$ix]{USE}) {
1126 + $hunk[$ix]{USE} = 0;
1127 + }
1128 + $ix++;
1129 + }
1130 + $quit = 1;
1131 + next;
1132 + }
1133 elsif ($line =~ m|^/(.*)|) {
1134 my $regex = $1;
1135 if ($1 eq "") {
@@ -1239,6 +1256,7 @@ sub patch_update_file {
1256 }
1257
1258 print "\n";
1259 + return $quit;
1260 }
1261
1262 sub diff_cmd {