| 1318 | } |
| 1319 | |
| 1320 | static int fsck_blobs(struct oidset *blobs_found, struct oidset *blobs_done, |
| 1321 | enum fsck_msg_id msg_missing, enum fsck_msg_id msg_type, |
| 1322 | struct fsck_options *options, const char *blob_type) |
| 1323 | { |
| 1324 | int ret = 0; |
| 1325 | struct oidset_iter iter; |
| 1326 | const struct object_id *oid; |
| 1327 | |
| 1328 | oidset_iter_init(blobs_found, &iter); |
| 1329 | while ((oid = oidset_iter_next(&iter))) { |
| 1330 | enum object_type type; |
| 1331 | size_t size; |
| 1332 | char *buf; |
| 1333 | |
| 1334 | if (oidset_contains(blobs_done, oid)) |
| 1335 | continue; |
| 1336 | |
| 1337 | buf = odb_read_object(options->repo->objects, oid, &type, &size); |
| 1338 | if (!buf) { |
| 1339 | if (is_promisor_object(options->repo, oid)) |
| 1340 | continue; |
| 1341 | ret |= report(options, |
| 1342 | oid, OBJ_BLOB, msg_missing, |
| 1343 | "unable to read %s blob", blob_type); |
| 1344 | continue; |
| 1345 | } |
| 1346 | |
| 1347 | if (type == OBJ_BLOB) |
| 1348 | ret |= fsck_blob(oid, buf, size, options); |
| 1349 | else |
| 1350 | ret |= report(options, oid, type, msg_type, |
| 1351 | "non-blob found at %s", blob_type); |
| 1352 | free(buf); |
| 1353 | } |
| 1354 | |
| 1355 | oidset_clear(blobs_found); |
| 1356 | oidset_clear(blobs_done); |
| 1357 | |
| 1358 | return ret; |
| 1359 | } |
| 1360 | |
| 1361 | int fsck_finish(struct fsck_options *options) |
| 1362 | { |
no test coverage detected