alloc: add repository argument to alloc_commit_index
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
dd5d9deb0155a27cb2d74d1a0faf0af84ef5f355
3 files changed
+5
-4
alloc.c
+2
-2
@@ -82,7 +82,7 @@ void *alloc_object_node_the_repository(void)
82
83
static struct alloc_state commit_state;
84
85
-unsigned int alloc_commit_index(void)
85
+unsigned int alloc_commit_index_the_repository(void)
86
{
87
static unsigned int count;
88
return count++;
@@ -92,7 +92,7 @@ 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;
95
- c->index = alloc_commit_index();
95
+ c->index = alloc_commit_index(the_repository);
96
return c;
97
}
98
cache.h
+2
-1
@@ -1776,7 +1776,8 @@ extern void *alloc_tag_node_the_repository(void);
1776
extern void *alloc_object_node_the_repository(void);
1777
#define alloc_report(r) alloc_report_##r()
1778
extern void alloc_report_the_repository(void);
1779
-extern unsigned int alloc_commit_index(void);
1779
+#define alloc_commit_index(r) alloc_commit_index_##r()
1780
+extern unsigned int alloc_commit_index_the_repository(void);
1781
1782
/* pkt-line.c */
1783
void packet_trace_identity(const char *prog);
object.c
+1
-1
@@ -162,7 +162,7 @@ void *object_as_type(struct object *obj, enum object_type type, int quiet)
162
return obj;
163
else if (obj->type == OBJ_NONE) {
164
if (type == OBJ_COMMIT)
165
- ((struct commit *)obj)->index = alloc_commit_index();
165
+ ((struct commit *)obj)->index = alloc_commit_index(the_repository);
166
obj->type = type;
167
return obj;
168
}