Skip to content

Commit 59d5eee

Browse files
szedergitster
authored andcommitted
bash: update 'git stash' completion
This update adds 'git stash (apply|pop) --quiet' and all options known to 'git stash save', and handles the DWIMery from 3c2eb80 (stash: simplify defaulting to "save" and reject unknown options, 2009-08-18). Care is taken to avoid offering subcommands in the DWIM case. Signed-off-by: SZEDER Gábor <[email protected]> Acked-by: Shawn O. Pearce <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 918c03c commit 59d5eee

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

contrib/completion/git-completion.bash

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1876,18 +1876,30 @@ _git_show_branch ()
18761876

18771877
_git_stash ()
18781878
{
1879+
local cur="${COMP_WORDS[COMP_CWORD]}"
1880+
local save_opts='--keep-index --no-keep-index --quiet --patch'
18791881
local subcommands='save list show apply clear drop pop create branch'
18801882
local subcommand="$(__git_find_on_cmdline "$subcommands")"
18811883
if [ -z "$subcommand" ]; then
1882-
__gitcomp "$subcommands"
1884+
case "$cur" in
1885+
--*)
1886+
__gitcomp "$save_opts"
1887+
;;
1888+
*)
1889+
if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
1890+
__gitcomp "$subcommands"
1891+
else
1892+
COMPREPLY=()
1893+
fi
1894+
;;
1895+
esac
18831896
else
1884-
local cur="${COMP_WORDS[COMP_CWORD]}"
18851897
case "$subcommand,$cur" in
18861898
save,--*)
1887-
__gitcomp "--keep-index"
1899+
__gitcomp "$save_opts"
18881900
;;
18891901
apply,--*|pop,--*)
1890-
__gitcomp "--index"
1902+
__gitcomp "--index --quiet"
18911903
;;
18921904
show,--*|drop,--*|branch,--*)
18931905
COMPREPLY=()

0 commit comments

Comments
 (0)