From: Junio C Hamano Date: Mon, 16 Nov 2026 15:29:46 GMT Subject: Re: [PATCH] promisor-remote: fix crash without a repository Message-ID: In-Reply-To: Patrick Steinhardt 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 ;-)