Skip to content

Commit fffd0cf

Browse files
scopgitster
authored andcommitted
completion: don't override given stash subcommand with -p
df70b19 (completion: make stash -p and alias for stash push -p, 2018-04-20) wanted to make sure "git stash -p <TAB>" offers the same completion as "git stash push -p <TAB>", but it did so by forcing the $subcommand to be "push" whenever then "-p" option is found on the command line. This harms any subcommand that can take the "-p" option---even when the subcommand is explicitly given, e.g. "git stash show -p", the code added by the change would overwrite the $subcommand the user gave us. Fix it by making sure that the defaulting to "push" happens only when there is no $subcommand given yet. Signed-off-by: Ville Skyttä <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent df70b19 commit fffd0cf

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

contrib/completion/git-completion.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2776,7 +2776,7 @@ _git_stash ()
27762776
local save_opts='--all --keep-index --no-keep-index --quiet --patch --include-untracked'
27772777
local subcommands='push list show apply clear drop pop create branch'
27782778
local subcommand="$(__git_find_on_cmdline "$subcommands save")"
2779-
if [ -n "$(__git_find_on_cmdline "-p")" ]; then
2779+
if [ -z "$subcommand" -a -n "$(__git_find_on_cmdline "-p")" ]; then
27802780
subcommand="push"
27812781
fi
27822782
if [ -z "$subcommand" ]; then

0 commit comments

Comments
 (0)