completion: query only refs/heads/ in __git_refs_remotes()

__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 <szeder@ira.uka.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

SZEDER Gábor committed Oct 8, 2011 at 16:54 UTC d79bcf2cf21ddb8c3fcbd95bafa431f872d47a96
1 file changed +5 -8
contrib/completion/git-completion.bash
+5 -8
@@ -651,17 +651,14 @@ __git_refs2 ()
651 # __git_refs_remotes requires 1 argument (to pass to ls-remote)
652 __git_refs_remotes ()
653 {
654 - local cmd i is_hash=y
655 - for i in $(git ls-remote "$1" 2>/dev/null); do
656 - case "$is_hash,$i" in
657 - n,refs/heads/*)
654 + local i is_hash=y
655 + for i in $(git ls-remote "$1" 'refs/heads/*' 2>/dev/null); do
656 + case "$is_hash" in
657 + n)
658 is_hash=y
659 echo "$i:refs/remotes/$1/${i#refs/heads/}"
660 ;;
661 - y,*) is_hash=n ;;
662 - n,*^{}) is_hash=y ;;
663 - n,refs/tags/*) is_hash=y;;
664 - n,*) is_hash=y; ;;
661 + y) is_hash=n ;;
662 esac
663 done
664 }