]> git.ipfire.org Git - thirdparty/git.git/commitdiff
completion: don't override given stash subcommand with -p
authorVille Skyttä <ville.skytta@iki.fi>
Thu, 21 May 2020 18:35:59 +0000 (21:35 +0300)
committerJunio C Hamano <gitster@pobox.com>
Thu, 21 May 2020 19:55:33 +0000 (12:55 -0700)
df70b190 (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ä <ville.skytta@iki.fi>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/completion/git-completion.bash

index adb6516b6d1b1e56cb00a15ac3cb8f58cdeabfc0..75724caafc55a4efbccf585e3f3f5844e8f1ab69 100644 (file)
@@ -2776,7 +2776,7 @@ _git_stash ()
        local save_opts='--all --keep-index --no-keep-index --quiet --patch --include-untracked'
        local subcommands='push list show apply clear drop pop create branch'
        local subcommand="$(__git_find_on_cmdline "$subcommands save")"
-       if [ -n "$(__git_find_on_cmdline "-p")" ]; then
+       if [ -z "$subcommand" -a -n "$(__git_find_on_cmdline "-p")" ]; then
                subcommand="push"
        fi
        if [ -z "$subcommand" ]; then