git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Wincent Colaiuta <win@wincent.com>
Cc: git@vger.kernel.org, peff@peff.net
Subject: Re: [PATCH] Add path-limiting to git-add--interactive
Date: Thu, 22 Nov 2007 01:45:48 -0800	[thread overview]
Message-ID: <7vd4u27gvn.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <7vpry27id0.fsf@gitster.siamese.dyndns.org> (Junio C. Hamano's message of "Thu, 22 Nov 2007 01:13:47 -0800")

Junio C Hamano <gitster@pobox.com> writes:

> Wincent Colaiuta <win@wincent.com> writes:
>
>> @@ -56,9 +56,14 @@ sub list_modified {
>>  	my ($only) = @_;
>>  	my (%data, @return);
>>  	my ($add, $del, $adddel, $file);
>> +	my @tracked = grep {
>> +		defined run_cmd_pipe(qw(git ls-files
>> +			                --exclude-standard --), $_)
>> +	} @ARGV;
>> +	return if $#tracked == -1 && $#ARGV != -1;
>
> Eek.  why?
>
> Did you mean to say:
>
>     my @tracked = run_cmd_pipe(gw(git ls-files --exclude-standard --) @ARGV);
>
> It would also make sense to use --error-unmatch and perhaps --with-tree=HEAD
> like git-commit.sh does.

Actually, the ls-files need to be chomped, but I'd prefer to
run -z form of the command and split with NUL.  Does run_cmd_pipe()
crap^Wstuff support that?

On top of:

 * refactor patch_update_cmd,
 * teach builtin-add to pass multiple paths,
 * add path-limiting to git-add--interacgtive (with an obvious
   suggested above),

the attached patch teaches [p]atch subcommand to take multiple
selections.  With these, you can do:

	$ git add -i 'u*.h'
	What now> p
                   staged     unstaged path
          1:    unchanged        +1/-0 unpack-trees.h
          2:    unchanged        +1/-0 utf8.h
        Patch update>> *
        diff --git a/unpack-trees.h b/unpack-trees.h
	...
        Stage this hunk [y/n/a/d/?]? y
        ...
	diff --git a/utf8.h b/utf8.h
        ...

-- >8 --
git-add -i: allow multiple selection in [p]atch subcommand

This allows more than one files from the list to be chosen from
the patch subcommand instead of going through the file one by
one.

This also updates the "list-and-choose" UI for usability.  When
the prompt ends with ">>", if you type '*' to choose all
choices, the prompt immediately returns the choice without
requiring an extra empty line to confirm the selection.

---
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 9236ffc..372dc2c 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -256,7 +256,7 @@ sub list_and_choose {
 				$chosen[$i] = $choose;
 			}
 		}
-		last if ($opts->{IMMEDIATE});
+		last if ($opts->{IMMEDIATE} || $line eq '*');
 	}
 	for ($i = 0; $i < @stuff; $i++) {
 		if ($chosen[$i]) {
@@ -563,12 +563,12 @@ sub patch_update_cmd {
 	@mods = grep { !($_->{BINARY}) } @mods;
 	return if (!@mods);
 
-	my ($it) = list_and_choose({ PROMPT => 'Patch update',
-				     SINGLETON => 1,
-				     IMMEDIATE => 1,
-				     HEADER => $status_head, },
-				   @mods);
-	patch_update_file($it->{VALUE}) if ($it);
+	my (@them) = list_and_choose({ PROMPT => 'Patch update',
+				       HEADER => $status_head, },
+				     @mods);
+	for (@them) {
+		patch_update_file($_->{VALUE});
+	}
 }
 
 sub patch_update_file {

  reply	other threads:[~2007-11-22  9:46 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-21 12:36 [PATCH] teaching git-add--interactive to accept a file param Wincent Colaiuta
2007-11-21 12:36 ` [PATCH 1/4] Refactor patch_update_cmd Wincent Colaiuta
2007-11-21 12:36   ` [PATCH 2/4] Teach git-add--interactive to accept a file path to patch Wincent Colaiuta
2007-11-21 12:36     ` [PATCH 3/4] Teach builtin-add to pass a path argument to git-add--interactive Wincent Colaiuta
2007-11-21 12:36       ` [PATCH 4/4] Document optional file parameter " Wincent Colaiuta
2007-11-21 15:21     ` [PATCH 2/4] Teach git-add--interactive to accept a file path to patch Jeff King
2007-11-21 16:15       ` Wincent Colaiuta
2007-11-21 20:40       ` Junio C Hamano
2007-11-21 22:44         ` Wincent Colaiuta
2007-11-22  0:02           ` Updates: teaching git-add--interactive to accept a file param Wincent Colaiuta
2007-11-22  0:02             ` [PATCH 1/4] Suppress spurious linefeeds in git-add--interactive Wincent Colaiuta
2007-11-22  0:02               ` [PATCH 2/4] Teach git-add--interactive to accept multiple file params Wincent Colaiuta
2007-11-22  0:02                 ` [PATCH 3/4] Teach builtin-add to pass multiple paths to git-add--interactive Wincent Colaiuta
2007-11-22  0:02                   ` [PATCH 4/4] Update git-add documentation for multiple interactive paths Wincent Colaiuta
2007-11-22  9:08                   ` [PATCH 3/4] Teach builtin-add to pass multiple paths to git-add--interactive Jeff King
2007-11-22 10:28                     ` Wincent Colaiuta
2007-11-22 10:33                       ` Jeff King
2007-11-22 11:02                         ` Wincent Colaiuta
2007-11-22 11:37                           ` Jeff King
2007-11-22  8:59               ` [PATCH 1/4] Suppress spurious linefeeds in git-add--interactive Jeff King
2007-11-22 10:18                 ` Wincent Colaiuta
2007-11-22 10:38                   ` Junio C Hamano
2007-11-22  0:18           ` [PATCH 2/4] Teach git-add--interactive to accept a file path to patch Junio C Hamano
2007-11-22  1:36             ` [PATCH] Add path-limiting to git-add--interactive Wincent Colaiuta
2007-11-22  9:13               ` Junio C Hamano
2007-11-22  9:45                 ` Junio C Hamano [this message]
2007-11-22 11:35                   ` Wincent Colaiuta
2007-11-22 11:14                 ` Wincent Colaiuta
2007-11-22  1:41             ` [PATCH 2/4] Teach git-add--interactive to accept a file path to patch Wincent Colaiuta
2007-11-22  9:13             ` Jeff King
2007-11-22  9:50               ` Junio C Hamano
2007-11-22  9:57                 ` Jeff King
2007-11-22 10:44                 ` Wincent Colaiuta
2007-11-22 11:24                   ` Jeff King
2007-11-22 11:29                   ` Junio C Hamano
2007-11-22 11:36                     ` Jeff King
2007-11-22 13:34                     ` Wincent Colaiuta
2007-11-22 19:29                       ` Junio C Hamano
2007-11-22 21:55                         ` Wincent Colaiuta

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=7vd4u27gvn.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    --cc=win@wincent.com \
    /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).