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
path: root/tests
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2015-04-23 07:51:34 +0300
committerCarlos Martín Nieto <cmn@dwim.me>2015-05-13 10:46:36 +0300
commit7725499072aaf4d9093c615fee5a65d8477100bc (patch)
treefc68cffcafe2d9e762729334dfe2f7a4ee15783e /tests
parent3fec548a989b09fc7a2c30f42b1d4fa123a8867e (diff)
remote: remove live changing of refspecs
The base refspecs changing can be a cause of confusion as to what is the current base refspec set and complicate saving the remote's configuration. Change `git_remote_add_{fetch,push}()` to update the configuration instead of an instance. This finally makes `git_remote_save()` a no-op, it will be removed in a later commit.
Diffstat (limited to 'tests')
-rw-r--r--tests/network/fetchlocal.c9
-rw-r--r--tests/network/remote/local.c1
-rw-r--r--tests/network/remote/remotes.c77
-rw-r--r--tests/online/clone.c9
-rw-r--r--tests/online/push.c6
-rw-r--r--tests/refs/branches/remote.c7
6 files changed, 25 insertions, 84 deletions
diff --git a/tests/network/fetchlocal.c b/tests/network/fetchlocal.c
index 73ccec031..06ee3dd36 100644
--- a/tests/network/fetchlocal.c
+++ b/tests/network/fetchlocal.c
@@ -358,16 +358,9 @@ static int remote_mirror_cb(git_remote **out, git_repository *repo,
GIT_UNUSED(payload);
- if ((error = git_remote_create(&remote, repo, name, url)) < 0)
+ if ((error = git_remote_create_with_fetchspec(&remote, repo, name, url, "+refs/*:refs/*")) < 0)
return error;
- git_remote_clear_refspecs(remote);
-
- if ((error = git_remote_add_fetch(remote, "+refs/*:refs/*")) < 0) {
- git_remote_free(remote);
- return error;
- }
-
*out = remote;
return 0;
}
diff --git a/tests/network/remote/local.c b/tests/network/remote/local.c
index bcde50cbb..21cb93c57 100644
--- a/tests/network/remote/local.c
+++ b/tests/network/remote/local.c
@@ -161,7 +161,6 @@ void test_network_remote_local__shorthand_fetch_refspec1(void)
git_reference *ref;
connect_to_local_repository(cl_fixture("testrepo.git"));
- git_remote_clear_refspecs(remote);
cl_git_pass(git_remote_fetch(remote, &array, NULL, NULL));
diff --git a/tests/network/remote/remotes.c b/tests/network/remote/remotes.c
index 819a22601..0da76da6c 100644
--- a/tests/network/remote/remotes.c
+++ b/tests/network/remote/remotes.c
@@ -115,9 +115,12 @@ void test_network_remote_remotes__add_fetchspec(void)
size = git_remote_refspec_count(_remote);
- cl_git_pass(git_remote_add_fetch(_remote, "refs/*:refs/*"));
-
+ cl_git_pass(git_remote_add_fetch(_repo, "test", "refs/*:refs/*"));
size++;
+
+ git_remote_free(_remote);
+ cl_git_pass(git_remote_lookup(&_remote, _repo, "test"));
+
cl_assert_equal_i((int)size, (int)git_remote_refspec_count(_remote));
_refspec = git_remote_get_refspec(_remote, size - 1);
@@ -156,8 +159,12 @@ void test_network_remote_remotes__add_pushspec(void)
size = git_remote_refspec_count(_remote);
- cl_git_pass(git_remote_add_push(_remote, "refs/*:refs/*"));
+ cl_git_pass(git_remote_add_push(_repo, "test", "refs/*:refs/*"));
size++;
+
+ git_remote_free(_remote);
+ cl_git_pass(git_remote_lookup(&_remote, _repo, "test"));
+
cl_assert_equal_i((int)size, (int)git_remote_refspec_count(_remote));
_refspec = git_remote_get_refspec(_remote, size - 1);
@@ -168,60 +175,6 @@ void test_network_remote_remotes__add_pushspec(void)
cl_assert_equal_b(_refspec->push, true);
}
-void test_network_remote_remotes__save(void)
-{
- git_strarray array;
- const char *fetch_refspec1 = "refs/heads/ns1/*:refs/remotes/upstream/ns1/*";
- const char *fetch_refspec2 = "refs/heads/ns2/*:refs/remotes/upstream/ns2/*";
- const char *push_refspec1 = "refs/heads/ns1/*:refs/heads/ns1/*";
- const char *push_refspec2 = "refs/heads/ns2/*:refs/heads/ns2/*";
-
- git_remote_free(_remote);
- _remote = NULL;
-
- /* Set up the remote and save it to config */
- cl_git_pass(git_remote_create(&_remote, _repo, "upstream", "git://github.com/libgit2/libgit2"));
- git_remote_free(_remote);
- cl_git_pass(git_remote_set_pushurl(_repo, "upstream", "git://github.com/libgit2/libgit2_push"));
- cl_git_pass(git_remote_lookup(&_remote, _repo, "upstream"));
-
- git_remote_clear_refspecs(_remote);
-
- cl_git_pass(git_remote_add_fetch(_remote, fetch_refspec1));
- cl_git_pass(git_remote_add_fetch(_remote, fetch_refspec2));
- cl_git_pass(git_remote_add_push(_remote, push_refspec1));
- cl_git_pass(git_remote_add_push(_remote, push_refspec2));
- cl_git_pass(git_remote_save(_remote));
- git_remote_free(_remote);
- _remote = NULL;
-
- /* Load it from config and make sure everything matches */
- cl_git_pass(git_remote_lookup(&_remote, _repo, "upstream"));
-
- cl_git_pass(git_remote_get_fetch_refspecs(&array, _remote));
- cl_assert_equal_i(2, (int)array.count);
- cl_assert_equal_s(fetch_refspec1, array.strings[0]);
- cl_assert_equal_s(fetch_refspec2, array.strings[1]);
- git_strarray_free(&array);
-
- cl_git_pass(git_remote_get_push_refspecs(&array, _remote));
- cl_assert_equal_i(2, (int)array.count);
- cl_assert_equal_s(push_refspec1, array.strings[0]);
- cl_assert_equal_s(push_refspec2, array.strings[1]);
- git_strarray_free(&array);
-
- cl_assert_equal_s(git_remote_url(_remote), "git://github.com/libgit2/libgit2");
- cl_assert_equal_s(git_remote_pushurl(_remote), "git://github.com/libgit2/libgit2_push");
-
- git_remote_free(_remote);
- _remote = NULL;
-
- /* remove the pushurl again and see if we can save that too */
- cl_git_pass(git_remote_set_pushurl(_repo, "upstream", NULL));
- cl_git_pass(git_remote_lookup(&_remote, _repo, "upstream"));
- cl_assert(git_remote_pushurl(_remote) == NULL);
-}
-
void test_network_remote_remotes__fnmatch(void)
{
cl_assert(git_refspec_src_matches(_refspec, "refs/heads/master"));
@@ -499,13 +452,16 @@ void test_network_remote_remotes__query_refspecs(void)
git_strarray array;
int i;
- cl_git_pass(git_remote_create_anonymous(&remote, _repo, "git://github.com/libgit2/libgit2", NULL));
+ cl_git_pass(git_remote_create_with_fetchspec(&remote, _repo, "query", "git://github.com/libgit2/libgit2", NULL));
+ git_remote_free(remote);
for (i = 0; i < 3; i++) {
- cl_git_pass(git_remote_add_fetch(remote, fetch_refspecs[i]));
- cl_git_pass(git_remote_add_push(remote, push_refspecs[i]));
+ cl_git_pass(git_remote_add_fetch(_repo, "query", fetch_refspecs[i]));
+ cl_git_pass(git_remote_add_push(_repo, "query", push_refspecs[i]));
}
+ cl_git_pass(git_remote_lookup(&remote, _repo, "query"));
+
cl_git_pass(git_remote_get_fetch_refspecs(&array, remote));
for (i = 0; i < 3; i++) {
cl_assert_equal_s(fetch_refspecs[i], array.strings[i]);
@@ -519,6 +475,7 @@ void test_network_remote_remotes__query_refspecs(void)
git_strarray_free(&array);
git_remote_free(remote);
+ git_remote_delete(_repo, "test");
}
void test_network_remote_remotes__fetch_from_anonymous(void)
diff --git a/tests/online/clone.c b/tests/online/clone.c
index 1d4196948..1930a8ba3 100644
--- a/tests/online/clone.c
+++ b/tests/online/clone.c
@@ -134,16 +134,9 @@ static int remote_mirror_cb(git_remote **out, git_repository *repo,
GIT_UNUSED(payload);
- if ((error = git_remote_create(&remote, repo, name, url)) < 0)
+ if ((error = git_remote_create_with_fetchspec(&remote, repo, name, url, "+refs/*:refs/*")) < 0)
return error;
- git_remote_clear_refspecs(remote);
-
- if ((error = git_remote_add_fetch(remote, "+refs/*:refs/*")) < 0) {
- git_remote_free(remote);
- return error;
- }
-
*out = remote;
return 0;
}
diff --git a/tests/online/push.c b/tests/online/push.c
index b35632755..04ad7a2ed 100644
--- a/tests/online/push.c
+++ b/tests/online/push.c
@@ -861,6 +861,7 @@ void test_online_push__configured(void)
{
git_oid note_oid, *target_oid, expected_oid;
git_signature *signature;
+ git_remote *old_remote;
const char *specs[] = { "refs/notes/commits:refs/notes/commits" };
push_status exp_stats[] = { { "refs/notes/commits", 1 } };
expected_ref exp_refs[] = { { "refs/notes/commits", &expected_oid } };
@@ -870,7 +871,10 @@ void test_online_push__configured(void)
target_oid = &_oid_b6;
- cl_git_pass(git_remote_add_push(_remote, specs[0]));
+ cl_git_pass(git_remote_add_push(_repo, git_remote_name(_remote), specs[0]));
+ old_remote = _remote;
+ cl_git_pass(git_remote_lookup(&_remote, _repo, git_remote_name(_remote)));
+ git_remote_free(old_remote);
/* Create note to push */
cl_git_pass(git_signature_new(&signature, "nulltoken", "emeric.fermas@gmail.com", 1323847743, 60)); /* Wed Dec 14 08:29:03 2011 +0100 */
diff --git a/tests/refs/branches/remote.c b/tests/refs/branches/remote.c
index bac088454..47526717f 100644
--- a/tests/refs/branches/remote.c
+++ b/tests/refs/branches/remote.c
@@ -57,12 +57,7 @@ void test_refs_branches_remote__ambiguous_remote_returns_error(void)
git_buf buf;
/* Create the remote */
- cl_git_pass(git_remote_create(&remote, g_repo, "addtest", "http://github.com/libgit2/libgit2"));
-
- /* Update the remote fetch spec */
- git_remote_clear_refspecs(remote);
- cl_git_pass(git_remote_add_fetch(remote, "refs/heads/*:refs/remotes/test/*"));
- cl_git_pass(git_remote_save(remote));
+ cl_git_pass(git_remote_create_with_fetchspec(&remote, g_repo, "addtest", "http://github.com/libgit2/libgit2", "refs/heads/*:refs/remotes/test/*"));
git_remote_free(remote);