Commit e2e3943d by Edward Thomson Committed by GitHub

Merge pull request #4367 from pks-t/pks/peel-peeled-to-tag

refs: do not use peeled OID if peeling to a tag
parents 62ac3931 b112b1e9
......@@ -1360,7 +1360,13 @@ int git_reference_peel(
return peel_error(error, ref, "Cannot resolve reference");
}
if (!git_oid_iszero(&resolved->peel)) {
/*
* If we try to peel an object to a tag, we cannot use
* the fully peeled object, as that will always resolve
* to a commit. So we only want to use the peeled value
* if it is not zero and the target is not a tag.
*/
if (target_type != GIT_OBJ_TAG && !git_oid_iszero(&resolved->peel)) {
error = git_object_lookup(&target,
git_reference_owner(ref), &resolved->peel, GIT_OBJ_ANY);
} else {
......
......@@ -117,3 +117,15 @@ void test_refs_peel__can_peel_fully_peeled_packed_refs(void)
"0df1a5865c8abfc09f1f2182e6a31be550e99f07",
GIT_OBJ_COMMIT);
}
void test_refs_peel__can_peel_fully_peeled_tag_to_tag(void)
{
assert_peel_generic(g_peel_repo,
"refs/tags/tag-inside-tags", GIT_OBJ_TAG,
"c2596aa0151888587ec5c0187f261e63412d9e11",
GIT_OBJ_TAG);
assert_peel_generic(g_peel_repo,
"refs/foo/tag-outside-tags", GIT_OBJ_TAG,
"c2596aa0151888587ec5c0187f261e63412d9e11",
GIT_OBJ_TAG);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment