Skip to content

Commit 9a7a1e0

Browse files
moygitster
authored andcommitted
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>
1 parent c965c02 commit 9a7a1e0

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

Documentation/git-add.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ patch::
245245

246246
y - stage this hunk
247247
n - do not stage this hunk
248+
q - quite, do not stage this hunk nor any of the remaining ones
248249
a - stage this and all the remaining hunks in the file
249250
d - do not stage this hunk nor any of the remaining hunks in the file
250251
j - leave this hunk undecided, see next undecided hunk

git-add--interactive.perl

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,7 @@ sub help_patch_cmd {
894894
print colored $help_color, <<\EOF ;
895895
y - stage this hunk
896896
n - do not stage this hunk
897+
q - quit, do not stage this hunk nor any of the remaining ones
897898
a - stage this and all the remaining hunks in the file
898899
d - do not stage this hunk nor any of the remaining hunks in the file
899900
g - select a hunk to go to
@@ -930,7 +931,7 @@ sub patch_update_cmd {
930931
@mods);
931932
}
932933
for (@them) {
933-
patch_update_file($_->{VALUE});
934+
return 0 if patch_update_file($_->{VALUE});
934935
}
935936
}
936937

@@ -976,6 +977,7 @@ sub display_hunks {
976977
}
977978

978979
sub patch_update_file {
980+
my $quit = 0;
979981
my ($ix, $num);
980982
my $path = shift;
981983
my ($head, @hunk) = parse_diff($path);
@@ -1006,6 +1008,11 @@ sub patch_update_file {
10061008
$_->{USE} = 0 foreach ($mode, @hunk);
10071009
last;
10081010
}
1011+
elsif ($line =~ /^q/i) {
1012+
$_->{USE} = 0 foreach ($mode, @hunk);
1013+
$quit = 1;
1014+
last;
1015+
}
10091016
else {
10101017
help_patch_cmd('');
10111018
next;
@@ -1113,6 +1120,16 @@ sub patch_update_file {
11131120
}
11141121
next;
11151122
}
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+
}
11161133
elsif ($line =~ m|^/(.*)|) {
11171134
my $regex = $1;
11181135
if ($1 eq "") {
@@ -1239,6 +1256,7 @@ sub patch_update_file {
12391256
}
12401257

12411258
print "\n";
1259+
return $quit;
12421260
}
12431261

12441262
sub diff_cmd {

0 commit comments

Comments
 (0)