Merge branch 'sp/maint-bash-completion-optim'

* sp/maint-bash-completion-optim:
  bash completion: Resolve git show ref:path<tab> losing ref: portion
  bash completion: Append space after file names have been completed
maint
Junio C Hamano 2008-07-14 23:36:08 -07:00
commit 3df6499c22
1 changed files with 34 additions and 3 deletions

View File

@ -45,6 +45,11 @@
# git@vger.kernel.org # git@vger.kernel.org
# #


case "$COMP_WORDBREAKS" in
*:*) : great ;;
*) COMP_WORDBREAKS="$COMP_WORDBREAKS:"
esac

__gitdir () __gitdir ()
{ {
if [ -z "$1" ]; then if [ -z "$1" ]; then
@ -294,9 +299,23 @@ __git_complete_file ()
ls="$ref" ls="$ref"
;; ;;
esac esac

case "$COMP_WORDBREAKS" in
*:*) : great ;;
*) pfx="$ref:$pfx" ;;
esac

local IFS=$'\n'
COMPREPLY=($(compgen -P "$pfx" \ COMPREPLY=($(compgen -P "$pfx" \
-W "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \ -W "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \
| sed '/^100... blob /s,^.* ,, | sed '/^100... blob /{
s,^.* ,,
s,$, ,
}
/^120000 blob /{
s,^.* ,,
s,$, ,
}
/^040000 tree /{ /^040000 tree /{
s,^.* ,, s,^.* ,,
s,$,/, s,$,/,
@ -692,7 +711,12 @@ _git_fetch ()
*) *)
case "$cur" in case "$cur" in
*:*) *:*)
__gitcomp "$(__git_refs)" "" "${cur#*:}" local pfx=""
case "$COMP_WORDBREAKS" in
*:*) : great ;;
*) pfx="${cur%%:*}:" ;;
esac
__gitcomp "$(__git_refs)" "$pfx" "${cur#*:}"
;; ;;
*) *)
local remote local remote
@ -868,7 +892,14 @@ _git_push ()
git-push) remote="${COMP_WORDS[1]}" ;; git-push) remote="${COMP_WORDS[1]}" ;;
git) remote="${COMP_WORDS[2]}" ;; git) remote="${COMP_WORDS[2]}" ;;
esac 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#+}" __gitcomp "$(__git_refs)" + "${cur#+}"