diff options
author | Patrick Steinhardt <ps@pks.im> | 2025-07-01 14:22:23 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2025-07-01 14:46:37 -0700 |
commit | fc28a8a856a1e7978794e7dee61c42d7d5740a6b (patch) | |
tree | d86bf61bdd4f201cb86998393087359b24fb5035 /submodule.c | |
parent | 7eafd4472d7c273e10a408da6662ca9d4b9800fd (diff) |
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 <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'submodule.c')
-rw-r--r-- | submodule.c | 26 |
1 files changed, 0 insertions, 26 deletions
diff --git a/submodule.c b/submodule.c index 386be23423..788c9e55ed 100644 --- a/submodule.c +++ b/submodule.c @@ -31,7 +31,6 @@ #include "commit-reach.h" #include "read-cache-ll.h" #include "setup.h" -#include "trace2.h" static int config_update_recurse_submodules = RECURSE_SUBMODULES_OFF; static int initialized_fetch_ref_tips; @@ -176,31 +175,6 @@ void stage_updated_gitmodules(struct index_state *istate) die(_("staging updated .gitmodules failed")); } -static struct string_list added_submodule_odb_paths = STRING_LIST_INIT_DUP; - -void add_submodule_odb_by_path(const char *path) -{ - string_list_insert(&added_submodule_odb_paths, path); -} - -int register_all_submodule_odb_as_alternates(void) -{ - int i; - int ret = added_submodule_odb_paths.nr; - - for (i = 0; i < added_submodule_odb_paths.nr; i++) - odb_add_to_alternates_memory(the_repository->objects, - added_submodule_odb_paths.items[i].string); - if (ret) { - string_list_clear(&added_submodule_odb_paths, 0); - trace2_data_intmax("submodule", the_repository, - "register_all_submodule_odb_as_alternates/registered", ret); - if (git_env_bool("GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB", 0)) - BUG("register_all_submodule_odb_as_alternates() called"); - } - return ret; -} - void set_diffopt_flags_from_submodule_config(struct diff_options *diffopt, const char *path) { |