All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: K Jayatheerth <jayatheerthkulkarni2005@gmail.com>
Cc: git@vger.kernel.org,  joliss42@gmail.com,  joliss@gmail.com,
	 peff@peff.net
Subject: Re: [PATCH v4 1/2] remote-curl: fall back to default hash outside repo
Date: Mon, 23 Mar 2026 21:25:57 -0700	[thread overview]
Message-ID: <xmqqfr5p3lbe.fsf@gitster.g> (raw)
In-Reply-To: <20260324015734.18470-1-jayatheerthkulkarni2005@gmail.com> (K. Jayatheerth's message of "Tue, 24 Mar 2026 07:27:33 +0530")

K Jayatheerth <jayatheerthkulkarni2005@gmail.com> writes:

> Instead of pushing a NULL-guard workaround down into parse_refspec(),
> fix this by mirroring the ls-remote workaround directly in
> remote-curl.c. If we are operating outside a repository, initialize
> the_hash_algo to GIT_HASH_DEFAULT. This keeps the HTTP transport
> consistent with non-HTTP transports that execute in-process, preventing
> crashes without altering the generic refspec parsing logic.

Thanks.

>
> Reported-by: Jo Liss <joliss@gmail.com>
> Helped-by: Jeff King <peff@peff.net>
> Signed-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com>
> ---
> Thanks Peff and Junio this has been informative.
> I understood a lot of things here.
>
>  remote-curl.c               | 5 +++++
>  t/t5551-http-fetch-smart.sh | 7 +++++++
>  2 files changed, 12 insertions(+)
>
> diff --git a/remote-curl.c b/remote-curl.c
> index 92e40bb682..60774af929 100644
> --- a/remote-curl.c
> +++ b/remote-curl.c
> @@ -1552,6 +1552,11 @@ int cmd_main(int argc, const char **argv)
>  		goto cleanup;
>  	}
>  
> +	/* yuck, see 9e89dcb66a (builtin/ls-remote: fall back to SHA1 outside
> +	 * of a repo, 2024-08-02) */
> +	if (nongit)
> +		repo_set_hash_algo(the_repository, GIT_HASH_DEFAULT);
> +
>  	options.verbosity = 1;
>  	options.progress = !!isatty(2);
>  	options.thin = 1;
> diff --git a/t/t5551-http-fetch-smart.sh b/t/t5551-http-fetch-smart.sh
> index 73cf531580..a26b6c2844 100755
> --- a/t/t5551-http-fetch-smart.sh
> +++ b/t/t5551-http-fetch-smart.sh
> @@ -782,4 +782,11 @@ test_expect_success 'tag following always works over v0 http' '
>  	test_cmp expect actual
>  '
>  
> +test_expect_success 'ls-remote outside repo does not segfault with fetch refspec' '
> +	nongit git \
> +		-c remote.origin.url="$HTTPD_URL/smart/repo.git" \
> +		-c remote.origin.fetch=anything \
> +		ls-remote origin
> +'
> +
>  test_done

  parent reply	other threads:[~2026-03-24  4:26 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-21 19:11 remote-curl: segfault parsing remote.<name>.fetch outside a repository Jo Liss
2026-03-21 19:46 ` [PATCH] remote-curl: set fallback hash algorithm outside repo K Jayatheerth
2026-03-21 23:09   ` brian m. carlson
2026-03-22  2:35   ` [PATCH v2] refspec: safely parse refspecs outside a repository K Jayatheerth
2026-03-22  3:31     ` Junio C Hamano
2026-03-22  3:53     ` Jeff King
2026-03-22  5:36     ` [PATCH v3 1/2] " K Jayatheerth
2026-03-22  5:36       ` [PATCH v3 2/2] refspec: fix typo in comment K Jayatheerth
2026-03-23 22:27       ` [PATCH v3 1/2] refspec: safely parse refspecs outside a repository Junio C Hamano
2026-03-23 23:10         ` Jeff King
2026-03-23 23:39           ` Junio C Hamano
2026-03-24  1:57     ` [PATCH v4 1/2] remote-curl: fall back to default hash outside repo K Jayatheerth
2026-03-24  1:57       ` [PATCH v4 2/2] refspec: fix typo in comment K Jayatheerth
2026-03-24  4:25       ` Junio C Hamano [this message]
2026-03-21 21:06 ` remote-curl: segfault parsing remote.<name>.fetch outside a repository Jeff King
2026-03-22  1:20   ` Junio C Hamano
2026-03-22  1:37     ` Jeff King

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=xmqqfr5p3lbe.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=jayatheerthkulkarni2005@gmail.com \
    --cc=joliss42@gmail.com \
    --cc=joliss@gmail.com \
    --cc=peff@peff.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.