summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSascha Cunz <Sascha@BabbelBox.org>2012-07-25 01:32:31 +0200
committerSascha Cunz <Sascha@BabbelBox.org>2012-07-26 22:36:43 +0200
commit3ed4b5012bbdba844ae1ffdff884a1eb630e9884 (patch)
tree96357a598aa7734a427004f6b6a6724ce952695d /src
parentcb020f0d9936f221c6bd6f873994e8978657cd28 (diff)
downloadlibgit2-3ed4b5012bbdba844ae1ffdff884a1eb630e9884.tar.gz
Remotes: Load/Save for fetch.foo.pushurl
Diffstat (limited to 'src')
-rw-r--r--src/remote.c32
-rw-r--r--src/remote.h1
2 files changed, 33 insertions, 0 deletions
diff --git a/src/remote.c b/src/remote.c
index c0819ffeb..bcc4ab5b4 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -131,6 +131,26 @@ int git_remote_load(git_remote **out, git_repository *repo, const char *name)
GITERR_CHECK_ALLOC(remote->url);
git_buf_clear(&buf);
+ if (git_buf_printf(&buf, "remote.%s.pushurl", name) < 0) {
+ error = -1;
+ goto cleanup;
+ }
+
+ error = git_config_get_string(&val, config, git_buf_cstr(&buf));
+ if (error == GIT_ENOTFOUND)
+ error = 0;
+
+ if (error < 0) {
+ error = -1;
+ goto cleanup;
+ }
+
+ if (val) {
+ remote->pushurl = git__strdup(val);
+ GITERR_CHECK_ALLOC(remote->pushurl);
+ }
+
+ git_buf_clear(&buf);
if (git_buf_printf(&buf, "remote.%s.fetch", name) < 0) {
error = -1;
goto cleanup;
@@ -187,6 +207,17 @@ int git_remote_save(const git_remote *remote)
return -1;
}
+ if (remote->pushurl) {
+ git_buf_clear(&buf);
+ if (git_buf_printf(&buf, "remote.%s.pushurl", remote->name) < 0)
+ return -1;
+
+ if (git_config_set_string(config, git_buf_cstr(&buf), remote->pushurl) < 0) {
+ git_buf_free(&buf);
+ return -1;
+ }
+ }
+
if (remote->fetch.src != NULL && remote->fetch.dst != NULL) {
git_buf_clear(&buf);
git_buf_clear(&value);
@@ -429,6 +460,7 @@ void git_remote_free(git_remote *remote)
git__free(remote->push.src);
git__free(remote->push.dst);
git__free(remote->url);
+ git__free(remote->pushurl);
git__free(remote->name);
git__free(remote);
}
diff --git a/src/remote.h b/src/remote.h
index 0949ad434..abdaa5750 100644
--- a/src/remote.h
+++ b/src/remote.h
@@ -14,6 +14,7 @@
struct git_remote {
char *name;
char *url;
+ char *pushurl;
git_vector refs;
struct git_refspec fetch;
struct git_refspec push;