odb: get rid of the_repository in find_odb()

Get rid of our dependency on `the_repository` in `find_odb()` by passing
in the object database in which we want to search for the source and
adjusting all callers.

Rename the function to `odb_find_source()`.

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:17 +02:00
committed by Junio C Hamano
parent 2f5181fce6
commit bd52ea343d
4 changed files with 12 additions and 7 deletions

6
odb.c
View File

@@ -448,14 +448,14 @@ out:
return ref_git;
}
struct odb_source *find_odb(struct repository *r, const char *obj_dir)
struct odb_source *odb_find_source(struct object_database *odb, const char *obj_dir)
{
struct odb_source *source;
char *obj_dir_real = real_pathdup(obj_dir, 1);
struct strbuf odb_path_real = STRBUF_INIT;
prepare_alt_odb(r);
for (source = r->objects->sources; source; source = source->next) {
prepare_alt_odb(odb->repo);
for (source = odb->sources; source; source = source->next) {
strbuf_realpath(&odb_path_real, source->path, 1);
if (!strcmp(obj_dir_real, odb_path_real.buf))
break;