Remove more sed invocations from within bash completion.

This change removes between 1 and 4 sed invocations per completion
entered by the user.  In the case of cat-file the 4 invocations per
completion can take a while on Cygwin; running these replacements
directly within bash saves some time for the end user.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
Shawn O. Pearce 2006-11-05 06:25:25 -05:00 committed by Junio C Hamano
parent e5d5b21fdf
commit a79c6551a3

View File

@ -83,15 +83,15 @@ __git_remotes ()
__git_complete_file () __git_complete_file ()
{ {
local cur="${COMP_WORDS[COMP_CWORD]}" local pfx ls ref cur="${COMP_WORDS[COMP_CWORD]}"
case "$cur" in case "$cur" in
?*:*) ?*:*)
local pfx ls ref="$(echo "$cur" | sed 's,:.*$,,')" ref="${cur%%:*}"
cur="$(echo "$cur" | sed 's,^.*:,,')" cur="${cur#*:}"
case "$cur" in case "$cur" in
?*/*) ?*/*)
pfx="$(echo "$cur" | sed 's,/[^/]*$,,')" pfx="${cur%/*}"
cur="$(echo "$cur" | sed 's,^.*/,,')" cur="${cur##*/}"
ls="$ref:$pfx" ls="$ref:$pfx"
pfx="$pfx/" pfx="$pfx/"
;; ;;
@ -193,7 +193,7 @@ _git_fetch ()
*) *)
case "$cur" in case "$cur" in
*:*) *:*)
cur=$(echo "$cur" | sed 's/^.*://') cur="${cur#*:}"
COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur")) COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
;; ;;
*) *)
@ -287,7 +287,7 @@ _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
cur=$(echo "$cur" | sed 's/^.*://') cur="${cur#*:}"
COMPREPLY=($(compgen -W "$(__git_refs "$remote")" -- "$cur")) COMPREPLY=($(compgen -W "$(__git_refs "$remote")" -- "$cur"))
;; ;;
*) *)