From: SZEDER Gábor Date: Sat, 08 Oct 2011 14:54:40 GMT Subject: [PATCH 6/9] completion: query only refs/heads/ in __git_refs_remotes() Message-ID: <1318085683-29830-7-git-send-email-szeder@ira.uka.de> In-Reply-To: <1318085683-29830-1-git-send-email-szeder@ira.uka.de> __git_refs_remotes() is used to provide completion for refspecs to set 'remote.*.fetch' config variables for branches on the given remote. So it's really only interested in refs under 'refs/heads/', but it queries the remote for all its refs and then filters out all refs outside of 'refs/heads/'. Let 'git ls-remote' do the filtering. Also remove the unused $cmd variable from __git_refs_remotes(). Signed-off-by: SZEDER Gábor --- contrib/completion/git-completion.bash | 13 +++++-------- 1 files changed, 5 insertions(+), 8 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index a8d3597e..dc1d5e90 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -650,17 +650,14 @@ __git_refs2 () # __git_refs_remotes requires 1 argument (to pass to ls-remote) __git_refs_remotes () { - local cmd i is_hash=y - for i in $(git ls-remote "$1" 2>/dev/null); do - case "$is_hash,$i" in - n,refs/heads/*) + local i is_hash=y + for i in $(git ls-remote "$1" 'refs/heads/*' 2>/dev/null); do + case "$is_hash" in + n) is_hash=y echo "$i:refs/remotes/$1/${i#refs/heads/}" ;; - y,*) is_hash=n ;; - n,*^{}) is_hash=y ;; - n,refs/tags/*) is_hash=y;; - n,*) is_hash=y; ;; + y) is_hash=n ;; esac done } -- 1.7.7.187.ga41de