summaryrefslogtreecommitdiff
path: root/src/annotated_commit.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2015-03-17 10:21:28 -0400
committerEdward Thomson <ethomson@edwardthomson.com>2015-03-17 10:21:28 -0400
commit9bbc8f350b80a5a6e94651ec667cf9e5d545b317 (patch)
treea472cf837ffc1dbe7ddb81be0a773ca74f27b7f0 /src/annotated_commit.c
parent7800048afbb002d0003b54fcc09c98d0d3249949 (diff)
parent8acf058ff708582e9bbfe04e297d3b17a4d5c2e8 (diff)
downloadlibgit2-9bbc8f350b80a5a6e94651ec667cf9e5d545b317.tar.gz
Merge pull request #2962 from libgit2/cmn/reflog-annotated
Add annotated versions of ref-modying functions
Diffstat (limited to 'src/annotated_commit.c')
-rw-r--r--src/annotated_commit.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/annotated_commit.c b/src/annotated_commit.c
index 0a917802a..3f2d2ed17 100644
--- a/src/annotated_commit.c
+++ b/src/annotated_commit.c
@@ -12,6 +12,7 @@
#include "git2/refs.h"
#include "git2/repository.h"
#include "git2/annotated_commit.h"
+#include "git2/revparse.h"
static int annotated_commit_init(
git_annotated_commit **out,
@@ -96,6 +97,33 @@ int git_annotated_commit_from_fetchhead(
return annotated_commit_init(out, repo, id, branch_name, remote_url);
}
+int git_annotated_commit_from_revspec(
+ git_annotated_commit **out,
+ git_repository *repo,
+ const char *revspec)
+{
+ git_object *obj, *commit;
+ int error;
+
+ assert(out && repo && revspec);
+
+ if ((error = git_revparse_single(&obj, repo, revspec)) < 0)
+ return error;
+
+ if ((error = git_object_peel(&commit, obj, GIT_OBJ_COMMIT))) {
+ git_object_free(obj);
+ return error;
+ }
+
+ error = annotated_commit_init(out, repo, git_object_id(commit), revspec, NULL);
+
+ git_object_free(obj);
+ git_object_free(commit);
+
+ return error;
+}
+
+
const git_oid *git_annotated_commit_id(
const git_annotated_commit *annotated_commit)
{