In a previous commit we inserted a call to 'prepare_revision_walk()' before we started our traversal. This was done when we leveraged the revision machinery more (at the time, we were leaning on 'log_tree_commit()' which only worked after calling 'prepare_revision_walk()'). But, we have since dropped 'log_tree_commit()', so we don't need most of the initialization work of 'prepare_revision_walk()'. Now we ask it to do very little work during initialization by setting the '->no_walk' flag to '1', which leaves its internal state alone enough that we can still function as normal. Unfortunately, this means that we now no longer complain about non-commit inputs, since the revision machinery check this for us (it just silently ignores them). Based-on-patch-by: Taylor Blau <me@xxxxxxxxxxxx> Signed-off-by: Toon Claes <toon@xxxxxxxxx> --- blame-tree.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/blame-tree.c b/blame-tree.c index 2cb7a5045c..e244797b7e 100644 --- a/blame-tree.c +++ b/blame-tree.c @@ -271,6 +271,13 @@ static int maybe_changed_path(struct blame_tree *bt, if (!filter) return 1; + for (int i = 0; i < bt->rev.bloom_keys_nr; i++) { + if (!(bloom_filter_contains(filter, + &bt->rev.bloom_keys[i], + bt->rev.bloom_filter_settings))) + return 0; + } + hashmap_for_each_entry(&bt->paths, &iter, e, hashent) { if (active && !active->active[e->diff_idx]) continue; @@ -364,6 +371,7 @@ int blame_tree_run(struct blame_tree *bt, blame_tree_callback cb, void *cbdata) struct prio_queue queue = { compare_commits_by_gen_then_commit_date }; struct prio_queue not_queue = { compare_commits_by_gen_then_commit_date }; struct blame_tree_callback_data data; + struct commit_list *list; data.paths = &bt->paths; data.callback = cb; @@ -372,6 +380,9 @@ int blame_tree_run(struct blame_tree *bt, blame_tree_callback cb, void *cbdata) bt->rev.diffopt.output_format = DIFF_FORMAT_CALLBACK; bt->rev.diffopt.format_callback = blame_diff; bt->rev.diffopt.format_callback_data = &data; + bt->rev.no_walk = 1; + + prepare_revision_walk(&bt->rev); max_count = bt->rev.max_count; @@ -379,14 +390,12 @@ int blame_tree_run(struct blame_tree *bt, blame_tree_callback cb, void *cbdata) scratch = xcalloc(bt->all_paths_nr, sizeof(char)); /* - * bt->rev.pending holds the set of boundary commits for our walk. + * bt->rev.commits holds the set of boundary commits for our walk. * * Loop through each such commit, and place it in the appropriate queue. */ - for (size_t i = 0; i < bt->rev.pending.nr; i++) { - struct commit *c = lookup_commit(bt->rev.repo, - &bt->rev.pending.objects[i].item->oid); - repo_parse_commit(bt->rev.repo, c); + for (list = bt->rev.commits; list; list = list->next) { + struct commit *c = list->item; if (c->object.flags & BOTTOM) { prio_queue_put(¬_queue, c); @@ -409,12 +418,6 @@ int blame_tree_run(struct blame_tree *bt, blame_tree_callback cb, void *cbdata) } } - /* - * Now that we have processed the pending commits, allow the revision - * machinery to flush them by calling prepare_revision_walk(). - */ - prepare_revision_walk(&bt->rev); - while (queue.nr) { int parent_i; struct commit_list *p; -- 2.49.0.rc2