odb: get rid of the_repository when handling alternates

The functions to manage alternates all depend on `the_repository`.
Refactor them to accept an object database as a parameter and adjust all
callers. The functions are renamed accordingly.

Note that right now the situation is still somewhat weird because we end
up using the object store path provided by the object store's repository
anyway. Consequently, we could have instead passed in a pointer to the
repository instead of passing in the pointer to the object store. This
will be addressed in subsequent commits though, where we will start to
use the path owned by the object store itself.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt
2025-07-01 14:22:20 +02:00
committed by Junio C Hamano
parent 1b1679c688
commit c44185f6c1
14 changed files with 83 additions and 64 deletions

View File

@@ -1034,7 +1034,7 @@ static void prepare_packed_git(struct repository *r)
if (r->objects->packed_git_initialized)
return;
prepare_alt_odb(r);
odb_prepare_alternates(r->objects);
for (source = r->objects->sources; source; source = source->next) {
int local = (source == r->objects->sources);
prepare_multi_pack_index_one(r, source->path, local);
@@ -1059,7 +1059,7 @@ void reprepare_packed_git(struct repository *r)
* the lifetime of the process.
*/
r->objects->loaded_alternates = 0;
prepare_alt_odb(r);
odb_prepare_alternates(r->objects);
for (source = r->objects->sources; source; source = source->next)
odb_clear_loose_cache(source);