object: allow object_as_type to handle arbitrary repositories

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:22 UTC a962da1ef59c71b6b18f71aeb25f1edaa99769f6
2 files changed +3 -4
object.c
+2 -2
@@ -158,13 +158,13 @@ void *create_object(struct repository *r, const unsigned char *sha1, void *o)
158 return obj;
159 }
160
161 -void *object_as_type_the_repository(struct object *obj, enum object_type type, int quiet)
161 +void *object_as_type(struct repository *r, struct object *obj, enum object_type type, int quiet)
162 {
163 if (obj->type == type)
164 return obj;
165 else if (obj->type == OBJ_NONE) {
166 if (type == OBJ_COMMIT)
167 - ((struct commit *)obj)->index = alloc_commit_index(the_repository);
167 + ((struct commit *)obj)->index = alloc_commit_index(r);
168 obj->type = type;
169 return obj;
170 }
object.h
+1 -2
@@ -114,8 +114,7 @@ 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 -#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);
117 +void *object_as_type(struct repository *r, struct object *obj, enum object_type type, int quiet);
118
119 /*
120 * Returns the object, having parsed it to find out what it is.