[libgit2-glib/wip/adwaitrawat/remote-operations: 2/3] Added ggit_repository_set_remote_url



commit a5a35af1c00133c419f570eabae227eb2428be8f
Author: Adwait Rawat <adwait rawat gmail com>
Date:   Thu Jun 20 17:20:18 2019 +0900

    Added ggit_repository_set_remote_url

 libgit2-glib/ggit-repository.c | 36 ++++++++++++++++++++++++++++++++++++
 libgit2-glib/ggit-repository.h |  5 +++++
 2 files changed, 41 insertions(+)
---
diff --git a/libgit2-glib/ggit-repository.c b/libgit2-glib/ggit-repository.c
index 282747e..cac64c5 100644
--- a/libgit2-glib/ggit-repository.c
+++ b/libgit2-glib/ggit-repository.c
@@ -2191,6 +2191,42 @@ ggit_repository_remove_remote (GgitRepository   *repository,
        return TRUE;
 }
 
+/**
+ * ggit_repository_set_remote_url:
+ * @repository: a #GgitRepository.
+ * @remote: the remote name who's url is to be set.
+ * @url: url of the remote.
+ * @error: a #GError for error reporting, or %NULL.
+ *
+ * Sets url for the @remote from the @repository.
+ *
+ * Returns: %TRUE if there was no error, %FALSE otherwise
+ */
+gboolean
+ggit_repository_set_remote_url (GgitRepository   *repository,
+                                const gchar      *remote,
+                                const gchar      *url,
+                                GError          **error)
+{
+       gint ret;
+
+       g_return_val_if_fail (GGIT_IS_REPOSITORY (repository), FALSE);
+       g_return_val_if_fail (remote != NULL, FALSE);
+       g_return_val_if_fail (url != NULL, FALSE);
+
+       ret = git_remote_set_url(_ggit_native_get (repository),
+                                                  remote,
+                                                  url);
+
+       if (ret != GIT_OK)
+       {
+               _ggit_error_set (error, ret);
+               return FALSE;
+       }
+
+       return TRUE;
+}
+
 /**
  * ggit_repository_list_remotes:
  * @repository: a #GgitRepository.
diff --git a/libgit2-glib/ggit-repository.h b/libgit2-glib/ggit-repository.h
index 438f7e0..d351fda 100644
--- a/libgit2-glib/ggit-repository.h
+++ b/libgit2-glib/ggit-repository.h
@@ -271,6 +271,11 @@ gboolean            ggit_repository_remove_remote     (GgitRepository        *re
                                                        const gchar           *name,
                                                        GError               **error);
 
+gboolean            ggit_repository_set_remote_url    (GgitRepository        *repository,
+                                                       const gchar           *remote,
+                                                       const gchar           *url,
+                                                       GError               **error);
+
 gchar             **ggit_repository_list_remotes      (GgitRepository        *repository,
                                                        GError               **error);
 


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