Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2013-04-20 06:43:28 +0400
committerCarlos Martín Nieto <cmn@dwim.me>2013-04-20 19:54:13 +0400
commit4330ab26b53c0e1bf8cbb5e65704f65e3d116eba (patch)
tree14bf8d854854298bfe43b3a02c8c26f59377c988 /src/clone.c
parente5a27f039ee3ae1291fd5084707c3f9c168f10ba (diff)
remote: handle multiple refspecs
A remote can have a multitude of refspecs. Up to now our git_remote's have supported a single one for each fetch and push out of simplicity to get something working. Let the remotes and internal code know about multiple remotes and get the tests passing with them. Instead of setting a refspec, the external users can clear all and add refspecs. This should be enough for most uses, though we're still missing a querying function.
Diffstat (limited to 'src/clone.c')
-rw-r--r--src/clone.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/clone.c b/src/clone.c
index 0bbccd44b..cb4053736 100644
--- a/src/clone.c
+++ b/src/clone.c
@@ -187,6 +187,7 @@ static int get_head_callback(git_remote_head *head, void *payload)
static int update_head_to_remote(git_repository *repo, git_remote *remote)
{
int retcode = -1;
+ git_refspec dummy_spec;
git_remote_head *remote_head;
struct head_info head_info;
git_buf remote_master_name = GIT_BUF_INIT;
@@ -211,8 +212,13 @@ static int update_head_to_remote(git_repository *repo, git_remote *remote)
git_oid_cpy(&head_info.remote_head_oid, &remote_head->oid);
git_buf_init(&head_info.branchname, 16);
head_info.repo = repo;
- head_info.refspec = git_remote_fetchspec(remote);
+ head_info.refspec = git_remote__matching_refspec(remote, GIT_REFS_HEADS_MASTER_FILE);
head_info.found = 0;
+
+ if (head_info.refspec == NULL) {
+ memset(&dummy_spec, 0, sizeof(git_refspec));
+ head_info.refspec = &dummy_spec;
+ }
/* Determine the remote tracking reference name from the local master */
if (git_refspec_transform_r(
@@ -318,11 +324,11 @@ static int create_and_configure_origin(
goto on_error;
if (options->fetch_spec &&
- (error = git_remote_set_fetchspec(origin, options->fetch_spec)) < 0)
+ (error = git_remote_add_fetchspec(origin, options->fetch_spec)) < 0)
goto on_error;
if (options->push_spec &&
- (error = git_remote_set_pushspec(origin, options->push_spec)) < 0)
+ (error = git_remote_add_pushspec(origin, options->push_spec)) < 0)
goto on_error;
if (options->pushurl &&