git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Highlight keyboard shortcuts in git-add--interactive

From
Wincent Colaiuta <win@wincent.com>
Date
Dec 2, 2007, 14:11 UTC
Message-ID
<5B4BC281-10BD-437F-A956-EEB73F40A76C@wincent.com>
In-Reply-To
<7vy7cf87jz.fsf@gitster.siamese.dyndns.org>
El 1/12/2007, a las 3:36, Junio C Hamano escribió:
Show 8 quoted lines
> When list_and_choose() function is letting you choose more than one
> items, its prompt becomes ">> ", instead of "> " that is used for a
> singleton choice.  To that prompt, you can say "3-7" (Add these 5  
> items
> to the choice), "*" (I want all of them), "-2-4" (exclude 2 and 3  
> and 4
> from the set I have chosen so far).  These are also "hidden", and need
> to be documented, but that would be a separate patch.

I was just about to prepare some documentation for this when I saw that it is already documented, and by none other than you, Junio! (see 6a5ad23d).

Unless by "documentation" you meant to somehow expose these in the interface at runtime... something like this? (applied on top of the patch I just sent to the list):

diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 32fb9ea..e7b07ee 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -237,7 +237,8 @@ sub is_valid_prefix {
  	    !($prefix =~ /[\s,]/) && # separators
  	    !($prefix =~ /^-/) &&    # deselection
  	    !($prefix =~ /^\d+/) &&  # selection
-	    ($prefix ne '*');        # "all" wildcard
+	    ($prefix ne '*') &&      # "all" wildcard
+	    ($prefix ne '?');        # prompt help
  }

  # given a prefix/remainder tuple return a string with the prefix  
highlighted
@@ -308,7 +309,7 @@ sub list_and_choose {
  			print "> ";
  		}
  		else {
-			print ">> ";
+			print " (?)>> ";
  		}
  		my $line = <STDIN>;
  		if (!$line) {
@@ -318,6 +319,10 @@ sub list_and_choose {
  		}
  		chomp $line;
  		last if $line eq '';
+		if ($line eq '?' && !$opts->{SINGLETON}) {
+			prompt_help_cmd();
+			next TOPLOOP;
+		}
  		for my $choice (split(/[\s,]+/, $line)) {
  			my $choose = 1;
  			my ($bottom, $top);
@@ -363,6 +368,19 @@ sub list_and_choose {
  	return @return;
  }

+sub prompt_help_cmd {
+	print <<\EOF ;
+Prompt help:
+1          - select a single item
+3-5        - select a range of items
+2-3,6-9    - select multiple ranges
+foo        - select item based on unique prefix
+-...       - unselect specified items
+*          - choose all items
+           - (empty) finish selecting
+EOF
+}
+
  sub status_cmd {
  	list_and_choose({ LIST_ONLY => 1, HEADER => $status_head },
  			list_modified());


Cheers,
Wincent
Previous: Wincent ColaiutaNext: Junio C Hamano
Message 15 of 17 in “Highlight keyboard shortcuts in git-add--interactive”
  1. Highlight keyboard shortcuts in git-add--interactiveWincent Colaiuta, Nov 21, 2007
  2. Matthieu MoyNov 21, 2007
  3. Jeff KingNov 21, 2007
  4. Dan ZwellNov 21, 2007
  5. Junio C HamanoNov 28, 2007
  6. Wincent ColaiutaNov 29, 2007
  7. Highlight keyboard shortcuts in git-add--interactiveWincent Colaiuta, Nov 29, 2007
  8. Jeff KingNov 29, 2007
  9. Junio C HamanoDec 1, 2007
  10. Wincent ColaiutaDec 1, 2007
  11. 1/2 Highlight keyboard shortcuts in git-add--interactiveWincent Colaiuta, Dec 1, 2007
  12. 2/2 Teach git-add--interactive to highlight untracked file prefixesWincent Colaiuta, Dec 1, 2007
  13. Wincent ColaiutaDec 1, 2007
  14. Highlight keyboard shortcuts in git-add--interactiveWincent Colaiuta, Dec 1, 2007
  15. Wincent ColaiutaDec 2, 2007
  16. Junio C HamanoDec 2, 2007
  17. Wincent ColaiutaDec 3, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.