about summary refs log tree commit diff
path: root/third_party/git/tree.c
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/git/tree.c')
-rw-r--r--third_party/git/tree.c18
1 files changed, 3 insertions, 15 deletions
diff --git a/third_party/git/tree.c b/third_party/git/tree.c
index 4720945e6a68..1466bcc6a8cf 100644
--- a/third_party/git/tree.c
+++ b/third_party/git/tree.c
@@ -244,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);
 }