MCPcopy Index your code
hub / github.com/git/git / odb_source_inmemory_write_object

Function odb_source_inmemory_write_object

odb/source-inmemory.c:229–256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

227}
228
229static int odb_source_inmemory_write_object(struct odb_source *source,
230 const void *buf, unsigned long len,
231 enum object_type type,
232 struct object_id *oid,
233 struct object_id *compat_oid UNUSED,
234 enum odb_write_object_flags flags UNUSED)
235{
236 struct odb_source_inmemory *inmemory = odb_source_inmemory_downcast(source);
237 struct inmemory_object *object;
238
239 hash_object_file(source->odb->repo->hash_algo, buf, len, type, oid);
240
241 if (!inmemory->objects) {
242 CALLOC_ARRAY(inmemory->objects, 1);
243 oidtree_init(inmemory->objects);
244 } else if (oidtree_contains(inmemory->objects, oid)) {
245 return 0;
246 }
247
248 CALLOC_ARRAY(object, 1);
249 object->size = len;
250 object->type = type;
251 object->buf = xmemdupz(buf, len);
252
253 oidtree_insert(inmemory->objects, oid, object);
254
255 return 0;
256}
257
258static int odb_source_inmemory_write_object_stream(struct odb_source *source,
259 struct odb_write_stream *stream,

Calls 6

hash_object_fileFunction · 0.85
oidtree_initFunction · 0.85
oidtree_containsFunction · 0.85
xmemdupzFunction · 0.85
oidtree_insertFunction · 0.85

Tested by

no test coverage detected