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

Re: [PATCH] promisor-remote: fix crash without a repository

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 16, 2026, 15:29 UTC
Message-ID
<xmqqtslgn6ad.fsf@gitster.g>
In-Reply-To
<avqkLnnMwBNeWWtK@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
> I was wondering myself whether a better fix would be to start passing
> down the repository and then detect this case by checking for `!repo`
> instead.

That would be the most sensible way forward, as it would potentially allow us to help more code paths free from the_repository.

Show 7 quoted lines
> From my point of view it's nowadays a bit of a code smell to
> check whether the passed repository itself is actually an initialized
> one or not: if we aren't operating inside a repository, then the caller
> shouldn't pass one.
>
> That may be a bigger refactoring though, so depending on its scope I'm
> happy to live with the easier fix for now.
Yes.
Show 13 quoted lines
>> +	/* 
>> +	 * "ls-remote" has no business talking about promisors, and worse yet,
>> +	 * it can be run outside a repository.
>> +	 */
>> +	if (!repo->gitdir) {
>> +		if (accepted_out)
>> +			*accepted_out = NULL;
>> +		return;
>> +	}
>
> But in any case, we should also detect the case where `!repo`, I'd say.
> Otherwise we'll have to adapt this code again once this funciton's call
> chains get rid of `the_repository`.

Yes, again, but as long as we have sufficient test coverage right now, the dereference repo->gitdir would immediately segfault when our caller stops passing the_repository and instead passes NULL when it notices that we are not in a repository ;-)

Previous: Patrick Steinhardt
Message 4 of 4 in “promisor-remote: fix crash without a repository”
  1. promisor-remote: fix crash without a repositoryChristian Couder, Nov 13, 2026
  2. Junio C HamanoNov 13, 2026
  3. Patrick SteinhardtNov 16, 2026
  4. Junio C HamanoNov 16, 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.