git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

Previous: Derrick StoleeNext: Patrick Steinhardt
Message 11 of 22 in “commit-graph: several refactorings for writing commit graphs”
  1. 00/10 commit-graph: several refactorings for writing commit graphsPatrick Steinhardt, Nov 4, 2026
  2. 01/10 commit-graph: rename `struct commit_graph_opts`Patrick Steinhardt, Nov 4, 2026
  3. 02/10 commit-graph: pass writer flags via optionsPatrick Steinhardt, Nov 4, 2026
  4. 03/10 commit-graph: drop `NULL` checks for write optionsPatrick Steinhardt, Nov 4, 2026
  5. 04/10 commit-graph: drop redundant flags in write contextPatrick Steinhardt, Nov 4, 2026
  6. Junio C HamanoNov 4, 2026
  7. 05/10 commit-graph: merge the two commit graph writersPatrick Steinhardt, Nov 4, 2026
  8. Derrick StoleeNov 4, 2026
  9. 06/10 commit-graph: move remaining write parameters into optionsPatrick Steinhardt, Nov 4, 2026
  10. Derrick StoleeNov 4, 2026
  11. Kristofer KarlssonNov 4, 2026
  12. Patrick SteinhardtNov 5, 2026
  13. Kristofer KarlssonNov 5, 2026
  14. 07/10 commit-graph: fix mixup of write/verify flagsPatrick Steinhardt, Nov 4, 2026
  15. 08/10 builtin/commit-graph: set flags directlyPatrick Steinhardt, Nov 4, 2026
  16. 09/10 odb/source-files: verify commit-graphs as part of fsckPatrick Steinhardt, Nov 4, 2026
  17. 10/10 commit-graph: modernize function namesPatrick Steinhardt, Nov 4, 2026
  18. Derrick StoleeNov 4, 2026
  19. Patrick SteinhardtNov 5, 2026
  20. Patrick SteinhardtNov 5, 2026
  21. Derrick StoleeNov 5, 2026
  22. Patrick SteinhardtNov 5, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.