{
struct object *obj = lookup_object(sha1);
if (!obj) {
- struct tree *ret = xcalloc(1, sizeof(struct tree));
+ struct tree *ret = alloc_tree_node();
created_object(sha1, &ret->object);
- ret->object.type = tree_type;
+ ret->object.type = TYPE_TREE;
return ret;
}
if (!obj->type)
- obj->type = tree_type;
- if (obj->type != tree_type) {
- error("Object %s is a %s, not a tree",
- sha1_to_hex(sha1), obj->type);
+ obj->type = TYPE_TREE;
+ if (obj->type != TYPE_TREE) {
+ error("Object %s is a %s, not a tree",
+ sha1_to_hex(sha1), typename(obj->type));
return NULL;
}
return (struct tree *) obj;
do {
if (!obj)
return NULL;
- if (obj->type == tree_type)
+ if (obj->type == TYPE_TREE)
return (struct tree *) obj;
- else if (obj->type == commit_type)
+ else if (obj->type == TYPE_COMMIT)
obj = &(((struct commit *) obj)->tree->object);
- else if (obj->type == tag_type)
+ else if (obj->type == TYPE_TAG)
obj = ((struct tag *) obj)->tagged;
else
return NULL;