remote: use active refspec override in the tests This lets us test this bit as well as getting closer to what they were trying to do.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232
diff --git a/tests/network/remote/local.c b/tests/network/remote/local.c
index 0fbed60..ceccf45 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, NULL));
+ 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, NULL));
+ 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"));
@@ -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, NULL));
+ 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, NULL));
+ 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, NULL));
+ 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, NULL, 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, NULL));
+ 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, NULL, 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));
diff --git a/tests/online/fetchhead.c b/tests/online/fetchhead.c
index f6b9ab0..bd423bb 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, NULL));
+ 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);