completion: support full refs from remote repositories

When the __git_refs() completion helper function lists refs from a local repository, it usually lists the refs' short name, except when it needs to provide completion for words starting with refs, because in that case it lists full ref names, see 608efb87 (bash: complete full refs, 2008-11-28). Add the same functionality to the code path dealing with remote repositories, too. 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 fb772cca2bd38e97a3b23d5b241a8961156b681b
1 file changed +21 -8
contrib/completion/git-completion.bash
+21 -8
@@ -616,14 +616,27 @@ __git_refs ()
616 fi
617 return
618 fi
619 - git ls-remote "$dir" HEAD ORIG_HEAD 'refs/tags/*' 'refs/heads/*' 'refs/remotes/*' 2>/dev/null | \
620 - while read hash i; do
621 - case "$i" in
622 - *^{}) ;;
623 - refs/*) echo "${i#refs/*/}" ;;
624 - *) echo "$i" ;;
625 - esac
626 - done
619 + case "$cur" in
620 + refs|refs/*)
621 + git ls-remote "$dir" "$cur*" 2>/dev/null | \
622 + while read hash i; do
623 + case "$i" in
624 + *^{}) ;;
625 + *) echo "$i" ;;
626 + esac
627 + done
628 + ;;
629 + *)
630 + git ls-remote "$dir" HEAD ORIG_HEAD 'refs/tags/*' 'refs/heads/*' 'refs/remotes/*' 2>/dev/null | \
631 + while read hash i; do
632 + case "$i" in
633 + *^{}) ;;
634 + refs/*) echo "${i#refs/*/}" ;;
635 + *) echo "$i" ;;
636 + esac
637 + done
638 + ;;
639 + esac
640 }
641
642 # __git_refs2 requires 1 argument (to pass to __git_refs)