aboutsummaryrefslogtreecommitdiffstats
path: root/commit-graph.c
diff options
context:
space:
mode:
authorTaylor Blau <me@ttaylorr.com>2020-09-16 14:07:46 -0400
committerJunio C Hamano <gitster@pobox.com>2020-09-17 09:31:25 -0700
commit9a7a9ed10d56d6c22a0f16d7baf3f9895c47d693 (patch)
tree54b3c8c6eaa8edb700dc557c44aac4ddab5de366 /commit-graph.c
parent312cff520742c933bde070be18c51c27e132cff1 (diff)
downloadgit-9a7a9ed10d56d6c22a0f16d7baf3f9895c47d693.tar.gz
bloom: use provided 'struct bloom_filter_settings'
When 'get_or_compute_bloom_filter()' needs to compute a Bloom filter from scratch, it looks to the default 'struct bloom_filter_settings' in order to determine the maximum number of changed paths, number of bits per entry, and so on. All of these values have so far been constant, and so there was no need to pass in a pointer from the caller (eg., the one that is stored in the 'struct write_commit_graph_context'). Start passing in a 'struct bloom_filter_settings *' instead of using the default values to respect graph-specific settings (eg., in the case of setting 'GIT_TEST_BLOOM_SETTINGS_MAX_CHANGED_PATHS'). In order to have an initialized value for these settings, move its initialization to earlier in the commit-graph write. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit-graph.c')
-rw-r--r--commit-graph.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/commit-graph.c b/commit-graph.c
index 67a2812e79..4d6ce2967e 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -1428,6 +1428,7 @@ static void compute_bloom_filters(struct write_commit_graph_context *ctx)
ctx->r,
c,
1,
+ ctx->bloom_settings,
&computed);
if (computed & BLOOM_COMPUTED) {
ctx->count_bloom_filter_computed++;
@@ -1685,17 +1686,6 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)
int num_chunks = 3;
uint64_t chunk_offset;
struct object_id file_hash;
- struct bloom_filter_settings bloom_settings = DEFAULT_BLOOM_FILTER_SETTINGS;
-
- if (!ctx->bloom_settings) {
- bloom_settings.bits_per_entry = git_env_ulong("GIT_TEST_BLOOM_SETTINGS_BITS_PER_ENTRY",
- bloom_settings.bits_per_entry);
- bloom_settings.num_hashes = git_env_ulong("GIT_TEST_BLOOM_SETTINGS_NUM_HASHES",
- bloom_settings.num_hashes);
- bloom_settings.max_changed_paths = git_env_ulong("GIT_TEST_BLOOM_SETTINGS_MAX_CHANGED_PATHS",
- bloom_settings.max_changed_paths);
- ctx->bloom_settings = &bloom_settings;
- }
if (ctx->split) {
struct strbuf tmp_file = STRBUF_INIT;
@@ -2141,6 +2131,7 @@ int write_commit_graph(struct object_directory *odb,
uint32_t i, count_distinct = 0;
int res = 0;
int replace = 0;
+ struct bloom_filter_settings bloom_settings = DEFAULT_BLOOM_FILTER_SETTINGS;
if (!commit_graph_compatible(the_repository))
return 0;
@@ -2154,6 +2145,14 @@ int write_commit_graph(struct object_directory *odb,
ctx->split_opts = split_opts;
ctx->total_bloom_filter_data_size = 0;
+ bloom_settings.bits_per_entry = git_env_ulong("GIT_TEST_BLOOM_SETTINGS_BITS_PER_ENTRY",
+ bloom_settings.bits_per_entry);
+ bloom_settings.num_hashes = git_env_ulong("GIT_TEST_BLOOM_SETTINGS_NUM_HASHES",
+ bloom_settings.num_hashes);
+ bloom_settings.max_changed_paths = git_env_ulong("GIT_TEST_BLOOM_SETTINGS_MAX_CHANGED_PATHS",
+ bloom_settings.max_changed_paths);
+ ctx->bloom_settings = &bloom_settings;
+
if (flags & COMMIT_GRAPH_WRITE_BLOOM_FILTERS)
ctx->changed_paths = 1;
if (!(flags & COMMIT_GRAPH_NO_WRITE_BLOOM_FILTERS)) {