Remotes: Setter for url+pushurl; Getter for pushurl
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
diff --git a/include/git2/remote.h b/include/git2/remote.h
index 5c01949..6d4b6cc 100644
--- a/include/git2/remote.h
+++ b/include/git2/remote.h
@@ -80,6 +80,36 @@ GIT_EXTERN(const char *) git_remote_name(git_remote *remote);
GIT_EXTERN(const char *) git_remote_url(git_remote *remote);
/**
+ * Get the remote's url for pushing
+ *
+ * @param remote the remote
+ * @return a pointer to the url or NULL if no special url for pushing is set
+ */
+GIT_EXTERN(const char *) git_remote_pushurl(git_remote *remote);
+
+/**
+ * Set the remote's url
+ *
+ * Existing connections will not be updated.
+ *
+ * @param remote the remote
+ * @param url the url to set
+ * @return 0 or an error value
+ */
+GIT_EXTERN(int) git_remote_set_url(git_remote *remote, const char* url);
+
+/**
+ * Set the remote's url for pushing
+ *
+ * Existing connections will not be updated.
+ *
+ * @param remote the remote
+ * @param url the url to set or NULL to clear the pushurl
+ * @return 0 or an error value
+ */
+GIT_EXTERN(int) git_remote_set_pushurl(git_remote *remote, const char* url);
+
+/**
* Set the remote's fetch refspec
*
* @param remote the remote
diff --git a/src/remote.c b/src/remote.c
index bcc4ab5..cdd593c 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -269,6 +269,38 @@ const char *git_remote_url(git_remote *remote)
return remote->url;
}
+int git_remote_set_url(git_remote *remote, const char* url)
+{
+ assert(remote);
+ assert(url);
+
+ git__free(remote->url);
+ remote->url = git__strdup(url);
+ GITERR_CHECK_ALLOC(remote->url);
+
+ return 0;
+}
+
+const char *git_remote_pushurl(git_remote *remote)
+{
+ assert(remote);
+ return remote->pushurl;
+}
+
+int git_remote_set_pushurl(git_remote *remote, const char* url)
+{
+ assert(remote);
+
+ git__free(remote->pushurl);
+ if (url) {
+ remote->pushurl = git__strdup(url);
+ GITERR_CHECK_ALLOC(remote->pushurl);
+ } else {
+ remote->pushurl = NULL;
+ }
+ return 0;
+}
+
int git_remote_set_fetchspec(git_remote *remote, const char *spec)
{
git_refspec refspec;