* 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. */
| 269 | * to be checked at the end. |
| 270 | */ |
| 271 | static 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 | |
| 312 | static void resolve_delta(unsigned nr, enum object_type type, |
| 313 | void *base, unsigned long base_size, |
no test coverage detected