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>
Shawn O. Pearce committed
Nov 5, 2006 at 06:25 UTC
a79c6551a315b26f2461dd9734defce88014b77b
1 file changed
+7
-7
contrib/completion/git-completion.bash
+7
-7
@@ -83,15 +83,15 @@ __git_remotes ()
83
84
__git_complete_file ()
85
{
86
- local cur="${COMP_WORDS[COMP_CWORD]}"
86
+ local pfx ls ref cur="${COMP_WORDS[COMP_CWORD]}"
87
case "$cur" in
88
?*:*)
89
- local pfx ls ref="$(echo "$cur" | sed 's,:.*$,,')"
90
- cur="$(echo "$cur" | sed 's,^.*:,,')"
89
+ ref="${cur%%:*}"
90
+ cur="${cur#*:}"
91
case "$cur" in
92
?*/*)
93
- pfx="$(echo "$cur" | sed 's,/[^/]*$,,')"
94
- cur="$(echo "$cur" | sed 's,^.*/,,')"
93
+ pfx="${cur%/*}"
94
+ cur="${cur##*/}"
95
ls="$ref:$pfx"
96
pfx="$pfx/"
97
;;
@@ -193,7 +193,7 @@ _git_fetch ()
193
*)
194
case "$cur" in
195
*:*)
196
- cur=$(echo "$cur" | sed 's/^.*://')
196
+ cur="${cur#*:}"
197
COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
198
;;
199
*)
@@ -287,7 +287,7 @@ _git_push ()
287
git-push) remote="${COMP_WORDS[1]}" ;;
288
git) remote="${COMP_WORDS[2]}" ;;
289
esac
290
- cur=$(echo "$cur" | sed 's/^.*://')
290
+ cur="${cur#*:}"
291
COMPREPLY=($(compgen -W "$(__git_refs "$remote")" -- "$cur"))
292
;;
293
*)