pack-bitmap-write: use commit_stack

Use commit_stack instead of open-coding it. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Dec 24, 2025 at 18:03 UTC 065523812f574b432242fcb7d7f2c1ed8c85b4b7
1 file changed +7 -11
pack-bitmap-write.c
+7 -11
@@ -315,8 +315,7 @@ define_commit_slab(bb_data, struct bb_commit);
315
316 struct bitmap_builder {
317 struct bb_data data;
318 - struct commit **commits;
319 - size_t commits_nr, commits_alloc;
318 + struct commit_stack commits;
319 };
320
321 static void bitmap_builder_init(struct bitmap_builder *bb,
@@ -329,8 +328,8 @@ static void bitmap_builder_init(struct bitmap_builder *bb,
328 struct commit_list *r;
329 unsigned int i, num_maximal = 0;
330
332 - memset(bb, 0, sizeof(*bb));
331 init_bb_data(&bb->data);
332 + commit_stack_init(&bb->commits);
333
334 reset_revision_walk();
335 repo_init_revisions(writer->to_pack->repo, &revs, NULL);
@@ -390,8 +389,7 @@ static void bitmap_builder_init(struct bitmap_builder *bb,
389
390 if (c_ent->maximal) {
391 num_maximal++;
393 - ALLOC_GROW(bb->commits, bb->commits_nr + 1, bb->commits_alloc);
394 - bb->commits[bb->commits_nr++] = commit;
392 + commit_stack_push(&bb->commits, commit);
393 }
394
395 if (p) {
@@ -438,8 +436,7 @@ next:
436 }
437
438 for (r = reusable; r; r = r->next) {
441 - ALLOC_GROW(bb->commits, bb->commits_nr + 1, bb->commits_alloc);
442 - bb->commits[bb->commits_nr++] = r->item;
439 + commit_stack_push(&bb->commits, r->item);
440 }
441
442 trace2_data_intmax("pack-bitmap-write", writer->repo,
@@ -454,8 +451,7 @@ next:
451 static void bitmap_builder_clear(struct bitmap_builder *bb)
452 {
453 deep_clear_bb_data(&bb->data, clear_bb_commit);
457 - free(bb->commits);
458 - bb->commits_nr = bb->commits_alloc = 0;
454 + commit_stack_clear(&bb->commits);
455 }
456
457 static int fill_bitmap_tree(struct bitmap_writer *writer,
@@ -630,8 +626,8 @@ int bitmap_writer_build(struct bitmap_writer *writer)
626 mapping = NULL;
627
628 bitmap_builder_init(&bb, writer, old_bitmap);
633 - for (i = bb.commits_nr; i > 0; i--) {
634 - struct commit *commit = bb.commits[i-1];
629 + for (i = bb.commits.nr; i > 0; i--) {
630 + struct commit *commit = bb.commits.items[i-1];
631 struct bb_commit *ent = bb_data_at(&bb.data, commit);
632 struct commit *child;
633 int reused = 0;