[libgit2-glib] Add `git_repository_set_head_detached()` to the public API



commit eff1374ee122f18ea235cbc8464c7433636e9a35
Author: madmurphy <madmurphy333 gmail com>
Date:   Sun May 16 00:17:21 2021 +0200

    Add `git_repository_set_head_detached()` to the public API

 libgit2-glib/ggit-repository.c | 31 +++++++++++++++++++++++++++++++
 libgit2-glib/ggit-repository.h |  4 ++++
 2 files changed, 35 insertions(+)
---
diff --git a/libgit2-glib/ggit-repository.c b/libgit2-glib/ggit-repository.c
index a2a4301..1750ae2 100644
--- a/libgit2-glib/ggit-repository.c
+++ b/libgit2-glib/ggit-repository.c
@@ -942,6 +942,37 @@ ggit_repository_set_head (GgitRepository   *repository,
        return TRUE;
 }
 
+/**
+ * ggit_repository_set_head_detached:
+ * @repository: a #GgitRepository.
+ * @ref_name: canonical name of the reference HEAD should point to.
+ * @error: a #GError for error reporting, or %NULL.
+ *
+ * Returns: %TRUE if head was successfully set, %FALSE otherwise.
+ *
+ **/
+gboolean
+ggit_repository_set_head_detached (GgitRepository  *repository,
+                                   GgitOId         *oid,
+                                   GError         **error)
+{
+       gint ret;
+
+       g_return_val_if_fail (GGIT_IS_REPOSITORY (repository), FALSE);
+       g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+       ret = git_repository_set_head_detached (_ggit_native_get(repository),
+                                                (const git_oid *)_ggit_oid_get_oid(oid));
+
+       if (ret != GIT_OK)
+       {
+               _ggit_error_set (error, ret);
+               return FALSE;
+       }
+
+       return TRUE;
+}
+
 /**
  * ggit_repository_discover:
  * @location: the base location where the lookup starts.
diff --git a/libgit2-glib/ggit-repository.h b/libgit2-glib/ggit-repository.h
index e522e0d..361afba 100644
--- a/libgit2-glib/ggit-repository.h
+++ b/libgit2-glib/ggit-repository.h
@@ -301,6 +301,10 @@ gboolean            ggit_repository_set_head          (GgitRepository        *re
                                                        const gchar           *ref_name,
                                                        GError               **error);
 
+gboolean            ggit_repository_set_head_detached (GgitRepository        *repository,
+                                                       GgitOId               *oid,
+                                                       GError               **error);
+
 GFile              *ggit_repository_discover          (GFile                 *location,
                                                        GError               **error);
 


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