[libgit2-glib] Bind git_reference_dwim
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgit2-glib] Bind git_reference_dwim
- Date: Wed, 5 Aug 2015 17:12:53 +0000 (UTC)
commit 011ef056502fffd6c6c27dfa0722f4e7634b5236
Author: Jesse van den Kieboom <jessevdk gnome org>
Date: Wed Aug 5 19:12:17 2015 +0200
Bind git_reference_dwim
libgit2-glib/ggit-repository.c | 39 +++++++++++++++++++++++++++++++++++++++
libgit2-glib/ggit-repository.h | 4 ++++
2 files changed, 43 insertions(+), 0 deletions(-)
---
diff --git a/libgit2-glib/ggit-repository.c b/libgit2-glib/ggit-repository.c
index ff9c2a8..af0df9e 100644
--- a/libgit2-glib/ggit-repository.c
+++ b/libgit2-glib/ggit-repository.c
@@ -735,6 +735,45 @@ ggit_repository_lookup_reference (GgitRepository *repository,
}
/**
+ * ggit_repository_lookup_reference_dwim:
+ * @repository: a #GgitRepository.
+ * @short_name: the short name for the reference (e.g. master, v0.1.0, ...).
+ * @error: a #GError for error reporting, or %NULL.
+ *
+ * Lookups a reference by its short name in @repository applying the git precendence
+ * rules to the given shorthand to determine which reference the user is referring to.
+ * The returned #GgitRef must be freed with g_object_unref().
+ *
+ * Returns: (transfer full): the searched reference.
+ */
+GgitRef *
+ggit_repository_lookup_reference_dwim (GgitRepository *repository,
+ const gchar *short_name,
+ GError **error)
+{
+ GgitRef *ref = NULL;
+ git_reference *reference;
+ gint ret;
+
+ g_return_val_if_fail (GGIT_IS_REPOSITORY (repository), NULL);
+ g_return_val_if_fail (short_name != NULL, NULL);
+
+ ret = git_reference_dwim (&reference, _ggit_native_get (repository),
+ short_name);
+
+ if (ret == GIT_OK)
+ {
+ ref = _ggit_ref_wrap (reference, FALSE);
+ }
+ else
+ {
+ _ggit_error_set (error, ret);
+ }
+
+ return ref;
+}
+
+/**
* ggit_repository_create_reference:
* @repository: a #GgitRepository.
* @name: the name for the new #GgitRef.
diff --git a/libgit2-glib/ggit-repository.h b/libgit2-glib/ggit-repository.h
index b9e00ad..2c933a1 100644
--- a/libgit2-glib/ggit-repository.h
+++ b/libgit2-glib/ggit-repository.h
@@ -98,6 +98,10 @@ GgitRef *ggit_repository_lookup_reference (GgitRepository *re
const gchar *name,
GError **error);
+GgitRef *ggit_repository_lookup_reference_dwim (GgitRepository *repository,
+ const gchar *short_name,
+ GError **error);
+
GgitRef *ggit_repository_create_reference (GgitRepository *repository,
const gchar *name,
GgitOId *oid,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]