aboutsummaryrefslogtreecommitdiff
path: root/commit.h
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2026-03-02 17:06:53 -0800
committerJunio C Hamano <gitster@pobox.com>2026-03-02 17:06:53 -0800
commit13763ecf7d92be72beff75c59163c5448d9e085e (patch)
tree936c5d97e77cefb1f0da9b2aae1054b1433bc690 /commit.h
parent34113149cfde760b6b791939c6d8d87d27ca2767 (diff)
parentbb5da75d6116c35924a04a418ef4c3182663d0a2 (diff)
downloadgit-13763ecf7d92be72beff75c59163c5448d9e085e.tar.xz
Merge branch 'ps/receive-pack-shallow-optim'
The code to accept shallow "git push" has been optimized. * ps/receive-pack-shallow-optim: commit: use commit graph in `lookup_commit_reference_gently()` commit: make `repo_parse_commit_no_graph()` more robust commit: avoid parsing non-commits in `lookup_commit_reference_gently()`
Diffstat (limited to 'commit.h')
-rw-r--r--commit.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/commit.h b/commit.h
index 1635de418b..f2f39e1a89 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);