From: Matt Hunter Date: Sat, 13 Jun 2026 04:08:02 GMT Subject: Re: [PATCH] clone: accept DEPTH env var as fallback for --depth Message-ID: In-Reply-To: On Fri Jun 12, 2026 at 9:39 PM EDT, h8d13 via GitGitGadget wrote: > @@ -1022,6 +1022,12 @@ int cmd_clone(int argc, > usage_msg_opt(_("You must specify a repository to clone."), > builtin_clone_usage, builtin_clone_options); > > + if (!option_depth) { > + const char *env_depth = getenv("DEPTH"); Nearly all of the non-standard environment variables used by git start with "GIT_". "GIT_CLONE_DEPTH" may be a better choice. > + if (env_depth && *env_depth) > + option_depth = xstrdup(env_depth); Following normal command-line option parsing, if --depth is given, then option_depth points to the parsed string from cmd_clone's argv array directly and is not freed. Therefore, the string copy returned via xstrdup also goes unfreed before it is lost. One might argue this isn't very impactful, since we would expect the process to exit after git-clone completes, but there are already several explicit calls to free and related functions at the end of cmd_clone. > + } > + > if (option_depth || option_since || option_not.nr) > deepen = 1; > if (option_single_branch == -1) > > base-commit: 3e65291872de10c3f0bf05ea8c24187e7a71ebf0