> > - if (!core_commit_graph) > > + if (repo_config_get_bool(r, "core.commitgraph", &config_value) || > > + !config_value) > > + /* > > + * This repository is not configured to use commit graphs, so > > + * do not load one. (But report commit_graph_attempted anyway > > + * so that commit graph loading is not attempted again for this > > + * repository.) > > + */ > > I reacted first to complain about this extra config lookup, but it is > only run once per repository, so that should be fine. Thanks for checking. It is indeed run at most once per repository, and only if a commit graph is requested - the same as the current code. > The tests below form a decently-large patch on their own. Perhaps split > them out so it is easier to know that we have some interesting things to > check here. The patch is 168+ 42-, which doesn't seem that large to me, but I'll do this if others think that it is large too. > It's worth spending some extra time looking at this test pattern as I > believe we will want to follow it with other arbitrary repository changes. I agree - let me know if you notice anything you think should be changed. > > +static void test_get_commit_tree_in_graph(const char *gitdir, > > + const char *worktree, > > + const struct object_id *commit_oid) > > +{ > > + struct repository r; > > + struct commit *c; > > + struct tree *tree; > > + > > + /* > > + * Create a commit independent of any repository. > > + */ > > + c = lookup_commit(commit_oid); > > Would this be more accurate to say we are creating a commit object > stored in the object cache of the_repository? How would you expect this > to work if/when lookup_commit() takes an arbitrary repository? You want > to provide &r, right (after initializing)? Yes, you're right - Stefan too mentioned that this will need to be moved below lookup_commit(). I'm not sure what the best way is to handle this - maybe move this, and add a "needswork" stating that we need to pass r to lookup_commit once it supports taking in a repository argument, as an aid to the person who performs the merge. I'll do that if a reroll is needed. > Also, this will conflict with sb/object-store-lookup, won't it? I'm > guessing this is why you didn't touch the "git commit-graph > [write|verify]"code paths. It will conflict because of the change to lookup_commit(), but the only new code I'm writing is in t/helper/test-repository.c, so hopefully the merge won't be too tedious. The main reason why I didn't touch the writing/verifying part is to reduce the size of this patch set, and because that change is not needed to update parse_commit() and others. > > + > > + repo_init(&r, gitdir, worktree); > > I think you want to move the lookup_commit() to after this. Yes, that's right. > > +int cmd__repository(int argc, const char **argv) > > +{ > > + if (argc < 2) > > + die("must have at least 2 arguments"); > > I think this "test-tool repository <verb>" pattern is a good way to get > some testing here. Thanks.