Skip to content

Commit d79bcf2

Browse files
szedergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fb772cc commit d79bcf2

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

contrib/completion/git-completion.bash

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -651,17 +651,14 @@ __git_refs2 ()
651651
# __git_refs_remotes requires 1 argument (to pass to ls-remote)
652652
__git_refs_remotes ()
653653
{
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)
658658
is_hash=y
659659
echo "$i:refs/remotes/$1/${i#refs/heads/}"
660660
;;
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 ;;
665662
esac
666663
done
667664
}

0 commit comments

Comments
 (0)