author | Junio C Hamano <gitster@pobox.com> | |
Wed, 22 Dec 2010 00:46:52 +0000 (16:46 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 22 Dec 2010 00:46:52 +0000 (16:46 -0800) |
* pd/bash-4-completion:
bash: simple reimplementation of _get_comp_words_by_ref
bash: get --pretty=m<tab> completion to work with bash v4
Conflicts:
contrib/completion/git-completion.bash
bash: simple reimplementation of _get_comp_words_by_ref
bash: get --pretty=m<tab> completion to work with bash v4
Conflicts:
contrib/completion/git-completion.bash
1 | 2 | |||
---|---|---|---|---|
contrib/completion/git-completion.bash | patch | | diff1 | | diff2 | | blob | history |
diff --cc contrib/completion/git-completion.bash
index 803da09a126ad75ad3578a90d117e13cef48ba46,d117055f56ea2200ebe6d23a558c7b654b1035cf..893b7716cafa4811d237480a980140d308aa20dc
done
}
-# __git_refs accepts 0 or 1 arguments (to pass to __gitdir)
+# __git_refs accepts 0, 1 (to pass to __gitdir), or 2 arguments
+# presence of 2nd argument means use the guess heuristic employed
+# by checkout for tracking branches
__git_refs ()
{
- local i is_hash=y dir="$(__gitdir "${1-}")"
+ local i is_hash=y dir="$(__gitdir "${1-}")" track="${2-}"
- local cur="${COMP_WORDS[COMP_CWORD]}" format refs
+ local cur format refs
+ _get_comp_words_by_ref -n =: cur
if [ -d "$dir" ]; then
case "$cur" in
refs|refs/*)
if [ -f "$g/MERGE_HEAD" ]; then
merge="--merge"
fi
+ local cur
+ _get_comp_words_by_ref -n =: cur
case "$cur" in
--pretty=*)
- __gitcomp "$__git_log_pretty_formats
+ __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
" "" "${cur##--pretty=}"
return
;;
_git_notes ()
{
- local subcommands="edit show"
- local words cword
- _get_comp_words_by_ref -n =: words cword
- 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]}"
++ local cur words cword
++ _get_comp_words_by_ref -n =: cur words cword
- case "${words[cword-1]}" in
- -m|-F)
- COMPREPLY=()
+ case "$subcommand,$cur" in
+ ,--*)
+ __gitcomp '--ref'
+ ;;
+ ,*)
- case "${COMP_WORDS[COMP_CWORD-1]}" in
++ case "${words[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,*)
;;
*)
- case "${COMP_WORDS[COMP_CWORD-1]}" in
- __gitcomp "$(__git_refs)"
++ case "${words[cword-1]}" in
+ -m|-F)
+ ;;
+ *)
+ __gitcomp "$(__git_refs)"
+ ;;
+ esac
;;
esac
}
{
__git_has_doubledash && return
- local cur="${COMP_WORDS[COMP_CWORD]}"
+ local cur
+ _get_comp_words_by_ref -n =: cur
case "$cur" in
--pretty=*)
- __gitcomp "$__git_log_pretty_formats
+ __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
" "" "${cur##--pretty=}"
return
;;