bash completion: More completions for 'git stash'

Add branch subcommand to completions and USAGE for git-stash.sh.
Complete stash names for show, apply, drop, pop, and branch.
Add "--index" long option for apply.

Signed-off-by: Lee Marlow <lee.marlow@gmail.com>
Acked-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Lee Marlow
2008-08-04 23:50:35 -06:00
committed by Junio C Hamano
parent a6c2be244f
commit 95d43780cf
2 changed files with 12 additions and 2 deletions

View File

@ -1371,7 +1371,7 @@ _git_show_branch ()
_git_stash () _git_stash ()
{ {
local subcommands='save list show apply clear drop pop create' local subcommands='save list show apply clear drop pop create branch'
local subcommand="$(__git_find_subcommand "$subcommands")" local subcommand="$(__git_find_subcommand "$subcommands")"
if [ -z "$subcommand" ]; then if [ -z "$subcommand" ]; then
__gitcomp "$subcommands" __gitcomp "$subcommands"
@ -1381,6 +1381,16 @@ _git_stash ()
save,--*) save,--*)
__gitcomp "--keep-index" __gitcomp "--keep-index"
;; ;;
apply,--*)
__gitcomp "--index"
;;
show,--*|apply,--*|drop,--*|pop,--*|branch,--*)
COMPREPLY=()
;;
show,*|apply,*|drop,*|pop,*|branch,*)
__gitcomp "$(git --git-dir="$(__gitdir)" stash list \
| sed -n -e 's/:.*//p')"
;;
*) *)
COMPREPLY=() COMPREPLY=()
;; ;;

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
# Copyright (c) 2007, Nanako Shiraishi # Copyright (c) 2007, Nanako Shiraishi
USAGE='[ | save | list | show | apply | clear | drop | pop | create ]' USAGE='[ | save | list | show | apply | clear | drop | pop | create | branch ]'
SUBDIRECTORY_OK=Yes SUBDIRECTORY_OK=Yes
OPTIONS_SPEC= OPTIONS_SPEC=