|
16 | 16 | #include "hashmap.h"
|
17 | 17 | #include "replace-object.h"
|
18 | 18 | #include "progress.h"
|
| 19 | +#include "bloom.h" |
19 | 20 |
|
20 | 21 | #define GRAPH_SIGNATURE 0x43475048 /* "CGPH" */
|
21 | 22 | #define GRAPH_CHUNKID_OIDFANOUT 0x4f494446 /* "OIDF" */
|
@@ -789,9 +790,11 @@ struct write_commit_graph_context {
|
789 | 790 | unsigned append:1,
|
790 | 791 | report_progress:1,
|
791 | 792 | split:1,
|
792 |
| - check_oids:1; |
| 793 | + check_oids:1, |
| 794 | + changed_paths:1; |
793 | 795 |
|
794 | 796 | const struct split_commit_graph_opts *split_opts;
|
| 797 | + size_t total_bloom_filter_data_size; |
795 | 798 | };
|
796 | 799 |
|
797 | 800 | static void write_graph_chunk_fanout(struct hashfile *f,
|
@@ -1134,6 +1137,28 @@ static void compute_generation_numbers(struct write_commit_graph_context *ctx)
|
1134 | 1137 | stop_progress(&ctx->progress);
|
1135 | 1138 | }
|
1136 | 1139 |
|
| 1140 | +static void compute_bloom_filters(struct write_commit_graph_context *ctx) |
| 1141 | +{ |
| 1142 | + int i; |
| 1143 | + struct progress *progress = NULL; |
| 1144 | + |
| 1145 | + init_bloom_filters(); |
| 1146 | + |
| 1147 | + if (ctx->report_progress) |
| 1148 | + progress = start_delayed_progress( |
| 1149 | + _("Computing commit changed paths Bloom filters"), |
| 1150 | + ctx->commits.nr); |
| 1151 | + |
| 1152 | + for (i = 0; i < ctx->commits.nr; i++) { |
| 1153 | + struct commit *c = ctx->commits.list[i]; |
| 1154 | + struct bloom_filter *filter = get_bloom_filter(ctx->r, c); |
| 1155 | + ctx->total_bloom_filter_data_size += sizeof(unsigned char) * filter->len; |
| 1156 | + display_progress(progress, i + 1); |
| 1157 | + } |
| 1158 | + |
| 1159 | + stop_progress(&progress); |
| 1160 | +} |
| 1161 | + |
1137 | 1162 | static int add_ref_to_list(const char *refname,
|
1138 | 1163 | const struct object_id *oid,
|
1139 | 1164 | int flags, void *cb_data)
|
@@ -1776,6 +1801,8 @@ int write_commit_graph(struct object_directory *odb,
|
1776 | 1801 | ctx->split = flags & COMMIT_GRAPH_WRITE_SPLIT ? 1 : 0;
|
1777 | 1802 | ctx->check_oids = flags & COMMIT_GRAPH_WRITE_CHECK_OIDS ? 1 : 0;
|
1778 | 1803 | ctx->split_opts = split_opts;
|
| 1804 | + ctx->changed_paths = flags & COMMIT_GRAPH_WRITE_BLOOM_FILTERS ? 1 : 0; |
| 1805 | + ctx->total_bloom_filter_data_size = 0; |
1779 | 1806 |
|
1780 | 1807 | if (ctx->split) {
|
1781 | 1808 | struct commit_graph *g;
|
@@ -1870,6 +1897,9 @@ int write_commit_graph(struct object_directory *odb,
|
1870 | 1897 |
|
1871 | 1898 | compute_generation_numbers(ctx);
|
1872 | 1899 |
|
| 1900 | + if (ctx->changed_paths) |
| 1901 | + compute_bloom_filters(ctx); |
| 1902 | + |
1873 | 1903 | res = write_commit_graph_file(ctx);
|
1874 | 1904 |
|
1875 | 1905 | if (ctx->split)
|
|
0 commit comments