From fc28a8a856a1e7978794e7dee61c42d7d5740a6b Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Tue, 1 Jul 2025 14:22:23 +0200 Subject: odb: get rid of `the_repository` when handling submodule sources The "--recursive" flag for git-grep(1) allows users to grep for a string across submodule boundaries. To make this work we add each submodule's object sources to our own object database so that the objects can be accessed directly. The infrastructure for this depends on a global string list of submodule paths. The caller is expected to call `add_submodule_odb_by_path()` for each source and the object database will then eventually register all submodule sources via `do_oid_object_info_extended()` in case it isn't able to look up a specific object. This reliance on global state is of course suboptimal with regards to our libification efforts. Refactor the logic so that the list of submodule sources is instead tracked in the object database itself. This allows us to lose the condition of `r == the_repository` before registering submodule sources as we only ever add submodule sources to `the_repository` anyway. As such, behaviour before and after this refactoring should always be the same. Rename the functions accordingly. Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- builtin/grep.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'builtin/grep.c') diff --git a/builtin/grep.c b/builtin/grep.c index 336cfcab6f..cfcf916bce 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -505,7 +505,8 @@ static int grep_submodule(struct grep_opt *opt, * lazily registered as alternates when needed (and except in an * unexpected code interaction, it won't be needed). */ - add_submodule_odb_by_path(subrepo->objects->sources->path); + odb_add_submodule_source_by_path(the_repository->objects, + subrepo->objects->sources->path); obj_read_unlock(); memcpy(&subopt, opt, sizeof(subopt)); -- cgit v1.2.3