summaryrefslogtreecommitdiff
path: root/git-add--interactive.perl
diff options
context:
space:
mode:
authorPhillip Wood <phillip.wood@dunelm.org.uk>2018-02-13 10:32:39 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-02-13 21:01:56 (GMT)
commit01a6966021a50dc7aff76c0f951bbdd6e1bdd444 (patch)
tree8c4db6eca1404a7faede18942b1862554d87ba87 /git-add--interactive.perl
parent5be1f00a9a701532232f57958efab4be8c959a29 (diff)
downloadgit-01a6966021a50dc7aff76c0f951bbdd6e1bdd444.zip
git-01a6966021a50dc7aff76c0f951bbdd6e1bdd444.tar.gz
git-01a6966021a50dc7aff76c0f951bbdd6e1bdd444.tar.bz2
add -p: only display help for active keys
If the user presses a key that add -p wasn't expecting then it prints a list of key bindings. Although the prompt only lists the active bindings the help was printed for all bindings. Fix this by using the list of keys in the prompt to filter the help. Note that the list of keys was already passed to help_patch_cmd() by the caller so there is no change needed to the call site. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-add--interactive.perl')
-rwxr-xr-xgit-add--interactive.perl8
1 files changed, 7 insertions, 1 deletions
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 964c3a7..76b941f 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -1184,7 +1184,13 @@ d - do not apply this hunk or any of the later hunks in the file"),
);
sub help_patch_cmd {
- print colored $help_color, __($help_patch_modes{$patch_mode}), "\n", __ <<EOF ;
+ local $_;
+ my $other = $_[0] . ",/,?";
+ print colored $help_color, __($help_patch_modes{$patch_mode}), "\n",
+ map { "$_\n" } grep {
+ my $c = quotemeta(substr($_, 0, 1));
+ $other =~ /,$c/
+ } split "\n", __ <<EOF ;
g - select a hunk to go to
/ - search for a hunk matching the given regex
j - leave this hunk undecided, see next undecided hunk