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 <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Derrick Stolee committed
Feb 18, 2021 at 14:07 UTC
b4d941420bce15cd48bccabc1faa90477bda2fae
1 file changed
+10
-11
midx.c
+10
-11
@@ -643,27 +643,26 @@ static struct pack_midx_entry *get_sorted_entries(struct multi_pack_index *m,
643
return deduplicated_entries;
644
}
645
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)
647
{
648
+ struct write_midx_context *ctx = data;
649
uint32_t i;
650
unsigned char padding[MIDX_CHUNK_ALIGNMENT];
651
size_t written = 0;
652
654
- for (i = 0; i < num_packs; i++) {
653
+ for (i = 0; i < ctx->nr; i++) {
654
size_t writelen;
655
657
- if (info[i].expired)
656
+ if (ctx->info[i].expired)
657
continue;
658
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)
660
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);
663
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);
666
written += writelen;
667
}
668
@@ -990,7 +989,7 @@ static int write_midx_internal(const char *object_dir, struct multi_pack_index *
989
990
switch (chunk_ids[i]) {
991
case MIDX_CHUNKID_PACKNAMES:
993
- written += write_midx_pack_names(f, ctx.info, ctx.nr);
992
+ written += write_midx_pack_names(f, &ctx);
993
break;
994
995
case MIDX_CHUNKID_OIDFANOUT: