In cg-fetch, you have some code at the bottom starting with:
$get -i -s -u -d "$uri/refs/tags" "$_git/refs/tags" || rsyncerr=1
Under http, I presume get is get_http which is recursive wget to slurp all tags to .git/refs/tags?
Earlier you were talking about fetching tags automatically as the user follows a branch (or multiple branches) development, but the current git-http-fetch's semantics of making sure the repository has all the reachable objects when slurping from a ref makes it impossible, and you are playing things safer by essentially cloning the remote repository.
The latest "master" branch of git-core sends unwrapped tag information to make this easier to implement. I think you should be able to do something like this (between "FIXME: Warn about conflicting tag names?" and "rm fetch-$name-dirty").
git-ls-remote --tags $uri/ |
# SHA1 refs/tags/v0.99.8^{} --> SHA1 tags/v0.99.8
# where SHA1 is the object v0.99.8 tag points at.
sed -ne 's:\([^ ]\) refs/\(tags/.*\)^{}$:\1 \2:p' |
while read sha1 tagname
do
# do we have the object pointed at by the tag?
git-cat-file -t "$sha1" >/dev/null 2>&1 ||
continue # if so, fetch the tag -- which should be a
# cheap operation -- to complete the chain.
$fetch "$tagname" "$uri" "$tagname"
doneThis sample code assumes your $fetch implements the same semantics for various transports ($1 is the ref to fetch, $2 is the repo url, $3 is the local ref to write into); I only checked http transport in your code.