diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2015-04-23 06:51:34 +0200 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2015-05-13 09:46:36 +0200 |
commit | 7725499072aaf4d9093c615fee5a65d8477100bc (patch) | |
tree | fc68cffcafe2d9e762729334dfe2f7a4ee15783e /tests/network | |
parent | 3fec548a989b09fc7a2c30f42b1d4fa123a8867e (diff) | |
download | libgit2-7725499072aaf4d9093c615fee5a65d8477100bc.tar.gz |
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/network')
-rw-r--r-- | tests/network/fetchlocal.c | 9 | ||||
-rw-r--r-- | tests/network/remote/local.c | 1 | ||||
-rw-r--r-- | tests/network/remote/remotes.c | 77 |
3 files changed, 18 insertions, 69 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) |