commit-graph: anonymize data in chunk_write_fn

In preparation for creating an API around file formats using chunks and tables of contents, prepare the commit-graph write code to use prototypes that will match this new API. Specifically, convert chunk_write_fn to take a "void *data" parameter instead of the commit-graph-specific "struct write_commit_graph_context" pointer. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Derrick Stolee committed Feb 5, 2021 at 14:30 UTC eb9071912f5ca370d7e30e88434ffa10c182ed81
1 file changed +19 -10
commit-graph.c
+19 -10
@@ -1040,8 +1040,9 @@ struct write_commit_graph_context {
1040 };
1041
1042 static int write_graph_chunk_fanout(struct hashfile *f,
1043 - struct write_commit_graph_context *ctx)
1043 + void *data)
1044 {
1045 + struct write_commit_graph_context *ctx = data;
1046 int i, count = 0;
1047 struct commit **list = ctx->commits.list;
1048
@@ -1066,8 +1067,9 @@ static int write_graph_chunk_fanout(struct hashfile *f,
1067 }
1068
1069 static int write_graph_chunk_oids(struct hashfile *f,
1069 - struct write_commit_graph_context *ctx)
1070 + void *data)
1071 {
1072 + struct write_commit_graph_context *ctx = data;
1073 struct commit **list = ctx->commits.list;
1074 int count;
1075 for (count = 0; count < ctx->commits.nr; count++, list++) {
@@ -1085,8 +1087,9 @@ static const unsigned char *commit_to_sha1(size_t index, void *table)
1087 }
1088
1089 static int write_graph_chunk_data(struct hashfile *f,
1088 - struct write_commit_graph_context *ctx)
1090 + void *data)
1091 {
1092 + struct write_commit_graph_context *ctx = data;
1093 struct commit **list = ctx->commits.list;
1094 struct commit **last = ctx->commits.list + ctx->commits.nr;
1095 uint32_t num_extra_edges = 0;
@@ -1187,8 +1190,9 @@ static int write_graph_chunk_data(struct hashfile *f,
1190 }
1191
1192 static int write_graph_chunk_generation_data(struct hashfile *f,
1190 - struct write_commit_graph_context *ctx)
1193 + void *data)
1194 {
1195 + struct write_commit_graph_context *ctx = data;
1196 int i, num_generation_data_overflows = 0;
1197
1198 for (i = 0; i < ctx->commits.nr; i++) {
@@ -1208,8 +1212,9 @@ static int write_graph_chunk_generation_data(struct hashfile *f,
1212 }
1213
1214 static int write_graph_chunk_generation_data_overflow(struct hashfile *f,
1211 - struct write_commit_graph_context *ctx)
1215 + void *data)
1216 {
1217 + struct write_commit_graph_context *ctx = data;
1218 int i;
1219 for (i = 0; i < ctx->commits.nr; i++) {
1220 struct commit *c = ctx->commits.list[i];
@@ -1226,8 +1231,9 @@ static int write_graph_chunk_generation_data_overflow(struct hashfile *f,
1231 }
1232
1233 static int write_graph_chunk_extra_edges(struct hashfile *f,
1229 - struct write_commit_graph_context *ctx)
1234 + void *data)
1235 {
1236 + struct write_commit_graph_context *ctx = data;
1237 struct commit **list = ctx->commits.list;
1238 struct commit **last = ctx->commits.list + ctx->commits.nr;
1239 struct commit_list *parent;
@@ -1280,8 +1286,9 @@ static int write_graph_chunk_extra_edges(struct hashfile *f,
1286 }
1287
1288 static int write_graph_chunk_bloom_indexes(struct hashfile *f,
1283 - struct write_commit_graph_context *ctx)
1289 + void *data)
1290 {
1291 + struct write_commit_graph_context *ctx = data;
1292 struct commit **list = ctx->commits.list;
1293 struct commit **last = ctx->commits.list + ctx->commits.nr;
1294 uint32_t cur_pos = 0;
@@ -1315,8 +1322,9 @@ static void trace2_bloom_filter_settings(struct write_commit_graph_context *ctx)
1322 }
1323
1324 static int write_graph_chunk_bloom_data(struct hashfile *f,
1318 - struct write_commit_graph_context *ctx)
1325 + void *data)
1326 {
1327 + struct write_commit_graph_context *ctx = data;
1328 struct commit **list = ctx->commits.list;
1329 struct commit **last = ctx->commits.list + ctx->commits.nr;
1330
@@ -1737,8 +1745,9 @@ static int write_graph_chunk_base_1(struct hashfile *f,
1745 }
1746
1747 static int write_graph_chunk_base(struct hashfile *f,
1740 - struct write_commit_graph_context *ctx)
1748 + void *data)
1749 {
1750 + struct write_commit_graph_context *ctx = data;
1751 int num = write_graph_chunk_base_1(f, ctx->new_base_graph);
1752
1753 if (num != ctx->num_commit_graphs_after - 1) {
@@ -1750,7 +1759,7 @@ static int write_graph_chunk_base(struct hashfile *f,
1759 }
1760
1761 typedef int (*chunk_write_fn)(struct hashfile *f,
1753 - struct write_commit_graph_context *ctx);
1762 + void *data);
1763
1764 struct chunk_info {
1765 uint32_t id;