Christian Couder found that 'git ls-remote' run outside a repository crashes if promisor-related config makes it write configuration. With 'promisor.acceptFromServerUrl', which auto-creates a remote, it crashes in configure_auto_promisor_remote(). With 'promisor.acceptFromServer' plus 'promisor.storeFields', which stores fields, it crashes in store_one_field(). In both cases the repo argument has a NULL gitdir. The storeFields case dates to 3e20258d11 and the auto-configure case to 7a56394fc6. Couder says the bug was found during the NVIDIA hackathon after the Gerrit User Summit 2026.

Version 2 is a two-patch series. The first, a preparatory refactoring, adds a 'struct repository *repo' parameter to promisor_remote_reply() and passes it on to filter_promisor_remote(), which already takes one. Its two callers, in connect.c and fetch-pack.c, pass the_repository for now. It is described as a small step away from the_repository, with no functional change intended.

The second patch fixes the crash when replying to a server's 'promisor-remote' advertisement. If Git is configured to save information from the server into a repository config it does not have, it should not try to reply at all.

In response to review from Junio Hamano and Patrick Steinhardt, Couder said the v2 implements their suggestions and the check is '!repo || !repo->gitdir'. He said that even with test coverage the extra check costs little and prepares for when NULL is passed. He decided no more than the small preparatory refactoring was needed in this series.