alloc: add repository argument to alloc_commit_node
authorStefan Beller <sbeller@google.com>
Tue, 8 May 2018 19:37:29 +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
blame.c
cache.h
commit.c
merge-recursive.c
diff --git a/alloc.c b/alloc.c
index 2c8d1430758b973270b68e234387b36c29130b4b..9e2b897ec1dea281485402f1c55d87107cf52f50 100644 (file)
--- a/alloc.c
+++ b/alloc.c
@@ -88,7 +88,7 @@ unsigned int alloc_commit_index(void)
        return count++;
 }
 
-void *alloc_commit_node(void)
+void *alloc_commit_node_the_repository(void)
 {
        struct commit *c = alloc_node(&commit_state, sizeof(struct commit));
        c->object.type = OBJ_COMMIT;
diff --git a/blame.c b/blame.c
index dfa24473dc6e3d3d6428ca0fcdff75861d0c1aec..ba9b18e7542b225316e8a5739e88ac3700784d7b 100644 (file)
--- a/blame.c
+++ b/blame.c
@@ -161,7 +161,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,
 
        read_cache();
        time(&now);
-       commit = alloc_commit_node();
+       commit = alloc_commit_node(the_repository);
        commit->object.parsed = 1;
        commit->date = now;
        parent_tail = &commit->parents;
diff --git a/cache.h b/cache.h
index 1717d07a2c5d18e4181cc5b4f5928ed69e94f089..bf6e8c87d83d1106abf99d7f26c0036e6f0a17f2 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -1768,7 +1768,8 @@ void encode_85(char *buf, const unsigned char *data, int bytes);
 extern void *alloc_blob_node_the_repository(void);
 #define alloc_tree_node(r) alloc_tree_node_##r()
 extern void *alloc_tree_node_the_repository(void);
-extern void *alloc_commit_node(void);
+#define alloc_commit_node(r) alloc_commit_node_##r()
+extern void *alloc_commit_node_the_repository(void);
 extern void *alloc_tag_node(void);
 extern void *alloc_object_node(void);
 extern void alloc_report(void);
index 9106acf0aadca1047002cfa32d62ececb78f60c3..a9a43e79bae3ced1ea7bd66e09c9f47d8e63997d 100644 (file)
--- a/commit.c
+++ b/commit.c
@@ -51,7 +51,7 @@ struct commit *lookup_commit(const struct object_id *oid)
        struct object *obj = lookup_object(oid->hash);
        if (!obj)
                return create_object(the_repository, oid->hash,
-                                    alloc_commit_node());
+                                    alloc_commit_node(the_repository));
        return object_as_type(obj, OBJ_COMMIT, 0);
 }
 
index 0c0d48624da1d6162f0804e4a105841d965bb2c2..6dac890864882744d3936391bbe5067a23411af3 100644 (file)
@@ -98,7 +98,7 @@ static struct tree *shift_tree_object(struct tree *one, struct tree *two,
 
 static struct commit *make_virtual_commit(struct tree *tree, const char *comment)
 {
-       struct commit *commit = alloc_commit_node();
+       struct commit *commit = alloc_commit_node(the_repository);
 
        set_merge_remote_desc(commit, comment, (struct object *)commit);
        commit->tree = tree;