[PATCH 18/18] odb/source-loose: drop pointer to the "files" source
- From
Patrick Steinhardt <ps@pks.im>
- Date
- May 21, 2026, 08:22 UTC
- Message-ID
- <20260521-b4-pks-odb-source-loose-v1-18-6553b399be2d@pks.im>
- In-Reply-To
- <20260521-b4-pks-odb-source-loose-v1-0-6553b399be2d@pks.im>
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> --- odb/source-files.c | 2 +- odb/source-loose.c | 8 ++++---- odb/source-loose.h | 7 ++++--- 3 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/odb/source-files.c b/odb/source-files.c index 83f8066c67..5bdd042922 100644 --- a/odb/source-files.c +++ b/odb/source-files.c @@ -268,7 +268,7 @@ struct odb_source_files *odb_source_files_new(struct object_database *odb, CALLOC_ARRAY(files, 1); odb_source_init(&files->base, odb, ODB_SOURCE_FILES, path, local); - files->loose = odb_source_loose_new(files); + files->loose = odb_source_loose_new(odb, path, local); files->packed = packfile_store_new(&files->base); files->base.free = odb_source_files_free; diff --git a/odb/source-loose.c b/odb/source-loose.c index e174941318..7d7ea2fb84 100644 --- a/odb/source-loose.c +++ b/odb/source-loose.c @@ -705,14 +705,14 @@ static void odb_source_loose_free(struct odb_source *source) free(loose); } -struct odb_source_loose *odb_source_loose_new(struct odb_source_files *files) +struct odb_source_loose *odb_source_loose_new(struct object_database *odb, + const char *path, + bool local) { struct odb_source_loose *loose; CALLOC_ARRAY(loose, 1); - odb_source_init(&loose->base, files->base.odb, ODB_SOURCE_LOOSE, - files->base.path, files->base.local); - loose->files = files; + odb_source_init(&loose->base, odb, ODB_SOURCE_LOOSE, path, local); loose->base.free = odb_source_loose_free; loose->base.close = odb_source_loose_close; diff --git a/odb/source-loose.h b/odb/source-loose.h index 825e703072..fb75e3bbff 100644 --- a/odb/source-loose.h +++ b/odb/source-loose.h @@ -9,11 +9,10 @@ struct oidtree; /* * An object database source that stores its objects in loose format, one - * file per object. This source is part of the files source. + * file per object. */ struct odb_source_loose { struct odb_source base; - struct odb_source_files *files; /* * Used to store the results of readdir(3) calls when we are OK @@ -31,7 +30,9 @@ struct odb_source_loose { struct loose_object_map *map; }; -struct odb_source_loose *odb_source_loose_new(struct odb_source_files *files); +struct odb_source_loose *odb_source_loose_new(struct object_database *odb, + const char *path, + bool local); /* * Cast the given object database source to the loose backend. This will cause
-- 2.54.0.926.g75ba10bac6.dirty