Skip to content

Commit fb772cc

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

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

contrib/completion/git-completion.bash

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -616,14 +616,27 @@ __git_refs ()
616616
fi
617617
return
618618
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
627640
}
628641

629642
# __git_refs2 requires 1 argument (to pass to __git_refs)

0 commit comments

Comments
 (0)