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

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

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 10, 2025, 11:25 UTC
Message-ID
<xmqq34flb00k.fsf@gitster.g>
In-Reply-To
<pull.1877.git.1741515155475.gitgitgadget@gmail.com>
"emilylime via GitGitGadget" <gitgitgadget@gmail.com> writes:
> From: emilylime <emilyyyylime+git@gmail.com>

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 <emilyyyylime+git@gmail.com>
Documentation/SubmittingPatches:[[real-name]]?
Show 21 quoted lines
> ---
>     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.

Previous: Junio C Hamano
Message 4 of 4 in “archive: error instead of triggering a segfault in `git archive --remote=""`”
  1. archive: error instead of triggering a segfault in `git archive --remote=""`emilylime via GitGitGadget, Mar 9, 2025
  2. Patrick SteinhardtMar 10, 2025
  3. Junio C HamanoMar 10, 2025
  4. Junio C HamanoMar 10, 2025

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.