Compare

b4dedbc0615bddbad6a5bd18345d9da766d95dfa..f0eb23a8f57d06cd461e72b35caf500145980ce8

odb: remove the ability to link sources ad-hoc

Over the course of this patch series we have adapted all callers of
`odb_add_to_alternates_memory()` to not do so anymore. Remove the
function.

This series of refactorings doesn't only simplify our code base. More
importantly, with those changes in place we can now unconditionally
assume that the list of sources linked to the object database only
consists of the primary source and its alternates. This serves as the
foundation to eventually move handling of alternates into the "files"
backend itself.

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
29 files changed, +150 −236
modified builtin/fetch.c
@@ -2681,7 +2681,7 @@ int cmd_fetch(int argc,
2681 2681 int *rs = config.recurse_submodules == RECURSE_SUBMODULES_DEFAULT
2682 2682 ? &config.recurse_submodules : NULL;
2683 2683
2684 - fetch_config_from_gitmodules(sfjc, rs);
2684 + fetch_config_from_gitmodules(the_repository, sfjc, rs);
2685 2685 }
2686 2686
2687 2687
modified builtin/grep.c
@@ -463,16 +463,6 @@ static int grep_submodule(struct grep_opt *opt,
463 463 ALLOC_GROW(repos_to_free, repos_to_free_nr + 1, repos_to_free_alloc);
464 464 repos_to_free[repos_to_free_nr++] = subrepo;
465 465
466 - /*
467 - * NEEDSWORK: repo_read_gitmodules() might call
468 - * odb_add_to_alternates_memory() via config_from_gitmodules(). This
469 - * operation causes a race condition with concurrent object readings
470 - * performed by the worker threads. That's why we need obj_read_lock()
471 - * here. It should be removed once it's no longer necessary to add the
472 - * subrepo's odbs to the in-memory alternates list.
473 - */
474 - obj_read_lock();
475 -
476 466 /*
477 467 * NEEDSWORK: when reading a submodule, the sparsity settings in the
478 468 * superproject are incorrectly forgotten or misused. For example:
@@ -498,18 +488,14 @@ static int grep_submodule(struct grep_opt *opt,
498 488 * ditto.
499 489 *
500 490 * Note that this list is not exhaustive.
491 + *
492 + * NEEDSWORK: initializing the subrepository is not thread-safe,
493 + * either, as it may cause us to race around `get_main_ref_store()`. We
494 + * thus need to hold the object-read lock to serialize all readers with
495 + * one another.
501 496 */
497 + obj_read_lock();
502 498 repo_read_gitmodules(subrepo, 0);
503 -
504 - /*
505 - * All code paths tested by test code no longer need submodule ODBs to
506 - * be added as alternates, but add it to the list just in case.
507 - * Submodule ODBs added through add_submodule_odb_by_path() will be
508 - * lazily registered as alternates when needed (and except in an
509 - * unexpected code interaction, it won't be needed).
510 - */
511 - odb_add_submodule_source_by_path(the_repository->objects,
512 - subrepo->objects->sources->path);
513 499 obj_read_unlock();
514 500
515 501 memcpy(&subopt, opt, sizeof(subopt));
@@ -897,7 +883,7 @@ static int grep_objects(struct grep_opt *opt, const struct pathspec *pathspec,
897 883 if (recurse_submodules) {
898 884 submodule_free(opt->repo);
899 885 obj_read_lock();
900 - gitmodules_config_oid(&real_obj->oid);
886 + gitmodules_config_oid(the_repository, &real_obj->oid);
901 887 obj_read_unlock();
902 888 }
903 889 if (grep_object(opt, pathspec, real_obj, list->objects[i].name,
modified builtin/multi-pack-index.c
@@ -90,7 +90,8 @@ static struct odb_source_files *handle_object_dir_option(struct repository *repo
90 90 {
91 91 struct odb_source *source = odb_find_source(repo->objects, opts.object_dir);
92 92 if (!source)
93 - source = odb_add_to_alternates_memory(repo->objects, opts.object_dir);
93 + die(_("object directory is not an alternate of the current repository: '%s'"),
94 + opts.object_dir);
94 95 return odb_source_files_downcast(source);
95 96 }
96 97
modified builtin/submodule--helper.c
@@ -3041,7 +3041,7 @@ static int module_update(int argc, const char **argv, const char *prefix,
3041 3041 NULL
3042 3042 };
3043 3043
3044 - update_clone_config_from_gitmodules(&opt.max_jobs);
3044 + update_clone_config_from_gitmodules(the_repository, &opt.max_jobs);
3045 3045 repo_config(the_repository, git_update_clone_config, &opt.max_jobs);
3046 3046
3047 3047 argc = parse_options(argc, argv, prefix, module_update_options,
@@ -3255,7 +3255,7 @@ static int module_set_url(int argc, const char **argv, const char *prefix,
3255 3255 path);
3256 3256
3257 3257 config_name = xstrfmt("submodule.%s.url", sub->name);
3258 - ret = config_set_in_gitmodules_file_gently(config_name, newurl);
3258 + ret = config_set_in_gitmodules_file_gently(the_repository, config_name, newurl);
3259 3259
3260 3260 if (!ret) {
3261 3261 repo_read_gitmodules(the_repository, 0);
@@ -3311,7 +3311,7 @@ static int module_set_branch(int argc, const char **argv, const char *prefix,
3311 3311 path);
3312 3312
3313 3313 config_name = xstrfmt("submodule.%s.branch", sub->name);
3314 - ret = config_set_in_gitmodules_file_gently(config_name, opt_branch);
3314 + ret = config_set_in_gitmodules_file_gently(the_repository, config_name, opt_branch);
3315 3315
3316 3316 free(config_name);
3317 3317 return !!ret;
@@ -3510,7 +3510,7 @@ static int config_submodule_in_gitmodules(const char *name, const char *var, con
3510 3510 die(_("please make sure that the .gitmodules file is in the working tree"));
3511 3511
3512 3512 key = xstrfmt("submodule.%s.%s", name, var);
3513 - ret = config_set_in_gitmodules_file_gently(key, value);
3513 + ret = config_set_in_gitmodules_file_gently(the_repository, key, value);
3514 3514 free(key);
3515 3515
3516 3516 return ret;
modified cache-tree.c
@@ -1,4 +1,3 @@
1 - #define USE_THE_REPOSITORY_VARIABLE
2 1 #define DISABLE_SIGN_COMPARE_WARNINGS
3 2
4 3 #include "git-compat-util.h"
@@ -298,12 +297,14 @@ int cache_tree_fully_valid(struct index_state *istate)
298 297 istate->cache_tree);
299 298 }
300 299
301 - static int must_check_existence(const struct cache_entry *ce)
300 + static int must_check_existence(const struct cache_entry *ce, void *cb_data)
302 301 {
303 - return !(repo_has_promisor_remote(the_repository) && ce_skip_worktree(ce));
302 + struct repository *repo = cb_data;
303 + return !(repo_has_promisor_remote(repo) && ce_skip_worktree(ce));
304 304 }
305 305
306 - static int update_one(struct cache_tree *it,
306 + static int update_one(struct repository *repo,
307 + struct cache_tree *it,
307 308 struct cache_entry **cache,
308 309 int entries,
309 310 const char *base,
@@ -341,7 +342,7 @@ static int update_one(struct cache_tree *it,
341 342 }
342 343
343 344 if (0 <= it->entry_count &&
344 - odb_has_object(the_repository->objects, &it->oid,
345 + odb_has_object(repo->objects, &it->oid,
345 346 ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))
346 347 return it->entry_count;
347 348
@@ -382,7 +383,8 @@ static int update_one(struct cache_tree *it,
382 383 sub = find_subtree(it, path + baselen, sublen, 1);
383 384 if (!sub->cache_tree)
384 385 sub->cache_tree = cache_tree();
385 - subcnt = update_one(sub->cache_tree,
386 + subcnt = update_one(repo,
387 + sub->cache_tree,
386 388 cache + i, entries - i,
387 389 path,
388 390 baselen + sublen + 1,
@@ -446,10 +448,10 @@ static int update_one(struct cache_tree *it,
446 448 }
447 449
448 450 ce_missing_ok = mode == S_IFGITLINK || missing_ok ||
449 - !must_check_existence(ce);
451 + !must_check_existence(ce, repo);
450 452 if (is_null_oid(oid) ||
451 453 (!ce_missing_ok &&
452 - !odb_has_object(the_repository->objects, oid,
454 + !odb_has_object(repo->objects, oid,
453 455 ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))) {
454 456 strbuf_release(&buffer);
455 457 if (expected_missing)
@@ -481,12 +483,12 @@ static int update_one(struct cache_tree *it,
481 483 /*
482 484 * "sub" can be an empty tree if all subentries are i-t-a.
483 485 */
484 - if (contains_ita && is_empty_tree_oid(oid, the_repository->hash_algo))
486 + if (contains_ita && is_empty_tree_oid(oid, repo->hash_algo))
485 487 continue;
486 488
487 489 strbuf_grow(&buffer, entlen + 100);
488 490 strbuf_addf(&buffer, "%o %.*s%c", mode, entlen, path + baselen, '\0');
489 - strbuf_add(&buffer, oid->hash, the_hash_algo->rawsz);
491 + strbuf_add(&buffer, oid->hash, repo->hash_algo->rawsz);
490 492
491 493 #if DEBUG_CACHE_TREE
492 494 fprintf(stderr, "cache-tree update-one %o %.*s\n",
@@ -496,16 +498,16 @@ static int update_one(struct cache_tree *it,
496 498
497 499 if (repair) {
498 500 struct object_id oid;
499 - hash_object_file(the_hash_algo, buffer.buf, buffer.len,
501 + hash_object_file(repo->hash_algo, buffer.buf, buffer.len,
500 502 OBJ_TREE, &oid);
501 - if (odb_has_object(the_repository->objects, &oid, ODB_HAS_OBJECT_RECHECK_PACKED))
503 + if (odb_has_object(repo->objects, &oid, ODB_HAS_OBJECT_RECHECK_PACKED))
502 504 oidcpy(&it->oid, &oid);
503 505 else
504 506 to_invalidate = 1;
505 507 } else if (dryrun) {
506 - hash_object_file(the_hash_algo, buffer.buf, buffer.len,
508 + hash_object_file(repo->hash_algo, buffer.buf, buffer.len,
507 509 OBJ_TREE, &it->oid);
508 - } else if (odb_write_object_ext(the_repository->objects, buffer.buf, buffer.len, OBJ_TREE,
510 + } else if (odb_write_object_ext(repo->objects, buffer.buf, buffer.len, OBJ_TREE,
509 511 &it->oid, NULL, flags & WRITE_TREE_SILENT ? ODB_WRITE_OBJECT_SILENT : 0)) {
510 512 strbuf_release(&buffer);
511 513 return -1;
@@ -523,7 +525,7 @@ static int update_one(struct cache_tree *it,
523 525
524 526 int cache_tree_update(struct index_state *istate, int flags)
525 527 {
526 - int inflight = !!the_repository->objects->transaction;
528 + int inflight = !!istate->repo->objects->transaction;
527 529 struct odb_transaction *transaction;
528 530 int skip, i;
529 531
@@ -535,14 +537,14 @@ int cache_tree_update(struct index_state *istate, int flags)
535 537 if (!istate->cache_tree)
536 538 istate->cache_tree = cache_tree();
537 539
538 - if (!(flags & WRITE_TREE_MISSING_OK) && repo_has_promisor_remote(the_repository))
539 - prefetch_cache_entries(istate, must_check_existence);
540 + if (!(flags & WRITE_TREE_MISSING_OK) && repo_has_promisor_remote(istate->repo))
541 + prefetch_cache_entries(istate, must_check_existence, istate->repo);
540 542
541 543 trace_performance_enter();
542 544 trace2_region_enter("cache_tree", "update", istate->repo);
543 545 if (!inflight)
544 - odb_transaction_begin_or_die(the_repository->objects, &transaction, 0);
545 - i = update_one(istate->cache_tree, istate->cache, istate->cache_nr,
546 + odb_transaction_begin_or_die(istate->repo->objects, &transaction, 0);
547 + i = update_one(istate->repo, istate->cache_tree, istate->cache, istate->cache_nr,
546 548 "", 0, &skip, flags);
547 549 if (!inflight)
548 550 odb_transaction_commit_and_finalize_or_die(transaction);
@@ -554,7 +556,8 @@ int cache_tree_update(struct index_state *istate, int flags)
554 556 return 0;
555 557 }
556 558
557 - static void write_one(struct strbuf *buffer, struct cache_tree *it,
559 + static void write_one(struct repository *repo,
560 + struct strbuf *buffer, struct cache_tree *it,
558 561 const char *path, int pathlen)
559 562 {
560 563 int i;
@@ -580,7 +583,7 @@ static void write_one(struct strbuf *buffer, struct cache_tree *it,
580 583 #endif
581 584
582 585 if (0 <= it->entry_count) {
583 - strbuf_add(buffer, it->oid.hash, the_hash_algo->rawsz);
586 + strbuf_add(buffer, it->oid.hash, repo->hash_algo->rawsz);
584 587 }
585 588 for (i = 0; i < it->subtree_nr; i++) {
586 589 struct cache_tree_sub *down = it->down[i];
@@ -590,15 +593,16 @@ static void write_one(struct strbuf *buffer, struct cache_tree *it,
590 593 prev->name, prev->namelen) <= 0)
591 594 die("fatal - unsorted cache subtree");
592 595 }
593 - write_one(buffer, down->cache_tree, down->name, down->namelen);
596 + write_one(repo, buffer, down->cache_tree, down->name, down->namelen);
594 597 }
595 598 }
596 599
597 - void cache_tree_write(struct strbuf *sb, struct cache_tree *root)
600 + void cache_tree_write(struct repository *repo,
601 + struct strbuf *sb, struct cache_tree *root)
598 602 {
599 - trace2_region_enter("cache_tree", "write", the_repository);
600 - write_one(sb, root, "", 0);
601 - trace2_region_leave("cache_tree", "write", the_repository);
603 + trace2_region_enter("cache_tree", "write", repo);
604 + write_one(repo, sb, root, "", 0);
605 + trace2_region_leave("cache_tree", "write", repo);
602 606 }
603 607
604 608 static int parse_int(const char **ptr, unsigned long *len_p, int *out)
@@ -632,13 +636,14 @@ static int parse_int(const char **ptr, unsigned long *len_p, int *out)
632 636 return 0;
633 637 }
634 638
635 - static struct cache_tree *read_one(const char **buffer, unsigned long *size_p)
639 + static struct cache_tree *read_one(struct repository *repo,
640 + const char **buffer, unsigned long *size_p)
636 641 {
637 642 const char *buf = *buffer;
638 643 unsigned long size = *size_p;
639 644 struct cache_tree *it;
640 645 int i, subtree_nr;
641 - const unsigned rawsz = the_hash_algo->rawsz;
646 + const unsigned rawsz = repo->hash_algo->rawsz;
642 647
643 648 it = NULL;
644 649 /* skip name, but make sure name exists */
@@ -665,7 +670,7 @@ static struct cache_tree *read_one(const char **buffer, unsigned long *size_p)
665 670 if (size < rawsz)
666 671 goto free_return;
667 672 oidread(&it->oid, (const unsigned char *)buf,
668 - the_repository->hash_algo);
673 + repo->hash_algo);
669 674 buf += rawsz;
670 675 size -= rawsz;
671 676 }
@@ -693,7 +698,7 @@ static struct cache_tree *read_one(const char **buffer, unsigned long *size_p)
693 698 struct cache_tree_sub *subtree;
694 699 const char *name = buf;
695 700
696 - sub = read_one(&buf, &size);
701 + sub = read_one(repo, &buf, &size);
697 702 if (!sub)
698 703 goto free_return;
699 704 subtree = cache_tree_sub(it, name);
@@ -710,16 +715,17 @@ static struct cache_tree *read_one(const char **buffer, unsigned long *size_p)
710 715 return NULL;
711 716 }
712 717
713 - struct cache_tree *cache_tree_read(const char *buffer, unsigned long size)
718 + struct cache_tree *cache_tree_read(struct repository *repo,
719 + const char *buffer, unsigned long size)
714 720 {
715 721 struct cache_tree *result;
716 722
717 723 if (buffer[0])
718 724 return NULL; /* not the whole tree */
719 725
720 - trace2_region_enter("cache_tree", "read", the_repository);
721 - result = read_one(&buffer, &size);
722 - trace2_region_leave("cache_tree", "read", the_repository);
726 + trace2_region_enter("cache_tree", "read", repo);
727 + result = read_one(repo, &buffer, &size);
728 + trace2_region_leave("cache_tree", "read", repo);
723 729
724 730 return result;
725 731 }
@@ -810,7 +816,7 @@ int write_index_as_tree(struct object_id *oid, struct index_state *index_state,
810 816 hold_lock_file_for_update(&lock_file, index_path, LOCK_DIE_ON_ERROR);
811 817
812 818 entries = read_index_from(index_state, index_path,
813 - repo_get_git_dir(the_repository));
819 + repo_get_git_dir(index_state->repo));
814 820 if (entries < 0) {
815 821 ret = WRITE_TREE_UNREADABLE_INDEX;
816 822 goto out;
@@ -866,7 +872,7 @@ static void prime_cache_tree_rec(struct repository *r,
866 872 struct cache_tree_sub *sub;
867 873 struct tree *subtree = lookup_tree(r, &entry.oid);
868 874
869 - if (repo_parse_tree(the_repository, subtree) < 0)
875 + if (repo_parse_tree(r, subtree) < 0)
870 876 exit(128);
871 877 sub = cache_tree_sub(it, entry.path);
872 878 sub->cache_tree = cache_tree();
modified cache-tree.h
@@ -28,8 +28,9 @@ struct cache_tree_sub *cache_tree_sub(struct cache_tree *, const char *);
28 28
29 29 int cache_tree_subtree_pos(struct cache_tree *it, const char *path, int pathlen);
30 30
31 - void cache_tree_write(struct strbuf *, struct cache_tree *root);
32 - struct cache_tree *cache_tree_read(const char *buffer, unsigned long size);
31 + void cache_tree_write(struct repository *repo, struct strbuf *, struct cache_tree *root);
32 + struct cache_tree *cache_tree_read(struct repository *repo,
33 + const char *buffer, unsigned long size);
33 34
34 35 int cache_tree_fully_valid(struct index_state *);
35 36 int cache_tree_update(struct index_state *, int);
modified odb.c
@@ -247,12 +247,6 @@ void odb_add_to_alternates_file(struct object_database *odb,
247 247 odb_add_alternate_recursively(odb, dir, 0);
248 248 }
249 249
250 - struct odb_source *odb_add_to_alternates_memory(struct object_database *odb,
251 - const char *dir)
252 - {
253 - return odb_add_alternate_recursively(odb, dir, 0);
254 - }
255 -
256 250 struct odb_source *odb_set_temporary_primary_source(struct object_database *odb,
257 251 const char *dir, int will_destroy,
258 252 struct odb_source **prev_source)
@@ -388,12 +382,6 @@ struct odb_source *odb_find_source_or_die(struct object_database *odb, const cha
388 382 return source;
389 383 }
390 384
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 385 static void fill_alternate_refs_command(struct repository *repo,
398 386 struct child_process *cmd,
399 387 const char *repo_path)
@@ -549,23 +537,6 @@ void disable_obj_read_lock(void)
549 537 pthread_mutex_destroy(&obj_read_mutex);
550 538 }
551 539
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 540 static enum odb_read_status do_oid_object_info_extended(struct object_database *odb,
570 541 const struct object_id *oid,
571 542 struct object_info *oi, unsigned flags)
@@ -614,16 +585,6 @@ static enum odb_read_status do_oid_object_info_extended(struct object_database *
614 585 }
615 586 }
616 587
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 588 /* Check if it is a missing object */
628 589 if (odb->repo->fetch_if_missing && repo_has_promisor_remote(odb->repo) &&
629 590 !already_retried &&
@@ -1109,7 +1070,6 @@ struct object_database *odb_new(struct repository *repo,
1109 1070 CALLOC_ARRAY(o, 1);
1110 1071 o->repo = repo;
1111 1072 pthread_mutex_init(&o->replace_mutex, NULL);
1112 - string_list_init_dup(&o->submodule_source_paths);
1113 1073 hashmap_init(&o->source_by_path, odb_source_by_path_cmp, o, 0);
1114 1074 o->source_paths_icase = -1;
1115 1075
@@ -1166,8 +1126,6 @@ void odb_free(struct object_database *o)
1166 1126 odb_close(o);
1167 1127 odb_free_sources(o);
1168 1128
1169 - string_list_clear(&o->submodule_source_paths, 0);
1170 -
1171 1129 free(o);
1172 1130 }
1173 1131
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
@@ -272,14 +258,6 @@ int odb_has_alternates(struct object_database *odb);
272 258 void odb_add_to_alternates_file(struct object_database *odb,
273 259 const char *dir);
274 260
275 - /*
276 - * Add the directory to the in-memory list of alternate sources (along with any
277 - * recursive alternates it points to), but do not modify the on-disk alternates
278 - * file.
279 - */
280 - struct odb_source *odb_add_to_alternates_memory(struct object_database *odb,
281 - const char *dir);
282 -
283 261 /*
284 262 * Read an object from the database. Returns the object data and assigns object
285 263 * type and size to the `type` and `size` pointers, if these pointers are
modified odb/source-packed.c
@@ -844,6 +844,7 @@ static void odb_source_packed_free(struct odb_source *source)
844 844
845 845 chdir_notify_unregister(odb_source_packed_reparent, packed);
846 846
847 + odb_source_close(source);
847 848 for (struct packfile_list_entry *e = packed->packs.head; e; e = e->next)
848 849 free(e->pack);
849 850 packfile_list_clear(&packed->packs);
modified read-cache-ll.h
@@ -269,9 +269,10 @@ void validate_cache_entries(const struct index_state *istate);
269 269 * the given predicate. This function should only be called if
270 270 * repo_has_promisor_remote() returns true.
271 271 */
272 - typedef int (*must_prefetch_predicate)(const struct cache_entry *);
272 + typedef int (*must_prefetch_predicate)(const struct cache_entry *, void *cb_data);
273 273 void prefetch_cache_entries(const struct index_state *istate,
274 - must_prefetch_predicate must_prefetch);
274 + must_prefetch_predicate must_prefetch,
275 + void *cb_data);
275 276
276 277 /* Initialize and use the cache information */
277 278 struct lock_file;
modified read-cache.c
@@ -1748,7 +1748,7 @@ static int read_index_extension(struct index_state *istate,
1748 1748 {
1749 1749 switch (CACHE_EXT(ext)) {
1750 1750 case CACHE_EXT_TREE:
1751 - istate->cache_tree = cache_tree_read(data, sz);
1751 + istate->cache_tree = cache_tree_read(istate->repo, data, sz);
1752 1752 break;
1753 1753 case CACHE_EXT_RESOLVE_UNDO:
1754 1754 istate->resolve_undo = resolve_undo_read(data, sz, the_hash_algo);
@@ -3012,7 +3012,7 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
3012 3012 !drop_cache_tree && istate->cache_tree) {
3013 3013 strbuf_reset(&sb);
3014 3014
3015 - cache_tree_write(&sb, istate->cache_tree);
3015 + cache_tree_write(istate->repo, &sb, istate->cache_tree);
3016 3016 err = write_index_ext_header(f, eoie_c, CACHE_EXT_TREE, sb.len) < 0;
3017 3017 hashwrite(f, sb.buf, sb.len);
3018 3018 if (err) {
@@ -3733,7 +3733,8 @@ static void write_ieot_extension(struct strbuf *sb, struct index_entry_offset_ta
3733 3733 }
3734 3734
3735 3735 void prefetch_cache_entries(const struct index_state *istate,
3736 - must_prefetch_predicate must_prefetch)
3736 + must_prefetch_predicate must_prefetch,
3737 + void *cb_data)
3737 3738 {
3738 3739 int i;
3739 3740 struct oid_array to_fetch = OID_ARRAY_INIT;
@@ -3741,7 +3742,7 @@ void prefetch_cache_entries(const struct index_state *istate,
3741 3742 for (i = 0; i < istate->cache_nr; i++) {
3742 3743 struct cache_entry *ce = istate->cache[i];
3743 3744
3744 - if (S_ISGITLINK(ce->ce_mode) || !must_prefetch(ce))
3745 + if (S_ISGITLINK(ce->ce_mode) || !must_prefetch(ce, cb_data))
3745 3746 continue;
3746 3747 if (!odb_read_object_info_extended(the_repository->objects,
3747 3748 &ce->oid, NULL,
modified submodule-config.c
@@ -1,4 +1,3 @@
1 - #define USE_THE_REPOSITORY_VARIABLE
2 1 #define DISABLE_SIGN_COMPARE_WARNINGS
3 2
4 3 #include "git-compat-util.h"
@@ -133,7 +132,9 @@ void submodule_cache_free(struct submodule_cache *cache)
133 132 static unsigned int hash_oid_string(const struct object_id *oid,
134 133 const char *string)
135 134 {
136 - return memhash(oid->hash, the_hash_algo->rawsz) + strhash(string);
135 + if (oid->algo == GIT_HASH_UNKNOWN)
136 + BUG("hashing an object ID with unknown algorithm");
137 + return memhash(oid->hash, hash_algos[oid->algo].rawsz) + strhash(string);
137 138 }
138 139
139 140 static void cache_put_path(struct submodule_cache *cache,
@@ -667,19 +668,20 @@ static int parse_config(const char *var, const char *value,
667 668 return ret;
668 669 }
669 670
670 - static int gitmodule_oid_from_commit(const struct object_id *treeish_name,
671 + static int gitmodule_oid_from_commit(struct repository *repo,
672 + const struct object_id *treeish_name,
671 673 struct object_id *gitmodules_oid,
672 674 struct strbuf *rev)
673 675 {
674 676 int ret = 0;
675 677
676 678 if (is_null_oid(treeish_name)) {
677 - oidclr(gitmodules_oid, the_repository->hash_algo);
679 + oidclr(gitmodules_oid, repo->hash_algo);
678 680 return 1;
679 681 }
680 682
681 683 strbuf_addf(rev, "%s:.gitmodules", oid_to_hex(treeish_name));
682 - if (repo_get_oid(the_repository, rev->buf, gitmodules_oid) >= 0)
684 + if (repo_get_oid(repo, rev->buf, gitmodules_oid) >= 0)
683 685 ret = 1;
684 686
685 687 return ret;
@@ -689,9 +691,11 @@ static int gitmodule_oid_from_commit(const struct object_id *treeish_name,
689 691 * (key) with on-demand reading of the appropriate .gitmodules from
690 692 * revisions.
691 693 */
692 - static const struct submodule *config_from(struct submodule_cache *cache,
693 - const struct object_id *treeish_name, const char *key,
694 - enum lookup_type lookup_type)
694 + static const struct submodule *config_from(struct repository *repo,
695 + struct submodule_cache *cache,
696 + const struct object_id *treeish_name,
697 + const char *key,
698 + enum lookup_type lookup_type)
695 699 {
696 700 struct strbuf rev = STRBUF_INIT;
697 701 size_t config_size;
@@ -718,7 +722,7 @@ static const struct submodule *config_from(struct submodule_cache *cache,
718 722 return entry->config;
719 723 }
720 724
721 - if (!gitmodule_oid_from_commit(treeish_name, &oid, &rev))
725 + if (!gitmodule_oid_from_commit(repo, treeish_name, &oid, &rev))
722 726 goto out;
723 727
724 728 switch (lookup_type) {
@@ -732,7 +736,7 @@ static const struct submodule *config_from(struct submodule_cache *cache,
732 736 if (submodule)
733 737 goto out;
734 738
735 - config = odb_read_object(the_repository->objects, &oid,
739 + config = odb_read_object(repo->objects, &oid,
736 740 &type, &config_size);
737 741 if (!config || type != OBJ_BLOB)
738 742 goto out;
@@ -798,9 +802,6 @@ static void config_from_gitmodules(config_fn_t fn, struct repository *repo, void
798 802 } else if (repo_get_oid(repo, GITMODULES_INDEX, &oid) >= 0 ||
799 803 repo_get_oid(repo, GITMODULES_HEAD, &oid) >= 0) {
800 804 config_source.blob = oidstr = xstrdup(oid_to_hex(&oid));
801 - if (repo != the_repository)
802 - odb_add_submodule_source_by_path(the_repository->objects,
803 - repo->objects->sources->path);
804 805 } else {
805 806 goto out;
806 807 }
@@ -821,7 +822,7 @@ static int gitmodules_cb(const char *var, const char *value,
821 822
822 823 parameter.cache = repo->submodule_cache;
823 824 parameter.treeish_name = NULL;
824 - parameter.gitmodules_oid = null_oid(the_hash_algo);
825 + parameter.gitmodules_oid = null_oid(repo->hash_algo);
825 826 parameter.overwrite = 1;
826 827
827 828 return parse_config(var, value, ctx, &parameter);
@@ -843,21 +844,22 @@ void repo_read_gitmodules(struct repository *repo, int skip_if_read)
843 844 repo->submodule_cache->gitmodules_read = 1;
844 845 }
845 846
846 - void gitmodules_config_oid(const struct object_id *commit_oid)
847 + void gitmodules_config_oid(struct repository *repo,
848 + const struct object_id *commit_oid)
847 849 {
848 850 struct strbuf rev = STRBUF_INIT;
849 851 struct object_id oid;
850 852
851 - submodule_cache_check_init(the_repository);
853 + submodule_cache_check_init(repo);
852 854
853 - if (gitmodule_oid_from_commit(commit_oid, &oid, &rev)) {
855 + if (gitmodule_oid_from_commit(repo, commit_oid, &oid, &rev)) {
854 856 git_config_from_blob_oid(gitmodules_cb, rev.buf,
855 - the_repository, &oid, the_repository,
857 + repo, &oid, repo,
856 858 CONFIG_SCOPE_UNKNOWN);
857 859 }
858 860 strbuf_release(&rev);
859 861
860 - the_repository->submodule_cache->gitmodules_read = 1;
862 + repo->submodule_cache->gitmodules_read = 1;
861 863 }
862 864
863 865 const struct submodule *submodule_from_name(struct repository *r,
@@ -865,7 +867,7 @@ const struct submodule *submodule_from_name(struct repository *r,
865 867 const char *name)
866 868 {
867 869 repo_read_gitmodules(r, 1);
868 - return config_from(r->submodule_cache, treeish_name, name, lookup_name);
870 + return config_from(r, r->submodule_cache, treeish_name, name, lookup_name);
869 871 }
870 872
871 873 const struct submodule *submodule_from_path(struct repository *r,
@@ -873,7 +875,7 @@ const struct submodule *submodule_from_path(struct repository *r,
873 875 const char *path)
874 876 {
875 877 repo_read_gitmodules(r, 1);
876 - return config_from(r->submodule_cache, treeish_name, path, lookup_path);
878 + return config_from(r, r->submodule_cache, treeish_name, path, lookup_path);
877 879 }
878 880
879 881 /**
@@ -980,11 +982,12 @@ int print_config_from_gitmodules(struct repository *repo, const char *key)
980 982 return 0;
981 983 }
982 984
983 - int config_set_in_gitmodules_file_gently(const char *key, const char *value)
985 + int config_set_in_gitmodules_file_gently(struct repository *repo,
986 + const char *key, const char *value)
984 987 {
985 988 int ret;
986 989
987 - ret = repo_config_set_in_file_gently(the_repository, GITMODULES_FILE, key, NULL, value);
990 + ret = repo_config_set_in_file_gently(repo, GITMODULES_FILE, key, NULL, value);
988 991 if (ret < 0)
989 992 /* Maybe the user already did that, don't error out here */
990 993 warning(_("Could not update .gitmodules entry %s"), key);
@@ -1017,13 +1020,15 @@ static int gitmodules_fetch_config(const char *var, const char *value,
1017 1020 return 0;
1018 1021 }
1019 1022
1020 - void fetch_config_from_gitmodules(int *max_children, int *recurse_submodules)
1023 + void fetch_config_from_gitmodules(struct repository *repo,
1024 + int *max_children,
1025 + int *recurse_submodules)
1021 1026 {
1022 1027 struct fetch_config config = {
1023 1028 .max_children = max_children,
1024 1029 .recurse_submodules = recurse_submodules
1025 1030 };
1026 - config_from_gitmodules(gitmodules_fetch_config, the_repository, &config);
1031 + config_from_gitmodules(gitmodules_fetch_config, repo, &config);
1027 1032 }
1028 1033
1029 1034 static int gitmodules_update_clone_config(const char *var, const char *value,
@@ -1036,7 +1041,7 @@ static int gitmodules_update_clone_config(const char *var, const char *value,
1036 1041 return 0;
1037 1042 }
1038 1043
1039 - void update_clone_config_from_gitmodules(int *max_jobs)
1044 + void update_clone_config_from_gitmodules(struct repository *repo, int *max_jobs)
1040 1045 {
1041 - config_from_gitmodules(gitmodules_update_clone_config, the_repository, max_jobs);
1046 + config_from_gitmodules(gitmodules_update_clone_config, repo, max_jobs);
1042 1047 }
modified submodule-config.h
@@ -57,7 +57,8 @@ int option_fetch_parse_recurse_submodules(const struct option *opt,
57 57 int parse_update_recurse_submodules_arg(const char *opt, const char *arg);
58 58 int parse_push_recurse_submodules_arg(const char *opt, const char *arg);
59 59 void repo_read_gitmodules(struct repository *repo, int skip_if_read);
60 - void gitmodules_config_oid(const struct object_id *commit_oid);
60 + void gitmodules_config_oid(struct repository *repo,
61 + const struct object_id *commit_oid);
61 62
62 63 /**
63 64 * Same as submodule_from_path but lookup by name.
@@ -80,7 +81,8 @@ const struct submodule *submodule_from_path(struct repository *r,
80 81 void submodule_free(struct repository *r);
81 82
82 83 int print_config_from_gitmodules(struct repository *repo, const char *key);
83 - int config_set_in_gitmodules_file_gently(const char *key, const char *value);
84 + int config_set_in_gitmodules_file_gently(struct repository *repo,
85 + const char *key, const char *value);
84 86
85 87 /*
86 88 * Returns 0 if the name is syntactically acceptable as a submodule "name"
@@ -100,8 +102,10 @@ int check_submodule_url(const char *url);
100 102 * New helpers to retrieve arbitrary configuration from the '.gitmodules' file
101 103 * should NOT be added.
102 104 */
103 - void fetch_config_from_gitmodules(int *max_children, int *recurse_submodules);
104 - void update_clone_config_from_gitmodules(int *max_jobs);
105 + void fetch_config_from_gitmodules(struct repository *repo,
106 + int *max_children,
107 + int *recurse_submodules);
108 + void update_clone_config_from_gitmodules(struct repository *repo, int *max_jobs);
105 109
106 110 /*
107 111 * Submodule entry that contains relevant information about a
modified submodule.c
@@ -133,7 +133,7 @@ int update_path_in_gitmodules(const char *oldpath, const char *newpath)
133 133 strbuf_addstr(&entry, "submodule.");
134 134 strbuf_addstr(&entry, submodule->name);
135 135 strbuf_addstr(&entry, ".path");
136 - ret = config_set_in_gitmodules_file_gently(entry.buf, newpath);
136 + ret = config_set_in_gitmodules_file_gently(the_repository, entry.buf, newpath);
137 137 strbuf_release(&entry);
138 138 return ret;
139 139 }
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/helper/test-read-midx.c
@@ -5,34 +5,42 @@
5 5 #include "midx.h"
6 6 #include "repository.h"
7 7 #include "odb.h"
8 + #include "odb/source-packed.h"
8 9 #include "pack-bitmap.h"
9 10 #include "packfile.h"
10 11 #include "setup.h"
11 12 #include "gettext.h"
12 13 #include "pack-revindex.h"
13 14
14 - static struct multi_pack_index *setup_midx(const char *object_dir)
15 + static struct multi_pack_index *setup_midx(const char *object_dir,
16 + struct odb_source_packed **out)
15 17 {
16 - struct odb_source_files *files;
18 + struct odb_source_packed *packed;
17 19 struct odb_source *source;
20 +
18 21 setup_git_directory(the_repository);
22 +
19 23 source = odb_find_source(the_repository->objects, object_dir);
20 - if (!source)
21 - source = odb_add_to_alternates_memory(the_repository->objects,
22 - object_dir);
23 - files = odb_source_files_downcast(source);
24 + if (source) {
25 + packed = odb_source_files_downcast(source)->packed;
26 + } else {
27 + packed = odb_source_packed_new(the_repository->objects,
28 + object_dir, false);
29 + *out = packed;
30 + }
24 31
25 - return load_multi_pack_index(files->packed);
32 + return load_multi_pack_index(packed);
26 33 }
27 34
28 35 static int read_midx_file(const char *object_dir, const char *checksum,
29 36 int show_objects)
30 37 {
38 + struct odb_source_packed *packed = NULL;
31 39 uint32_t i;
32 40 struct multi_pack_index *m, *tip;
33 41 int ret = 0;
34 42
35 - m = tip = setup_midx(object_dir);
43 + m = tip = setup_midx(object_dir, &packed);
36 44
37 45 if (!m)
38 46 return 1;
@@ -91,29 +99,35 @@ static int read_midx_file(const char *object_dir, const char *checksum,
91 99
92 100 out:
93 101 close_midx(tip);
102 + if (packed)
103 + odb_source_free(&packed->base);
94 104
95 105 return ret;
96 106 }
97 107
98 108 static int read_midx_checksum(const char *object_dir)
99 109 {
110 + struct odb_source_packed *packed = NULL;
100 111 struct multi_pack_index *m;
101 112
102 - m = setup_midx(object_dir);
113 + m = setup_midx(object_dir, &packed);
103 114 if (!m)
104 115 return 1;
105 116 printf("%s\n", midx_get_checksum_hex(m));
106 117
107 118 close_midx(m);
119 + if (packed)
120 + odb_source_free(&packed->base);
108 121 return 0;
109 122 }
110 123
111 124 static int read_midx_preferred_pack(const char *object_dir)
112 125 {
126 + struct odb_source_packed *packed = NULL;
113 127 struct multi_pack_index *midx = NULL;
114 128 uint32_t preferred_pack;
115 129
116 - midx = setup_midx(object_dir);
130 + midx = setup_midx(object_dir, &packed);
117 131 if (!midx)
118 132 return 1;
119 133
@@ -124,17 +138,21 @@ static int read_midx_preferred_pack(const char *object_dir)
124 138 }
125 139
126 140 printf("%s\n", midx->pack_names[preferred_pack]);
141 +
127 142 close_midx(midx);
143 + if (packed)
144 + odb_source_free(&packed->base);
128 145 return 0;
129 146 }
130 147
131 148 static int read_midx_bitmapped_packs(const char *object_dir)
132 149 {
150 + struct odb_source_packed *packed = NULL;
133 151 struct multi_pack_index *midx = NULL;
134 152 struct bitmapped_pack pack;
135 153 uint32_t i;
136 154
137 - midx = setup_midx(object_dir);
155 + midx = setup_midx(object_dir, &packed);
138 156 if (!midx)
139 157 return 1;
140 158
@@ -150,7 +168,8 @@ static int read_midx_bitmapped_packs(const char *object_dir)
150 168 }
151 169
152 170 close_midx(midx);
153 -
171 + if (packed)
172 + odb_source_free(&packed->base);
154 173 return 0;
155 174 }
156 175
modified t/helper/test-ref-store.c
@@ -74,14 +74,6 @@ static const char **get_store(const char **argv, struct ref_store **refs)
74 74 } else if (!strcmp(argv[0], "main")) {
75 75 *refs = get_main_ref_store(the_repository);
76 76 } else if (skip_prefix(argv[0], "submodule:", &gitdir)) {
77 - struct strbuf sb = STRBUF_INIT;
78 -
79 - if (!repo_submodule_path_append(the_repository,
80 - &sb, gitdir, "objects/"))
81 - die("computing submodule path failed");
82 - odb_add_to_alternates_memory(the_repository->objects, sb.buf);
83 - strbuf_release(&sb);
84 -
85 77 *refs = repo_get_submodule_ref_store(the_repository, gitdir);
86 78 } else if (skip_prefix(argv[0], "worktree:", &gitdir)) {
87 79 struct worktree **p, **worktrees = get_worktrees(the_repository);
modified t/helper/test-submodule.c
@@ -168,7 +168,7 @@ static int cmd__submodule_config_set(int argc, const char **argv)
168 168 if (!is_writing_gitmodules_ok())
169 169 die("please make sure that the .gitmodules file is in the working tree");
170 170
171 - return config_set_in_gitmodules_file_gently(argv[1], argv[2]);
171 + return config_set_in_gitmodules_file_gently(the_repository, argv[1], argv[2]);
172 172 }
173 173 usage_with_options(usage, options);
174 174 }
@@ -188,7 +188,7 @@ static int cmd__submodule_config_unset(int argc, const char **argv)
188 188 if (argc == 2) {
189 189 if (!is_writing_gitmodules_ok())
190 190 die("please make sure that the .gitmodules file is in the working tree");
191 - return config_set_in_gitmodules_file_gently(argv[1], NULL);
191 + return config_set_in_gitmodules_file_gently(the_repository, argv[1], NULL);
192 192 }
193 193 usage_with_options(usage, options);
194 194 }
modified t/t5319-multi-pack-index.sh
@@ -698,10 +698,9 @@ test_expect_success 'force some 64-bit offsets with pack-objects' '
698 698 corrupt_data $idx64 $(test_oid idxoff) "\02" &&
699 699 # objects64 is not a real repository, but can serve as an alternate
700 700 # anyway so we can write a MIDX into it
701 - git init repo &&
702 - test_when_finished "rm -fr repo" &&
701 + git init repo64 &&
703 702 (
704 - cd repo &&
703 + cd repo64 &&
705 704 ( cd ../objects64 && pwd ) >.git/objects/info/alternates &&
706 705 midx64=$(git multi-pack-index --object-dir=../objects64 write)
707 706 ) &&
@@ -709,7 +708,7 @@ test_expect_success 'force some 64-bit offsets with pack-objects' '
709 708 '
710 709
711 710 test_expect_success 'verify multi-pack-index with 64-bit offsets' '
712 - git multi-pack-index verify --object-dir=objects64
711 + git -C repo64 multi-pack-index verify --object-dir=../objects64
713 712 '
714 713
715 714 NUM_OBJECTS=63
@@ -721,7 +720,7 @@ MIDX_BYTE_LARGE_OFFSET=$(($MIDX_OFFSET_LARGE_OFFSETS + 3))
721 720
722 721 test_expect_success 'verify incorrect 64-bit offset' '
723 722 corrupt_midx_and_verify $MIDX_BYTE_LARGE_OFFSET "\07" objects64 \
724 - "incorrect object offset"
723 + "incorrect object offset" "git -C repo64 multi-pack-index verify --object-dir=../objects64"
725 724 '
726 725
727 726 test_expect_success 'setup expire tests' '
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 &&
modified tmp-objdir.c
@@ -321,11 +321,6 @@ const char **tmp_objdir_env(const struct tmp_objdir *t)
321 321 return t->env.v;
322 322 }
323 323
324 - void tmp_objdir_add_as_alternate(const struct tmp_objdir *t)
325 - {
326 - odb_add_to_alternates_memory(t->repo->objects, t->path.buf);
327 - }
328 -
329 324 struct odb_source *tmp_objdir_replace_primary_odb(struct tmp_objdir *t,
330 325 int will_destroy)
331 326 {
modified tmp-objdir.h
@@ -55,12 +55,6 @@ int tmp_objdir_destroy(struct tmp_objdir *);
55 55 */
56 56 void tmp_objdir_discard_objects(struct tmp_objdir *);
57 57
58 - /*
59 - * Add the temporary object directory as an alternate object store in the
60 - * current process.
61 - */
62 - void tmp_objdir_add_as_alternate(const struct tmp_objdir *);
63 -
64 58 /*
65 59 * Replaces the writable object store in the current process with the temporary
66 60 * object directory and makes the former main object store an alternate.
modified unpack-trees.c
@@ -416,7 +416,8 @@ static void report_collided_checkout(struct index_state *index)
416 416 string_list_clear(&list, 0);
417 417 }
418 418
419 - static int must_checkout(const struct cache_entry *ce)
419 + static int must_checkout(const struct cache_entry *ce,
420 + void *cb_data UNUSED)
420 421 {
421 422 return ce->ce_flags & CE_UPDATE;
422 423 }
@@ -477,7 +478,7 @@ static int check_updates(struct unpack_trees_options *o,
477 478 * Prefetch the objects that are to be checked out in the loop
478 479 * below.
479 480 */
480 - prefetch_cache_entries(index, must_checkout);
481 + prefetch_cache_entries(index, must_checkout, NULL);
481 482
482 483 get_parallel_checkout_configs(&pc_workers, &pc_threshold);
483 484
@@ -487,7 +488,7 @@ static int check_updates(struct unpack_trees_options *o,
487 488 for (i = 0; i < index->cache_nr; i++) {
488 489 struct cache_entry *ce = index->cache[i];
489 490
490 - if (must_checkout(ce)) {
491 + if (must_checkout(ce, NULL)) {
491 492 size_t last_pc_queue_size = pc_queue_size();
492 493
493 494 if (ce->ce_flags & CE_WT_REMOVE)