[libgit2-glib] Add ggit_repository_revparse



commit 36dccdaafb337c72a3fdf53504e23a5ef988ab3e
Author: Jesse van den Kieboom <jesse vandenkieboom epfl ch>
Date:   Thu Jul 12 11:16:38 2012 +0200

    Add ggit_repository_revparse

 libgit2-glib/ggit-repository.c |   40 ++++++++++++++++++++++++++++++++++++++++
 libgit2-glib/ggit-repository.h |    4 ++++
 2 files changed, 44 insertions(+), 0 deletions(-)
---
diff --git a/libgit2-glib/ggit-repository.c b/libgit2-glib/ggit-repository.c
index 3d6b44f..591a44a 100644
--- a/libgit2-glib/ggit-repository.c
+++ b/libgit2-glib/ggit-repository.c
@@ -28,6 +28,7 @@
 #include <git2/remote.h>
 #include <git2/reset.h>
 #include <git2/submodule.h>
+#include <git2/revparse.h>
 
 #include "ggit-error.h"
 #include "ggit-oid.h"
@@ -467,6 +468,45 @@ ggit_repository_lookup (GgitRepository  *repository,
 }
 
 /**
+ * ggit_repository_revparse:
+ * @repository: a #GgitRepository.
+ * @spec: the revision specification.
+ * @error: a #GError.
+ *
+ * Find an object, as specified by a revision string. See `man gitrevisions`,
+ * or the documentation for `git rev-parse` for information on the syntax
+ * accepted.
+ *
+ * Returns: a #GgitObject or %NULL if the revision could not be found.
+ *
+ **/
+GgitObject *
+ggit_repository_revparse (GgitRepository  *repository,
+                          const gchar     *spec,
+                          GError         **error)
+{
+	GgitObject *object = NULL;
+	git_object *obj = NULL;
+	gint ret;
+
+	g_return_val_if_fail (GGIT_IS_REPOSITORY (repository), NULL);
+	g_return_val_if_fail (spec != NULL, NULL);
+
+	ret = git_revparse_single (&obj, _ggit_native_get (repository), spec);
+
+	if (ret == GIT_OK)
+	{
+		object = ggit_utils_create_real_object (obj, TRUE);
+	}
+	else
+	{
+		_ggit_error_set (error, ret);
+	}
+
+	return object;
+}
+
+/**
  * ggit_repository_lookup_reference:
  * @repository: a #GgitRepository.
  * @name: the long name for the reference (e.g. HEAD, ref/heads/master, refs/tags/v0.1.0, ...).
diff --git a/libgit2-glib/ggit-repository.h b/libgit2-glib/ggit-repository.h
index 2450048..9860f6f 100644
--- a/libgit2-glib/ggit-repository.h
+++ b/libgit2-glib/ggit-repository.h
@@ -214,6 +214,10 @@ void                ggit_repository_reset              (GgitRepository
                                                         GgitResetType            reset_type,
                                                         GError                 **error);
 
+GgitObject         *ggit_repository_revparse          (GgitRepository        *repository,
+                                                       const gchar           *spec,
+                                                       GError               **error);
+
 G_END_DECLS
 
 #endif /* __GGIT_REPOSITORY_H__ */



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