From: Junio C Hamano <gitster@pobox.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: Christian Couder <christian.couder@gmail.com>, git@vger.kernel.org
Subject: Re: [PATCH] promisor-remote: fix crash without a repository
Date: Mon, 16 Nov 2026 07:29:46 -0800 [thread overview]
Message-ID: <xmqqtslgn6ad.fsf@gitster.g> (raw)
In-Reply-To: <avqkLnnMwBNeWWtK@pks.im> (Patrick Steinhardt's message of "Mon, 16 Nov 2026 07:35:26 +0100")
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.
> 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.
>> + /*
>> + * "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 ;-)
prev parent reply other threads:[~2026-11-16 15:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 0:06 [PATCH] promisor-remote: fix crash without a repository Christian Couder
2026-11-13 19:42 ` Junio C Hamano
2026-11-16 6:35 ` Patrick Steinhardt
2026-11-16 15:29 ` Junio C Hamano [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=xmqqtslgn6ad.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--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