[PATCH 3/3] builtin/grep: read ".gitmodules" via passed-in repository
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Oct 30, 2026, 10:21 UTC
- Message-ID
- <20261030-pks-grep-recurse-submodule-v1-3-d4eb5c87d8fb@pks.im>
- In-Reply-To
- <20261030-pks-grep-recurse-submodule-v1-0-d4eb5c87d8fb@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 <ps@pks.im> --- 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.341.g393f52fd96.dirty