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> --- last-modified.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/last-modified.c b/last-modified.c index 0a0818cdf1..b1458db0bc 100644 --- a/last-modified.c +++ b/last-modified.c @@ -271,6 +271,13 @@ static int maybe_changed_path(struct last_modified *lm, if (!filter) return 1; + for (int i = 0; i < lm->rev.bloom_keys_nr; i++) { + if (!(bloom_filter_contains(filter, + &lm->rev.bloom_keys[i], + lm->rev.bloom_filter_settings))) + return 0; + } + hashmap_for_each_entry(&lm->paths, &iter, ent, hashent) { if (active && !active->active[ent->diff_idx]) continue; @@ -364,6 +371,7 @@ int last_modified_run(struct last_modified *lm, last_modified_callback cb, void struct prio_queue queue = { compare_commits_by_gen_then_commit_date }; struct prio_queue not_queue = { compare_commits_by_gen_then_commit_date }; struct last_modified_callback_data data; + struct commit_list *list; data.paths = &lm->paths; data.callback = cb; @@ -372,6 +380,9 @@ int last_modified_run(struct last_modified *lm, last_modified_callback cb, void lm->rev.diffopt.output_format = DIFF_FORMAT_CALLBACK; lm->rev.diffopt.format_callback = last_modified_diff; lm->rev.diffopt.format_callback_data = &data; + lm->rev.no_walk = 1; + + prepare_revision_walk(&lm->rev); max_count = lm->rev.max_count; @@ -379,14 +390,12 @@ int last_modified_run(struct last_modified *lm, last_modified_callback cb, void scratch = xcalloc(lm->all_paths_nr, sizeof(char)); /* - * lm->rev.pending holds the set of boundary commits for our walk. + * lm->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 < lm->rev.pending.nr; i++) { - struct commit *c = lookup_commit(lm->rev.repo, - &lm->rev.pending.objects[i].item->oid); - repo_parse_commit(lm->rev.repo, c); + for (list = lm->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 last_modified_run(struct last_modified *lm, last_modified_callback cb, void } } - /* - * Now that we have processed the pending commits, allow the revision - * machinery to flush them by calling prepare_revision_walk(). - */ - prepare_revision_walk(&lm->rev); - while (queue.nr) { int parent_i; struct commit_list *p; -- 2.49.0