• Jonathan Tan's avatar
    fetch-pack: exclude blobs when lazy-fetching trees · 4c7f9567
    Jonathan Tan authored
    A partial clone with missing trees can be obtained using "git clone
    --filter=tree:none <repo>". In such a repository, when a tree needs to
    be lazily fetched, any tree or blob it directly or indirectly references
    is fetched as well, regardless of whether the original command required
    those objects, or if the local repository already had some of them.
    This is because the fetch protocol, which the lazy fetch uses, does not
    allow clients to request that only the wanted objects be sent, which
    would be the ideal solution. This patch implements a partial solution:
    specify the "blob:none" filter, somewhat reducing the fetch payload.
    This change has no effect when lazily fetching blobs (due to how filters
    work). And if lazily fetching a commit (such repositories are difficult
    to construct and is not a use case we support very well, but it is
    possible), referenced commits and trees are still fetched - only the
    blobs are not fetched.
    The necessary code change is done in fetch_pack() instead of somewhere
    closer to where the "filter" instruction is written to the wire so that
    only one part of the code needs to be changed in order for users of all
    protocol versions to benefit from this optimization.
    Signed-off-by: default avatarJonathan Tan <jonathantanmy@google.com>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
fetch-pack.h 2.91 KB