]> git.ipfire.org Git - thirdparty/git.git/blobdiff - commit-graph.c
builtin/commit-graph.c: introduce '--max-new-filters=<n>'
[thirdparty/git.git] / commit-graph.c
index 1a53a03f5d472f34cd5a1bf43deeb61c4c394eb3..1aedc1c4df45299445cf03f1f45383a86051c57d 100644 (file)
@@ -1408,6 +1408,7 @@ static void compute_bloom_filters(struct write_commit_graph_context *ctx)
        int i;
        struct progress *progress = NULL;
        struct commit **sorted_commits;
+       int max_new_filters;
 
        init_bloom_filters();
 
@@ -1424,13 +1425,16 @@ static void compute_bloom_filters(struct write_commit_graph_context *ctx)
        else
                QSORT(sorted_commits, ctx->commits.nr, commit_gen_cmp);
 
+       max_new_filters = ctx->opts && ctx->opts->max_new_filters >= 0 ?
+               ctx->opts->max_new_filters : ctx->commits.nr;
+
        for (i = 0; i < ctx->commits.nr; i++) {
                enum bloom_filter_computed computed = 0;
                struct commit *c = sorted_commits[i];
                struct bloom_filter *filter = get_or_compute_bloom_filter(
                        ctx->r,
                        c,
-                       1,
+                       ctx->count_bloom_filter_computed < max_new_filters,
                        ctx->bloom_settings,
                        &computed);
                if (computed & BLOOM_COMPUTED) {
@@ -1441,7 +1445,8 @@ static void compute_bloom_filters(struct write_commit_graph_context *ctx)
                                ctx->count_bloom_filter_trunc_large++;
                } else if (computed & BLOOM_NOT_COMPUTED)
                        ctx->count_bloom_filter_not_computed++;
-               ctx->total_bloom_filter_data_size += sizeof(unsigned char) * filter->len;
+               ctx->total_bloom_filter_data_size += filter
+                       ? sizeof(unsigned char) * filter->len : 0;
                display_progress(progress, i + 1);
        }