odb/source-loose: drop pointer to the "files" source

Now that all callbacks of the loose source operate on `struct odb_source_loose` directly we no longer have to reach into the "files" source at all. Drop this field and update `odb_source_loose_new()` to instead accept all parameters required to initialize itself. This ensures that the "loose" backend is a fully standalone source. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Jun 1, 2026 at 10:20 UTC ef4778bcba323ab38d442811f851af092760b6b5
3 files changed +9 -8
odb/source-files.c
+1 -1
@@ -268,7 +268,7 @@ struct odb_source_files *odb_source_files_new(struct object_database *odb,
268
269 CALLOC_ARRAY(files, 1);
270 odb_source_init(&files->base, odb, ODB_SOURCE_FILES, path, local);
271 - files->loose = odb_source_loose_new(files);
271 + files->loose = odb_source_loose_new(odb, path, local);
272 files->packed = packfile_store_new(&files->base);
273
274 files->base.free = odb_source_files_free;
odb/source-loose.c
+4 -4
@@ -705,14 +705,14 @@ static void odb_source_loose_free(struct odb_source *source)
705 free(loose);
706 }
707
708 -struct odb_source_loose *odb_source_loose_new(struct odb_source_files *files)
708 +struct odb_source_loose *odb_source_loose_new(struct object_database *odb,
709 + const char *path,
710 + bool local)
711 {
712 struct odb_source_loose *loose;
713
714 CALLOC_ARRAY(loose, 1);
713 - odb_source_init(&loose->base, files->base.odb, ODB_SOURCE_LOOSE,
714 - files->base.path, files->base.local);
715 - loose->files = files;
715 + odb_source_init(&loose->base, odb, ODB_SOURCE_LOOSE, path, local);
716
717 loose->base.free = odb_source_loose_free;
718 loose->base.close = odb_source_loose_close;
odb/source-loose.h
+4 -3
@@ -9,11 +9,10 @@ struct oidtree;
9
10 /*
11 * An object database source that stores its objects in loose format, one
12 - * file per object. This source is part of the files source.
12 + * file per object.
13 */
14 struct odb_source_loose {
15 struct odb_source base;
16 - struct odb_source_files *files;
16
17 /*
18 * Used to store the results of readdir(3) calls when we are OK
@@ -31,7 +30,9 @@ struct odb_source_loose {
30 struct loose_object_map *map;
31 };
32
34 -struct odb_source_loose *odb_source_loose_new(struct odb_source_files *files);
33 +struct odb_source_loose *odb_source_loose_new(struct object_database *odb,
34 + const char *path,
35 + bool local);
36
37 /*
38 * Cast the given object database source to the loose backend. This will cause