From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Jo Liss <joliss42@gmail.com>, Patrick Steinhardt <ps@pks.im>,
git@vger.kernel.org
Subject: Re: remote-curl: segfault parsing remote.<name>.fetch outside a repository
Date: Sat, 21 Mar 2026 21:37:44 -0400 [thread overview]
Message-ID: <20260322013744.GA816455@coredump.intra.peff.net> (raw)
In-Reply-To: <xmqqa4w0acdr.fsf@gitster.g>
On Sat, Mar 21, 2026 at 06:20:16PM -0700, Junio C Hamano wrote:
> Jeff King <peff@peff.net> writes:
>
> > It's a curious case, though. The crashing code is parse_refspec() does
> > this:
> >
> > if (llen == the_hash_algo->hexsz && !get_oid_hex(item->src, &unused))
> > item->exact_sha1 = 1; /* ok */
> >
> > But what is the correct hash algo to use here when we are outside a
> > repository?
>
> Hmph, who is calling into the transport outside a repository in the
> first place? Even "git clone" should create the receiving
> repository before it calls into the transport, no? Is this "git
> ls-remote" or something?
Yes, exactly; the real-world case that Jo mentioned is ls-remote.
> > to make the segfault go away, but it is mostly papering over the
> > problem. I'm not sure if the exact_sha1 flag would matter when we are
> > not actually fetching (and we cannot fetch when we are not in a local
> > repo). Grepping around, it looks like it does influence the ref prefixes
> > we send to the other side (yet another chicken-and-egg!).
>
> Yup, I agree with your assessment that exact_sha1 should mostly be
> garbage if we do not have a repository in the first place.
There's at least one more instance of the same problem:
if (item->negative)
...
else if (llen == the_hash_algo->hexsz && !get_oid_hex(item->src, &unused))
return 0; /* negative refpsecs cannot be exact sha1 */
It might be OK to quietly disable the check outside a repo there, too.
-Peff
prev parent reply other threads:[~2026-03-22 1:37 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 ` [PATCH v4 1/2] remote-curl: fall back to default hash outside repo Junio C Hamano
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 [this message]
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=20260322013744.GA816455@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=joliss42@gmail.com \
--cc=ps@pks.im \
/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