]> git.ipfire.org Git - thirdparty/git.git/commitdiff
odb/source-loose: drop pointer to the "files" source
authorPatrick Steinhardt <ps@pks.im>
Thu, 21 May 2026 08:22:38 +0000 (10:22 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 21 May 2026 13:35:20 +0000 (22:35 +0900)
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>
odb/source-files.c
odb/source-loose.c
odb/source-loose.h

index 83f8066c67dd3ce70c3421acd65834bae5487dad..5bdd04292253971fdfc3cb60fb9f1201a6075f2e 100644 (file)
@@ -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;
index e17494131841601596431c5504b9ce0c4433ced1..7d7ea2fb842537fe924e4761d5b56f8bbfde1e4d 100644 (file)
@@ -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;
index 825e7030724ac1ef7589954983c8688ca74a221e..fb75e3bbff40b124c2b3fdcf3b28be92e54d1633 100644 (file)
@@ -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