X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=object.c;h=21f872ee163e9eeff1a52854791c5b96a2ec2ceb;hb=180926636e47ecfe28d03cec493af75899994f0f;hp=5e8378857028afeb4d1cd91c0de26c8414e137de;hpb=5d6ccf5ce7f28e576a87f6c6f4f99fae90e06db6;p=git.git diff --git a/object.c b/object.c index 5e837885..21f872ee 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;