Re: [PATCH 06/10] commit-graph: move remaining write parameters into options
- From
Kristofer Karlsson <krka@spotify.com>
- Date
- Nov 4, 2026, 17:49 UTC
- Message-ID
- <CAL71e4N4BvO=eMfO0wnJ9=gGbfTRz5ayWFZULoN1dGSF7uCZAA@mail.gmail.com>
- In-Reply-To
- <20261104-pks-commit-graph-write-refactorings-v1-6-d013d9401a59@pks.im>
On Wed, 4 Nov 2026 at 17:15, Patrick Steinhardt <ps@pks.im> wrote:
Show 5 quoted lines
> > if (graph_write_mode != GRAPH_WRITE_TIPS) > write_opts.flags |= COMMIT_GRAPH_WRITE_REACHABLE; > + else > + write_opts.commits = &updated_tips;
Ah, this touches on my previous patch cef2d8c4cb (fetch: write commit-graph using updated refs only, 2026-10-07).
My only nit would be that the if/else also covers the skip case, so one of the branches always fires for it. A switch would make each mode set exactly what it needs:
switch (graph_write_mode) {
case GRAPH_WRITE_SKIP:
break;
case GRAPH_WRITE_REACHABLE:
write_opts.flags |= COMMIT_GRAPH_WRITE_REACHABLE;
break;
case GRAPH_WRITE_TIPS:
write_opts.commits = &updated_tips;
break;
}It doesn't matter for correctness since the skip case never calls the writer, but it looks easier to reason about to me.
But that's just a preference, I don't feel strongly about it.
Show 20 quoted lines
>
> if (graph_write_mode != GRAPH_WRITE_SKIP) {
> trace2_region_enter("fetch", "write-commit-graph",
> the_repository);
> - if (graph_write_mode == GRAPH_WRITE_TIPS)
> - write_commit_graph(
> - the_repository,
> - the_repository->objects->source->path,
> - NULL, &updated_tips, &write_opts);
> - else
> - write_commit_graph(
> - the_repository,
> - the_repository->objects->source->path,
> - NULL, NULL, &write_opts);
> + write_commit_graph(the_repository,
> + the_repository->objects->source->path,
> + &write_opts);
> trace2_region_leave("fetch", "write-commit-graph",
> the_repository);
> }I really like this unification of the call sites and the patch looks great overall!
Thanks, Kristofer