From 89e4202f9828c18f5db4db80a008a2a8a458855e Mon Sep 17 00:00:00 2001 From: Daniel Barkalow Date: Tue, 21 Jun 2005 20:35:10 -0400 Subject: [PATCH] Parse tags for absent objects Handle parsing a tag for a non-present object. This adds a function to lookup an object with lookup_* for * in a string, so that it can get the right storage based on the "type" line in the tag. Signed-off-by: Daniel Barkalow Signed-off-by: Linus Torvalds --- object.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'object.c') diff --git a/object.c b/object.c index 5e83788570..21f872ee16 100644 --- a/object.c +++ b/object.c @@ -98,6 +98,22 @@ void mark_reachable(struct object *obj, unsigned int mask) } } +struct object *lookup_object_type(const unsigned char *sha1, const char *type) +{ + if (!strcmp(type, blob_type)) { + return &lookup_blob(sha1)->object; + } else if (!strcmp(type, tree_type)) { + return &lookup_tree(sha1)->object; + } else if (!strcmp(type, commit_type)) { + return &lookup_commit(sha1)->object; + } else if (!strcmp(type, tag_type)) { + return &lookup_tag(sha1)->object; + } else { + error("Unknown type %s", type); + return NULL; + } +} + struct object *parse_object(const unsigned char *sha1) { unsigned long mapsize; -- cgit v1.2.3