git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Matt Hunter <m@lfurio.us>
Date
Jun 13, 2026, 04:08 UTC
Message-ID
<DJ7MJMIFZR5N.2SG1RWB46WPQB@lfurio.us>
In-Reply-To
<pull.2333.git.git.1781314780645.gitgitgadget@gmail.com>
On Fri Jun 12, 2026 at 9:39 PM EDT, h8d13 via GitGitGadget wrote:
Show 6 quoted lines
> @@ -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.

Show 7 quoted lines
> +	}
> +
>  	if (option_depth || option_since || option_not.nr)
>  		deepen = 1;
>  	if (option_single_branch == -1)
>
> base-commit: 3e65291872de10c3f0bf05ea8c24187e7a71ebf0
Previous: h8d13 via GitGitGadgetNext: Junio C Hamano
Message 2 of 3 in “clone: accept DEPTH env var as fallback for --depth”
  1. clone: accept DEPTH env var as fallback for --depthh8d13 via GitGitGadget, Jun 13, 2026
  2. Matt HunterJun 13, 2026
  3. Junio C HamanoJun 13, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.