1
0
mirror of https://github.com/git/git.git synced 2024-11-20 14:13:58 +01:00

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

* 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
  bash completion: Don't offer "a.." as a completion for "a."
  bash completion: Improve responsiveness of git-log completion
This commit is contained in:
Junio C Hamano 2008-07-16 15:25:24 -07:00
commit c9784cd0c8

@ -45,6 +45,11 @@
# git@vger.kernel.org
#
case "$COMP_WORDBREAKS" in
*:*) : great ;;
*) COMP_WORDBREAKS="$COMP_WORDBREAKS:"
esac
__gitdir ()
{
if [ -z "$1" ]; then
@ -114,9 +119,20 @@ __git_ps1 ()
fi
}
__gitcomp_1 ()
{
local c IFS=' '$'\t'$'\n'
for c in $1; do
case "$c$2" in
--*=*) printf %s$'\n' "$c$2" ;;
*.) printf %s$'\n' "$c$2" ;;
*) printf %s$'\n' "$c$2 " ;;
esac
done
}
__gitcomp ()
{
local all c s=$'\n' IFS=' '$'\t'$'\n'
local cur="${COMP_WORDS[COMP_CWORD]}"
if [ $# -gt 2 ]; then
cur="$3"
@ -124,21 +140,14 @@ __gitcomp ()
case "$cur" in
--*=)
COMPREPLY=()
return
;;
*)
for c in $1; do
case "$c$4" in
--*=*) all="$all$c$4$s" ;;
*.) all="$all$c$4$s" ;;
*) all="$all$c$4 $s" ;;
esac
done
local IFS=$'\n'
COMPREPLY=($(compgen -P "$2" \
-W "$(__gitcomp_1 "$1" "$4")" \
-- "$cur"))
;;
esac
IFS=$s
COMPREPLY=($(compgen -P "$2" -W "$all" -- "$cur"))
return
}
__git_heads ()
@ -290,9 +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,$,/,
@ -320,9 +343,6 @@ __git_complete_revlist ()
cur="${cur#*..}"
__gitcomp "$(__git_refs)" "$pfx" "$cur"
;;
*.)
__gitcomp "$cur."
;;
*)
__gitcomp "$(__git_refs)"
;;
@ -691,7 +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
@ -864,7 +889,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#+}"