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
@ -1098,7 +1098,8 @@ static void write_graph_chunk_bloom_indexes(struct hashfile *f,
|
||||
|
||||
while (list < last) {
|
||||
struct bloom_filter *filter = get_bloom_filter(ctx->r, *list, 0);
|
||||
cur_pos += filter->len;
|
||||
size_t len = filter ? filter->len : 0;
|
||||
cur_pos += len;
|
||||
display_progress(progress, ++i);
|
||||
hashwrite_be32(f, cur_pos);
|
||||
list++;
|
||||
@ -1126,8 +1127,11 @@ static void write_graph_chunk_bloom_data(struct hashfile *f,
|
||||
|
||||
while (list < last) {
|
||||
struct bloom_filter *filter = get_bloom_filter(ctx->r, *list, 0);
|
||||
size_t len = filter ? filter->len : 0;
|
||||
display_progress(progress, ++i);
|
||||
hashwrite(f, filter->data, filter->len * sizeof(unsigned char));
|
||||
|
||||
if (len)
|
||||
hashwrite(f, filter->data, len * sizeof(unsigned char));
|
||||
list++;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user