MCPcopy Create free account
hub / github.com/git/git / check_object

Function check_object

builtin/unpack-objects.c:218–252  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

216 * Verify its reachability and validity recursively and write it out.
217 */
218static 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
254static void write_rest(void)
255{

Callers 1

write_restFunction · 0.70

Calls 7

odb_read_object_infoFunction · 0.85
lookup_object_bufferFunction · 0.85
oid_to_hexFunction · 0.85
fsck_objectFunction · 0.85
fsck_walkFunction · 0.85
write_cached_objectFunction · 0.85
dieFunction · 0.50

Tested by

no test coverage detected