summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorSZEDER Gábor <szeder@ira.uka.de>2010-10-10 23:43:33 +0200
committerJunio C Hamano <gitster@pobox.com>2010-10-13 15:08:59 -0700
commit2a5da75579310a674431e6b91fed1d712f4c24ae (patch)
tree9d6b169809db165a44143dbdc3bad66333469896 /contrib
parent128191f5eec4365c4798d2bc8ef86008edb7d1bb (diff)
downloadgit-2a5da75579310a674431e6b91fed1d712f4c24ae.tar.gz
bash: support more 'git notes' subcommands and their options
The current completion function for 'git notes' only supported the 'edit' and 'show' subcommands and none of their options. This patch adds support for all missing subcommands, options, and their arguments (files or refs), if any. The code responsible for completing subcommand looks different compared to the completion functions of other git commands with subcommands. This is because of the '--ref <notes-ref>' option which comes before the subcommand (i.e. git notes --ref <notes-ref> add). Signed-off-by: SZEDER Gábor <szeder@ira.uka.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/completion/git-completion.bash50
1 files changed, 41 insertions, 9 deletions
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index d739113153..d69724f529 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1472,18 +1472,50 @@ _git_name_rev ()
_git_notes ()
{
- local subcommands="edit show"
- if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
- __gitcomp "$subcommands"
- return
- fi
+ local subcommands='add append copy edit list prune remove show'
+ local subcommand="$(__git_find_on_cmdline "$subcommands")"
+ local cur="${COMP_WORDS[COMP_CWORD]}"
- case "${COMP_WORDS[COMP_CWORD-1]}" in
- -m|-F)
- COMPREPLY=()
+ case "$subcommand,$cur" in
+ ,--*)
+ __gitcomp '--ref'
+ ;;
+ ,*)
+ case "${COMP_WORDS[COMP_CWORD-1]}" in
+ --ref)
+ __gitcomp "$(__git_refs)"
+ ;;
+ *)
+ __gitcomp "$subcommands --ref"
+ ;;
+ esac
+ ;;
+ add,--reuse-message=*|append,--reuse-message=*)
+ __gitcomp "$(__git_refs)" "" "${cur##--reuse-message=}"
+ ;;
+ add,--reedit-message=*|append,--reedit-message=*)
+ __gitcomp "$(__git_refs)" "" "${cur##--reedit-message=}"
+ ;;
+ add,--*|append,--*)
+ __gitcomp '--file= --message= --reedit-message=
+ --reuse-message='
+ ;;
+ copy,--*)
+ __gitcomp '--stdin'
+ ;;
+ prune,--*)
+ __gitcomp '--dry-run --verbose'
+ ;;
+ prune,*)
;;
*)
- __gitcomp "$(__git_refs)"
+ case "${COMP_WORDS[COMP_CWORD-1]}" in
+ -m|-F)
+ ;;
+ *)
+ __gitcomp "$(__git_refs)"
+ ;;
+ esac
;;
esac
}