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 3c2eb80f (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 <szeder@ira.uka.de> Acked-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
SZEDER Gábor committed
Sep 15, 2009 at 12:21 UTC
59d5eeee9f7e0cb71c10bde3da0fa01c3b3dbf8d
1 file changed
+16
-4
contrib/completion/git-completion.bash
+16
-4
@@ -1876,18 +1876,30 @@ _git_show_branch ()
1876
1877
_git_stash ()
1878
{
1879
+ local cur="${COMP_WORDS[COMP_CWORD]}"
1880
+ local save_opts='--keep-index --no-keep-index --quiet --patch'
1881
local subcommands='save list show apply clear drop pop create branch'
1882
local subcommand="$(__git_find_on_cmdline "$subcommands")"
1883
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
1896
else
1884
- local cur="${COMP_WORDS[COMP_CWORD]}"
1897
case "$subcommand,$cur" in
1898
save,--*)
1887
- __gitcomp "--keep-index"
1899
+ __gitcomp "$save_opts"
1900
;;
1901
apply,--*|pop,--*)
1890
- __gitcomp "--index"
1902
+ __gitcomp "--index --quiet"
1903
;;
1904
show,--*|drop,--*|branch,--*)
1905
COMPREPLY=()