git-fetch: Avoid reading packed refs over and over again
When checking which tags to fetch, the old code used to call git-show-ref --verify for each remote tag. Since reading even packed refs is not a cheap operation when there are a lot of local refs, the code became quite slow. This fixes it by teaching git-show-ref to filter out existing refs using a new mode of operation of git-show-ref. Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
12
git-fetch.sh
12
git-fetch.sh
@ -242,7 +242,7 @@ esac
|
||||
reflist=$(get_remote_refs_for_fetch "$@")
|
||||
if test "$tags"
|
||||
then
|
||||
taglist=`IFS=" " &&
|
||||
taglist=`IFS=' ' &&
|
||||
echo "$ls_remote_result" |
|
||||
while read sha1 name
|
||||
do
|
||||
@ -438,17 +438,11 @@ case "$no_tags$tags" in
|
||||
*:refs/*)
|
||||
# effective only when we are following remote branch
|
||||
# using local tracking branch.
|
||||
taglist=$(IFS=" " &&
|
||||
taglist=$(IFS=' ' &&
|
||||
echo "$ls_remote_result" |
|
||||
sed -n -e 's|^\('"$_x40"'\) \(refs/tags/.*\)^{}$|\1 \2|p' \
|
||||
-e 's|^\('"$_x40"'\) \(refs/tags/.*\)$|\1 \2|p' |
|
||||
git-show-ref --exclude-existing=refs/tags/ |
|
||||
while read sha1 name
|
||||
do
|
||||
git-show-ref --verify --quiet -- "$name" && continue
|
||||
git-check-ref-format "$name" || {
|
||||
echo >&2 "warning: tag ${name} ignored"
|
||||
continue
|
||||
}
|
||||
git-cat-file -t "$sha1" >/dev/null 2>&1 || continue
|
||||
echo >&2 "Auto-following $name"
|
||||
echo ".${name}:${name}"
|
||||
|
Reference in New Issue
Block a user