Skip to content

Commit 770c032

Browse files
pks-tgitster
authored andcommitted
odb/source-inmemory: implement freshen_object() callback
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>
1 parent aaa0a85 commit 770c032

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

odb/source-inmemory.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,15 @@ static int odb_source_inmemory_write_object_stream(struct odb_source *source,
294294
return ret;
295295
}
296296

297+
static int odb_source_inmemory_freshen_object(struct odb_source *source,
298+
const struct object_id *oid)
299+
{
300+
struct odb_source_inmemory *inmemory = odb_source_inmemory_downcast(source);
301+
if (find_cached_object(inmemory, oid))
302+
return 1;
303+
return 0;
304+
}
305+
297306
static int inmemory_object_free(const struct object_id *oid UNUSED,
298307
void *node_data,
299308
void *cb_data UNUSED)
@@ -336,6 +345,7 @@ struct odb_source_inmemory *odb_source_inmemory_new(struct object_database *odb)
336345
source->base.count_objects = odb_source_inmemory_count_objects;
337346
source->base.write_object = odb_source_inmemory_write_object;
338347
source->base.write_object_stream = odb_source_inmemory_write_object_stream;
348+
source->base.freshen_object = odb_source_inmemory_freshen_object;
339349

340350
return source;
341351
}

0 commit comments

Comments
 (0)