Skip to content

Commit b4d9414

Browse files
derrickstoleegitster
authored andcommitted
midx: use context in write_midx_pack_names()
In an effort to align the write_midx_internal() to use the chunk-format API, start converting chunk writing methods to match chunk_write_fn. The first case is to convert write_midx_pack_names() to take "void *data". We already have the necessary data in "struct write_midx_context", so this conversion is rather mechanical. Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 577dc49 commit b4d9414

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

midx.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -643,27 +643,26 @@ static struct pack_midx_entry *get_sorted_entries(struct multi_pack_index *m,
643643
return deduplicated_entries;
644644
}
645645

646-
static size_t write_midx_pack_names(struct hashfile *f,
647-
struct pack_info *info,
648-
uint32_t num_packs)
646+
static size_t write_midx_pack_names(struct hashfile *f, void *data)
649647
{
648+
struct write_midx_context *ctx = data;
650649
uint32_t i;
651650
unsigned char padding[MIDX_CHUNK_ALIGNMENT];
652651
size_t written = 0;
653652

654-
for (i = 0; i < num_packs; i++) {
653+
for (i = 0; i < ctx->nr; i++) {
655654
size_t writelen;
656655

657-
if (info[i].expired)
656+
if (ctx->info[i].expired)
658657
continue;
659658

660-
if (i && strcmp(info[i].pack_name, info[i - 1].pack_name) <= 0)
659+
if (i && strcmp(ctx->info[i].pack_name, ctx->info[i - 1].pack_name) <= 0)
661660
BUG("incorrect pack-file order: %s before %s",
662-
info[i - 1].pack_name,
663-
info[i].pack_name);
661+
ctx->info[i - 1].pack_name,
662+
ctx->info[i].pack_name);
664663

665-
writelen = strlen(info[i].pack_name) + 1;
666-
hashwrite(f, info[i].pack_name, writelen);
664+
writelen = strlen(ctx->info[i].pack_name) + 1;
665+
hashwrite(f, ctx->info[i].pack_name, writelen);
667666
written += writelen;
668667
}
669668

@@ -990,7 +989,7 @@ static int write_midx_internal(const char *object_dir, struct multi_pack_index *
990989

991990
switch (chunk_ids[i]) {
992991
case MIDX_CHUNKID_PACKNAMES:
993-
written += write_midx_pack_names(f, ctx.info, ctx.nr);
992+
written += write_midx_pack_names(f, &ctx);
994993
break;
995994

996995
case MIDX_CHUNKID_OIDFANOUT:

0 commit comments

Comments
 (0)