475
unsigned expired : 1;
476
};
477
478
+static void fill_pack_info(struct pack_info *info,
479
+ struct packed_git *p, const char *pack_name,
480
+ uint32_t orig_pack_int_id)
481
+{
482
+ memset(info, 0, sizeof(struct pack_info));
483
+
484
+ info->orig_pack_int_id = orig_pack_int_id;
485
+ info->pack_name = xstrdup(pack_name);
486
+ info->p = p;
487
+}
488
+
489
static int pack_info_compare(const void *_a, const void *_b)
490
{
491
struct pack_info *a = (struct pack_info *)_a;
526
const char *file_name, void *data)
527
{
528
struct write_midx_context *ctx = data;
529
+ struct packed_git *p;
530
531
if (ends_with(file_name, ".idx")) {
532
display_progress(ctx->progress, ++ctx->pack_paths_checked);
553
554
ALLOC_GROW(ctx->info, ctx->nr + 1, ctx->alloc);
555
544
- ctx->info[ctx->nr].p = add_packed_git(full_path,
545
- full_path_len,
546
- 0);
547
-
548
- if (!ctx->info[ctx->nr].p) {
556
+ p = add_packed_git(full_path, full_path_len, 0);
557
+ if (!p) {
558
warning(_("failed to add packfile '%s'"),
559
full_path);
560
return;
561
}
562
554
- if (open_pack_index(ctx->info[ctx->nr].p)) {
563
+ if (open_pack_index(p)) {
564
warning(_("failed to open pack-index '%s'"),
565
full_path);
557
- close_pack(ctx->info[ctx->nr].p);
558
- FREE_AND_NULL(ctx->info[ctx->nr].p);
566
+ close_pack(p);
567
+ free(p);
568
return;
569
}
570
562
- ctx->info[ctx->nr].pack_name = xstrdup(file_name);
563
- ctx->info[ctx->nr].orig_pack_int_id = ctx->nr;
564
- ctx->info[ctx->nr].expired = 0;
571
+ fill_pack_info(&ctx->info[ctx->nr], p, file_name, ctx->nr);
572
ctx->nr++;
573
}
574
}
1328
for (i = 0; i < ctx.m->num_packs; i++) {
1329
ALLOC_GROW(ctx.info, ctx.nr + 1, ctx.alloc);
1330
1324
- ctx.info[ctx.nr].orig_pack_int_id = i;
1325
- ctx.info[ctx.nr].pack_name = xstrdup(ctx.m->pack_names[i]);
1326
- ctx.info[ctx.nr].p = ctx.m->packs[i];
1327
- ctx.info[ctx.nr].expired = 0;
1328
-
1331
if (flags & MIDX_WRITE_REV_INDEX) {
1332
/*
1333
* If generating a reverse index, need to have
1343
if (open_pack_index(ctx.m->packs[i]))
1344
die(_("could not open index for %s"),
1345
ctx.m->packs[i]->pack_name);
1344
- ctx.info[ctx.nr].p = ctx.m->packs[i];
1346
}
1347
1347
- ctx.nr++;
1348
+ fill_pack_info(&ctx.info[ctx.nr++], ctx.m->packs[i],
1349
+ ctx.m->pack_names[i], i);
1350
}
1351
}
1352