Subject: Re: Supporting --depth when cloning from a bundle

From: Junio C Hamano <[email-masked]>
Date: Wed, 16 Feb 2022 14:37:20 -0800

Konstantin Ryabitsev <[email-masked]> writes:

> Hello, all:
>
> It would be pretty handy if it was possible to do shallow clones from a bundle
> file. For example, this would be nice for CI environments that first download
> a clone.bundle file from a locally cached location, clone from it, and then
> fetch any remaining objects from remote.
>
> E.g., in my mind this outta work:
>
> $ wget https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/clone.bundle
> $ git clone --depth 1 clone.bundle linux -b master
>
> Right now, this operation succeeds as-is without any errors, but the resulting
> git repository isn't actually shallow.
>
> Oh, it would be even awesomer if the bundle files could be used directly with
> --reference, e.g.:
>
> $ git clone --reference clone.bundle --dissociate \
>   https://git.kernel.org/.../torvalds/linux.git linux
>
> Any reason that can't work?

The "depth" is used to negitiate what objects to include in the
packfile that is transmit from the other side.  That would not
fundamentally work on bundles, because a bundle is pregenerated and
there is nobody on the other side for you to negotiate with to
affect what objects are included in the packfile which is contained
in the bundle file.

You _should_ be able to make the resulting full clone into a shallow
one, though.