@matheusbsbs / matheus-bagliano / commits / 7e018be2ad
Fork 0

git-add -i: add help text for list-and-choose UI

Signed-off-by: Junio C Hamano <gitster@pobox.com>

Wincent Colaiuta committed Dec 3, 2007 at 09:09 UTC 7e018be2ada073c92da59eb41442cde22c0c2796
1 file changed +30 -1
git-add--interactive.perl
+30 -1
@@ -237,7 +237,8 @@ sub is_valid_prefix {
237 !($prefix =~ /[\s,]/) && # separators
238 !($prefix =~ /^-/) && # deselection
239 !($prefix =~ /^\d+/) && # selection
240 - ($prefix ne '*'); # "all" wildcard
240 + ($prefix ne '*') && # "all" wildcard
241 + ($prefix ne '?'); # prompt help
242 }
243
244 # given a prefix/remainder tuple return a string with the prefix highlighted
@@ -318,6 +319,12 @@ sub list_and_choose {
319 }
320 chomp $line;
321 last if $line eq '';
322 + if ($line eq '?') {
323 + $opts->{SINGLETON} ?
324 + singleton_prompt_help_cmd() :
325 + prompt_help_cmd();
326 + next TOPLOOP;
327 + }
328 for my $choice (split(/[\s,]+/, $line)) {
329 my $choose = 1;
330 my ($bottom, $top);
@@ -363,6 +370,28 @@ sub list_and_choose {
370 return @return;
371 }
372
373 +sub singleton_prompt_help_cmd {
374 + print <<\EOF ;
375 +Prompt help:
376 +1 - select a numbered item
377 +foo - select item based on unique prefix
378 + - (empty) select nothing
379 +EOF
380 +}
381 +
382 +sub prompt_help_cmd {
383 + print <<\EOF ;
384 +Prompt help:
385 +1 - select a single item
386 +3-5 - select a range of items
387 +2-3,6-9 - select multiple ranges
388 +foo - select item based on unique prefix
389 +-... - unselect specified items
390 +* - choose all items
391 + - (empty) finish selecting
392 +EOF
393 +}
394 +
395 sub status_cmd {
396 list_and_choose({ LIST_ONLY => 1, HEADER => $status_head },
397 list_modified());