Commit 6ea9381b by Carlos Martín Nieto

annotated_commit: peel to commit instead of assuming we have one

We want to allow the creation of annotated commits out of annotated tags and for
that we have to peel the reference all the way to the commit instead of stopping
at the first id it provides.
parent 5bd78c48
......@@ -123,19 +123,19 @@ int git_annotated_commit_from_ref(
git_repository *repo,
const git_reference *ref)
{
git_reference *resolved;
git_object *peeled;
int error = 0;
assert(out && repo && ref);
*out = NULL;
if ((error = git_reference_resolve(&resolved, ref)) < 0)
if ((error = git_reference_peel(&peeled, ref, GIT_OBJ_COMMIT)) < 0)
return error;
error = annotated_commit_init_from_id(out,
repo,
git_reference_target(resolved),
git_object_id(peeled),
git_reference_name(ref));
if (!error) {
......@@ -143,7 +143,7 @@ int git_annotated_commit_from_ref(
GITERR_CHECK_ALLOC((*out)->ref_name);
}
git_reference_free(resolved);
git_object_free(peeled);
return error;
}
......
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