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>
This commit is contained in:
parent
7fbfe07ab4
commit
98037f2bf2
@ -882,6 +882,7 @@ struct write_commit_graph_context {
|
|||||||
|
|
||||||
const struct split_commit_graph_opts *split_opts;
|
const struct split_commit_graph_opts *split_opts;
|
||||||
size_t total_bloom_filter_data_size;
|
size_t total_bloom_filter_data_size;
|
||||||
|
const struct bloom_filter_settings *bloom_settings;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void write_graph_chunk_fanout(struct hashfile *f,
|
static void write_graph_chunk_fanout(struct hashfile *f,
|
||||||
@ -1103,8 +1104,7 @@ static void write_graph_chunk_bloom_indexes(struct hashfile *f,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void write_graph_chunk_bloom_data(struct hashfile *f,
|
static void write_graph_chunk_bloom_data(struct hashfile *f,
|
||||||
struct write_commit_graph_context *ctx,
|
struct write_commit_graph_context *ctx)
|
||||||
const struct bloom_filter_settings *settings)
|
|
||||||
{
|
{
|
||||||
struct commit **list = ctx->commits.list;
|
struct commit **list = ctx->commits.list;
|
||||||
struct commit **last = ctx->commits.list + ctx->commits.nr;
|
struct commit **last = ctx->commits.list + ctx->commits.nr;
|
||||||
@ -1116,9 +1116,9 @@ static void write_graph_chunk_bloom_data(struct hashfile *f,
|
|||||||
_("Writing changed paths Bloom filters data"),
|
_("Writing changed paths Bloom filters data"),
|
||||||
ctx->commits.nr);
|
ctx->commits.nr);
|
||||||
|
|
||||||
hashwrite_be32(f, settings->hash_version);
|
hashwrite_be32(f, ctx->bloom_settings->hash_version);
|
||||||
hashwrite_be32(f, settings->num_hashes);
|
hashwrite_be32(f, ctx->bloom_settings->num_hashes);
|
||||||
hashwrite_be32(f, settings->bits_per_entry);
|
hashwrite_be32(f, ctx->bloom_settings->bits_per_entry);
|
||||||
|
|
||||||
while (list < last) {
|
while (list < last) {
|
||||||
struct bloom_filter *filter = get_bloom_filter(ctx->r, *list, 0);
|
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)
|
|||||||
struct object_id file_hash;
|
struct object_id file_hash;
|
||||||
const struct bloom_filter_settings bloom_settings = DEFAULT_BLOOM_FILTER_SETTINGS;
|
const struct bloom_filter_settings bloom_settings = DEFAULT_BLOOM_FILTER_SETTINGS;
|
||||||
|
|
||||||
|
ctx->bloom_settings = &bloom_settings;
|
||||||
|
|
||||||
if (ctx->split) {
|
if (ctx->split) {
|
||||||
struct strbuf tmp_file = STRBUF_INIT;
|
struct strbuf tmp_file = STRBUF_INIT;
|
||||||
|
|
||||||
@ -1642,7 +1644,7 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)
|
|||||||
write_graph_chunk_extra_edges(f, ctx);
|
write_graph_chunk_extra_edges(f, ctx);
|
||||||
if (ctx->changed_paths) {
|
if (ctx->changed_paths) {
|
||||||
write_graph_chunk_bloom_indexes(f, ctx);
|
write_graph_chunk_bloom_indexes(f, ctx);
|
||||||
write_graph_chunk_bloom_data(f, ctx, &bloom_settings);
|
write_graph_chunk_bloom_data(f, ctx);
|
||||||
}
|
}
|
||||||
if (ctx->num_commit_graphs_after > 1 &&
|
if (ctx->num_commit_graphs_after > 1 &&
|
||||||
write_graph_chunk_base(f, ctx)) {
|
write_graph_chunk_base(f, ctx)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user