Skip to content

Commit 1268dfa

Browse files
stefanbellergitster
authored andcommitted
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>
1 parent 1ec5bfd commit 1268dfa

File tree

8 files changed

+10
-9
lines changed

8 files changed

+10
-9
lines changed

blob.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ struct blob *lookup_blob(const struct object_id *oid)
1111
if (!obj)
1212
return create_object(the_repository, oid->hash,
1313
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);
1515
}
1616

1717
int parse_blob_buffer(struct blob *item, void *buffer, unsigned long size)

builtin/fsck.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static const char *printable_type(struct object *obj)
7070
enum object_type type = oid_object_info(the_repository,
7171
&obj->oid, NULL);
7272
if (type > 0)
73-
object_as_type(obj, type, 0);
73+
object_as_type(the_repository, obj, type, 0);
7474
}
7575

7676
ret = type_name(obj->type);

commit.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct commit *lookup_commit_reference_gently(const struct object_id *oid,
3232

3333
if (!obj)
3434
return NULL;
35-
return object_as_type(obj, OBJ_COMMIT, quiet);
35+
return object_as_type(the_repository, obj, OBJ_COMMIT, quiet);
3636
}
3737

3838
struct commit *lookup_commit_reference(const struct object_id *oid)
@@ -58,7 +58,7 @@ struct commit *lookup_commit(const struct object_id *oid)
5858
if (!obj)
5959
return create_object(the_repository, oid->hash,
6060
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);
6262
}
6363

6464
struct commit *lookup_commit_reference_by_name(const char *name)

object.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ void *create_object(struct repository *r, const unsigned char *sha1, void *o)
158158
return obj;
159159
}
160160

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)
162162
{
163163
if (obj->type == type)
164164
return obj;

object.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ struct object *lookup_object_the_repository(const unsigned char *sha1);
114114

115115
extern void *create_object(struct repository *r, const unsigned char *sha1, void *obj);
116116

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

119120
/*
120121
* Returns the object, having parsed it to find out what it is.

refs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ enum peel_status peel_object(const struct object_id *name, struct object_id *oid
305305

306306
if (o->type == OBJ_NONE) {
307307
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))
309309
return PEEL_INVALID;
310310
}
311311

tag.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ struct tag *lookup_tag(const struct object_id *oid)
9898
if (!obj)
9999
return create_object(the_repository, oid->hash,
100100
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);
102102
}
103103

104104
static timestamp_t parse_tag_date(const char *buf, const char *tail)

tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ struct tree *lookup_tree(const struct object_id *oid)
201201
if (!obj)
202202
return create_object(the_repository, oid->hash,
203203
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);
205205
}
206206

207207
int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size)

0 commit comments

Comments
 (0)