Skip to content

Commit 719c709

Browse files
ttaylorrderrickstolee
authored andcommitted
revision: empty pathspecs should not use Bloom filters
The prepare_to_use_bloom_filter() method was not intended to be called on an empty pathspec. However, 'git log -- .' and 'git log' are subtly different: the latter reports all commits while the former will simplify commits that do not change the root tree. This means that the path used to construct the bloom_key might be empty, and that value is not added to the Bloom filter during construction. That means that the results are likely incorrect! To resolve the issue, be careful about the length of the path and stop filling Bloom filters. To be completely sure we do not use them, drop the pointer to the bloom_filter_settings from the commit-graph. That allows our test to look at the trace2 logs to verify no Bloom filter statistics are reported. Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Derrick Stolee <[email protected]>
1 parent 0bcfc1f commit 719c709

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

revision.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,10 @@ static void prepare_to_use_bloom_filter(struct rev_info *revs)
704704
path = pi->match;
705705

706706
len = strlen(path);
707+
if (!len) {
708+
revs->bloom_filter_settings = NULL;
709+
return;
710+
}
707711

708712
revs->bloom_key = xmalloc(sizeof(struct bloom_key));
709713
fill_bloom_key(path, len, revs->bloom_key, revs->bloom_filter_settings);

t/t4216-log-bloom.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ test_expect_success 'git log -- multiple path specs does not use Bloom filters'
112112
test_bloom_filters_not_used "-- file4 A/file1"
113113
'
114114

115+
test_expect_success 'git log -- "." pathspec at root does not use Bloom filters' '
116+
test_bloom_filters_not_used "-- ."
117+
'
118+
115119
test_expect_success 'git log with wildcard that resolves to a single path uses Bloom filters' '
116120
test_bloom_filters_used "-- *4" &&
117121
test_bloom_filters_used "-- *renamed"

0 commit comments

Comments
 (0)