From: Felipe Contreras Date: Wed, 29 May 2013 03:20:48 +0000 (-0500) Subject: completion: avoid ls-remote in certain scenarios X-Git-Tag: v1.8.4-rc0~193^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e832f5c09680;p=thirdparty%2Fgit.git completion: avoid ls-remote in certain scenarios It's _very_ slow in many cases, and there's really no point in fetching *everything* from the remote just for completion. In many cases it might be faster for the user to type the whole thing. If the user manually specifies 'refs/*', then the full ls-remote completion is triggered. Signed-off-by: Felipe Contreras Signed-off-by: Junio C Hamano --- diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 1c35eef56a..2ce4f7de45 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -427,14 +427,8 @@ __git_refs () done ;; *) - git ls-remote "$dir" HEAD ORIG_HEAD 'refs/tags/*' 'refs/heads/*' 'refs/remotes/*' 2>/dev/null | \ - while read -r hash i; do - case "$i" in - *^{}) ;; - refs/*) echo "${i#refs/*/}" ;; - *) echo "$i" ;; - esac - done + echo "HEAD" + git for-each-ref --format="%(refname:short)" -- "refs/remotes/$dir/" | sed -e "s#^$dir/##" ;; esac }