aboutsummaryrefslogtreecommitdiffstats
path: root/alloc.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-02-05 14:26:19 -0800
committerJunio C Hamano <gitster@pobox.com>2019-02-05 14:26:19 -0800
commit2ed3de439e2de9646e1501a46bc4fd80c977e611 (patch)
tree4b384ce7129b83b3af93ccd2d4ee8101f1ac93e7 /alloc.c
parentMerge branch 'nd/fetch-compact-update' (diff)
parentobject_as_type: initialize commit-graph-related fields of 'struct commit' (diff)
downloadgit-2ed3de439e2de9646e1501a46bc4fd80c977e611.tar.gz
git-2ed3de439e2de9646e1501a46bc4fd80c977e611.zip
Merge branch 'sg/object-as-type-commit-graph-fix'
The commit-graph facility did not work when in-core objects that are promoted from unknown type to commit (e.g. a commit that is accessed via a tag that refers to it) were involved, which has been corrected. * sg/object-as-type-commit-graph-fix: object_as_type: initialize commit-graph-related fields of 'struct commit'
Diffstat (limited to 'alloc.c')
-rw-r--r--alloc.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/alloc.c b/alloc.c
index e7aa81b7aa..1c64c4dd16 100644
--- a/alloc.c
+++ b/alloc.c
@@ -99,18 +99,23 @@ void *alloc_object_node(struct repository *r)
return obj;
}
-unsigned int alloc_commit_index(struct repository *r)
+static unsigned int alloc_commit_index(struct repository *r)
{
return r->parsed_objects->commit_count++;
}
-void *alloc_commit_node(struct repository *r)
+void init_commit_node(struct repository *r, struct commit *c)
{
- struct commit *c = alloc_node(r->parsed_objects->commit_state, sizeof(struct commit));
c->object.type = OBJ_COMMIT;
c->index = alloc_commit_index(r);
c->graph_pos = COMMIT_NOT_FROM_GRAPH;
c->generation = GENERATION_NUMBER_INFINITY;
+}
+
+void *alloc_commit_node(struct repository *r)
+{
+ struct commit *c = alloc_node(r->parsed_objects->commit_state, sizeof(struct commit));
+ init_commit_node(r, c);
return c;
}