aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--commit.h14
-rw-r--r--contrib/coccinelle/commit.cocci2
2 files changed, 13 insertions, 3 deletions
diff --git a/commit.h b/commit.h
index 79a761c37d..05165a48a5 100644
--- a/commit.h
+++ b/commit.h
@@ -103,16 +103,26 @@ static inline int repo_parse_commit(struct repository *r, struct commit *item)
return repo_parse_commit_gently(r, item, 0);
}
+void unparse_commit(struct repository *r, const struct object_id *oid);
+
static inline int repo_parse_commit_no_graph(struct repository *r,
struct commit *commit)
{
+ /*
+ * When the commit has been parsed but its tree wasn't populated then
+ * this is an indicator that it has been parsed via the commit-graph.
+ * We cannot read the tree via the commit-graph, as we're explicitly
+ * told not to use it. We thus have to first un-parse the object so
+ * that we can re-parse it without the graph.
+ */
+ if (commit->object.parsed && !commit->maybe_tree)
+ unparse_commit(r, &commit->object.oid);
+
return repo_parse_commit_internal(r, commit, 0, 0);
}
void parse_commit_or_die(struct commit *item);
-void unparse_commit(struct repository *r, const struct object_id *oid);
-
struct buffer_slab;
struct buffer_slab *allocate_commit_buffer_slab(void);
void free_commit_buffer_slab(struct buffer_slab *bs);
diff --git a/contrib/coccinelle/commit.cocci b/contrib/coccinelle/commit.cocci
index c5284604c5..42725161e9 100644
--- a/contrib/coccinelle/commit.cocci
+++ b/contrib/coccinelle/commit.cocci
@@ -26,7 +26,7 @@ expression s;
// repo_get_commit_tree() on the LHS.
@@
identifier f != { repo_get_commit_tree, get_commit_tree_in_graph_one,
- load_tree_for_commit, set_commit_tree };
+ load_tree_for_commit, set_commit_tree, repo_parse_commit_no_graph };
expression c;
@@
f(...) {<...