From: Derrick Stolee Date: Tue, 24 Feb 2026 12:07:57 GMT Subject: Re: [PATCH 1/2] for-each-repo: stop using the_repository Message-ID: <614c8072-347a-4ba5-8796-4742868389d3@gmail.com> In-Reply-To: On 2/24/26 4:18 AM, Patrick Steinhardt wrote: > On Tue, Feb 24, 2026 at 03:32:29AM +0000, Derrick Stolee via GitGitGadget wrote: >> diff --git a/builtin/for-each-repo.c b/builtin/for-each-repo.c >> index 325a7925f1..478ccf1287 100644 >> --- a/builtin/for-each-repo.c >> +++ b/builtin/for-each-repo.c >> @@ -1,5 +1,3 @@ >> -#define USE_THE_REPOSITORY_VARIABLE >> - >> #include "builtin.h" >> #include "config.h" >> #include "gettext.h" >> @@ -33,7 +31,7 @@ static int run_command_on_repo(const char *path, int argc, const char ** argv) >> int cmd_for_each_repo(int argc, >> const char **argv, >> const char *prefix, >> - struct repository *repo UNUSED) >> + struct repository *repo) >> { >> static const char *config_key = NULL; >> int keep_going = 0; >> @@ -55,7 +53,7 @@ int cmd_for_each_repo(int argc, >> if (!config_key) >> die(_("missing --config=")); >> >> - err = repo_config_get_string_multi(the_repository, config_key, &values); >> + err = repo_config_get_string_multi(repo, config_key, &values); >> if (err < 0) >> usage_msg_optf(_("got bad config --config=%s"), >> for_each_repo_usage, options, config_key); > > The command is marked as `RUN_SETUP_GENTLY`, so it may run in a context > where there is no repository. In such cases, `repo` would be `NULL`, and > that would cause the command to segfault here, wouldn't it? Ah. That's an interesting subtlety of the setup that I did not know. I'll make sure this is covered in tests, because the current tests run in the default test repo but our expected use case should be outside a repo. Thanks, -Stolee