Skip to content

Commit 01a6966

Browse files
phillipwoodgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5be1f00 commit 01a6966

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

git-add--interactive.perl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,13 @@ sub edit_hunk_loop {
11841184
);
11851185

11861186
sub help_patch_cmd {
1187-
print colored $help_color, __($help_patch_modes{$patch_mode}), "\n", __ <<EOF ;
1187+
local $_;
1188+
my $other = $_[0] . ",/,?";
1189+
print colored $help_color, __($help_patch_modes{$patch_mode}), "\n",
1190+
map { "$_\n" } grep {
1191+
my $c = quotemeta(substr($_, 0, 1));
1192+
$other =~ /,$c/
1193+
} split "\n", __ <<EOF ;
11881194
g - select a hunk to go to
11891195
/ - search for a hunk matching the given regex
11901196
j - leave this hunk undecided, see next undecided hunk

0 commit comments

Comments
 (0)