Merge branch 'sg/clean-nested-repo-with-ignored'
[gitweb.git] / tree.c
diff --git a/tree.c b/tree.c
index f416afc57d784f8f63ba66ec8c7424ef1e4fcaa1..1466bcc6a8cf093970dc3d39e5554a61112548fd 100644 (file)
--- a/tree.c
+++ b/tree.c
@@ -197,10 +197,9 @@ int read_tree(struct repository *r, struct tree *tree, int stage,
 
 struct tree *lookup_tree(struct repository *r, const struct object_id *oid)
 {
-       struct object *obj = lookup_object(r, oid->hash);
+       struct object *obj = lookup_object(r, oid);
        if (!obj)
-               return create_object(r, oid->hash,
-                                    alloc_tree_node(r));
+               return create_object(r, oid, alloc_tree_node(r));
        return object_as_type(r, obj, OBJ_TREE, 0);
 }
 
@@ -245,19 +244,7 @@ void free_tree_buffer(struct tree *tree)
 
 struct tree *parse_tree_indirect(const struct object_id *oid)
 {
-       struct object *obj = parse_object(the_repository, oid);
-       do {
-               if (!obj)
-                       return NULL;
-               if (obj->type == OBJ_TREE)
-                       return (struct tree *) obj;
-               else if (obj->type == OBJ_COMMIT)
-                       obj = &(get_commit_tree(((struct commit *)obj))->object);
-               else if (obj->type == OBJ_TAG)
-                       obj = ((struct tag *) obj)->tagged;
-               else
-                       return NULL;
-               if (!obj->parsed)
-                       parse_object(the_repository, &obj->oid);
-       } while (1);
+       struct repository *r = the_repository;
+       struct object *obj = parse_object(r, oid);
+       return (struct tree *)repo_peel_to_type(r, NULL, 0, obj, OBJ_TREE);
 }