| 559 | } |
| 560 | |
| 561 | static int write_midx_object_offsets(struct hashfile *f, |
| 562 | void *data) |
| 563 | { |
| 564 | struct write_midx_context *ctx = data; |
| 565 | struct pack_midx_entry *list = ctx->entries; |
| 566 | uint32_t i, nr_large_offset = 0; |
| 567 | |
| 568 | for (i = 0; i < ctx->entries_nr; i++) { |
| 569 | struct pack_midx_entry *obj = list++; |
| 570 | |
| 571 | if (midx_pack_perm(ctx, obj->pack_int_id) == PACK_EXPIRED) |
| 572 | BUG("object %s is in an expired pack with int-id %d", |
| 573 | oid_to_hex(&obj->oid), |
| 574 | obj->pack_int_id); |
| 575 | |
| 576 | hashwrite_be32(f, midx_pack_perm(ctx, obj->pack_int_id)); |
| 577 | |
| 578 | if (ctx->large_offsets_needed && obj->offset >> 31) |
| 579 | hashwrite_be32(f, MIDX_LARGE_OFFSET_NEEDED | nr_large_offset++); |
| 580 | else if (!ctx->large_offsets_needed && obj->offset >> 32) |
| 581 | BUG("object %s requires a large offset (%"PRIx64") but the MIDX is not writing large offsets!", |
| 582 | oid_to_hex(&obj->oid), |
| 583 | obj->offset); |
| 584 | else |
| 585 | hashwrite_be32(f, (uint32_t)obj->offset); |
| 586 | } |
| 587 | |
| 588 | return 0; |
| 589 | } |
| 590 | |
| 591 | static int write_midx_large_offsets(struct hashfile *f, |
| 592 | void *data) |
nothing calls this directly
no test coverage detected