Skip to content

Commit 0cbef8f

Browse files
derrickstoleegitster
authored andcommitted
commit-graph: load a root tree from specific graph
When lazy-loading a tree for a commit, it will be important to select the tree from a specific struct commit_graph. Create a new method that specifies the commit-graph file and use that in get_commit_tree_in_graph(). Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9b19ada commit 0cbef8f

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

commit-graph.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,14 +362,20 @@ static struct tree *load_tree_for_commit(struct commit_graph *g, struct commit *
362362
return c->maybe_tree;
363363
}
364364

365-
struct tree *get_commit_tree_in_graph(const struct commit *c)
365+
static struct tree *get_commit_tree_in_graph_one(struct commit_graph *g,
366+
const struct commit *c)
366367
{
367368
if (c->maybe_tree)
368369
return c->maybe_tree;
369370
if (c->graph_pos == COMMIT_NOT_FROM_GRAPH)
370-
BUG("get_commit_tree_in_graph called from non-commit-graph commit");
371+
BUG("get_commit_tree_in_graph_one called from non-commit-graph commit");
372+
373+
return load_tree_for_commit(g, (struct commit *)c);
374+
}
371375

372-
return load_tree_for_commit(commit_graph, (struct commit *)c);
376+
struct tree *get_commit_tree_in_graph(const struct commit *c)
377+
{
378+
return get_commit_tree_in_graph_one(commit_graph, c);
373379
}
374380

375381
static void write_graph_chunk_fanout(struct hashfile *f,

0 commit comments

Comments
 (0)