| 1368 | */ |
| 1369 | static void fix_unresolved_deltas(struct hashfile *f); |
| 1370 | static void conclude_pack(int fix_thin_pack, const char *curr_pack, unsigned char *pack_hash) |
| 1371 | { |
| 1372 | if (nr_ref_deltas + nr_ofs_deltas == nr_resolved_deltas) { |
| 1373 | stop_progress(&progress); |
| 1374 | /* Flush remaining pack final hash. */ |
| 1375 | flush(); |
| 1376 | return; |
| 1377 | } |
| 1378 | |
| 1379 | if (fix_thin_pack) { |
| 1380 | struct hashfile *f; |
| 1381 | unsigned char read_hash[GIT_MAX_RAWSZ], tail_hash[GIT_MAX_RAWSZ]; |
| 1382 | struct strbuf msg = STRBUF_INIT; |
| 1383 | int nr_unresolved = nr_ofs_deltas + nr_ref_deltas - nr_resolved_deltas; |
| 1384 | int nr_objects_initial = nr_objects; |
| 1385 | if (nr_unresolved <= 0) |
| 1386 | die(_("confusion beyond insanity")); |
| 1387 | REALLOC_ARRAY(objects, nr_objects + nr_unresolved + 1); |
| 1388 | memset(objects + nr_objects + 1, 0, |
| 1389 | nr_unresolved * sizeof(*objects)); |
| 1390 | f = hashfd(the_repository->hash_algo, output_fd, curr_pack); |
| 1391 | fix_unresolved_deltas(f); |
| 1392 | strbuf_addf(&msg, Q_("completed with %d local object", |
| 1393 | "completed with %d local objects", |
| 1394 | nr_objects - nr_objects_initial), |
| 1395 | nr_objects - nr_objects_initial); |
| 1396 | stop_progress_msg(&progress, msg.buf); |
| 1397 | strbuf_release(&msg); |
| 1398 | finalize_hashfile(f, tail_hash, FSYNC_COMPONENT_PACK, 0); |
| 1399 | hashcpy(read_hash, pack_hash, the_repository->hash_algo); |
| 1400 | fixup_pack_header_footer(the_hash_algo, output_fd, pack_hash, |
| 1401 | curr_pack, nr_objects, |
| 1402 | read_hash, consumed_bytes-the_hash_algo->rawsz); |
| 1403 | if (!hasheq(read_hash, tail_hash, the_repository->hash_algo)) |
| 1404 | die(_("Unexpected tail checksum for %s " |
| 1405 | "(disk corruption?)"), curr_pack); |
| 1406 | } |
| 1407 | if (nr_ofs_deltas + nr_ref_deltas != nr_resolved_deltas) |
| 1408 | die(Q_("pack has %d unresolved delta", |
| 1409 | "pack has %d unresolved deltas", |
| 1410 | nr_ofs_deltas + nr_ref_deltas - nr_resolved_deltas), |
| 1411 | nr_ofs_deltas + nr_ref_deltas - nr_resolved_deltas); |
| 1412 | } |
| 1413 | |
| 1414 | static int write_compressed(struct hashfile *f, void *in, unsigned int size) |
| 1415 | { |
no test coverage detected