summaryrefslogtreecommitdiff
path: root/git-add--interactive.perl
diff options
context:
space:
mode:
authorMatthieu Moy <Matthieu.Moy@imag.fr>2009-04-10 16:57:01 +0200
committerJunio C Hamano <gitster@pobox.com>2009-04-15 19:41:35 -0700
commit9a7a1e03d5e530cdad98c41c109e3319c008ce69 (patch)
tree10264819c881f230ed1de56a32cf3c385b2245c7 /git-add--interactive.perl
parentc965c029330b1f81cc107c5d829e7fd79c61d8ea (diff)
downloadgit-9a7a1e03d5e530cdad98c41c109e3319c008ce69.tar.gz
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>
Diffstat (limited to 'git-add--interactive.perl')
-rwxr-xr-xgit-add--interactive.perl20
1 files changed, 19 insertions, 1 deletions
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index def062a9e2..210d23022d 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -894,6 +894,7 @@ sub help_patch_cmd {
print colored $help_color, <<\EOF ;
y - stage this hunk
n - do not stage this hunk
+q - quit, do not stage this hunk nor any of the remaining ones
a - stage this and all the remaining hunks in the file
d - do not stage this hunk nor any of the remaining hunks in the file
g - select a hunk to go to
@@ -930,7 +931,7 @@ sub patch_update_cmd {
@mods);
}
for (@them) {
- patch_update_file($_->{VALUE});
+ return 0 if patch_update_file($_->{VALUE});
}
}
@@ -976,6 +977,7 @@ sub display_hunks {
}
sub patch_update_file {
+ my $quit = 0;
my ($ix, $num);
my $path = shift;
my ($head, @hunk) = parse_diff($path);
@@ -1006,6 +1008,11 @@ sub patch_update_file {
$_->{USE} = 0 foreach ($mode, @hunk);
last;
}
+ elsif ($line =~ /^q/i) {
+ $_->{USE} = 0 foreach ($mode, @hunk);
+ $quit = 1;
+ last;
+ }
else {
help_patch_cmd('');
next;
@@ -1113,6 +1120,16 @@ sub patch_update_file {
}
next;
}
+ elsif ($line =~ /^q/i) {
+ while ($ix < $num) {
+ if (!defined $hunk[$ix]{USE}) {
+ $hunk[$ix]{USE} = 0;
+ }
+ $ix++;
+ }
+ $quit = 1;
+ next;
+ }
elsif ($line =~ m|^/(.*)|) {
my $regex = $1;
if ($1 eq "") {
@@ -1239,6 +1256,7 @@ sub patch_update_file {
}
print "\n";
+ return $quit;
}
sub diff_cmd {