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

Re: remote-curl: segfault parsing remote.<name>.fetch outside a repository

From
Jeff King <peff@peff.net>
Date
Mar 22, 2026, 01:37 UTC
Message-ID
<20260322013744.GA816455@coredump.intra.peff.net>
In-Reply-To
<xmqqa4w0acdr.fsf@gitster.g>
On Sat, Mar 21, 2026 at 06:20:16PM -0700, Junio C Hamano wrote:
Show 15 quoted lines
> 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.
Show 8 quoted lines
> > 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
Previous: Junio C Hamano
Message 17 of 17 in “remote-curl: segfault parsing remote.<name>.fetch outside a repository”
  1. Jo LissMar 21, 2026
  2. remote-curl: set fallback hash algorithm outside repoK Jayatheerth, Mar 21, 2026
  3. brian m. carlsonMar 21, 2026
  4. refspec: safely parse refspecs outside a repositoryK Jayatheerth, Mar 22, 2026
  5. Junio C HamanoMar 22, 2026
  6. Jeff KingMar 22, 2026
  7. 1/2 refspec: safely parse refspecs outside a repositoryK Jayatheerth, Mar 22, 2026
  8. 2/2 refspec: fix typo in commentK Jayatheerth, Mar 22, 2026
  9. Junio C HamanoMar 23, 2026
  10. Jeff KingMar 23, 2026
  11. Junio C HamanoMar 23, 2026
  12. 1/2 remote-curl: fall back to default hash outside repoK Jayatheerth, Mar 24, 2026
  13. 2/2 refspec: fix typo in commentK Jayatheerth, Mar 24, 2026
  14. Junio C HamanoMar 24, 2026
  15. Jeff KingMar 21, 2026
  16. Junio C HamanoMar 22, 2026
  17. Jeff KingMar 22, 2026

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.