completion: improve ls-remote output filtering in __git_refs_remotes()
authorSZEDER Gábor <szeder@ira.uka.de>
Sat, 8 Oct 2011 14:54:41 +0000 (16:54 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 21 Oct 2011 21:38:23 +0000 (14:38 -0700)
This follows suit of a previous patch for __git_refs(): use a
while-read loop and let bash's word splitting get rid of object names
from 'git ls-remote's output.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/completion/git-completion.bash

index 396c8e98f75ddd5da3d2867fd0552e6e3baaf92c..f992b1399d94fc5b20a475412efc855f27af2595 100755 (executable)
@@ -651,15 +651,10 @@ __git_refs2 ()
 # __git_refs_remotes requires 1 argument (to pass to ls-remote)
 __git_refs_remotes ()
 {
-       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 ;;
-               esac
+       local i hash
+       git ls-remote "$1" 'refs/heads/*' 2>/dev/null | \
+       while read hash i; do
+               echo "$i:refs/remotes/$1/${i#refs/heads/}"
        done
 }