commit-graph: lazy-load trees for commits
[gitweb.git] / commit.c
index aea2ca1f8ba307f540f17d4f4b93071f9eb45b5f..711f674c18d00c8d62b117764e67c5d9c6731616 100644 (file)
--- a/commit.c
+++ b/commit.c
@@ -298,7 +298,13 @@ void free_commit_buffer(struct commit *commit)
 
 struct tree *get_commit_tree(const struct commit *commit)
 {
-       return commit->maybe_tree;
+       if (commit->maybe_tree || !commit->object.parsed)
+               return commit->maybe_tree;
+
+       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);
 }
 
 struct object_id *get_commit_tree_oid(const struct commit *commit)