object: add repository argument to object_as_type
Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Stefan Beller committed
Jun 28, 2018 at 18:21 UTC
1268dfac1e98e973c63abb142551c64bba6a44ca
8 files changed
+10
-9
blob.c
+1
-1
@@ -11,7 +11,7 @@ struct blob *lookup_blob(const struct object_id *oid)
11
if (!obj)
12
return create_object(the_repository, oid->hash,
13
alloc_blob_node(the_repository));
14
- return object_as_type(obj, OBJ_BLOB, 0);
14
+ return object_as_type(the_repository, obj, OBJ_BLOB, 0);
15
}
16
17
int parse_blob_buffer(struct blob *item, void *buffer, unsigned long size)
builtin/fsck.c
+1
-1
@@ -70,7 +70,7 @@ static const char *printable_type(struct object *obj)
70
enum object_type type = oid_object_info(the_repository,
71
&obj->oid, NULL);
72
if (type > 0)
73
- object_as_type(obj, type, 0);
73
+ object_as_type(the_repository, obj, type, 0);
74
}
75
76
ret = type_name(obj->type);
commit.c
+2
-2
@@ -32,7 +32,7 @@ struct commit *lookup_commit_reference_gently(const struct object_id *oid,
32
33
if (!obj)
34
return NULL;
35
- return object_as_type(obj, OBJ_COMMIT, quiet);
35
+ return object_as_type(the_repository, obj, OBJ_COMMIT, quiet);
36
}
37
38
struct commit *lookup_commit_reference(const struct object_id *oid)
@@ -58,7 +58,7 @@ struct commit *lookup_commit(const struct object_id *oid)
58
if (!obj)
59
return create_object(the_repository, oid->hash,
60
alloc_commit_node(the_repository));
61
- return object_as_type(obj, OBJ_COMMIT, 0);
61
+ return object_as_type(the_repository, obj, OBJ_COMMIT, 0);
62
}
63
64
struct commit *lookup_commit_reference_by_name(const char *name)
object.c
+1
-1
@@ -158,7 +158,7 @@ void *create_object(struct repository *r, const unsigned char *sha1, void *o)
158
return obj;
159
}
160
161
-void *object_as_type(struct object *obj, enum object_type type, int quiet)
161
+void *object_as_type_the_repository(struct object *obj, enum object_type type, int quiet)
162
{
163
if (obj->type == type)
164
return obj;
object.h
+2
-1
@@ -114,7 +114,8 @@ struct object *lookup_object_the_repository(const unsigned char *sha1);
114
115
extern void *create_object(struct repository *r, const unsigned char *sha1, void *obj);
116
117
-void *object_as_type(struct object *obj, enum object_type type, int quiet);
117
+#define object_as_type(r, o, t, q) object_as_type_##r(o, t, q)
118
+void *object_as_type_the_repository(struct object *obj, enum object_type type, int quiet);
119
120
/*
121
* Returns the object, having parsed it to find out what it is.
refs.c
+1
-1
@@ -305,7 +305,7 @@ enum peel_status peel_object(const struct object_id *name, struct object_id *oid
305
306
if (o->type == OBJ_NONE) {
307
int type = oid_object_info(the_repository, name, NULL);
308
- if (type < 0 || !object_as_type(o, type, 0))
308
+ if (type < 0 || !object_as_type(the_repository, o, type, 0))
309
return PEEL_INVALID;
310
}
311
tag.c
+1
-1
@@ -98,7 +98,7 @@ struct tag *lookup_tag(const struct object_id *oid)
98
if (!obj)
99
return create_object(the_repository, oid->hash,
100
alloc_tag_node(the_repository));
101
- return object_as_type(obj, OBJ_TAG, 0);
101
+ return object_as_type(the_repository, obj, OBJ_TAG, 0);
102
}
103
104
static timestamp_t parse_tag_date(const char *buf, const char *tail)
tree.c
+1
-1
@@ -201,7 +201,7 @@ struct tree *lookup_tree(const struct object_id *oid)
201
if (!obj)
202
return create_object(the_repository, oid->hash,
203
alloc_tree_node(the_repository));
204
- return object_as_type(obj, OBJ_TREE, 0);
204
+ return object_as_type(the_repository, obj, OBJ_TREE, 0);
205
}
206
207
int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size)