Skip to content

Commit

Permalink
git-add -i: add help text for list-and-choose UI
Browse files Browse the repository at this point in the history
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Wincent Colaiuta authored and Junio C Hamano committed Dec 3, 2007
1 parent 6332098 commit 7e018be
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion git-add--interactive.perl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -318,6 +319,12 @@ sub list_and_choose {
}
chomp $line;
last if $line eq '';
if ($line eq '?') {
$opts->{SINGLETON} ?
singleton_prompt_help_cmd() :
prompt_help_cmd();
next TOPLOOP;
}
for my $choice (split(/[\s,]+/, $line)) {
my $choose = 1;
my ($bottom, $top);
Expand Down Expand Up @@ -363,6 +370,28 @@ sub list_and_choose {
return @return;
}

sub singleton_prompt_help_cmd {
print <<\EOF ;
Prompt help:
1 - select a numbered item
foo - select item based on unique prefix
- (empty) select nothing
EOF
}

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());
Expand Down

0 comments on commit 7e018be

Please sign in to comment.