summaryrefslogtreecommitdiff
path: root/src/annotated_commit.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2018-12-14 14:43:09 +0100
committerCarlos Martín Nieto <cmn@dwim.me>2018-12-14 14:47:07 +0100
commit6ea9381b01ad18616e009ed72bd9266d4a37865b (patch)
treead9c00f6bfe8ad5dca5d2049953fad433cd2953f /src/annotated_commit.c
parent5bd78c48e10a8a025b17a53ed700a42d1b594c08 (diff)
downloadlibgit2-6ea9381b01ad18616e009ed72bd9266d4a37865b.tar.gz
annotated_commit: peel to commit instead of assuming we have onecmn/annotated-from-tag
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.
Diffstat (limited to 'src/annotated_commit.c')
-rw-r--r--src/annotated_commit.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/annotated_commit.c b/src/annotated_commit.c
index 3d982cbb4..d95d44093 100644
--- a/src/annotated_commit.c
+++ b/src/annotated_commit.c
@@ -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;
}