# Re: [PATCH] clone: accept DEPTH env var as fallback for --depth

2 messages from 2026-06-13 to 2026-06-14. Participants: Hadrien Loge, brian m. carlson.
Thread: https://gitlist.dev/t/65804

## Hadrien Loge, 2026-06-13 17:43

Subject: Re: [PATCH] clone: accept DEPTH env var as fallback for --depth
Message-ID: <CADeHOfw6kNstNFucG7an6+Mbm2+=-PnOH8xtZkO9RK8=eWsx=w@mail.gmail.com>

```
Well mainly I'm asking this for packaging (Arch/Alpine/Etc)
These all follow similar conventions (PKGBUILD/APKBUILD).

But in nested flows the ENV var seems like the proper solution.

Mainly I gave this example on github:

    git clone --depth 1 url dest
    cd dest
    bash run.sh
    here run.sh has its own clone deps (perhaps even multiple)
    --depth 1 is now lost

And only ENV vars that I can think of properly propagate for CI
flows/clean chroot envirs.
Thank you for considering the solution. It would be very useful
for speeding up packaging.
Even on 5k commits history it's 900kb vs 17mb.

I have also reworked the commit to include tests/docs.
and rename to GIT_CLONE_DEPTH

Kind regards,
Hade

```

## brian m. carlson, 2026-06-14 01:08

Subject: Re: [PATCH] clone: accept DEPTH env var as fallback for --depth
Message-ID: <ai3_CEstWqtw51MF@fruit.crustytoothpaste.net>
In-Reply-To: <CADeHOfw6kNstNFucG7an6+Mbm2+=-PnOH8xtZkO9RK8=eWsx=w@mail.gmail.com>

```
On 2026-06-13 at 17:43:23, Hadrien Loge wrote:
> Well mainly I'm asking this for packaging (Arch/Alpine/Etc)
> These all follow similar conventions (PKGBUILD/APKBUILD).

Debian builds packages without network access because they want to make
sure that every piece of the source is in the source package, that every
package is reproducibly built, and that users can rebuild source
packages if they like without worrying about needing network access or
having their location exposed to the author.

Wouldn't that be the right decision for reproducibility and privacy
reasons?  If so, then the download of the source would happen before
building and could be tailored to meet your needs with the existing
command-line option.

> But in nested flows the ENV var seems like the proper solution.
> 
> Mainly I gave this example on github:
> 
>     git clone --depth 1 url dest
>     cd dest
>     bash run.sh
>     here run.sh has its own clone deps (perhaps even multiple)
>     --depth 1 is now lost
> 
> And only ENV vars that I can think of properly propagate for CI
> flows/clean chroot envirs.
> Thank you for considering the solution. It would be very useful
> for speeding up packaging.
> Even on 5k commits history it's 900kb vs 17mb.
> 
> I have also reworked the commit to include tests/docs.
> and rename to GIT_CLONE_DEPTH

So say someone has this set in their environment and then they run a
script that clones a repository and runs `git describe`.  That no longer
works and the script fails because it assumed that it had history.

It's also a problem if you then do a fetch into the shallow repository
because shallow fetches are _extremely_ expensive to serve (more
expensive than full clones), so having automation that now runs
thousands of these shallow fetches means that your requests will be
throttled by the server operator whereas they wouldn't with a regular
fetch.

There's no one right solution here and while I am sympathetic to your
situation, it will also result in hard-to-reproduce breakage for other
tooling.  People rely on `git clone` and similar commands only honouring
command line arguments.
-- 
brian m. carlson (they/them)
Toronto, Ontario, CA

```
