From: Matthieu Moy <Matthieu.Moy@imag.fr>
To: git@vger.kernel.org
Cc: Matthieu Moy <Matthieu.Moy@imag.fr>
Subject: [RFC PATCH] git add -p: new "quit" command at the prompt.
Date: Fri, 10 Apr 2009 16:57:01 +0200 [thread overview]
Message-ID: <1239375421-2556-1-git-send-email-Matthieu.Moy@imag.fr> (raw)
There's already 'd' to stop staging hunks in a file, but no command to
stop the interactive staging (for the current files and the remaining
ones). This patch implements this functionality, and binds it to 'q'.
---
I'm not familiar at all with the code in git-add--interactive.perl, so
my code is mostly cut-and-pasted+adapted from the 'd' command.
Probably suboptimal.
git-add--interactive.perl | 20 +++++++++++++++++++-
1 files changed, 19 insertions(+), 1 deletions(-)
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index def062a..210d230 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 {
--
1.6.2.2.449.g92961.dirty
next reply other threads:[~2009-04-10 15:32 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-10 14:57 Matthieu Moy [this message]
2009-04-11 19:22 ` [RFC PATCH] git add -p: new "quit" command at the prompt Junio C Hamano
2009-04-12 12:45 ` Matthieu Moy
2009-04-12 12:54 ` Sverre Rabbelier
2009-04-13 1:39 ` Miles Bader
2009-04-12 17:29 ` [RFC PATCH] " Nicolas Sebrecht
2009-04-13 16:38 ` [RFC PATCH] " Wincent Colaiuta
2009-04-14 20:44 ` Matthieu Moy
2009-04-15 23:25 ` Junio C Hamano
2009-04-16 6:00 ` Jeff King
2009-04-16 6:52 ` Jeff King
2009-04-16 7:14 ` Jeff King
2009-04-16 16:44 ` Matthieu Moy
2009-04-16 16:46 ` [PATCH 1/2] " Matthieu Moy
2009-04-16 16:46 ` [PATCH 2/2] Update git-add.txt according to the new possibilities of 'git add -p' Matthieu Moy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1239375421-2556-1-git-send-email-Matthieu.Moy@imag.fr \
--to=matthieu.moy@imag.fr \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).