summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu Moy <Matthieu.Moy@imag.fr>2009-04-10 14:57:01 (GMT)
committerJunio C Hamano <gitster@pobox.com>2009-04-19 19:35:37 (GMT)
commitcbd3a01ed803778b2377e0148448f7e617bc381a (patch)
tree63b3f497fc804243786439f96ead38df2b80d93b
parent3bd1bb327eb4d3e386800897734f9f42b48280ff (diff)
downloadgit-cbd3a01ed803778b2377e0148448f7e617bc381a.zip
git-cbd3a01ed803778b2377e0148448f7e617bc381a.tar.gz
git-cbd3a01ed803778b2377e0148448f7e617bc381a.tar.bz2
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>
-rw-r--r--Documentation/git-add.txt1
-rwxr-xr-xgit-add--interactive.perl20
2 files changed, 20 insertions, 1 deletions
diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt
index ce71838..709e04b 100644
--- a/Documentation/git-add.txt
+++ b/Documentation/git-add.txt
@@ -245,6 +245,7 @@ patch::
y - stage this hunk
n - do not stage this hunk
+ q - quite, 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
j - leave this hunk undecided, see next undecided hunk
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 064d4c6..4fbd033 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -890,6 +890,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
@@ -926,7 +927,7 @@ sub patch_update_cmd {
@mods);
}
for (@them) {
- patch_update_file($_->{VALUE});
+ return 0 if patch_update_file($_->{VALUE});
}
}
@@ -972,6 +973,7 @@ sub display_hunks {
}
sub patch_update_file {
+ my $quit = 0;
my ($ix, $num);
my $path = shift;
my ($head, @hunk) = parse_diff($path);
@@ -1002,6 +1004,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;
@@ -1109,6 +1116,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 "") {
@@ -1235,6 +1252,7 @@ sub patch_update_file {
}
print "\n";
+ return $quit;
}
sub diff_cmd {