[libgit2-glib] Added ggit_repository_get_descendant_of



commit ef62523a85ae0937ea031612fca128438b4a7127
Author: Jesse van den Kieboom <jessevdk gnome org>
Date:   Wed Jun 25 10:43:30 2014 +0200

    Added ggit_repository_get_descendant_of

 libgit2-glib/ggit-repository.c |   45 ++++++++++++++++++++++++++++++++++++++++
 libgit2-glib/ggit-repository.h |    5 ++++
 2 files changed, 50 insertions(+), 0 deletions(-)
---
diff --git a/libgit2-glib/ggit-repository.c b/libgit2-glib/ggit-repository.c
index c38ef0f..2dfc161 100644
--- a/libgit2-glib/ggit-repository.c
+++ b/libgit2-glib/ggit-repository.c
@@ -2165,6 +2165,51 @@ ggit_repository_get_ahead_behind (GgitRepository  *repository,
 }
 
 /**
+ * ggit_repository_get_descendant_of:
+ * @repository: a #GgitRepository.
+ * @commit: the commit.
+ * @ancestor: the ancestor.
+ * @error: a #GError for error reporting, or %NULL.
+ *
+ * Check whether @com mit is a descendant of @ancestor. Note that if this
+ * function returns %FALSE, an error might have occurred. If so, @error will
+ * be set appropriately.
+ *
+ * Returns: %TRUE if @commit is a descendant of @ancestor, or %FALSE otherwise.
+ *
+ */
+gboolean
+ggit_repository_get_descendant_of (GgitRepository  *repository,
+                                   GgitOId         *commit,
+                                   GgitOId         *ancestor,
+                                   GError         **error)
+{
+       gint ret;
+
+       g_return_val_if_fail (GGIT_IS_REPOSITORY (repository), FALSE);
+       g_return_val_if_fail (commit != NULL, FALSE);
+       g_return_val_if_fail (ancestor != NULL, FALSE);
+       g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+       ret = git_graph_descendant_of (_ggit_native_get (repository),
+                                      _ggit_oid_get_oid (commit),
+                                      _ggit_oid_get_oid (ancestor));
+
+       if (ret == 1)
+       {
+               return TRUE;
+       }
+
+       if (ret != GIT_OK)
+       {
+               _ggit_error_set (error, ret);
+
+       }
+
+       return FALSE;
+}
+
+/**
  * ggit_repository_create_blob:
  * @repository: a #GgitRepository.
  *
diff --git a/libgit2-glib/ggit-repository.h b/libgit2-glib/ggit-repository.h
index 4db326c..7efbc37 100644
--- a/libgit2-glib/ggit-repository.h
+++ b/libgit2-glib/ggit-repository.h
@@ -340,6 +340,11 @@ void                ggit_repository_get_ahead_behind  (GgitRepository        *re
                                                        gsize                 *behind,
                                                        GError               **error);
 
+gboolean            ggit_repository_get_descendant_of (GgitRepository        *repository,
+                                                       GgitOId               *commit,
+                                                       GgitOId               *ancestor,
+                                                       GError               **error);
+
 GgitBlame          *ggit_repository_blame_file        (GgitRepository        *repository,
                                                        GFile                 *file,
                                                        GgitBlameOptions      *blame_options,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]