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

Function write_midx_object_offsets

midx-write.c:561–589  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

559}
560
561static 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
591static int write_midx_large_offsets(struct hashfile *f,
592 void *data)

Callers

nothing calls this directly

Calls 3

midx_pack_permFunction · 0.85
oid_to_hexFunction · 0.85
hashwrite_be32Function · 0.85

Tested by

no test coverage detected