summaryrefslogtreecommitdiff
path: root/object.c
diff options
context:
space:
mode:
Diffstat (limited to 'object.c')
-rw-r--r--object.c16
1 files changed, 16 insertions, 0 deletions
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;