diff options
| author | Edward Thomson <ethomson@edwardthomson.com> | 2014-10-09 10:41:38 -0400 |
|---|---|---|
| committer | Edward Thomson <ethomson@edwardthomson.com> | 2014-10-09 10:41:38 -0400 |
| commit | 8be28acfcd26b66275abe225700b24c838bbfd69 (patch) | |
| tree | 9a293eca108b6c08fe986057ae3a06dbbf110936 /tests | |
| parent | 8bd747cfb4e6223490a71a0f3beecbed1a1a344a (diff) | |
| parent | c5837cad85c2730d30cd3c8b1018bd392ca8115a (diff) | |
| download | libgit2-8be28acfcd26b66275abe225700b24c838bbfd69.tar.gz | |
Merge pull request #2462 from libgit2/cmn/remote-fetch-refs
Implement opportunistic ref updates
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/fetchhead/nonetwork.c | 2 | ||||
| -rw-r--r-- | tests/network/fetchlocal.c | 4 | ||||
| -rw-r--r-- | tests/network/remote/local.c | 114 | ||||
| -rw-r--r-- | tests/online/fetch.c | 10 | ||||
| -rw-r--r-- | tests/online/fetchhead.c | 8 | ||||
| -rw-r--r-- | tests/online/push.c | 2 |
6 files changed, 102 insertions, 38 deletions
diff --git a/tests/fetchhead/nonetwork.c b/tests/fetchhead/nonetwork.c index 7b64a6339..c8191c5f5 100644 --- a/tests/fetchhead/nonetwork.c +++ b/tests/fetchhead/nonetwork.c @@ -335,7 +335,7 @@ void test_fetchhead_nonetwork__unborn_with_upstream(void) cl_git_pass(git_remote_set_url(remote, cl_fixture("testrepo.git"))); cl_git_pass(git_remote_save(remote)); - cl_git_pass(git_remote_fetch(remote, NULL, NULL)); + cl_git_pass(git_remote_fetch(remote, NULL, NULL, NULL)); git_remote_free(remote); cl_git_pass(git_repository_fetchhead_foreach(repo, assert_master_for_merge, NULL)); diff --git a/tests/network/fetchlocal.c b/tests/network/fetchlocal.c index 8809f427d..bf0d0872b 100644 --- a/tests/network/fetchlocal.c +++ b/tests/network/fetchlocal.c @@ -36,7 +36,7 @@ void test_network_fetchlocal__complete(void) cl_git_pass(git_remote_create(&origin, repo, GIT_REMOTE_ORIGIN, url)); git_remote_set_callbacks(origin, &callbacks); cl_git_pass(git_remote_connect(origin, GIT_DIRECTION_FETCH)); - cl_git_pass(git_remote_download(origin)); + cl_git_pass(git_remote_download(origin, NULL)); cl_git_pass(git_remote_update_tips(origin, NULL, NULL)); cl_git_pass(git_reference_list(&refnames, repo)); @@ -74,7 +74,7 @@ void test_network_fetchlocal__partial(void) cl_git_pass(git_remote_create(&origin, repo, GIT_REMOTE_ORIGIN, url)); git_remote_set_callbacks(origin, &callbacks); cl_git_pass(git_remote_connect(origin, GIT_DIRECTION_FETCH)); - cl_git_pass(git_remote_download(origin)); + cl_git_pass(git_remote_download(origin, NULL)); cl_git_pass(git_remote_update_tips(origin, NULL, NULL)); git_strarray_free(&refnames); diff --git a/tests/network/remote/local.c b/tests/network/remote/local.c index f1084fc38..c6c9e4ca9 100644 --- a/tests/network/remote/local.c +++ b/tests/network/remote/local.c @@ -116,16 +116,20 @@ void test_network_remote_local__nested_tags_are_completely_peeled(void) void test_network_remote_local__shorthand_fetch_refspec0(void) { - const char *refspec = "master:remotes/sloppy/master"; - const char *refspec2 = "master:boh/sloppy/master"; + char *refspec_strings[] = { + "master:remotes/sloppy/master", + "master:boh/sloppy/master", + }; + git_strarray array = { + refspec_strings, + 2, + }; git_reference *ref; connect_to_local_repository(cl_fixture("testrepo.git")); - cl_git_pass(git_remote_add_fetch(remote, refspec)); - cl_git_pass(git_remote_add_fetch(remote, refspec2)); - cl_git_pass(git_remote_download(remote)); + cl_git_pass(git_remote_download(remote, &array)); cl_git_pass(git_remote_update_tips(remote, NULL, NULL)); cl_git_pass(git_reference_lookup(&ref, repo, "refs/remotes/sloppy/master")); @@ -137,17 +141,21 @@ void test_network_remote_local__shorthand_fetch_refspec0(void) void test_network_remote_local__shorthand_fetch_refspec1(void) { - const char *refspec = "master"; - const char *refspec2 = "hard_tag"; + char *refspec_strings[] = { + "master", + "hard_tag", + }; + git_strarray array = { + refspec_strings, + 2, + }; git_reference *ref; connect_to_local_repository(cl_fixture("testrepo.git")); git_remote_clear_refspecs(remote); - cl_git_pass(git_remote_add_fetch(remote, refspec)); - cl_git_pass(git_remote_add_fetch(remote, refspec2)); - cl_git_pass(git_remote_download(remote)); + cl_git_pass(git_remote_download(remote, &array)); cl_git_pass(git_remote_update_tips(remote, NULL, NULL)); cl_git_fail(git_reference_lookup(&ref, repo, "refs/remotes/master")); @@ -162,7 +170,7 @@ void test_network_remote_local__tagopt(void) connect_to_local_repository(cl_fixture("testrepo.git")); git_remote_set_autotag(remote, GIT_REMOTE_DOWNLOAD_TAGS_ALL); - cl_git_pass(git_remote_download(remote)); + cl_git_pass(git_remote_download(remote, NULL)); cl_git_pass(git_remote_update_tips(remote, NULL, NULL)); @@ -174,14 +182,20 @@ void test_network_remote_local__tagopt(void) void test_network_remote_local__push_to_bare_remote(void) { + char *refspec_strings[] = { + "master:master", + }; + git_strarray array = { + refspec_strings, + 1, + }; /* Should be able to push to a bare remote */ git_remote *localremote; git_push *push; /* Get some commits */ connect_to_local_repository(cl_fixture("testrepo.git")); - cl_git_pass(git_remote_add_fetch(remote, "master:master")); - cl_git_pass(git_remote_download(remote)); + cl_git_pass(git_remote_download(remote, &array)); cl_git_pass(git_remote_update_tips(remote, NULL, NULL)); git_remote_disconnect(remote); @@ -210,6 +224,13 @@ void test_network_remote_local__push_to_bare_remote(void) void test_network_remote_local__push_to_bare_remote_with_file_url(void) { + char *refspec_strings[] = { + "master:master", + }; + git_strarray array = { + refspec_strings, + 1, + }; /* Should be able to push to a bare remote */ git_remote *localremote; git_push *push; @@ -217,8 +238,7 @@ void test_network_remote_local__push_to_bare_remote_with_file_url(void) /* Get some commits */ connect_to_local_repository(cl_fixture("testrepo.git")); - cl_git_pass(git_remote_add_fetch(remote, "master:master")); - cl_git_pass(git_remote_download(remote)); + cl_git_pass(git_remote_download(remote, &array)); cl_git_pass(git_remote_update_tips(remote, NULL, NULL)); git_remote_disconnect(remote); @@ -251,14 +271,20 @@ void test_network_remote_local__push_to_bare_remote_with_file_url(void) void test_network_remote_local__push_to_non_bare_remote(void) { + char *refspec_strings[] = { + "master:master", + }; + git_strarray array = { + refspec_strings, + 1, + }; /* Shouldn't be able to push to a non-bare remote */ git_remote *localremote; git_push *push; /* Get some commits */ connect_to_local_repository(cl_fixture("testrepo.git")); - cl_git_pass(git_remote_add_fetch(remote, "master:master")); - cl_git_pass(git_remote_download(remote)); + cl_git_pass(git_remote_download(remote, &array)); cl_git_pass(git_remote_update_tips(remote, NULL, NULL)); git_remote_disconnect(remote); @@ -287,7 +313,13 @@ void test_network_remote_local__push_to_non_bare_remote(void) void test_network_remote_local__fetch(void) { - const char *refspec = "master:remotes/sloppy/master"; + char *refspec_strings[] = { + "master:remotes/sloppy/master", + }; + git_strarray array = { + refspec_strings, + 1, + }; git_reflog *log; const git_reflog_entry *entry; @@ -297,9 +329,8 @@ void test_network_remote_local__fetch(void) cl_git_pass(git_signature_now(&sig, "Foo Bar", "foo@example.com")); connect_to_local_repository(cl_fixture("testrepo.git")); - cl_git_pass(git_remote_add_fetch(remote, refspec)); - cl_git_pass(git_remote_fetch(remote, sig, "UPDAAAAAATE!!")); + cl_git_pass(git_remote_fetch(remote, &array, sig, "UPDAAAAAATE!!")); cl_git_pass(git_reference_lookup(&ref, repo, "refs/remotes/sloppy/master")); git_reference_free(ref); @@ -316,7 +347,13 @@ void test_network_remote_local__fetch(void) void test_network_remote_local__reflog(void) { - const char *refspec = "master:remotes/sloppy/master"; + char *refspec_strings[] = { + "master:remotes/sloppy/master", + }; + git_strarray array = { + refspec_strings, + 1, + }; git_reflog *log; const git_reflog_entry *entry; @@ -325,9 +362,8 @@ void test_network_remote_local__reflog(void) cl_git_pass(git_signature_now(&sig, "Foo Bar", "foo@example.com")); connect_to_local_repository(cl_fixture("testrepo.git")); - cl_git_pass(git_remote_add_fetch(remote, refspec)); - cl_git_pass(git_remote_download(remote)); + cl_git_pass(git_remote_download(remote, &array)); cl_git_pass(git_remote_update_tips(remote, sig, "UPDAAAAAATE!!")); cl_git_pass(git_reflog_read(&log, repo, "refs/remotes/sloppy/master")); @@ -342,7 +378,13 @@ void test_network_remote_local__reflog(void) void test_network_remote_local__fetch_default_reflog_message(void) { - const char *refspec = "master:remotes/sloppy/master"; + char *refspec_strings[] = { + "master:remotes/sloppy/master", + }; + git_strarray array = { + refspec_strings, + 1, + }; git_reflog *log; const git_reflog_entry *entry; @@ -352,9 +394,8 @@ void test_network_remote_local__fetch_default_reflog_message(void) cl_git_pass(git_signature_now(&sig, "Foo Bar", "foo@example.com")); connect_to_local_repository(cl_fixture("testrepo.git")); - cl_git_pass(git_remote_add_fetch(remote, refspec)); - cl_git_pass(git_remote_fetch(remote, sig, NULL)); + cl_git_pass(git_remote_fetch(remote, &array, sig, NULL)); cl_git_pass(git_reflog_read(&log, repo, "refs/remotes/sloppy/master")); cl_assert_equal_i(1, git_reflog_entrycount(log)); @@ -367,3 +408,24 @@ void test_network_remote_local__fetch_default_reflog_message(void) git_reflog_free(log); git_signature_free(sig); } + +void test_network_remote_local__opportunistic_update(void) +{ + git_reference *ref; + char *refspec_strings[] = { + "master", + }; + git_strarray array = { + refspec_strings, + 1, + }; + + /* this remote has a passive refspec of "refs/heads/<star>:refs/remotes/origin/<star>" */ + cl_git_pass(git_remote_create(&remote, repo, "origin", cl_git_fixture_url("testrepo.git"))); + /* and we pass the active refspec "master" */ + cl_git_pass(git_remote_fetch(remote, &array, NULL, NULL)); + + /* and we expect that to update our copy of origin's master */ + cl_git_pass(git_reference_lookup(&ref, repo, "refs/remotes/origin/master")); + git_reference_free(ref); +} diff --git a/tests/online/fetch.c b/tests/online/fetch.c index f03a6faa6..ce92ee82b 100644 --- a/tests/online/fetch.c +++ b/tests/online/fetch.c @@ -47,7 +47,7 @@ static void do_fetch(const char *url, git_remote_autotag_option_t flag, int n) git_remote_set_callbacks(remote, &callbacks); git_remote_set_autotag(remote, flag); cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH)); - cl_git_pass(git_remote_download(remote)); + cl_git_pass(git_remote_download(remote, NULL)); cl_git_pass(git_remote_update_tips(remote, NULL, NULL)); git_remote_disconnect(remote); cl_assert_equal_i(counter, n); @@ -86,11 +86,11 @@ void test_online_fetch__fetch_twice(void) git_remote *remote; cl_git_pass(git_remote_create(&remote, _repo, "test", "git://github.com/libgit2/TestGitRepository.git")); cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH)); - cl_git_pass(git_remote_download(remote)); + cl_git_pass(git_remote_download(remote, NULL)); git_remote_disconnect(remote); git_remote_connect(remote, GIT_DIRECTION_FETCH); - cl_git_pass(git_remote_download(remote)); + cl_git_pass(git_remote_download(remote, NULL)); git_remote_disconnect(remote); git_remote_free(remote); @@ -128,7 +128,7 @@ void test_online_fetch__doesnt_retrieve_a_pack_when_the_repository_is_up_to_date callbacks.transfer_progress = &transferProgressCallback; callbacks.payload = &invoked; git_remote_set_callbacks(remote, &callbacks); - cl_git_pass(git_remote_download(remote)); + cl_git_pass(git_remote_download(remote, NULL)); cl_assert_equal_i(false, invoked); @@ -162,7 +162,7 @@ void test_online_fetch__can_cancel(void) git_remote_set_callbacks(remote, &callbacks); cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH)); - cl_git_fail_with(git_remote_download(remote), -4321); + cl_git_fail_with(git_remote_download(remote, NULL), -4321); git_remote_disconnect(remote); git_remote_free(remote); } diff --git a/tests/online/fetchhead.c b/tests/online/fetchhead.c index 3f27e1331..bd423bbb0 100644 --- a/tests/online/fetchhead.c +++ b/tests/online/fetchhead.c @@ -40,17 +40,19 @@ static void fetchhead_test_fetch(const char *fetchspec, const char *expected_fet git_remote *remote; git_buf fetchhead_buf = GIT_BUF_INIT; int equals = 0; + git_strarray array, *active_refs = NULL; cl_git_pass(git_remote_load(&remote, g_repo, "origin")); git_remote_set_autotag(remote, GIT_REMOTE_DOWNLOAD_TAGS_AUTO); if(fetchspec != NULL) { - git_remote_clear_refspecs(remote); - git_remote_add_fetch(remote, fetchspec); + array.count = 1; + array.strings = (char **) &fetchspec; + active_refs = &array; } cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH)); - cl_git_pass(git_remote_download(remote)); + cl_git_pass(git_remote_download(remote, active_refs)); cl_git_pass(git_remote_update_tips(remote, NULL, NULL)); git_remote_disconnect(remote); git_remote_free(remote); diff --git a/tests/online/push.c b/tests/online/push.c index 70ec705fe..b09c7ad1f 100644 --- a/tests/online/push.c +++ b/tests/online/push.c @@ -408,7 +408,7 @@ void test_online_push__initialize(void) /* Now that we've deleted everything, fetch from the remote */ cl_git_pass(git_remote_connect(_remote, GIT_DIRECTION_FETCH)); - cl_git_pass(git_remote_download(_remote)); + cl_git_pass(git_remote_download(_remote, NULL)); cl_git_pass(git_remote_update_tips(_remote, NULL, NULL)); git_remote_disconnect(_remote); } |
