mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
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>
This commit is contained in:
committed by
Junio C Hamano
parent
7b671f8c2b
commit
949197420e
14
bloom.c
14
bloom.c
@@ -186,7 +186,7 @@ struct bloom_filter *get_bloom_filter(struct repository *r,
|
||||
struct diff_options diffopt;
|
||||
int max_changes = 512;
|
||||
|
||||
if (bloom_filters.slab_size == 0)
|
||||
if (!bloom_filters.slab_size)
|
||||
return NULL;
|
||||
|
||||
filter = bloom_filter_slab_at(&bloom_filters, c);
|
||||
@@ -194,16 +194,14 @@ struct bloom_filter *get_bloom_filter(struct repository *r,
|
||||
if (!filter->data) {
|
||||
load_commit_graph_info(r, c);
|
||||
if (c->graph_pos != COMMIT_NOT_FROM_GRAPH &&
|
||||
r->objects->commit_graph->chunk_bloom_indexes) {
|
||||
if (load_bloom_filter_from_graph(r->objects->commit_graph, filter, c))
|
||||
return filter;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
r->objects->commit_graph->chunk_bloom_indexes)
|
||||
load_bloom_filter_from_graph(r->objects->commit_graph, filter, c);
|
||||
}
|
||||
|
||||
if (filter->data || !compute_if_not_present)
|
||||
if (filter->data)
|
||||
return filter;
|
||||
if (!compute_if_not_present)
|
||||
return NULL;
|
||||
|
||||
repo_diff_setup(r, &diffopt);
|
||||
diffopt.flags.recursive = 1;
|
||||
|
||||
Reference in New Issue
Block a user