bloom: fix logic in get_bloom_filter()
authorDerrick Stolee <dstolee@microsoft.com>
Wed, 1 Jul 2020 13:27:23 +0000 (13:27 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 1 Jul 2020 21:17:43 +0000 (14:17 -0700)
commit949197420e3da13c06c6a15fd4b4ed3120753c42
tree7d3f979f256acf64d4db492688199951b3532766
parent7b671f8c2b6b7de511fd2f6587e4540c25764b61
bloom: fix logic in get_bloom_filter()

The get_bloom_filter() method is a bit complicated in some parts where
it does not need to be. In particular, it needs to return a NULL filter
only when compute_if_not_present is zero AND the filter data cannot be
loaded from a commit-graph file. This currently happens by accident
because the commit-graph does not load changed-path Bloom filters from
an existing commit-graph when writing a new one. This will change in a
later patch.

Also clean up some style issues while we are here.

One side-effect of returning a NULL filter is that the filters that are
reported as "too large" will now be reported as NULL insead of length
zero. This case was not properly covered before, so add a test. Further,
remote the counting of the zero-length filters from revision.c and the
trace2 logs.

Helped-by: René Scharfe <l.s.r@web.de>
Helped-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
bloom.c
commit-graph.c
revision.c
t/t4216-log-bloom.sh