completion: avoid ls-remote in certain scenarios

It's _very_ slow in many cases, and there's really no point in fetching
*everything* from the remote just for completion. In many cases it might
be faster for the user to type the whole thing.

If the user manually specifies 'refs/*', then the full ls-remote
completion is triggered.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Felipe Contreras 2013-05-28 22:20:48 -05:00 коммит произвёл Junio C Hamano
Родитель edca415256
Коммит e832f5c096
1 изменённых файлов: 2 добавлений и 8 удалений

Просмотреть файл

@ -427,14 +427,8 @@ __git_refs ()
done done
;; ;;
*) *)
git ls-remote "$dir" HEAD ORIG_HEAD 'refs/tags/*' 'refs/heads/*' 'refs/remotes/*' 2>/dev/null | \ echo "HEAD"
while read -r hash i; do git for-each-ref --format="%(refname:short)" -- "refs/remotes/$dir/" | sed -e "s#^$dir/##"
case "$i" in
*^{}) ;;
refs/*) echo "${i#refs/*/}" ;;
*) echo "$i" ;;
esac
done
;; ;;
esac esac
} }