From: Junio C Hamano Date: Tue, 15 Jul 2008 06:36:08 +0000 (-0700) Subject: Merge branch 'sp/maint-bash-completion-optim' X-Git-Tag: v1.6.0-rc0~69 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=3df6499c227c28310b545edc42cdbd713ee0898a;hp=-c;p=git.git Merge branch 'sp/maint-bash-completion-optim' * sp/maint-bash-completion-optim: bash completion: Resolve git show ref:path losing ref: portion bash completion: Append space after file names have been completed --- 3df6499c227c28310b545edc42cdbd713ee0898a diff --combined contrib/completion/git-completion.bash index d48dbf267,72f02f208..37f52d539 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@@ -45,6 -45,11 +45,11 @@@ # git@vger.kernel.org # + case "$COMP_WORDBREAKS" in + *:*) : great ;; + *) COMP_WORDBREAKS="$COMP_WORDBREAKS:" + esac + __gitdir () { if [ -z "$1" ]; then @@@ -294,9 -299,23 +299,23 @@@ __git_complete_file ( ls="$ref" ;; esac + + case "$COMP_WORDBREAKS" in + *:*) : great ;; + *) pfx="$ref:$pfx" ;; + esac + + local IFS=$'\n' COMPREPLY=($(compgen -P "$pfx" \ -W "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \ - | sed '/^100... blob /s,^.* ,, + | sed '/^100... blob /{ + s,^.* ,, + s,$, , + } + /^120000 blob /{ + s,^.* ,, + s,$, , + } /^040000 tree /{ s,^.* ,, s,$,/, @@@ -528,7 -547,7 +547,7 @@@ _git_bisect ( { __git_has_doubledash && return - local subcommands="start bad good reset visualize replay log" + local subcommands="start bad good skip reset visualize replay log run" local subcommand="$(__git_find_subcommand "$subcommands")" if [ -z "$subcommand" ]; then __gitcomp "$subcommands" @@@ -536,7 -555,7 +555,7 @@@ fi case "$subcommand" in - bad|good|reset) + bad|good|reset|skip) __gitcomp "$(__git_refs)" ;; *) @@@ -563,7 -582,7 +582,7 @@@ _git_branch ( --*) __gitcomp " --color --no-color --verbose --abbrev= --no-abbrev - --track --no-track + --track --no-track --contains --merged --no-merged " ;; *) @@@ -692,7 -711,12 +711,12 @@@ _git_fetch ( *) case "$cur" in *:*) - __gitcomp "$(__git_refs)" "" "${cur#*:}" + local pfx="" + case "$COMP_WORDBREAKS" in + *:*) : great ;; + *) pfx="${cur%%:*}:" ;; + esac + __gitcomp "$(__git_refs)" "$pfx" "${cur#*:}" ;; *) local remote @@@ -785,9 -809,6 +809,9 @@@ _git_log ( --not --all --left-right --cherry-pick --graph + --stat --numstat --shortstat + --decorate --diff-filter= + --color-words --walk-reflogs " return ;; @@@ -868,7 -889,14 +892,14 @@@ _git_push ( git-push) remote="${COMP_WORDS[1]}" ;; git) remote="${COMP_WORDS[2]}" ;; esac - __gitcomp "$(__git_refs "$remote")" "" "${cur#*:}" + + local pfx="" + case "$COMP_WORDBREAKS" in + *:*) : great ;; + *) pfx="${cur%%:*}:" ;; + esac + + __gitcomp "$(__git_refs "$remote")" "$pfx" "${cur#*:}" ;; +*) __gitcomp "$(__git_refs)" + "${cur#+}" @@@ -905,24 -933,6 +936,24 @@@ _git_rebase ( __gitcomp "$(__git_refs)" } +_git_send_email () +{ + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$cur" in + --*) + __gitcomp "--bcc --cc --cc-cmd --chain-reply-to --compose + --dry-run --envelope-sender --from --identity + --in-reply-to --no-chain-reply-to --no-signed-off-by-cc + --no-suppress-from --no-thread --quiet + --signed-off-by-cc --smtp-pass --smtp-server + --smtp-server-port --smtp-ssl --smtp-user --subject + --suppress-cc --suppress-from --thread --to" + return + ;; + esac + COMPREPLY=() +} + _git_config () { local cur="${COMP_WORDS[COMP_CWORD]}" @@@ -1082,6 -1092,7 +1113,6 @@@ pull.octopus pull.twohead repack.useDeltaBaseOffset - show.difftree showbranch.default tar.umask transfer.unpackLimit @@@ -1090,6 -1101,7 +1121,6 @@@ user.name user.email user.signingkey - whatchanged.difftree branch. remote. " } @@@ -1182,19 -1194,8 +1213,19 @@@ _git_show ( _git_stash () { local subcommands='save list show apply clear drop pop create' - if [ -z "$(__git_find_subcommand "$subcommands")" ]; then + local subcommand="$(__git_find_subcommand "$subcommands")" + if [ -z "$subcommand" ]; then __gitcomp "$subcommands" + else + local cur="${COMP_WORDS[COMP_CWORD]}" + case "$subcommand,$cur" in + save,--*) + __gitcomp "--keep-index" + ;; + *) + COMPREPLY=() + ;; + esac fi } @@@ -1394,7 -1395,6 +1425,7 @@@ _git ( rebase) _git_rebase ;; remote) _git_remote ;; reset) _git_reset ;; + send-email) _git_send_email ;; shortlog) _git_shortlog ;; show) _git_show ;; show-branch) _git_log ;; @@@ -1454,7 -1454,6 +1485,7 @@@ complete -o default -o nospace -F _git_ complete -o default -o nospace -F _git_config git-config complete -o default -o nospace -F _git_remote git-remote complete -o default -o nospace -F _git_reset git-reset +complete -o default -o nospace -F _git_send_email git-send-email complete -o default -o nospace -F _git_shortlog git-shortlog complete -o default -o nospace -F _git_show git-show complete -o default -o nospace -F _git_stash git-stash