path: root/commit.c
diff options
authorJeff King <>2014-06-10 21:39:04 (GMT)
committerJunio C Hamano <>2014-06-12 17:29:42 (GMT)
commit969eba6341a5af8ac52c67e26462548ed05e23e3 (patch)
tree5ad116ce4e50cd2396c16d6de4f17cdb4cd30e80 /commit.c
parentc335d74d349d201cb7627aa7233638d2953a4b02 (diff)
commit: push commit_index update into alloc_commit_node
Whenever we create a commit object via lookup_commit, we give it a unique index to be used with the commit-slab API. The theory is that any "struct commit" we create would follow this code path, so any such struct would get an index. However, callers could use alloc_commit_node() directly (and get multiple commits with index 0). Let's push the indexing into alloc_commit_node so that it's hard for callers to get it wrong. Signed-off-by: Jeff King <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'commit.c')
1 files changed, 0 insertions, 2 deletions
diff --git a/commit.c b/commit.c
index bd3d5af..fbdc480 100644
--- a/commit.c
+++ b/commit.c
@@ -17,7 +17,6 @@ static struct commit_extra_header *read_commit_extra_header_lines(const char *bu
int save_commit_buffer = 1;
const char *commit_type = "commit";
-static int commit_count;
static struct commit *check_commit(struct object *obj,
const unsigned char *sha1,
@@ -64,7 +63,6 @@ struct commit *lookup_commit(const unsigned char *sha1)
struct object *obj = lookup_object(sha1);
if (!obj) {
struct commit *c = alloc_commit_node();
- c->index = commit_count++;
return create_object(sha1, OBJ_COMMIT, c);
if (!obj->type)