Git development
 help / color / mirror / Atom feed
From: "Matt Hunter" <m@lfurio.us>
To: "h8d13 via GitGitGadget" <gitgitgadget@gmail.com>, <git@vger.kernel.org>
Cc: "h8d13" <hadean-eon-dev@proton.me>
Subject: Re: [PATCH] clone: accept DEPTH env var as fallback for --depth
Date: Sat, 13 Jun 2026 00:08:02 -0400	[thread overview]
Message-ID: <DJ7MJMIFZR5N.2SG1RWB46WPQB@lfurio.us> (raw)
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:
> @@ -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


  reply	other threads:[~2026-06-13  4:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-13  1:39 [PATCH] clone: accept DEPTH env var as fallback for --depth h8d13 via GitGitGadget
2026-06-13  4:08 ` Matt Hunter [this message]
2026-06-13 15:20   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DJ7MJMIFZR5N.2SG1RWB46WPQB@lfurio.us \
    --to=m@lfurio.us \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=hadean-eon-dev@proton.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox