summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarlos Martín Nieto <carlos@cmartin.tk>2012-02-20 18:37:07 +0100
committerCarlos Martín Nieto <carlos@cmartin.tk>2012-02-20 18:42:05 +0100
commitbcb8c007f149da6d31a6c17c179f6f89ce823d2e (patch)
treeb36c1c99846ec4c5930a83fea3e7afc49729c31a /src
parent555c81f3356b8166c09f887450eac008b221cdc3 (diff)
downloadlibgit2-bcb8c007f149da6d31a6c17c179f6f89ce823d2e.tar.gz
Add git_remote_set_{fetch,push}spec()
Allow setting the fetch and push refspecs, which is useful for creating new refspecs.
Diffstat (limited to 'src')
-rw-r--r--src/remote.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/remote.c b/src/remote.c
index c10c33757..9733511cb 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -199,12 +199,50 @@ const char *git_remote_url(git_remote *remote)
return remote->url;
}
+int git_remote_set_fetchspec(git_remote *remote, const char *spec)
+{
+ int error;
+ git_refspec refspec;
+
+ assert(remote && spec);
+
+ error = refspec_parse(&refspec, spec);
+ if (error != GIT_SUCCESS)
+ return error;
+
+ git__free(remote->fetch.src);
+ git__free(remote->fetch.dst);
+ remote->fetch.src = refspec.src;
+ remote->fetch.dst = refspec.dst;
+
+ return GIT_SUCCESS;
+}
+
const git_refspec *git_remote_fetchspec(git_remote *remote)
{
assert(remote);
return &remote->fetch;
}
+int git_remote_set_pushspec(git_remote *remote, const char *spec)
+{
+ int error;
+ git_refspec refspec;
+
+ assert(remote && spec);
+
+ error = refspec_parse(&refspec, spec);
+ if (error != GIT_SUCCESS)
+ return error;
+
+ git__free(remote->push.src);
+ git__free(remote->push.dst);
+ remote->push.src = refspec.src;
+ remote->push.dst = refspec.dst;
+
+ return GIT_SUCCESS;
+}
+
const git_refspec *git_remote_pushspec(git_remote *remote)
{
assert(remote);