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

Re: [PATCH 5/5] commit-graph: add repo arg to graph readers

From
JTJonathan Tan <jonathantanmy@google.com>
Date
Jun 22, 2018, 17:21 UTC
Message-ID
<20180622172146.1727-1-jonathantanmy@google.com>
In-Reply-To
<d7a42ecf-7261-ec14-5736-b1f9bc70ba64@gmail.com>
Show 56 quoted lines
> On 6/21/2018 7:06 PM, Jonathan Tan wrote:
> >>> diff --git a/commit.c b/commit.c
> >>> index 0030e79940..38c12b002f 100644
> >>> --- a/commit.c
> >>> +++ b/commit.c
> >>> @@ -317,7 +317,7 @@ struct tree *get_commit_tree(const struct commit *commit)
> >>>          if (commit->graph_pos == COMMIT_NOT_FROM_GRAPH)
> >>>                  BUG("commit has NULL tree, but was not loaded from commit-graph");
> >>>
> >>> -       return get_commit_tree_in_graph(commit);
> >>> +       return get_commit_tree_in_graph(the_repository, commit);
> >> Here..
> >>
> >>>   }
> >>>
> >>>   struct object_id *get_commit_tree_oid(const struct commit *commit)
> >>> @@ -413,7 +413,7 @@ int parse_commit_gently(struct commit *item, int quiet_on_missing)
> >>>                  return -1;
> >>>          if (item->object.parsed)
> >>>                  return 0;
> >>> -       if (parse_commit_in_graph(item))
> >>> +       if (parse_commit_in_graph(the_repository, item))
> >> and here
> >>
> >>> +static void test_parse_commit_in_graph(const char *gitdir, const char *worktree,
> >>> +                                      const struct object_id *commit_oid)
> >>> +{
> >>> +       struct repository r;
> >>> +       struct commit *c;
> >>> +       struct commit_list *parent;
> >>> +
> >>> +       /*
> >>> +        * Create a commit independent of any repository.
> >>> +        */
> >>> +       c = lookup_commit(commit_oid);
> >> .. and this one are unfortunate as the rest of the object store series
> >> has not progressed as far as needed.
> > I think the first 2 are in reverse - get_commit_tree depends on
> > get_commit_tree_in_graph and parse_commit_gently depends on
> > parse_commit_in_graph, so we need the commit-graph functions to be
> > changed first. But I agree about lookup_commit.
> >
> >> The lookup_commit series is out there already, and that will
> >> teach lookup_commit a repository argument. When rerolling
> >> that series I need to switch the order of repo_init and lookup_commit
> >> such that we can pass the repo to the lookup.
> > For future reference, Stefan is talking about this series:
> > https://public-inbox.org/git/20180613230522.55335-1-sbeller@google.com/
> >
> > Let me know if you want to reroll yours on top of mine, or vice versa. I
> > think it's clearer if mine goes in first, though, since (as you said in
> > that e-mail) parse_commit depends on this change in the commit graph.
> 
> I was about to comment that I thought 'parse_commit_in_graph' should 
> take a 'struct commit_graph' instead of 'struct repository', except for 
> these lookup_commit() calls will need the repository parameter.

Not sure what you mean by the lookup_commit() calls (if you're referring to the part quoted above, that is test code), but parse_commit_in_graph() has to take a struct repository (or at least a struct object_store, perhaps) because it needs to load the commit graph for the repository if it is not already loaded.

(An alternative, of course, is to require the user to explicitly load the graph, but since parse_commit_in_graph() is called from parse_commit(), I think that this implicit loading is fine.)

Show 9 quoted lines
> Please also keep in mind that ds/commit-graph-fsck has already updated 
> this method to parse from a specific graph [1]. I'm just waiting for 
> some things like ds/generation-numbers to get into 'master' and some 
> more object-store patches to be final before I re-roll that series. I 
> mentioned this in a message that I had sent, but apparently didn't make 
> it on the list (so I re-sent it recently).
> 
> [1] 
> https://public-inbox.org/git/20180608135548.216405-4-dstolee@microsoft.com/

Thanks - I see that you introduced a new parse_commit_in_graph_one(struct commit_graph *, struct commit *) and made the existing parse_commit_in_graph(struct commit *item) use the former. Combining our changes would be just adding a repository argument to parse_commit_in_graph() and passing the graph through parse_commit_in_graph_one() (after prepare_commit_graph() and ensuring that the graph exists).

Previous: Derrick StoleeNext: Jonathan Tan
Message 17 of 49 in “Object store refactoring: commit graph”
  1. 0/5 Object store refactoring: commit graphJonathan Tan, Jun 21, 2018
  2. 1/5 object-store: add missing includeJonathan Tan, Jun 21, 2018
  3. 2/5 commit-graph: add missing forward declarationJonathan Tan, Jun 21, 2018
  4. Stefan BellerJun 21, 2018
  5. Jonathan TanJun 21, 2018
  6. Derrick StoleeJun 22, 2018
  7. 3/5 commit-graph: add free_commit_graphJonathan Tan, Jun 21, 2018
  8. 4/5 commit-graph: store graph in struct object_storeJonathan Tan, Jun 21, 2018
  9. Junio C HamanoJun 25, 2018
  10. Jonathan TanJun 25, 2018
  11. Junio C HamanoJun 26, 2018
  12. 5/5 commit-graph: add repo arg to graph readersJonathan Tan, Jun 21, 2018
  13. Stefan BellerJun 21, 2018
  14. Jonathan TanJun 21, 2018
  15. Derrick StoleeJun 22, 2018
  16. Derrick StoleeJun 22, 2018
  17. Jonathan TanJun 22, 2018
  18. 0/6 Object store refactoring: commit graphJonathan Tan, Jul 9, 2018
  19. 1/6 commit-graph: refactor preparing commit graphJonathan Tan, Jul 9, 2018
  20. Stefan BellerJul 9, 2018
  21. Derrick StoleeJul 10, 2018
  22. 2/6 object-store: add missing includeJonathan Tan, Jul 9, 2018
  23. 3/6 commit-graph: add missing forward declarationJonathan Tan, Jul 9, 2018
  24. 4/6 commit-graph: add free_commit_graphJonathan Tan, Jul 9, 2018
  25. 5/6 commit-graph: store graph in struct object_storeJonathan Tan, Jul 9, 2018
  26. 6/6 commit-graph: add repo arg to graph readersJonathan Tan, Jul 9, 2018
  27. Derrick StoleeJul 10, 2018
  28. Jonathan TanJul 10, 2018
  29. Derrick StoleeJul 11, 2018
  30. Jonathan TanJul 11, 2018
  31. SZEDER GáborJul 10, 2018
  32. Johannes SchindelinJul 10, 2018
  33. Jonathan TanJul 10, 2018
  34. Stefan BellerJul 9, 2018
  35. Junio C HamanoJul 9, 2018
  36. Derrick StoleeJul 10, 2018
  37. Derrick StoleeJul 10, 2018
  38. 0/6 Object store refactoring: commit graphJonathan Tan, Jul 11, 2018
  39. 1/6 commit-graph: refactor preparing commit graphJonathan Tan, Jul 11, 2018
  40. 2/6 object-store: add missing includeJonathan Tan, Jul 11, 2018
  41. 3/6 commit-graph: add missing forward declarationJonathan Tan, Jul 11, 2018
  42. 4/6 commit-graph: add free_commit_graphJonathan Tan, Jul 11, 2018
  43. 5/6 commit-graph: store graph in struct object_storeJonathan Tan, Jul 11, 2018
  44. 6/6 commit-graph: add repo arg to graph readersJonathan Tan, Jul 11, 2018
  45. t5318: avoid unnecessary command substitutionsSZEDER Gábor, Aug 13, 2018
  46. Derrick StoleeAug 13, 2018
  47. Junio C HamanoAug 13, 2018
  48. Junio C HamanoJul 12, 2018
  49. Derrick StoleeJul 12, 2018

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.