From d8057a5b0ed644b1f72a4eb80f82da7ce8977958 Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Mon, 27 Aug 2012 11:53:59 -0700 Subject: Make git_object_peel a bit smarter This expands the types of peeling that `git_object_peel` knows how to do to include TAG -> BLOB peeling, and makes the errors slightly more consistent depending on the situation. It also adds a new special behavior where peeling to ANY will peel until the object type changes (e.g. chases TAGs to a non-TAG). Using this expanded peeling, this replaces peeling code that was embedded in `git_tag_peel` and `git_reset`. --- src/tag.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) (limited to 'src/tag.c') diff --git a/src/tag.c b/src/tag.c index 463619f63..6495d470f 100644 --- a/src/tag.c +++ b/src/tag.c @@ -445,20 +445,5 @@ int git_tag_list(git_strarray *tag_names, git_repository *repo) int git_tag_peel(git_object **tag_target, git_tag *tag) { - int error; - git_object *target; - - assert(tag_target && tag); - - if (git_tag_target(&target, tag) < 0) - return -1; - - if (git_object_type(target) == GIT_OBJ_TAG) { - error = git_tag_peel(tag_target, (git_tag *)target); - git_object_free(target); - return error; - } - - *tag_target = target; - return 0; + return git_object_peel(tag_target, (git_object *)tag, GIT_OBJ_ANY); } -- cgit v1.2.3