alloc: add repository argument to alloc_commit_index
authorStefan Beller <sbeller@google.com>
Tue, 8 May 2018 19:37:33 +0000 (12:37 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 9 May 2018 03:12:36 +0000 (12:12 +0900)
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>
alloc.c
cache.h
object.c
diff --git a/alloc.c b/alloc.c
index 28b85b221441b9802736f375638fff469b3c01b1..277dadd221b3a672d11328d950f38713e861324c 100644 (file)
--- a/alloc.c
+++ b/alloc.c
@@ -82,7 +82,7 @@ void *alloc_object_node_the_repository(void)
 
 static struct alloc_state commit_state;
 
-unsigned int alloc_commit_index(void)
+unsigned int alloc_commit_index_the_repository(void)
 {
        static unsigned int count;
        return count++;
@@ -92,7 +92,7 @@ void *alloc_commit_node_the_repository(void)
 {
        struct commit *c = alloc_node(&commit_state, sizeof(struct commit));
        c->object.type = OBJ_COMMIT;
-       c->index = alloc_commit_index();
+       c->index = alloc_commit_index(the_repository);
        return c;
 }
 
diff --git a/cache.h b/cache.h
index 01cc207d218f6cf9c99fadbe585746d2a8b88a1e..0e6c5dd5639c80b0c97e6c583ca260e71b2b4f66 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -1776,7 +1776,8 @@ extern void *alloc_tag_node_the_repository(void);
 extern void *alloc_object_node_the_repository(void);
 #define alloc_report(r) alloc_report_##r()
 extern void alloc_report_the_repository(void);
-extern unsigned int alloc_commit_index(void);
+#define alloc_commit_index(r) alloc_commit_index_##r()
+extern unsigned int alloc_commit_index_the_repository(void);
 
 /* pkt-line.c */
 void packet_trace_identity(const char *prog);
index b8c3f923c515cb24cb65947c0c24fead9b543e87..a365a910859f74f69d7082d89bcd5b76ad263e14 100644 (file)
--- a/object.c
+++ b/object.c
@@ -162,7 +162,7 @@ void *object_as_type(struct object *obj, enum object_type type, int quiet)
                return obj;
        else if (obj->type == OBJ_NONE) {
                if (type == OBJ_COMMIT)
-                       ((struct commit *)obj)->index = alloc_commit_index();
+                       ((struct commit *)obj)->index = alloc_commit_index(the_repository);
                obj->type = type;
                return obj;
        }