Skip to content

Commit 1fe1084

Browse files
ttaylorrgitster
authored andcommitted
commit-graph.c: extract 'refs_cb_data'
In subsequent patches, we are going to update a progress meter when 'add_ref_to_set()' is called, and need a convenient way to pass a 'struct progress *' in from the caller. Introduce 'refs_cb_data' as a catch-all for parameters that 'add_ref_to_set' may need, and wrap the existing single parameter in that struct. Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b34789c commit 1fe1084

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

commit-graph.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,13 +1318,17 @@ static void compute_bloom_filters(struct write_commit_graph_context *ctx)
13181318
stop_progress(&progress);
13191319
}
13201320

1321+
struct refs_cb_data {
1322+
struct oidset *commits;
1323+
};
1324+
13211325
static int add_ref_to_set(const char *refname,
13221326
const struct object_id *oid,
13231327
int flags, void *cb_data)
13241328
{
1325-
struct oidset *commits = (struct oidset *)cb_data;
1329+
struct refs_cb_data *data = (struct refs_cb_data *)cb_data;
13261330

1327-
oidset_insert(commits, oid);
1331+
oidset_insert(data->commits, oid);
13281332
return 0;
13291333
}
13301334

@@ -1333,9 +1337,13 @@ int write_commit_graph_reachable(struct object_directory *odb,
13331337
const struct split_commit_graph_opts *split_opts)
13341338
{
13351339
struct oidset commits = OIDSET_INIT;
1340+
struct refs_cb_data data;
13361341
int result;
13371342

1338-
for_each_ref(add_ref_to_set, &commits);
1343+
memset(&data, 0, sizeof(data));
1344+
data.commits = &commits;
1345+
1346+
for_each_ref(add_ref_to_set, &data);
13391347
result = write_commit_graph(odb, NULL, &commits,
13401348
flags, split_opts);
13411349

0 commit comments

Comments
 (0)