]> git.ipfire.org Git - thirdparty/git.git/commitdiff
odb/source-inmemory: implement `freshen_object()` callback
authorPatrick Steinhardt <ps@pks.im>
Fri, 10 Apr 2026 12:12:44 +0000 (14:12 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 14 May 2026 19:50:45 +0000 (04:50 +0900)
Implement the `freshen_object()` callback function for the in-memory
source.

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

index 674dbcad3001a621e0608b823226dff0406de55a..8934e0f54785dea6d6c6120ef1e6f7a3237dc5ea 100644 (file)
@@ -294,6 +294,15 @@ out:
        return ret;
 }
 
+static int odb_source_inmemory_freshen_object(struct odb_source *source,
+                                             const struct object_id *oid)
+{
+       struct odb_source_inmemory *inmemory = odb_source_inmemory_downcast(source);
+       if (find_cached_object(inmemory, oid))
+               return 1;
+       return 0;
+}
+
 static int inmemory_object_free(const struct object_id *oid UNUSED,
                                void *node_data,
                                void *cb_data UNUSED)
@@ -336,6 +345,7 @@ struct odb_source_inmemory *odb_source_inmemory_new(struct object_database *odb)
        source->base.count_objects = odb_source_inmemory_count_objects;
        source->base.write_object = odb_source_inmemory_write_object;
        source->base.write_object_stream = odb_source_inmemory_write_object_stream;
+       source->base.freshen_object = odb_source_inmemory_freshen_object;
 
        return source;
 }