@matheusbsbs / matheus-bagliano / commits / 98037f2bf2
Fork 0

commit-graph: place bloom_settings in context

Place an instance of struct bloom_settings into the struct write_commit_graph_context. This allows simplifying the function prototype of write_graph_chunk_bloom_data(). This will allow us to combine the function prototypes and use function pointers to simplify write_commit_graph_file(). By using a pointer, we can later replace the settings to match those that exist in the current commit-graph, in case a future Git version allows customization of these parameters. Reported-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>

Derrick Stolee committed Jun 23, 2020 at 17:47 UTC 98037f2bf2fb82845179f3311d8f64f7e27d77c4
1 file changed +8 -6
commit-graph.c
+8 -6
@@ -882,6 +882,7 @@ struct write_commit_graph_context {
882
883 const struct split_commit_graph_opts *split_opts;
884 size_t total_bloom_filter_data_size;
885 + const struct bloom_filter_settings *bloom_settings;
886 };
887
888 static void write_graph_chunk_fanout(struct hashfile *f,
@@ -1103,8 +1104,7 @@ static void write_graph_chunk_bloom_indexes(struct hashfile *f,
1104 }
1105
1106 static void write_graph_chunk_bloom_data(struct hashfile *f,
1106 - struct write_commit_graph_context *ctx,
1107 - const struct bloom_filter_settings *settings)
1107 + struct write_commit_graph_context *ctx)
1108 {
1109 struct commit **list = ctx->commits.list;
1110 struct commit **last = ctx->commits.list + ctx->commits.nr;
@@ -1116,9 +1116,9 @@ static void write_graph_chunk_bloom_data(struct hashfile *f,
1116 _("Writing changed paths Bloom filters data"),
1117 ctx->commits.nr);
1118
1119 - hashwrite_be32(f, settings->hash_version);
1120 - hashwrite_be32(f, settings->num_hashes);
1121 - hashwrite_be32(f, settings->bits_per_entry);
1119 + hashwrite_be32(f, ctx->bloom_settings->hash_version);
1120 + hashwrite_be32(f, ctx->bloom_settings->num_hashes);
1121 + hashwrite_be32(f, ctx->bloom_settings->bits_per_entry);
1122
1123 while (list < last) {
1124 struct bloom_filter *filter = get_bloom_filter(ctx->r, *list, 0);
@@ -1541,6 +1541,8 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)
1541 struct object_id file_hash;
1542 const struct bloom_filter_settings bloom_settings = DEFAULT_BLOOM_FILTER_SETTINGS;
1543
1544 + ctx->bloom_settings = &bloom_settings;
1545 +
1546 if (ctx->split) {
1547 struct strbuf tmp_file = STRBUF_INIT;
1548
@@ -1642,7 +1644,7 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)
1644 write_graph_chunk_extra_edges(f, ctx);
1645 if (ctx->changed_paths) {
1646 write_graph_chunk_bloom_indexes(f, ctx);
1645 - write_graph_chunk_bloom_data(f, ctx, &bloom_settings);
1647 + write_graph_chunk_bloom_data(f, ctx);
1648 }
1649 if (ctx->num_commit_graphs_after > 1 &&
1650 write_graph_chunk_base(f, ctx)) {