Subject: Re: [PATCH] archive: error instead of triggering a segfault in `git archive --remote=""`

From: Junio C Hamano <[email-masked]>
Date: Mon, 10 Mar 2025 04:25:31 -0700

"emilylime via GitGitGadget" <[email-masked]> writes:

> From: emilylime <[email-masked]>

Here is a place to explain what the change is about, how to
reproduce and observe the symptom, why the current code behaves the
undesirable way, etc. and then propose how to fix it.

> Signed-off-by: emilylime <[email-masked]>

Documentation/SubmittingPatches:[[real-name]]?

> ---
>     Error instead of triggering a segfault in git archive --remote=""
>
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1877%2Femilyyyylime%2Ffix-archive-remote-segfault-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1877/emilyyyylime/fix-archive-remote-segfault-v1
> Pull-Request: https://github.com/gitgitgadget/git/pull/1877
>
>  builtin/archive.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/builtin/archive.c b/builtin/archive.c
> index 13ea7308c8b..b6fdbfc7dca 100644
> --- a/builtin/archive.c
> +++ b/builtin/archive.c
> @@ -97,6 +97,10 @@ int cmd_archive(int argc,
>  	argc = parse_options(argc, argv, prefix, local_opts, NULL,
>  			     PARSE_OPT_KEEP_ALL);
>  
> +	if (remote && !remote[0]) {
> +		usage(N_("Option 'remote' may not be left empty"));
> +	}

Style--useless {braces} around a single-statement block.

Style--downcase "O" in "Option".

N_() merely marks the string for translation, but yields the string
as-is to the calling function (i.e. usage()).  You probably meant to
use _() instead.