| 629 | static int fill_bitmap_commit_found_ancestor_nr; |
| 630 | |
| 631 | static int fill_bitmap_commit(struct bitmap_writer *writer, |
| 632 | struct bb_commit *ent, |
| 633 | struct commit *commit, |
| 634 | struct prio_queue *queue, |
| 635 | struct prio_queue *tree_queue, |
| 636 | struct bitmap_index *old_bitmap, |
| 637 | const uint32_t *mapping) |
| 638 | { |
| 639 | int found; |
| 640 | int from_pseudo_merge = commit->object.flags & BITMAP_PSEUDO_MERGE; |
| 641 | uint32_t pos; |
| 642 | |
| 643 | if (ent->pseudo_merge) |
| 644 | BUG("unexpected pseudo-merge commit in fill_bitmap_commit()"); |
| 645 | |
| 646 | fill_bitmap_commit_calls_nr++; |
| 647 | |
| 648 | if (!ent->bitmap) |
| 649 | ent->bitmap = bitmap_new(); |
| 650 | |
| 651 | prio_queue_put(queue, commit); |
| 652 | |
| 653 | while (queue->nr) { |
| 654 | struct commit_list *p; |
| 655 | struct commit *c = prio_queue_get(queue); |
| 656 | |
| 657 | if (old_bitmap && mapping) { |
| 658 | struct ewah_bitmap *old; |
| 659 | struct bitmap *remapped = bitmap_new(); |
| 660 | |
| 661 | old = bitmap_for_commit(old_bitmap, c); |
| 662 | /* |
| 663 | * If this commit has an old bitmap, then translate that |
| 664 | * bitmap and add its bits to this one. No need to walk |
| 665 | * parents or the tree for this commit. |
| 666 | */ |
| 667 | if (old && !rebuild_bitmap(mapping, old, remapped)) { |
| 668 | bitmap_or(ent->bitmap, remapped); |
| 669 | bitmap_free(remapped); |
| 670 | reused_bitmaps_nr++; |
| 671 | continue; |
| 672 | } |
| 673 | bitmap_free(remapped); |
| 674 | } |
| 675 | |
| 676 | /* |
| 677 | * If we encounter an ancestor for which we have already |
| 678 | * computed a bitmap during this build (i.e. a regular |
| 679 | * selected commit processed earlier in topo order), we can |
| 680 | * short-circuit the walk: its stored bitmap already covers |
| 681 | * the commit itself, its tree, and all of its ancestors. |
| 682 | */ |
| 683 | if (c != commit) { |
| 684 | khiter_t hash_pos = kh_get_oid_map(writer->bitmaps, |
| 685 | c->object.oid); |
| 686 | if (hash_pos != kh_end(writer->bitmaps)) { |
| 687 | struct bitmapped_commit *stored = |
| 688 | kh_value(writer->bitmaps, hash_pos); |
no test coverage detected