Skip to content

Commit 68f95d3

Browse files
stefanbellergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Stefan Beller <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 99bf115 commit 68f95d3

File tree

6 files changed

+14
-7
lines changed

6 files changed

+14
-7
lines changed

blob.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
#include "cache.h"
22
#include "blob.h"
3+
#include "repository.h"
34

45
const char *blob_type = "blob";
56

67
struct blob *lookup_blob(const struct object_id *oid)
78
{
89
struct object *obj = lookup_object(oid->hash);
910
if (!obj)
10-
return create_object(oid->hash, alloc_blob_node());
11+
return create_object(the_repository, oid->hash,
12+
alloc_blob_node());
1113
return object_as_type(obj, OBJ_BLOB, 0);
1214
}
1315

commit.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ struct commit *lookup_commit(const struct object_id *oid)
5050
{
5151
struct object *obj = lookup_object(oid->hash);
5252
if (!obj)
53-
return create_object(oid->hash, alloc_commit_node());
53+
return create_object(the_repository, oid->hash,
54+
alloc_commit_node());
5455
return object_as_type(obj, OBJ_COMMIT, 0);
5556
}
5657

object.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ static void grow_object_hash(void)
138138
the_repository->parsed_objects->obj_hash_size = new_hash_size;
139139
}
140140

141-
void *create_object(const unsigned char *sha1, void *o)
141+
void *create_object_the_repository(const unsigned char *sha1, void *o)
142142
{
143143
struct object *obj = o;
144144

@@ -178,7 +178,8 @@ struct object *lookup_unknown_object(const unsigned char *sha1)
178178
{
179179
struct object *obj = lookup_object(sha1);
180180
if (!obj)
181-
obj = create_object(sha1, alloc_object_node());
181+
obj = create_object(the_repository, sha1,
182+
alloc_object_node());
182183
return obj;
183184
}
184185

object.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ extern struct object *get_indexed_object(unsigned int);
9393
*/
9494
struct object *lookup_object(const unsigned char *sha1);
9595

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);
9798

9899
void *object_as_type(struct object *obj, enum object_type type, int quiet);
99100

tag.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ struct tag *lookup_tag(const struct object_id *oid)
9393
{
9494
struct object *obj = lookup_object(oid->hash);
9595
if (!obj)
96-
return create_object(oid->hash, alloc_tag_node());
96+
return create_object(the_repository, oid->hash,
97+
alloc_tag_node());
9798
return object_as_type(obj, OBJ_TAG, 0);
9899
}
99100

tree.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ struct tree *lookup_tree(const struct object_id *oid)
196196
{
197197
struct object *obj = lookup_object(oid->hash);
198198
if (!obj)
199-
return create_object(oid->hash, alloc_tree_node());
199+
return create_object(the_repository, oid->hash,
200+
alloc_tree_node());
200201
return object_as_type(obj, OBJ_TREE, 0);
201202
}
202203

0 commit comments

Comments
 (0)