alloc: add repository argument to alloc_commit_node

This is a small mechanical change; it doesn't change the implementation to handle repositories other than the_repository yet. Use a macro to catch callers passing a repository other than the_repository at compile time. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Stefan Beller committed May 8, 2018 at 12:37 UTC 8ba0e5ec57e4a7da18f735416e3028a9a8b8b1ad
5 files changed +6 -5
alloc.c
+1 -1
@@ -88,7 +88,7 @@ unsigned int alloc_commit_index(void)
88 return count++;
89 }
90
91 -void *alloc_commit_node(void)
91 +void *alloc_commit_node_the_repository(void)
92 {
93 struct commit *c = alloc_node(&commit_state, sizeof(struct commit));
94 c->object.type = OBJ_COMMIT;
blame.c
+1 -1
@@ -161,7 +161,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,
161
162 read_cache();
163 time(&now);
164 - commit = alloc_commit_node();
164 + commit = alloc_commit_node(the_repository);
165 commit->object.parsed = 1;
166 commit->date = now;
167 parent_tail = &commit->parents;
cache.h
+2 -1
@@ -1768,7 +1768,8 @@ void encode_85(char *buf, const unsigned char *data, int bytes);
1768 extern void *alloc_blob_node_the_repository(void);
1769 #define alloc_tree_node(r) alloc_tree_node_##r()
1770 extern void *alloc_tree_node_the_repository(void);
1771 -extern void *alloc_commit_node(void);
1771 +#define alloc_commit_node(r) alloc_commit_node_##r()
1772 +extern void *alloc_commit_node_the_repository(void);
1773 extern void *alloc_tag_node(void);
1774 extern void *alloc_object_node(void);
1775 extern void alloc_report(void);
commit.c
+1 -1
@@ -51,7 +51,7 @@ struct commit *lookup_commit(const struct object_id *oid)
51 struct object *obj = lookup_object(oid->hash);
52 if (!obj)
53 return create_object(the_repository, oid->hash,
54 - alloc_commit_node());
54 + alloc_commit_node(the_repository));
55 return object_as_type(obj, OBJ_COMMIT, 0);
56 }
57
merge-recursive.c
+1 -1
@@ -98,7 +98,7 @@ static struct tree *shift_tree_object(struct tree *one, struct tree *two,
98
99 static struct commit *make_virtual_commit(struct tree *tree, const char *comment)
100 {
101 - struct commit *commit = alloc_commit_node();
101 + struct commit *commit = alloc_commit_node(the_repository);
102
103 set_merge_remote_desc(commit, comment, (struct object *)commit);
104 commit->tree = tree;