]> git.ipfire.org Git - thirdparty/git.git/commitdiff
bloom: parse commit before computing filters
authorDerrick Stolee <dstolee@microsoft.com>
Mon, 11 May 2020 11:56:10 +0000 (11:56 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 11 May 2020 16:33:56 +0000 (09:33 -0700)
When computing changed-path Bloom filters for a commit, we need to
know if the commit has a parent or not. If the commit is not parsed,
then its parent pointer will be NULL.

As far as I can tell, the only opportunity to reach this code
without parsing the commit is inside "test-tool bloom
get_filter_for_commit" but it is best to be safe.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
bloom.c

diff --git a/bloom.c b/bloom.c
index 2e3e0f5037ba9479fef53ceb27c9ed79a3d21c12..9679278271910e28059bb4b96a9871e4098a93b8 100644 (file)
--- a/bloom.c
+++ b/bloom.c
@@ -193,6 +193,9 @@ struct bloom_filter *get_bloom_filter(struct repository *r,
        diffopt.max_changes = max_changes;
        diff_setup_done(&diffopt);
 
+       /* ensure commit is parsed so we have parent information */
+       repo_parse_commit(r, c);
+
        if (c->parents)
                diff_tree_oid(&c->parents->item->object.oid, &c->object.oid, "", &diffopt);
        else