From: Junio C Hamano Date: Wed, 22 Dec 2010 22:40:55 +0000 (-0800) Subject: Merge branch 'pd/bash-4-completion' X-Git-Tag: v1.7.4-rc0~11 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=02fedc0f4835de7414b78e21739464a29520c94a;p=git.git Merge branch 'pd/bash-4-completion' * pd/bash-4-completion: bash: simple reimplementation of _get_comp_words_by_ref bash: get --pretty=m completion to work with bash v4 Conflicts: contrib/completion/git-completion.bash --- 02fedc0f4835de7414b78e21739464a29520c94a diff --cc contrib/completion/git-completion.bash index 803da09a1,d117055f5..893b7716c --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@@ -386,13 -543,12 +543,14 @@@ __git_tags ( 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/*) @@@ -1412,9 -1557,11 +1597,11 @@@ _git_log ( 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 ;; @@@ -1514,50 -1664,20 +1704,51 @@@ _git_name_rev ( _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 } @@@ -2249,10 -2306,11 +2451,11 @@@ _git_show ( { __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 ;;