struct commit **commits, size_t commits_nr,
struct ahead_behind_count *counts, size_t counts_nr)
{
- struct prio_queue queue = { .compare = compare_commits_by_gen_then_commit_date };
+ struct nonstale_queue queue = {
+ { .compare = compare_commits_by_gen_then_commit_date }
+ };
+ void *entry;
size_t width = DIV_ROUND_UP(commits_nr, BITS_IN_EWORD);
if (!commits_nr || !counts_nr)
/* STALE is used here, PARENT2 is used by insert_no_dup(). */
repo_clear_commit_marks(r, PARENT2 | STALE);
- for (size_t i = 0; i < queue.pq.nr; i++)
- free_bit_array(queue.pq.array[i].data);
- prio_queue_for_each(&queue, entry)
++ prio_queue_for_each(&queue.pq, entry)
+ free_bit_array(entry);
clear_bit_arrays(&bit_arrays);
- clear_prio_queue(&queue);
+ clear_nonstale_queue(&queue);
}
struct commit_and_index {
struct bitmap_index *old_bitmap,
const uint32_t *mapping)
{
- struct tree *tree;
+ struct commit *c;
++ struct tree *t;
int found;
+ int from_pseudo_merge = commit->object.flags & BITMAP_PSEUDO_MERGE;
uint32_t pos;
+
+ if (ent->pseudo_merge)
+ BUG("unexpected pseudo-merge commit in fill_bitmap_commit()");
+
+ fill_bitmap_commit_calls_nr++;
+
if (!ent->bitmap)
ent->bitmap = bitmap_new();
}
}
- while (tree_queue->nr) {
- struct tree *t = prio_queue_get(tree_queue);
- while ((tree = prio_queue_get(tree_queue))) {
- if (fill_bitmap_tree(writer, ent->bitmap, tree) < 0)
++ while ((t = prio_queue_get(tree_queue))) {
+ int found;
+
+ pos = find_object_pos(writer, &t->object.oid, &found);
+ if (!found)
+ return -1;
+ if (bitmap_get(ent->bitmap, pos)) {
+ /*
+ * If our bit is already set, then there is
+ * nothing to do. Both this tree and all of its
+ * children will be set.
+ */
+ continue;
+ }
+
+ if (fill_bitmap_tree(writer, ent->bitmap, t, pos) < 0)
return -1;
}
return 0;
}
}
-static void merge_queue_into_list(struct prio_queue *q, struct commit_list **list)
+static void merge_queue_into_prio_queue(struct prio_queue *from,
+ struct prio_queue *to)
{
- while (from->nr)
- prio_queue_put(to, prio_queue_get(from));
+ struct commit *item;
- while ((item = prio_queue_peek(q))) {
- struct commit_list *p = *list;
-
- if (p && p->item->date >= item->date)
- list = &p->next;
- else {
- p = commit_list_insert(item, list);
- list = &p->next; /* skip newly added item */
- prio_queue_get(q); /* pop item */
- }
- }
++ while ((item = prio_queue_get(from)))
++ prio_queue_put(to, item);
}
static enum rewrite_result rewrite_one(struct rev_info *revs, struct commit **pp)