[libgit2-glib/wip/adwaitrawat/remote-operations: 3/3] Added ggit_repository_rename_remote
- From: Alberto Fanjul <albfan src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgit2-glib/wip/adwaitrawat/remote-operations: 3/3] Added ggit_repository_rename_remote
- Date: Sun, 30 Jun 2019 08:05:11 +0000 (UTC)
commit 50ef1d47c01cb3d0a57d372c658f7e0a1b92c6aa
Author: Adwait Rawat <adwait rawat gmail com>
Date: Thu Jun 20 18:49:48 2019 +0900
Added ggit_repository_rename_remote
libgit2-glib/ggit-repository.c | 39 +++++++++++++++++++++++++++++++++++++++
libgit2-glib/ggit-repository.h | 5 +++++
2 files changed, 44 insertions(+)
---
diff --git a/libgit2-glib/ggit-repository.c b/libgit2-glib/ggit-repository.c
index cac64c5..e09f729 100644
--- a/libgit2-glib/ggit-repository.c
+++ b/libgit2-glib/ggit-repository.c
@@ -2227,6 +2227,45 @@ ggit_repository_set_remote_url (GgitRepository *repository,
return TRUE;
}
+/**
+ * ggit_repository_rename_remote:
+ * @repository: a #GgitRepository.
+ * @name: the remote name to be renamed.
+ * @new_name: new name of the remote.
+ * @error: a #GError for error reporting, or %NULL.
+ *
+ * Rename the remote of @repository from @name to @new_name.
+ *
+ * Returns: (transfer full) (nullable): non-default refspecs that
+ * cannot be renamed.
+ */
+gchar **
+ggit_repository_rename_remote (GgitRepository *repository,
+ const gchar *name,
+ const gchar *new_name,
+ GError **error)
+{
+ gint ret;
+ git_strarray problems;
+
+ g_return_val_if_fail (GGIT_IS_REPOSITORY (repository), NULL);
+ g_return_val_if_fail (name != NULL, NULL);
+ g_return_val_if_fail (new_name != NULL, NULL);
+
+ ret = git_remote_rename (&problems,
+ _ggit_native_get (repository),
+ name,
+ new_name);
+
+ if (ret != GIT_OK)
+ {
+ _ggit_error_set (error, ret);
+ return NULL;
+ }
+
+ return ggit_utils_get_str_array_from_git_strarray (&problems);
+}
+
/**
* ggit_repository_list_remotes:
* @repository: a #GgitRepository.
diff --git a/libgit2-glib/ggit-repository.h b/libgit2-glib/ggit-repository.h
index d351fda..0b3c7ca 100644
--- a/libgit2-glib/ggit-repository.h
+++ b/libgit2-glib/ggit-repository.h
@@ -276,6 +276,11 @@ gboolean ggit_repository_set_remote_url (GgitRepository *re
const gchar *url,
GError **error);
+gchar **ggit_repository_rename_remote (GgitRepository *repository,
+ const gchar *name,
+ const gchar *new_name,
+ 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]