From b84469ad6ec8feb1159ab4ee67ab73c1d66e9826 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Tue, 1 Sep 2026 13:09:05 +0200 Subject: [PATCH] odb: remove infrastructure to register submodule sources The preceding commits have removed the last two users of `odb_add_submodule_source_by_path()`. The mechanism was only ever meant as a transitional crutch while migrating submodule object access away from "add the submodule ODB as an alternate of the_repository" towards explicitly passing the submodule repository, see a35e03dee0 (submodule: lazily add submodule ODBs as alternates, 2021-08-16). Remove it. As GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB is now a no-op, remove its documentation and the exports from the test suite, as well. Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- odb.c | 36 -------------------------- odb.h | 14 ---------- t/README | 7 ----- t/t5526-fetch-submodules.sh | 3 --- t/t5531-deep-submodule-push.sh | 3 --- t/t5545-push-options.sh | 3 --- t/t5572-pull-submodule.sh | 3 --- t/t6437-submodule-merge.sh | 3 --- t/t7418-submodule-sparse-gitmodules.sh | 3 --- t/t7814-grep-recurse-submodules.sh | 3 --- 10 files changed, 78 deletions(-) diff --git a/odb.c b/odb.c index 6d5943e5ea..2f8a70a90c 100644 --- a/odb.c +++ b/odb.c @@ -388,12 +388,6 @@ struct odb_source *odb_find_source_or_die(struct object_database *odb, const cha return source; } -void odb_add_submodule_source_by_path(struct object_database *odb, - const char *path) -{ - string_list_insert(&odb->submodule_source_paths, path); -} - static void fill_alternate_refs_command(struct repository *repo, struct child_process *cmd, const char *repo_path) @@ -549,23 +543,6 @@ void disable_obj_read_lock(void) pthread_mutex_destroy(&obj_read_mutex); } -static int register_all_submodule_sources(struct object_database *odb) -{ - int ret = odb->submodule_source_paths.nr; - - for (size_t i = 0; i < odb->submodule_source_paths.nr; i++) - odb_add_to_alternates_memory(odb, - odb->submodule_source_paths.items[i].string); - if (ret) { - string_list_clear(&odb->submodule_source_paths, 0); - trace2_data_intmax("submodule", odb->repo, - "register_all_submodule_sources/registered", ret); - if (git_env_bool("GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB", 0)) - BUG("register_all_submodule_sources() called"); - } - return ret; -} - static enum odb_read_status do_oid_object_info_extended(struct object_database *odb, const struct object_id *oid, struct object_info *oi, unsigned flags) @@ -614,16 +591,6 @@ static enum odb_read_status do_oid_object_info_extended(struct object_database * } } - /* - * This might be an attempt at accessing a submodule object as - * if it were in main object store (having called - * `odb_add_submodule_source_by_path()` on that submodule's - * ODB). If any such ODBs exist, register them and try again. - */ - if (register_all_submodule_sources(odb)) - /* We added some alternates; retry */ - continue; - /* Check if it is a missing object */ if (odb->repo->fetch_if_missing && repo_has_promisor_remote(odb->repo) && !already_retried && @@ -1109,7 +1076,6 @@ struct object_database *odb_new(struct repository *repo, CALLOC_ARRAY(o, 1); o->repo = repo; pthread_mutex_init(&o->replace_mutex, NULL); - string_list_init_dup(&o->submodule_source_paths); hashmap_init(&o->source_by_path, odb_source_by_path_cmp, o, 0); o->source_paths_icase = -1; @@ -1166,8 +1132,6 @@ void odb_free(struct object_database *o) odb_close(o); odb_free_sources(o); - string_list_clear(&o->submodule_source_paths, 0); - free(o); } diff --git a/odb.h b/odb.h index 248ee9cdfa..54548efc55 100644 --- a/odb.h +++ b/odb.h @@ -89,12 +89,6 @@ struct object_database { unsigned long object_count; unsigned object_count_flags; unsigned object_count_valid : 1; - - /* - * Submodule source paths that will be added as additional sources to - * allow lookup of submodule objects via the main object database. - */ - struct string_list submodule_source_paths; }; enum odb_new_flags { @@ -224,14 +218,6 @@ void odb_restore_primary_source(struct object_database *odb, struct odb_source *restore_source, const char *old_path); -/* - * Call odb_add_submodule_source_by_path() to add the submodule at the given - * path to a list. The object stores of all submodules in that list will be - * added as additional sources in the object store when looking up objects. - */ -void odb_add_submodule_source_by_path(struct object_database *odb, - const char *path); - /* * Iterate through all alternates of the database and execute the provided * callback function for each of them. Stop iterating once the callback diff --git a/t/README b/t/README index 9a9daaf2af..f831c5355b 100644 --- a/t/README +++ b/t/README @@ -462,13 +462,6 @@ GIT_TEST_CHECKOUT_WORKERS= overrides the 'checkout.workers' setting to and 'checkout.thresholdForParallelism' to 0, forcing the execution of the parallel-checkout code. -GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=, when true, makes -registering submodule ODBs as alternates a fatal action. Support for -this environment variable can be removed once the migration to -explicitly providing repositories when accessing submodule objects is -complete or needs to be abandoned for whatever reason (in which case the -migrated codepaths still retain their performance benefits). - GIT_TEST_REQUIRE_PREREQ= allows specifying a space separated list of prereqs that are required to succeed. If a prereq in this list is triggered by a test and then fails then the whole test run will abort. This can help to make diff --git a/t/t5526-fetch-submodules.sh b/t/t5526-fetch-submodules.sh index 7b3b7359da..37d7373b36 100755 --- a/t/t5526-fetch-submodules.sh +++ b/t/t5526-fetch-submodules.sh @@ -3,9 +3,6 @@ test_description='Recursive "git fetch" for submodules' -GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=1 -export GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB - . ./test-lib.sh pwd=$(pwd) diff --git a/t/t5531-deep-submodule-push.sh b/t/t5531-deep-submodule-push.sh index 7d239dd31f..73429ec6e3 100755 --- a/t/t5531-deep-submodule-push.sh +++ b/t/t5531-deep-submodule-push.sh @@ -5,9 +5,6 @@ test_description='test push with submodules' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME -GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=1 -export GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB - . ./test-lib.sh test_expect_success setup ' diff --git a/t/t5545-push-options.sh b/t/t5545-push-options.sh index fb13549da7..239edd7d62 100755 --- a/t/t5545-push-options.sh +++ b/t/t5545-push-options.sh @@ -5,9 +5,6 @@ test_description='pushing to a repository using push options' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME -GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=1 -export GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB - . ./test-lib.sh mk_repo_pair () { diff --git a/t/t5572-pull-submodule.sh b/t/t5572-pull-submodule.sh index 42d14328b6..9969a3294e 100755 --- a/t/t5572-pull-submodule.sh +++ b/t/t5572-pull-submodule.sh @@ -2,9 +2,6 @@ test_description='pull can handle submodules' -GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=1 -export GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB - . ./test-lib.sh . "$TEST_DIRECTORY"/lib-submodule-update.sh diff --git a/t/t6437-submodule-merge.sh b/t/t6437-submodule-merge.sh index 107e13afbc..1546d5f773 100755 --- a/t/t6437-submodule-merge.sh +++ b/t/t6437-submodule-merge.sh @@ -5,9 +5,6 @@ test_description='merging with submodules' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME -GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=1 -export GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB - . ./test-lib.sh # diff --git a/t/t7418-submodule-sparse-gitmodules.sh b/t/t7418-submodule-sparse-gitmodules.sh index dde11ecce8..cf94e30e78 100755 --- a/t/t7418-submodule-sparse-gitmodules.sh +++ b/t/t7418-submodule-sparse-gitmodules.sh @@ -12,9 +12,6 @@ The test setup uses a sparse checkout, however the same scenario can be set up also by committing .gitmodules and then just removing it from the filesystem. ' -GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=1 -export GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB - . ./test-lib.sh test_expect_success 'setup' ' diff --git a/t/t7814-grep-recurse-submodules.sh b/t/t7814-grep-recurse-submodules.sh index e1cf53dc9e..3d149d34c1 100755 --- a/t/t7814-grep-recurse-submodules.sh +++ b/t/t7814-grep-recurse-submodules.sh @@ -9,9 +9,6 @@ submodules. TEST_CREATE_REPO_NO_TEMPLATE=1 . ./test-lib.sh -GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=1 -export GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB - test_expect_success 'setup directory structure and submodule' ' echo "(1|2)d(3|4)" >a && mkdir b &&