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

Re: [PATCH 2/6] commit-graph.h: store object directory in 'struct commit_graph'

From
Jeff King <peff@peff.net>
Date
Jan 31, 2020, 10:20 UTC
Message-ID
<20200131102049.GC2916051@coredump.intra.peff.net>
In-Reply-To
<CAN0heSrrrWjBKnzjMfzEkTMVTge2AfVdwsp6D5Mx==5S8-ZLJQ@mail.gmail.com>
On Fri, Jan 31, 2020 at 07:52:02AM +0100, Martin Ågren wrote:
Show 7 quoted lines
> > --- a/commit-graph.c
> > +++ b/commit-graph.c
> 
> > +struct object_directory *find_odb(struct repository *r, const char *obj_dir)
> 
> This doesn't look commit-graph related -- could/should it go somewhere
> else?

I think the right place is actually as a static inside builtin/commit-graph.c, as this is really about handling its weird --object-dir options.

But it can't go there in this patch, because there's a caller in commit-graph.c. In patch 4, we convert write_commit_graph() to take an odb, too, and that call goes away. At that point, we could move it into the builtin as a static.

Ideally we could flip the order of this patch and patch 4, but that doesn't work either: by switching to an odb we lose our path normalization, but if the other side hasn't switched either, then we can't just compare odb pointers. It would be a temporary regression.

So there's a circular dependency between the two patches. I think we ought to do done of:

  - move find_odb() to a static as a cleanup on top
  - squash those two patches together into a single
  - swap the patch order, but have write_commit_graph_ctx store both the
    "odb" _and_ the normalized copy of the path we do now. That leaves
    it correct, and then it can be cleaned up in favor of an odb pointer
    comparison in patch 5, along with the rest of the normalized bits.

I'm OK with any of those. The second two have the added bonus that we could introduce the die() behavior into find_odb() immediately, and explain it (there's another temporary weirdness in this patch where specifying an --object-dir outside of the repository becomes a silent noop, and then the next patch turns it into an error, but that could all be done in a single step when we introduce find_odb()).

> I think you could drop `cmp` and that final check, and write the loop
> body as "if (!strcmp(...)) break". You could also have an empty loop
> body, but I wouldn't go there -- I'd find that less readable. (Maybe
> that's just me.)

Yeah, I believe you are correct (and this is a nice simplification worth doing).

-Peff
Previous: Martin ÅgrenNext: Martin Ågren
Message 7 of 28 in “commit-graph: use 'struct object_directory *' everywhere”
  1. 0/6 commit-graph: use 'struct object_directory *' everywhereTaylor Blau, Jan 30, 2020
  2. 1/6 t5318: don't pass non-object directory to '--object-dir'Taylor Blau, Jan 30, 2020
  3. 5/6 commit-graph.c: remove path normalization, comparisonTaylor Blau, Jan 30, 2020
  4. 6/6 commit-graph.h: use odb in 'load_commit_graph_one_fd_st'Taylor Blau, Jan 30, 2020
  5. 2/6 commit-graph.h: store object directory in 'struct commit_graph'Taylor Blau, Jan 30, 2020
  6. Martin ÅgrenJan 31, 2020
  7. Jeff KingJan 31, 2020
  8. Martin ÅgrenJan 31, 2020
  9. Taylor BlauFeb 3, 2020
  10. Jeff KingFeb 3, 2020
  11. Junio C HamanoJan 31, 2020
  12. Taylor BlauFeb 3, 2020
  13. 4/6 commit-graph.h: store an odb in 'struct write_commit_graph_context'Taylor Blau, Jan 30, 2020
  14. 3/6 builtin/commit-graph.c: die() with unknown '--object-dir'Taylor Blau, Jan 30, 2020
  15. Jeff KingJan 31, 2020
  16. Derrick StoleeJan 31, 2020
  17. Taylor BlauFeb 3, 2020
  18. 0/5 commit-graph: use 'struct object_directory *' everywhereTaylor Blau, Feb 3, 2020
  19. 1/5 t5318: don't pass non-object directory to '--object-dir'Taylor Blau, Feb 3, 2020
  20. 2/5 commit-graph.h: store an odb in 'struct write_commit_graph_context'Taylor Blau, Feb 3, 2020
  21. 2/5 commit-graph.h: store an odb in 'struct write_commit_graph_context'Taylor Blau, Feb 4, 2020
  22. Junio C HamanoFeb 4, 2020
  23. Taylor BlauFeb 4, 2020
  24. Junio C HamanoFeb 4, 2020
  25. 5/5 commit-graph.h: use odb in 'load_commit_graph_one_fd_st'Taylor Blau, Feb 3, 2020
  26. 4/5 commit-graph.c: remove path normalization, comparisonTaylor Blau, Feb 3, 2020
  27. 3/5 commit-graph.h: store object directory in 'struct commit_graph'Taylor Blau, Feb 3, 2020
  28. Jeff KingFeb 5, 2020

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.