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>
Felipe Contreras committed
May 28, 2013 at 22:20 UTC
e832f5c0968031d687706c97464be21f2da7be21
1 file changed
+2
-8
contrib/completion/git-completion.bash
+2
-8
@@ -427,14 +427,8 @@ __git_refs ()
427
done
428
;;
429
*)
430
- git ls-remote "$dir" HEAD ORIG_HEAD 'refs/tags/*' 'refs/heads/*' 'refs/remotes/*' 2>/dev/null | \
431
- while read -r hash i; do
432
- case "$i" in
433
- *^{}) ;;
434
- refs/*) echo "${i#refs/*/}" ;;
435
- *) echo "$i" ;;
436
- esac
437
- done
430
+ echo "HEAD"
431
+ git for-each-ref --format="%(refname:short)" -- "refs/remotes/$dir/" | sed -e "s#^$dir/##"
432
;;
433
esac
434
}