pr-git-2333/h8d13/depth-env-v1
tagged this
13 Jun 01:39
From: h8d13 <hadean-eon-dev@proton.me> When git clone is run by a tool the user does not control directly (CI runners, package build scripts such as makepkg, or any wrapper that spawns nested clones), there is no way to request a shallow clone: --depth only exists as a command-line option on the process that invokes git clone, and unlike url.*.insteadOf there is no configuration key that could be injected via GIT_CONFIG_* to achieve the same effect. Teach git clone to read a DEPTH environment variable when --depth is not given on the command line. Since environment variables propagate to child processes, exporting DEPTH=1 once makes every nested clone underneath shallow, which is useful in CI pipelines and recursive build tools. An explicit --depth on the command line still takes precedence, and the value goes through the existing validation, so a non-positive DEPTH dies with the same error as a non-positive --depth. Signed-off-by: h8d13 <hadean-eon-dev@proton.me> Submitted-As: https://lore.kernel.org/git/pull.2333.git.git.1781314780645.gitgitgadget@gmail.com