summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-07-15 06:36:08 (GMT)
committerJunio C Hamano <gitster@pobox.com>2008-07-15 06:36:08 (GMT)
commit3df6499c227c28310b545edc42cdbd713ee0898a (patch)
tree37719aeff56c88f98b05b901640c1d731bfeeae8 /contrib
parentac9391093f54370ff3f06470e24d78b536a12327 (diff)
parentdb8a9ff03831a26aa8bfad8bb026b90739d684ec (diff)
downloadgit-3df6499c227c28310b545edc42cdbd713ee0898a.zip
git-3df6499c227c28310b545edc42cdbd713ee0898a.tar.gz
git-3df6499c227c28310b545edc42cdbd713ee0898a.tar.bz2
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
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/completion/git-completion.bash37
1 files changed, 34 insertions, 3 deletions
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index d48dbf2..37f52d5 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -45,6 +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 @@ __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,$,/,
@@ -692,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
@@ -868,7 +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#+}"