aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-09-30 13:19:26 +0900
committerJunio C Hamano <gitster@pobox.com>2019-09-30 13:19:26 +0900
commit430439536bd8a334188460bbb9da9ce81ef95630 (patch)
tree07b403f7257f49cde8f59c686c9289252ed310f1
parent991fd97b9ab1d15e11c5c9b867c5e32e4232559b (diff)
parent1577dc0f7c1326ce59e1e97fad8a0b1e8c826203 (diff)
downloadgit-430439536bd8a334188460bbb9da9ce81ef95630.tar.xz
Merge branch 'rs/parse-tree-indirect'
Code cleanup. * rs/parse-tree-indirect: tree: simplify parse_tree_indirect()
-rw-r--r--tree.c18
1 files changed, 3 insertions, 15 deletions
diff --git a/tree.c b/tree.c
index 4720945e6a..1466bcc6a8 100644
--- a/tree.c
+++ b/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);
}