Commit

5c5dfbeef6ab58debad8daaa43dfdd0370c48301

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 <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt <ps@pks.im> · 2026-09-11 05:51 UTC · committed by Junio C Hamano

Browse files
10 files changed, +0 −78
modified odb.c
@@ -388,12 +388,6 @@ struct odb_source *odb_find_source_or_die(struct object_database *odb, const cha
388 388 return source;
389 389 }
390 390
391 - void odb_add_submodule_source_by_path(struct object_database *odb,
392 - const char *path)
393 - {
394 - string_list_insert(&odb->submodule_source_paths, path);
395 - }
396 -
397 391 static void fill_alternate_refs_command(struct repository *repo,
398 392 struct child_process *cmd,
399 393 const char *repo_path)
@@ -549,23 +543,6 @@ void disable_obj_read_lock(void)
549 543 pthread_mutex_destroy(&obj_read_mutex);
550 544 }
551 545
552 - static int register_all_submodule_sources(struct object_database *odb)
553 - {
554 - int ret = odb->submodule_source_paths.nr;
555 -
556 - for (size_t i = 0; i < odb->submodule_source_paths.nr; i++)
557 - odb_add_to_alternates_memory(odb,
558 - odb->submodule_source_paths.items[i].string);
559 - if (ret) {
560 - string_list_clear(&odb->submodule_source_paths, 0);
561 - trace2_data_intmax("submodule", odb->repo,
562 - "register_all_submodule_sources/registered", ret);
563 - if (git_env_bool("GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB", 0))
564 - BUG("register_all_submodule_sources() called");
565 - }
566 - return ret;
567 - }
568 -
569 546 static enum odb_read_status do_oid_object_info_extended(struct object_database *odb,
570 547 const struct object_id *oid,
571 548 struct object_info *oi, unsigned flags)
@@ -614,16 +591,6 @@ static enum odb_read_status do_oid_object_info_extended(struct object_database *
614 591 }
615 592 }
616 593
617 - /*
618 - * This might be an attempt at accessing a submodule object as
619 - * if it were in main object store (having called
620 - * `odb_add_submodule_source_by_path()` on that submodule's
621 - * ODB). If any such ODBs exist, register them and try again.
622 - */
623 - if (register_all_submodule_sources(odb))
624 - /* We added some alternates; retry */
625 - continue;
626 -
627 594 /* Check if it is a missing object */
628 595 if (odb->repo->fetch_if_missing && repo_has_promisor_remote(odb->repo) &&
629 596 !already_retried &&
@@ -1109,7 +1076,6 @@ struct object_database *odb_new(struct repository *repo,
1109 1076 CALLOC_ARRAY(o, 1);
1110 1077 o->repo = repo;
1111 1078 pthread_mutex_init(&o->replace_mutex, NULL);
1112 - string_list_init_dup(&o->submodule_source_paths);
1113 1079 hashmap_init(&o->source_by_path, odb_source_by_path_cmp, o, 0);
1114 1080 o->source_paths_icase = -1;
1115 1081
@@ -1166,8 +1132,6 @@ void odb_free(struct object_database *o)
1166 1132 odb_close(o);
1167 1133 odb_free_sources(o);
1168 1134
1169 - string_list_clear(&o->submodule_source_paths, 0);
1170 -
1171 1135 free(o);
1172 1136 }
1173 1137
modified odb.h
@@ -89,12 +89,6 @@ struct object_database {
89 89 unsigned long object_count;
90 90 unsigned object_count_flags;
91 91 unsigned object_count_valid : 1;
92 -
93 - /*
94 - * Submodule source paths that will be added as additional sources to
95 - * allow lookup of submodule objects via the main object database.
96 - */
97 - struct string_list submodule_source_paths;
98 92 };
99 93
100 94 enum odb_new_flags {
@@ -224,14 +218,6 @@ void odb_restore_primary_source(struct object_database *odb,
224 218 struct odb_source *restore_source,
225 219 const char *old_path);
226 220
227 - /*
228 - * Call odb_add_submodule_source_by_path() to add the submodule at the given
229 - * path to a list. The object stores of all submodules in that list will be
230 - * added as additional sources in the object store when looking up objects.
231 - */
232 - void odb_add_submodule_source_by_path(struct object_database *odb,
233 - const char *path);
234 -
235 221 /*
236 222 * Iterate through all alternates of the database and execute the provided
237 223 * callback function for each of them. Stop iterating once the callback
modified t/README
@@ -462,13 +462,6 @@ GIT_TEST_CHECKOUT_WORKERS=<n> overrides the 'checkout.workers' setting
462 462 to <n> and 'checkout.thresholdForParallelism' to 0, forcing the
463 463 execution of the parallel-checkout code.
464 464
465 - GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=<boolean>, when true, makes
466 - registering submodule ODBs as alternates a fatal action. Support for
467 - this environment variable can be removed once the migration to
468 - explicitly providing repositories when accessing submodule objects is
469 - complete or needs to be abandoned for whatever reason (in which case the
470 - migrated codepaths still retain their performance benefits).
471 -
472 465 GIT_TEST_REQUIRE_PREREQ=<list> allows specifying a space separated list of
473 466 prereqs that are required to succeed. If a prereq in this list is triggered by
474 467 a test and then fails then the whole test run will abort. This can help to make
modified t/t5526-fetch-submodules.sh
@@ -3,9 +3,6 @@
3 3
4 4 test_description='Recursive "git fetch" for submodules'
5 5
6 - GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=1
7 - export GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB
8 -
9 6 . ./test-lib.sh
10 7
11 8 pwd=$(pwd)
modified t/t5531-deep-submodule-push.sh
@@ -5,9 +5,6 @@ test_description='test push with submodules'
5 5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6 6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7 7
8 - GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=1
9 - export GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB
10 -
11 8 . ./test-lib.sh
12 9
13 10 test_expect_success setup '
modified t/t5545-push-options.sh
@@ -5,9 +5,6 @@ test_description='pushing to a repository using push options'
5 5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6 6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7 7
8 - GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=1
9 - export GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB
10 -
11 8 . ./test-lib.sh
12 9
13 10 mk_repo_pair () {
modified t/t5572-pull-submodule.sh
@@ -2,9 +2,6 @@
2 2
3 3 test_description='pull can handle submodules'
4 4
5 - GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=1
6 - export GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB
7 -
8 5 . ./test-lib.sh
9 6 . "$TEST_DIRECTORY"/lib-submodule-update.sh
10 7
modified t/t6437-submodule-merge.sh
@@ -5,9 +5,6 @@ test_description='merging with submodules'
5 5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6 6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7 7
8 - GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=1
9 - export GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB
10 -
11 8 . ./test-lib.sh
12 9
13 10 #
modified 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
12 12 also by committing .gitmodules and then just removing it from the filesystem.
13 13 '
14 14
15 - GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=1
16 - export GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB
17 -
18 15 . ./test-lib.sh
19 16
20 17 test_expect_success 'setup' '
modified t/t7814-grep-recurse-submodules.sh
@@ -9,9 +9,6 @@ submodules.
9 9 TEST_CREATE_REPO_NO_TEMPLATE=1
10 10 . ./test-lib.sh
11 11
12 - GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB=1
13 - export GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB
14 -
15 12 test_expect_success 'setup directory structure and submodule' '
16 13 echo "(1|2)d(3|4)" >a &&
17 14 mkdir b &&