[libgit2-glib] Bind ggit_commit_get_nth_ancestor
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgit2-glib] Bind ggit_commit_get_nth_ancestor
- Date: Thu, 12 Jul 2012 18:36:49 +0000 (UTC)
commit 7cecf79826983722fba37b2ea91c2de51ac86ac2
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Thu Jul 12 20:25:01 2012 +0200
Bind ggit_commit_get_nth_ancestor
libgit2-glib/ggit-commit.c | 36 ++++++++++++++++++++++++++++++++++++
libgit2-glib/ggit-commit.h | 14 +++++++++-----
2 files changed, 45 insertions(+), 5 deletions(-)
---
diff --git a/libgit2-glib/ggit-commit.c b/libgit2-glib/ggit-commit.c
index 7392532..1237a29 100644
--- a/libgit2-glib/ggit-commit.c
+++ b/libgit2-glib/ggit-commit.c
@@ -20,6 +20,7 @@
#include <git2/errors.h>
+#include "ggit-error.h"
#include "ggit-commit.h"
#include "ggit-signature.h"
#include "ggit-oid.h"
@@ -450,4 +451,39 @@ ggit_commit_get_tree_id (GgitCommit *commit)
return _ggit_oid_new (oid);
}
+/**
+ * ggit_commit_get_nth_ancestor:
+ * @commit: a #GgitCommit
+ * @n: the requested ancestor
+ * @error: a #GError for error reporting, or %NULL.
+ *
+ * Gets the commit object that is the <n>th generation ancestor
+ * of the named commit object, following only the first parents.
+ * Passing %0 to the @n parameter returns another instance of @commit.
+ *
+ * Returns: (transfer full): the @n ancestor commit.
+ */
+GgitCommit *
+ggit_commit_get_nth_ancestor (GgitCommit *commit,
+ guint n,
+ GError **error)
+{
+ git_commit *ancestor;
+ gint ret;
+
+ g_return_val_if_fail (GGIT_IS_COMMIT (commit), NULL);
+ g_return_val_if_fail (n >= 0, NULL);
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+ ret = git_commit_nth_gen_ancestor (&ancestor, _ggit_native_get (commit), n);
+
+ if (ret != GIT_OK)
+ {
+ _ggit_error_set (error, ret);
+ return NULL;
+ }
+
+ return _ggit_commit_wrap (ancestor, TRUE);
+}
+
/* ex:set ts=8 noet: */
diff --git a/libgit2-glib/ggit-commit.h b/libgit2-glib/ggit-commit.h
index 0726841..5947578 100644
--- a/libgit2-glib/ggit-commit.h
+++ b/libgit2-glib/ggit-commit.h
@@ -75,7 +75,7 @@ GgitSignature *ggit_commit_get_committer (GgitCommit *commit
GgitSignature *ggit_commit_get_author (GgitCommit *commit);
-GgitCommitParents * ggit_commit_get_parents (GgitCommit *commit);
+GgitCommitParents *ggit_commit_get_parents (GgitCommit *commit);
@@ -84,15 +84,19 @@ void ggit_commit_parents_unref (GgitCommitParents *parent
guint ggit_commit_parents_size (GgitCommitParents *parents);
-GgitCommit * ggit_commit_parents_get (GgitCommitParents *parents,
+GgitCommit *ggit_commit_parents_get (GgitCommitParents *parents,
guint idx);
-GgitOId * ggit_commit_parents_get_id (GgitCommitParents *parents,
+GgitOId *ggit_commit_parents_get_id (GgitCommitParents *parents,
guint idx);
-GgitTree * ggit_commit_get_tree (GgitCommit *commit);
+GgitTree *ggit_commit_get_tree (GgitCommit *commit);
-GgitOId * ggit_commit_get_tree_id (GgitCommit *commit);
+GgitOId *ggit_commit_get_tree_id (GgitCommit *commit);
+
+GgitCommit *ggit_commit_get_nth_ancestor (GgitCommit *commit,
+ guint n,
+ GError **error);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]