tmm1/brew2deb — pull request #12 by peff (2012-02-17 07:00:01+00:00)
Title: git: detect clones more accurately in upload-pack patch

This should fix github/github#2116.

We keep statistics on clones versus fetches by asking
upload-pack to run a hook for us. It tells us which it saw
by checking git's existing create_full_pack flag. However,
that flag is intended for use by pack-objects and is defined
like this:

int create_full_pack = (nr_our_refs == want_obj.nr && !have_obj.nr);

I.e., the other side asked for everything we had, and
claimed to have nothing else. But the first half of the
condition is not true for most GitHub repositories, as we
have refs outside of refs/heads and refs/tags that are not
fetched by normal, non-mirror clones (e.g., our pull request
refs).

A better heuristic for clone vs fetch is to just take the
second half of that condition: check that the remote side
claimed not to have any objects in its repository. That will
catch clones and fetches into empty repositories, both of
which are identical from the server's perspective.

It will miss a clone with "--reference" to an alternates
repository. But that is a minority case, and arguably not
really a clone (it's indistinguishable on the server end
from a fetch from a related repository cloned from somewhere
else).