From: Patrick Steinhardt Date: Tue, 03 Nov 2026 12:43:22 GMT Subject: [PATCH v2 3/3] builtin/grep: read ".gitmodules" via passed-in repository Message-ID: <20261103-pks-grep-recurse-submodule-v2-3-b00e3b3dc865@pks.im> In-Reply-To: <20261103-pks-grep-recurse-submodule-v2-0-b00e3b3dc865@pks.im> When grepping through a list of objects with "--recurse-submodules", we call `gitmodules_config_oid()` to load gitmodules for the specific revision. But instead of passing `opt->repo` we pass `the_repository` to that function, which is somewhat fishy. This is again not a bug because `grep_objects()` is only ever called by `cmd_grep()`, and consequently we know that `opt->repo` is always going to be set to `the_repository`. But it's a code smell regardless of that, so adapt the code to use `opt->repo` instead. Signed-off-by: Patrick Steinhardt --- builtin/grep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/grep.c b/builtin/grep.c index cb518d8155e..22f0a1b0d0e 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -883,7 +883,7 @@ static int grep_objects(struct grep_opt *opt, const struct pathspec *pathspec, if (recurse_submodules) { submodule_free(opt->repo); obj_read_lock(); - gitmodules_config_oid(the_repository, &real_obj->oid); + gitmodules_config_oid(opt->repo, &real_obj->oid); obj_read_unlock(); } if (grep_object(opt, pathspec, real_obj, list->objects[i].name, -- 2.56.0.500.g5d06dc02cd.dirty