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

Function write_object

builtin/unpack-objects.c:271–310  ·  view source on GitHub ↗

* Write out nr-th object from the list, now we know the contents * of it. Under --strict, this buffers structured objects in-core, * to be checked at the end. */

Source from the content-addressed store, hash-verified

269 * to be checked at the end.
270 */
271static void write_object(unsigned nr, enum object_type type,
272 void *buf, unsigned long size)
273{
274 if (!strict) {
275 if (odb_write_object(the_repository->objects, buf, size, type,
276 &obj_list[nr].oid) < 0)
277 die("failed to write object");
278 added_object(nr, type, buf, size);
279 free(buf);
280 obj_list[nr].obj = NULL;
281 } else if (type == OBJ_BLOB) {
282 struct blob *blob;
283 if (odb_write_object(the_repository->objects, buf, size, type,
284 &obj_list[nr].oid) < 0)
285 die("failed to write object");
286 added_object(nr, type, buf, size);
287 free(buf);
288
289 blob = lookup_blob(the_repository, &obj_list[nr].oid);
290 if (blob)
291 blob->object.flags |= FLAG_WRITTEN;
292 else
293 die("invalid blob object");
294 obj_list[nr].obj = NULL;
295 } else {
296 struct object *obj;
297 int eaten;
298 hash_object_file(the_hash_algo, buf, size, type,
299 &obj_list[nr].oid);
300 added_object(nr, type, buf, size);
301 obj = parse_object_buffer(the_repository, &obj_list[nr].oid,
302 type, size, buf,
303 &eaten);
304 if (!obj)
305 die("invalid %s", type_name(type));
306 add_object_buffer(obj, buf, size);
307 obj->flags |= FLAG_OPEN;
308 obj_list[nr].obj = obj;
309 }
310}
311
312static void resolve_delta(unsigned nr, enum object_type type,
313 void *base, unsigned long base_size,

Callers 2

resolve_deltaFunction · 0.70
unpack_non_delta_entryFunction · 0.70

Calls 8

odb_write_objectFunction · 0.85
added_objectFunction · 0.85
lookup_blobFunction · 0.85
hash_object_fileFunction · 0.85
parse_object_bufferFunction · 0.85
type_nameFunction · 0.85
add_object_bufferFunction · 0.85
dieFunction · 0.50

Tested by

no test coverage detected