object: add repository argument to create_object
Add a repository argument to allow the callers of create_object to be more specific about which repository to act on. This is a small mechanical change; it doesn't change the implementation to handle repositories other than the_repository yet. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> 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
68f95d382b51b134b138c91f94adb8d9ef2f557a
6 files changed
+14
-7
blob.c
+3
-1
@@ -1,5 +1,6 @@
1
#include "cache.h"
2
#include "blob.h"
3
+#include "repository.h"
4
5
const char *blob_type = "blob";
6
@@ -7,7 +8,8 @@ struct blob *lookup_blob(const struct object_id *oid)
8
{
9
struct object *obj = lookup_object(oid->hash);
10
if (!obj)
10
- return create_object(oid->hash, alloc_blob_node());
11
+ return create_object(the_repository, oid->hash,
12
+ alloc_blob_node());
13
return object_as_type(obj, OBJ_BLOB, 0);
14
}
15
commit.c
+2
-1
@@ -50,7 +50,8 @@ struct commit *lookup_commit(const struct object_id *oid)
50
{
51
struct object *obj = lookup_object(oid->hash);
52
if (!obj)
53
- return create_object(oid->hash, alloc_commit_node());
53
+ return create_object(the_repository, oid->hash,
54
+ alloc_commit_node());
55
return object_as_type(obj, OBJ_COMMIT, 0);
56
}
57
object.c
+3
-2
@@ -138,7 +138,7 @@ static void grow_object_hash(void)
138
the_repository->parsed_objects->obj_hash_size = new_hash_size;
139
}
140
141
-void *create_object(const unsigned char *sha1, void *o)
141
+void *create_object_the_repository(const unsigned char *sha1, void *o)
142
{
143
struct object *obj = o;
144
@@ -178,7 +178,8 @@ struct object *lookup_unknown_object(const unsigned char *sha1)
178
{
179
struct object *obj = lookup_object(sha1);
180
if (!obj)
181
- obj = create_object(sha1, alloc_object_node());
181
+ obj = create_object(the_repository, sha1,
182
+ alloc_object_node());
183
return obj;
184
}
185
object.h
+2
-1
@@ -93,7 +93,8 @@ extern struct object *get_indexed_object(unsigned int);
93
*/
94
struct object *lookup_object(const unsigned char *sha1);
95
96
-extern void *create_object(const unsigned char *sha1, void *obj);
96
+#define create_object(r, s, o) create_object_##r(s, o)
97
+extern void *create_object_the_repository(const unsigned char *sha1, void *obj);
98
99
void *object_as_type(struct object *obj, enum object_type type, int quiet);
100
tag.c
+2
-1
@@ -93,7 +93,8 @@ struct tag *lookup_tag(const struct object_id *oid)
93
{
94
struct object *obj = lookup_object(oid->hash);
95
if (!obj)
96
- return create_object(oid->hash, alloc_tag_node());
96
+ return create_object(the_repository, oid->hash,
97
+ alloc_tag_node());
98
return object_as_type(obj, OBJ_TAG, 0);
99
}
100
tree.c
+2
-1
@@ -196,7 +196,8 @@ struct tree *lookup_tree(const struct object_id *oid)
196
{
197
struct object *obj = lookup_object(oid->hash);
198
if (!obj)
199
- return create_object(oid->hash, alloc_tree_node());
199
+ return create_object(the_repository, oid->hash,
200
+ alloc_tree_node());
201
return object_as_type(obj, OBJ_TREE, 0);
202
}
203