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`.
This commit is contained in:
Russell Belfer
2012-08-27 11:53:59 -07:00
parent 2b175ca972
commit d8057a5b0e
6 changed files with 53 additions and 74 deletions
+7 -4
View File
@@ -168,11 +168,14 @@ GIT_EXTERN(int) git_object_typeisloose(git_otype type);
GIT_EXTERN(size_t) git_object__size(git_otype type);
/**
* Recursively peel an object until an object of the specified
* type is met
* Recursively peel an object until an object of the specified type is met.
*
* The retrieved `peeled` object is owned by the repository
* and should be closed with the `git_object_free` method.
* The retrieved `peeled` object is owned by the repository and should be
* closed with the `git_object_free` method.
*
* If you pass `GIT_OBJ_ANY` as the target type, then the object will be
* peeled until the type changes (e.g. a tag will be chased until the
* referenced object is no longer a tag).
*
* @param peeled Pointer to the peeled git_object
* @param object The object to be processed
+1 -1
View File
@@ -37,7 +37,7 @@ GIT_BEGIN_DECL
*
* @return GIT_SUCCESS or an error code
*/
GIT_EXTERN(int) git_reset(git_repository *repo, const git_object *target, git_reset_type reset_type);
GIT_EXTERN(int) git_reset(git_repository *repo, git_object *target, git_reset_type reset_type);
/** @} */
GIT_END_DECL