]> git.ipfire.org Git - thirdparty/git.git/commitdiff
odb: generic in-memory source
authorPatrick Steinhardt <ps@pks.im>
Fri, 10 Apr 2026 12:12:46 +0000 (14:12 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 10 Apr 2026 15:00:07 +0000 (08:00 -0700)
Make the in-memory source generic.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
odb.c
odb.h

diff --git a/odb.c b/odb.c
index 24e929f03cbccfd04171edf791788f4744b4b698..965ef68e4eca222bc1af9a900665916b2231068f 100644 (file)
--- a/odb.c
+++ b/odb.c
@@ -560,7 +560,7 @@ static int do_oid_object_info_extended(struct object_database *odb,
        if (is_null_oid(real))
                return -1;
 
-       if (!odb_source_read_object_info(&odb->inmemory_objects->base, oid, oi, flags))
+       if (!odb_source_read_object_info(odb->inmemory_objects, oid, oi, flags))
                return 0;
 
        odb_prepare_alternates(odb);
@@ -737,7 +737,7 @@ int odb_pretend_object(struct object_database *odb,
        if (odb_has_object(odb, oid, 0))
                return 0;
 
-       return odb_source_write_object(&odb->inmemory_objects->base,
+       return odb_source_write_object(odb->inmemory_objects,
                                       buf, len, type, oid, NULL, 0);
 }
 
@@ -1020,7 +1020,7 @@ struct object_database *odb_new(struct repository *repo,
        o->sources = odb_source_new(o, primary_source, true);
        o->sources_tail = &o->sources->next;
        o->alternate_db = xstrdup_or_null(secondary_sources);
-       o->inmemory_objects = odb_source_inmemory_new(o);
+       o->inmemory_objects = &odb_source_inmemory_new(o)->base;
 
        free(to_free);
 
@@ -1045,7 +1045,7 @@ static void odb_free_sources(struct object_database *o)
                o->sources = next;
        }
 
-       odb_source_free(&o->inmemory_objects->base);
+       odb_source_free(o->inmemory_objects);
        o->inmemory_objects = NULL;
 
        kh_destroy_odb_path_map(o->source_by_path);
diff --git a/odb.h b/odb.h
index c3a7edf9c848dd5103e0dad2fe301a7556cbacd6..73553ed5a7b1ea1971f776a42e9c5780b044fa95 100644 (file)
--- a/odb.h
+++ b/odb.h
@@ -81,7 +81,7 @@ struct object_database {
         * to write them into the object store (e.g. a browse-only
         * application).
         */
-       struct odb_source_inmemory *inmemory_objects;
+       struct odb_source *inmemory_objects;
 
        /*
         * A fast, rough count of the number of objects in the repository.