Skip to content

Commit d4b682f

Browse files
committed
Merge branch 'rs/parse-tree-indirect' into jch
Code cleanup. * rs/parse-tree-indirect: tree: simplify parse_tree_indirect()
2 parents 920e142 + 1577dc0 commit d4b682f

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

tree.c

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -244,19 +244,7 @@ void free_tree_buffer(struct tree *tree)
244244

245245
struct tree *parse_tree_indirect(const struct object_id *oid)
246246
{
247-
struct object *obj = parse_object(the_repository, oid);
248-
do {
249-
if (!obj)
250-
return NULL;
251-
if (obj->type == OBJ_TREE)
252-
return (struct tree *) obj;
253-
else if (obj->type == OBJ_COMMIT)
254-
obj = &(get_commit_tree(((struct commit *)obj))->object);
255-
else if (obj->type == OBJ_TAG)
256-
obj = ((struct tag *) obj)->tagged;
257-
else
258-
return NULL;
259-
if (!obj->parsed)
260-
parse_object(the_repository, &obj->oid);
261-
} while (1);
247+
struct repository *r = the_repository;
248+
struct object *obj = parse_object(r, oid);
249+
return (struct tree *)repo_peel_to_type(r, NULL, 0, obj, OBJ_TREE);
262250
}

0 commit comments

Comments
 (0)