| 429 | }; |
| 430 | |
| 431 | static void bitmap_builder_init(struct bitmap_builder *bb, |
| 432 | struct bitmap_writer *writer, |
| 433 | struct bitmap_index *old_bitmap) |
| 434 | { |
| 435 | struct rev_info revs; |
| 436 | struct commit *commit; |
| 437 | struct commit_list *reusable = NULL; |
| 438 | struct commit_list *r; |
| 439 | unsigned int i, num_maximal = 0; |
| 440 | |
| 441 | init_bb_data(&bb->data); |
| 442 | commit_stack_init(&bb->commits); |
| 443 | |
| 444 | reset_revision_walk(); |
| 445 | repo_init_revisions(writer->to_pack->repo, &revs, NULL); |
| 446 | revs.topo_order = 1; |
| 447 | revs.first_parent_only = 1; |
| 448 | |
| 449 | for (i = 0; i < bitmap_writer_nr_selected_commits(writer); i++) { |
| 450 | struct bitmapped_commit *bc = &writer->selected[i]; |
| 451 | struct bb_commit *ent = bb_data_at(&bb->data, bc->commit); |
| 452 | |
| 453 | if (bc->pseudo_merge) |
| 454 | BUG("unexpected pseudo-merge at %"PRIuMAX, |
| 455 | (uintmax_t)i); |
| 456 | |
| 457 | ent->selected = 1; |
| 458 | ent->maximal = 1; |
| 459 | ent->pseudo_merge = 0; |
| 460 | ent->idx = i; |
| 461 | |
| 462 | ent->commit_mask = bitmap_new(); |
| 463 | bitmap_set(ent->commit_mask, i); |
| 464 | |
| 465 | add_pending_object(&revs, &bc->commit->object, ""); |
| 466 | } |
| 467 | |
| 468 | if (prepare_revision_walk(&revs)) |
| 469 | die("revision walk setup failed"); |
| 470 | |
| 471 | while ((commit = get_revision(&revs))) { |
| 472 | struct commit_list *p = commit->parents; |
| 473 | struct bb_commit *c_ent; |
| 474 | |
| 475 | parse_commit_or_die(commit); |
| 476 | |
| 477 | c_ent = bb_data_at(&bb->data, commit); |
| 478 | |
| 479 | /* |
| 480 | * If there is no commit_mask, there is no reason to iterate |
| 481 | * over this commit; it is not selected (if it were, it would |
| 482 | * not have a blank commit mask) and all its children have |
| 483 | * existing bitmaps (see the comment starting with "This commit |
| 484 | * has an existing bitmap" below), so it does not contribute |
| 485 | * anything to the final bitmap file or its descendants. |
| 486 | */ |
| 487 | if (!c_ent->commit_mask) |
| 488 | continue; |
no test coverage detected