completion: make refs completion consistent for local and remote repos
For a local repository the __git_refs() completion helper function lists refs under 'refs/(tags|heads|remotes)/', plus some special refs like HEAD and ORIG_HEAD. For a remote repository, however, it lists all refs. Fix this inconsistency by specifying refs filter patterns for 'git ls-remote' to only list refs under 'refs/(tags|heads|remotes)/'. For now this makes it impossible to complete refs outside of 'refs/(tags|heads|remotes)/' in a remote repository, but a followup patch will resurrect that. 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
abf05987de7b61972e85392ca2f1a4fc25046e57
1 file changed
+2
-4
contrib/completion/git-completion.bash
+2
-4
@@ -616,13 +616,11 @@ __git_refs ()
616
fi
617
return
618
fi
619
- for i in $(git ls-remote "$dir" 2>/dev/null); do
619
+ for i in $(git ls-remote "$dir" HEAD ORIG_HEAD 'refs/tags/*' 'refs/heads/*' 'refs/remotes/*' 2>/dev/null); do
620
case "$is_hash,$i" in
621
y,*) is_hash=n ;;
622
n,*^{}) is_hash=y ;;
623
- n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
624
- n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
625
- n,refs/remotes/*) is_hash=y; echo "${i#refs/remotes/}" ;;
623
+ n,refs/*) is_hash=y; echo "${i#refs/*/}" ;;
624
n,*) is_hash=y; echo "$i" ;;
625
esac
626
done