summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarlos Martín Nieto <carlos@cmartin.tk>2012-06-04 15:10:29 -0700
committerCarlos Martín Nieto <carlos@cmartin.tk>2012-06-04 15:10:29 -0700
commit01dbe273c9b6f86a613b67cee27212cf4bacf4c0 (patch)
treec9ab13794bcbfead83d9841cba9dd388ecebdb15 /src
parent8856849c1c8d7fd4c6c8768902845a2b96c29794 (diff)
parentd27bf6656158c6be1eca7e8c5e87b4d39958b18d (diff)
downloadlibgit2-01dbe273c9b6f86a613b67cee27212cf4bacf4c0.tar.gz
Merge pull request #737 from nulltoken/topic/git_remote_add_refspec
Remotes and refspecs
Diffstat (limited to 'src')
-rw-r--r--src/refspec.c7
-rw-r--r--src/remote.c6
2 files changed, 12 insertions, 1 deletions
diff --git a/src/refspec.c b/src/refspec.c
index 697b1bf87..b6b1158b7 100644
--- a/src/refspec.c
+++ b/src/refspec.c
@@ -53,6 +53,13 @@ const char *git_refspec_dst(const git_refspec *refspec)
return refspec == NULL ? NULL : refspec->dst;
}
+int git_refspec_force(const git_refspec *refspec)
+{
+ assert(refspec);
+
+ return refspec->force;
+}
+
int git_refspec_src_matches(const git_refspec *refspec, const char *refname)
{
if (refspec == NULL || refspec->src == NULL)
diff --git a/src/remote.c b/src/remote.c
index 9740344f8..5993ad02b 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -189,6 +189,8 @@ int git_remote_save(const git_remote *remote)
git_buf_clear(&buf);
git_buf_clear(&value);
git_buf_printf(&buf, "remote.%s.fetch", remote->name);
+ if (remote->fetch.force)
+ git_buf_putc(&value, '+');
git_buf_printf(&value, "%s:%s", remote->fetch.src, remote->fetch.dst);
if (git_buf_oom(&buf) || git_buf_oom(&value))
return -1;
@@ -201,6 +203,8 @@ int git_remote_save(const git_remote *remote)
git_buf_clear(&buf);
git_buf_clear(&value);
git_buf_printf(&buf, "remote.%s.push", remote->name);
+ if (remote->push.force)
+ git_buf_putc(&value, '+');
git_buf_printf(&value, "%s:%s", remote->push.src, remote->push.dst);
if (git_buf_oom(&buf) || git_buf_oom(&value))
return -1;
@@ -490,7 +494,7 @@ int git_remote_add(git_remote **out, git_repository *repo, const char *name, con
{
git_buf buf = GIT_BUF_INIT;
- if (git_buf_printf(&buf, "refs/heads/*:refs/remotes/%s/*", name) < 0)
+ if (git_buf_printf(&buf, "+refs/heads/*:refs/remotes/%s/*", name) < 0)
return -1;
if (git_remote_new(out, repo, name, url, git_buf_cstr(&buf)) < 0)