alloc: add repository argument to alloc_tree_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 cf7203bdc65f11de89d27f52115cb98052c52ce8
3 files changed +4 -3
alloc.c
+1 -1
@@ -57,7 +57,7 @@ void *alloc_blob_node_the_repository(void)
57 }
58
59 static struct alloc_state tree_state;
60 -void *alloc_tree_node(void)
60 +void *alloc_tree_node_the_repository(void)
61 {
62 struct tree *t = alloc_node(&tree_state, sizeof(struct tree));
63 t->object.type = OBJ_TREE;
cache.h
+2 -1
@@ -1766,7 +1766,8 @@ void encode_85(char *buf, const unsigned char *data, int bytes);
1766 /* alloc.c */
1767 #define alloc_blob_node(r) alloc_blob_node_##r()
1768 extern void *alloc_blob_node_the_repository(void);
1769 -extern void *alloc_tree_node(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);
1772 extern void *alloc_tag_node(void);
1773 extern void *alloc_object_node(void);
tree.c
+1 -1
@@ -197,7 +197,7 @@ struct tree *lookup_tree(const struct object_id *oid)
197 struct object *obj = lookup_object(oid->hash);
198 if (!obj)
199 return create_object(the_repository, oid->hash,
200 - alloc_tree_node());
200 + alloc_tree_node(the_repository));
201 return object_as_type(obj, OBJ_TREE, 0);
202 }
203