mirror of
https://github.com/git/git.git
synced 2024-06-08 00:46:11 +02:00
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>
This commit is contained in:
parent
a74093da5e
commit
a962da1ef5
4
object.c
4
object.c
|
@ -158,13 +158,13 @@ void *create_object(struct repository *r, const unsigned char *sha1, void *o)
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *object_as_type_the_repository(struct object *obj, enum object_type type, int quiet)
|
void *object_as_type(struct repository *r, struct object *obj, enum object_type type, int quiet)
|
||||||
{
|
{
|
||||||
if (obj->type == type)
|
if (obj->type == type)
|
||||||
return obj;
|
return obj;
|
||||||
else if (obj->type == OBJ_NONE) {
|
else if (obj->type == OBJ_NONE) {
|
||||||
if (type == OBJ_COMMIT)
|
if (type == OBJ_COMMIT)
|
||||||
((struct commit *)obj)->index = alloc_commit_index(the_repository);
|
((struct commit *)obj)->index = alloc_commit_index(r);
|
||||||
obj->type = type;
|
obj->type = type;
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
3
object.h
3
object.h
|
@ -114,8 +114,7 @@ struct object *lookup_object_the_repository(const unsigned char *sha1);
|
||||||
|
|
||||||
extern void *create_object(struct repository *r, const unsigned char *sha1, void *obj);
|
extern void *create_object(struct repository *r, const unsigned char *sha1, void *obj);
|
||||||
|
|
||||||
#define object_as_type(r, o, t, q) object_as_type_##r(o, t, q)
|
void *object_as_type(struct repository *r, struct object *obj, enum object_type type, int quiet);
|
||||||
void *object_as_type_the_repository(struct object *obj, enum object_type type, int quiet);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns the object, having parsed it to find out what it is.
|
* Returns the object, having parsed it to find out what it is.
|
||||||
|
|
Loading…
Reference in New Issue