struct tree *lookup_tree(const unsigned char *sha1) { struct object *obj = lookup_object(sha1); if (!obj) return create_object(sha1, alloc_tree_node()); return object_as_type(obj, OBJ_TREE, 0); }
struct tag *lookup_tag(const struct object_id *oid) { struct object *obj = lookup_object(oid->hash); if (!obj) return create_object(oid->hash, alloc_tag_node()); return object_as_type(obj, OBJ_TAG, 0); }
struct blob *lookup_blob(const struct object_id *oid) { struct object *obj = lookup_object(oid->hash); if (!obj) return create_object(oid->hash, alloc_blob_node()); return object_as_type(obj, OBJ_BLOB, 0); }
static const char *printable_type(struct object *obj) { const char *ret; if (obj->type == OBJ_NONE) { enum object_type type = sha1_object_info(obj->oid.hash, NULL); if (type > 0) object_as_type(obj, type, 0); } ret = typename(obj->type); if (!ret) ret = "unknown"; return ret; }
enum peel_status peel_object(const unsigned char *name, unsigned char *sha1) { struct object *o = lookup_unknown_object(name); if (o->type == OBJ_NONE) { int type = sha1_object_info(name, NULL); if (type < 0 || !object_as_type(o, type, 0)) return PEEL_INVALID; } if (o->type != OBJ_TAG) return PEEL_NON_TAG; o = deref_tag_noverify(o); if (!o) return PEEL_INVALID; hashcpy(sha1, o->oid.hash); return PEEL_PEELED; }