* At the very end of the processing, write_rest() scans the objects * that have reachability requirements and calls this function. * Verify its reachability and validity recursively and write it out. */
| 216 | * Verify its reachability and validity recursively and write it out. |
| 217 | */ |
| 218 | static int check_object(struct object *obj, enum object_type type, |
| 219 | void *data UNUSED, |
| 220 | struct fsck_options *options UNUSED) |
| 221 | { |
| 222 | struct obj_buffer *obj_buf; |
| 223 | |
| 224 | if (!obj) |
| 225 | return 1; |
| 226 | |
| 227 | if (obj->flags & FLAG_WRITTEN) |
| 228 | return 0; |
| 229 | |
| 230 | if (type != OBJ_ANY && obj->type != type) |
| 231 | die("object type mismatch"); |
| 232 | |
| 233 | if (!(obj->flags & FLAG_OPEN)) { |
| 234 | size_t size; |
| 235 | int type = odb_read_object_info(the_repository->objects, &obj->oid, &size); |
| 236 | if (type != obj->type || type <= 0) |
| 237 | die("object of unexpected type"); |
| 238 | obj->flags |= FLAG_WRITTEN; |
| 239 | return 0; |
| 240 | } |
| 241 | |
| 242 | obj_buf = lookup_object_buffer(obj); |
| 243 | if (!obj_buf) |
| 244 | die("Whoops! Cannot find object '%s'", oid_to_hex(&obj->oid)); |
| 245 | if (fsck_object(obj, obj_buf->buffer, obj_buf->size, &fsck_options)) |
| 246 | die("fsck error in packed object"); |
| 247 | fsck_options.walk = check_object; |
| 248 | if (fsck_walk(obj, NULL, &fsck_options)) |
| 249 | die("Error on reachable objects of %s", oid_to_hex(&obj->oid)); |
| 250 | write_cached_object(obj, obj_buf); |
| 251 | return 0; |
| 252 | } |
| 253 | |
| 254 | static void write_rest(void) |
| 255 | { |
no test coverage detected