]> git.proxmox.com Git - libgit2.git/blame - tests/network/remote/remotes.c
Merge pull request #2043 from arthurschreiber/arthur/fix-memory-leaks
[libgit2.git] / tests / network / remote / remotes.c
CommitLineData
3fd1520c 1#include "clar_libgit2.h"
279afd2a
CMN
2#include "buffer.h"
3#include "refspec.h"
eff5b499 4#include "remote.h"
3a2626f3 5
9462c471
VM
6static git_remote *_remote;
7static git_repository *_repo;
8static const git_refspec *_refspec;
3a2626f3 9
624924e8 10void test_network_remote_remotes__initialize(void)
3a2626f3 11{
e497b16c 12 _repo = cl_git_sandbox_init("testrepo.git");
9462c471 13
9462c471
VM
14 cl_git_pass(git_remote_load(&_remote, _repo, "test"));
15
1ffd0806 16 _refspec = git_remote_get_refspec(_remote, 0);
9462c471 17 cl_assert(_refspec != NULL);
3a2626f3
CMN
18}
19
624924e8 20void test_network_remote_remotes__cleanup(void)
3a2626f3 21{
9462c471 22 git_remote_free(_remote);
9094d30b
SC
23 _remote = NULL;
24
e497b16c 25 cl_git_sandbox_cleanup();
3a2626f3
CMN
26}
27
624924e8 28void test_network_remote_remotes__parsing(void)
3a2626f3 29{
8689a69d
SC
30 git_remote *_remote2 = NULL;
31
946a6dc4
VM
32 cl_assert_equal_s(git_remote_name(_remote), "test");
33 cl_assert_equal_s(git_remote_url(_remote), "git://github.com/libgit2/libgit2");
8689a69d
SC
34 cl_assert(git_remote_pushurl(_remote) == NULL);
35
df705148 36 cl_assert_equal_s(git_remote__urlfordirection(_remote, GIT_DIRECTION_FETCH),
eff5b499 37 "git://github.com/libgit2/libgit2");
df705148 38 cl_assert_equal_s(git_remote__urlfordirection(_remote, GIT_DIRECTION_PUSH),
eff5b499
SC
39 "git://github.com/libgit2/libgit2");
40
8689a69d
SC
41 cl_git_pass(git_remote_load(&_remote2, _repo, "test_with_pushurl"));
42 cl_assert_equal_s(git_remote_name(_remote2), "test_with_pushurl");
43 cl_assert_equal_s(git_remote_url(_remote2), "git://github.com/libgit2/fetchlibgit2");
44 cl_assert_equal_s(git_remote_pushurl(_remote2), "git://github.com/libgit2/pushlibgit2");
eff5b499 45
df705148 46 cl_assert_equal_s(git_remote__urlfordirection(_remote2, GIT_DIRECTION_FETCH),
eff5b499 47 "git://github.com/libgit2/fetchlibgit2");
df705148 48 cl_assert_equal_s(git_remote__urlfordirection(_remote2, GIT_DIRECTION_PUSH),
eff5b499
SC
49 "git://github.com/libgit2/pushlibgit2");
50
8689a69d
SC
51 git_remote_free(_remote2);
52}
53
624924e8 54void test_network_remote_remotes__pushurl(void)
8689a69d
SC
55{
56 cl_git_pass(git_remote_set_pushurl(_remote, "git://github.com/libgit2/notlibgit2"));
57 cl_assert_equal_s(git_remote_pushurl(_remote), "git://github.com/libgit2/notlibgit2");
58
59 cl_git_pass(git_remote_set_pushurl(_remote, NULL));
60 cl_assert(git_remote_pushurl(_remote) == NULL);
3a2626f3
CMN
61}
62
624924e8 63void test_network_remote_remotes__error_when_no_push_available(void)
b90eb84f
SB
64{
65 git_remote *r;
66 git_transport *t;
67 git_push *p;
68
69 cl_git_pass(git_remote_create_inmemory(&r, _repo, NULL, cl_fixture("testrepo.git")));
70
71 cl_git_pass(git_transport_local(&t,r,NULL));
72
73 /* Make sure that push is really not available */
74 t->push = NULL;
4cc326e9
ET
75 cl_git_pass(git_remote_set_transport(r, t));
76
b90eb84f
SB
77 cl_git_pass(git_remote_connect(r, GIT_DIRECTION_PUSH));
78 cl_git_pass(git_push_new(&p, r));
79 cl_git_pass(git_push_add_refspec(p, "refs/heads/master"));
80 cl_git_fail_with(git_push_finish(p), GIT_ERROR);
81
82 git_push_free(p);
83 git_remote_free(r);
84}
85
624924e8 86void test_network_remote_remotes__parsing_ssh_remote(void)
58448910
RW
87{
88 cl_assert( git_remote_valid_url("git@github.com:libgit2/libgit2.git") );
89}
90
624924e8 91void test_network_remote_remotes__parsing_local_path_fails_if_path_not_found(void)
58448910
RW
92{
93 cl_assert( !git_remote_valid_url("/home/git/repos/libgit2.git") );
94}
95
624924e8 96void test_network_remote_remotes__supported_transport_methods_are_supported(void)
7a544966 97{
e497b16c 98 cl_assert( git_remote_supported_url("git://github.com/libgit2/libgit2") );
7a544966
RW
99}
100
624924e8 101void test_network_remote_remotes__unsupported_transport_methods_are_unsupported(void)
7a544966 102{
0582ae6f 103#ifndef GIT_SSH
7a544966 104 cl_assert( !git_remote_supported_url("git@github.com:libgit2/libgit2.git") );
0582ae6f 105#endif
7a544966
RW
106}
107
624924e8 108void test_network_remote_remotes__refspec_parsing(void)
3a2626f3 109{
946a6dc4
VM
110 cl_assert_equal_s(git_refspec_src(_refspec), "refs/heads/*");
111 cl_assert_equal_s(git_refspec_dst(_refspec), "refs/remotes/test/*");
3a2626f3
CMN
112}
113
4330ab26 114void test_network_remote_remotes__add_fetchspec(void)
bcb8c007 115{
4330ab26
CMN
116 size_t size;
117
1ffd0806 118 size = git_remote_refspec_count(_remote);
4330ab26 119
bc6374ea 120 cl_git_pass(git_remote_add_fetch(_remote, "refs/*:refs/*"));
4330ab26
CMN
121
122 size++;
0f938c6b 123 cl_assert_equal_i((int)size, (int)git_remote_refspec_count(_remote));
4330ab26 124
1ffd0806 125 _refspec = git_remote_get_refspec(_remote, size - 1);
946a6dc4
VM
126 cl_assert_equal_s(git_refspec_src(_refspec), "refs/*");
127 cl_assert_equal_s(git_refspec_dst(_refspec), "refs/*");
1be680c4 128 cl_assert_equal_s(git_refspec_string(_refspec), "refs/*:refs/*");
0f938c6b 129 cl_assert_equal_b(_refspec->push, false);
bcb8c007
CMN
130}
131
4330ab26 132void test_network_remote_remotes__add_pushspec(void)
bcb8c007 133{
4330ab26
CMN
134 size_t size;
135
1ffd0806 136 size = git_remote_refspec_count(_remote);
4330ab26 137
bc6374ea 138 cl_git_pass(git_remote_add_push(_remote, "refs/*:refs/*"));
4330ab26 139 size++;
0f938c6b 140 cl_assert_equal_i((int)size, (int)git_remote_refspec_count(_remote));
4330ab26 141
1ffd0806 142 _refspec = git_remote_get_refspec(_remote, size - 1);
946a6dc4
VM
143 cl_assert_equal_s(git_refspec_src(_refspec), "refs/*");
144 cl_assert_equal_s(git_refspec_dst(_refspec), "refs/*");
1be680c4 145 cl_assert_equal_s(git_refspec_string(_refspec), "refs/*:refs/*");
4330ab26 146
0f938c6b 147 cl_assert_equal_b(_refspec->push, true);
bcb8c007
CMN
148}
149
624924e8 150void test_network_remote_remotes__save(void)
89e5ed98 151{
bc6374ea 152 git_strarray array;
3793fa9b
DRT
153 const char *fetch_refspec1 = "refs/heads/ns1/*:refs/remotes/upstream/ns1/*";
154 const char *fetch_refspec2 = "refs/heads/ns2/*:refs/remotes/upstream/ns2/*";
155 const char *push_refspec1 = "refs/heads/ns1/*:refs/heads/ns1/*";
156 const char *push_refspec2 = "refs/heads/ns2/*:refs/heads/ns2/*";
bc6374ea 157
89e5ed98 158 git_remote_free(_remote);
26290cd1 159 _remote = NULL;
89e5ed98
CMN
160
161 /* Set up the remote and save it to config */
40b99d05 162 cl_git_pass(git_remote_create(&_remote, _repo, "upstream", "git://github.com/libgit2/libgit2"));
4330ab26 163 git_remote_clear_refspecs(_remote);
4330ab26 164
3793fa9b
DRT
165 cl_git_pass(git_remote_add_fetch(_remote, fetch_refspec1));
166 cl_git_pass(git_remote_add_fetch(_remote, fetch_refspec2));
167 cl_git_pass(git_remote_add_push(_remote, push_refspec1));
168 cl_git_pass(git_remote_add_push(_remote, push_refspec2));
8689a69d 169 cl_git_pass(git_remote_set_pushurl(_remote, "git://github.com/libgit2/libgit2_push"));
89e5ed98
CMN
170 cl_git_pass(git_remote_save(_remote));
171 git_remote_free(_remote);
172 _remote = NULL;
173
174 /* Load it from config and make sure everything matches */
175 cl_git_pass(git_remote_load(&_remote, _repo, "upstream"));
176
bc6374ea 177 cl_git_pass(git_remote_get_fetch_refspecs(&array, _remote));
3793fa9b
DRT
178 cl_assert_equal_i(2, (int)array.count);
179 cl_assert_equal_s(fetch_refspec1, array.strings[0]);
180 cl_assert_equal_s(fetch_refspec2, array.strings[1]);
bc6374ea 181 git_strarray_free(&array);
8689a69d 182
bc6374ea 183 cl_git_pass(git_remote_get_push_refspecs(&array, _remote));
3793fa9b
DRT
184 cl_assert_equal_i(2, (int)array.count);
185 cl_assert_equal_s(push_refspec1, array.strings[0]);
186 cl_assert_equal_s(push_refspec2, array.strings[1]);
187 git_strarray_free(&array);
188
8689a69d
SC
189 cl_assert_equal_s(git_remote_url(_remote), "git://github.com/libgit2/libgit2");
190 cl_assert_equal_s(git_remote_pushurl(_remote), "git://github.com/libgit2/libgit2_push");
413d5563
SC
191
192 /* remove the pushurl again and see if we can save that too */
193 cl_git_pass(git_remote_set_pushurl(_remote, NULL));
194 cl_git_pass(git_remote_save(_remote));
195 git_remote_free(_remote);
196 _remote = NULL;
197
198 cl_git_pass(git_remote_load(&_remote, _repo, "upstream"));
199 cl_assert(git_remote_pushurl(_remote) == NULL);
89e5ed98
CMN
200}
201
624924e8 202void test_network_remote_remotes__fnmatch(void)
3a2626f3 203{
3fbcac89
VM
204 cl_assert(git_refspec_src_matches(_refspec, "refs/heads/master"));
205 cl_assert(git_refspec_src_matches(_refspec, "refs/heads/multi/level/branch"));
3a2626f3
CMN
206}
207
624924e8 208void test_network_remote_remotes__transform(void)
3a2626f3 209{
db4bb415 210 char ref[1024] = {0};
3a2626f3 211
9462c471 212 cl_git_pass(git_refspec_transform(ref, sizeof(ref), _refspec, "refs/heads/master"));
946a6dc4 213 cl_assert_equal_s(ref, "refs/remotes/test/master");
3a2626f3 214}
279afd2a 215
624924e8 216void test_network_remote_remotes__transform_destination_to_source(void)
db4bb415
JM
217{
218 char ref[1024] = {0};
219
220 cl_git_pass(git_refspec_rtransform(ref, sizeof(ref), _refspec, "refs/remotes/test/master"));
221 cl_assert_equal_s(ref, "refs/heads/master");
222}
223
624924e8 224void test_network_remote_remotes__transform_r(void)
279afd2a
CMN
225{
226 git_buf buf = GIT_BUF_INIT;
227
228 cl_git_pass(git_refspec_transform_r(&buf, _refspec, "refs/heads/master"));
946a6dc4 229 cl_assert_equal_s(git_buf_cstr(&buf), "refs/remotes/test/master");
771cde43 230 git_buf_free(&buf);
279afd2a 231}
9554cd51 232
624924e8 233void test_network_remote_remotes__missing_refspecs(void)
9554cd51
CMN
234{
235 git_config *cfg;
236
237 git_remote_free(_remote);
d5cf4665 238 _remote = NULL;
9554cd51
CMN
239
240 cl_git_pass(git_repository_config(&cfg, _repo));
241 cl_git_pass(git_config_set_string(cfg, "remote.specless.url", "http://example.com"));
242 cl_git_pass(git_remote_load(&_remote, _repo, "specless"));
243
244 git_config_free(cfg);
245}
8171998f 246
624924e8 247void test_network_remote_remotes__list(void)
8171998f
CMN
248{
249 git_strarray list;
250 git_config *cfg;
251
252 cl_git_pass(git_remote_list(&list, _repo));
aec87f71 253 cl_assert(list.count == 5);
8171998f
CMN
254 git_strarray_free(&list);
255
256 cl_git_pass(git_repository_config(&cfg, _repo));
aec87f71 257
258 /* Create a new remote */
8171998f 259 cl_git_pass(git_config_set_string(cfg, "remote.specless.url", "http://example.com"));
aec87f71 260
261 /* Update a remote (previously without any url/pushurl entry) */
262 cl_git_pass(git_config_set_string(cfg, "remote.no-remote-url.pushurl", "http://example.com"));
263
8171998f 264 cl_git_pass(git_remote_list(&list, _repo));
aec87f71 265 cl_assert(list.count == 7);
8171998f
CMN
266 git_strarray_free(&list);
267
268 git_config_free(cfg);
269}
9fb70f37 270
624924e8 271void test_network_remote_remotes__loading_a_missing_remote_returns_ENOTFOUND(void)
9fb70f37 272{
d5cf4665
SC
273 git_remote_free(_remote);
274 _remote = NULL;
275
9fb70f37 276 cl_assert_equal_i(GIT_ENOTFOUND, git_remote_load(&_remote, _repo, "just-left-few-minutes-ago"));
277}
a209a025 278
624924e8 279void test_network_remote_remotes__loading_with_an_invalid_name_returns_EINVALIDSPEC(void)
032ba9e4 280{
d5cf4665
SC
281 git_remote_free(_remote);
282 _remote = NULL;
283
032ba9e4 284 cl_assert_equal_i(GIT_EINVALIDSPEC, git_remote_load(&_remote, _repo, "Inv@{id"));
285}
286
d27bf665 287/*
288 * $ git remote add addtest http://github.com/libgit2/libgit2
289 *
290 * $ cat .git/config
291 * [...]
292 * [remote "addtest"]
293 * url = http://github.com/libgit2/libgit2
a146ba9e 294 * fetch = +refs/heads/\*:refs/remotes/addtest/\*
d27bf665 295 */
624924e8 296void test_network_remote_remotes__add(void)
a209a025
CMN
297{
298 git_remote_free(_remote);
d5cf4665
SC
299 _remote = NULL;
300
40b99d05 301 cl_git_pass(git_remote_create(&_remote, _repo, "addtest", "http://github.com/libgit2/libgit2"));
215af2cc 302 cl_assert_equal_i(GIT_REMOTE_DOWNLOAD_TAGS_AUTO, git_remote_autotag(_remote));
d5cf4665 303
a209a025 304 git_remote_free(_remote);
d5cf4665 305 _remote = NULL;
a209a025
CMN
306
307 cl_git_pass(git_remote_load(&_remote, _repo, "addtest"));
215af2cc 308 cl_assert_equal_i(GIT_REMOTE_DOWNLOAD_TAGS_AUTO, git_remote_autotag(_remote));
309
4330ab26 310 _refspec = git_vector_get(&_remote->refspecs, 0);
a7f8065f 311 cl_assert_equal_s("refs/heads/*", git_refspec_src(_refspec));
d27bf665 312 cl_assert(git_refspec_force(_refspec) == 1);
a7f8065f 313 cl_assert_equal_s("refs/remotes/addtest/*", git_refspec_dst(_refspec));
8689a69d 314 cl_assert_equal_s(git_remote_url(_remote), "http://github.com/libgit2/libgit2");
a209a025 315}
218c88a9 316
624924e8 317void test_network_remote_remotes__cannot_add_a_nameless_remote(void)
e497b16c 318{
319 git_remote *remote;
320
032ba9e4 321 cl_assert_equal_i(
322 GIT_EINVALIDSPEC,
40b99d05 323 git_remote_create(&remote, _repo, NULL, "git://github.com/libgit2/libgit2"));
e497b16c 324}
325
624924e8 326void test_network_remote_remotes__cannot_save_an_inmemory_remote(void)
e497b16c 327{
328 git_remote *remote;
329
0642c143 330 cl_git_pass(git_remote_create_inmemory(&remote, _repo, NULL, "git://github.com/libgit2/libgit2"));
e497b16c 331
b0aa14aa 332 cl_assert_equal_p(NULL, git_remote_name(remote));
333
874dcb25 334 cl_git_fail(git_remote_save(remote));
e497b16c 335 git_remote_free(remote);
032ba9e4 336}
e497b16c 337
624924e8 338void test_network_remote_remotes__cannot_add_a_remote_with_an_invalid_name(void)
032ba9e4 339{
d5cf4665 340 git_remote *remote = NULL;
e497b16c 341
032ba9e4 342 cl_assert_equal_i(
343 GIT_EINVALIDSPEC,
40b99d05 344 git_remote_create(&remote, _repo, "Inv@{id", "git://github.com/libgit2/libgit2"));
d5cf4665 345 cl_assert_equal_p(remote, NULL);
032ba9e4 346
347 cl_assert_equal_i(
032ba9e4 348 GIT_EINVALIDSPEC,
40b99d05 349 git_remote_create(&remote, _repo, "", "git://github.com/libgit2/libgit2"));
d5cf4665 350 cl_assert_equal_p(remote, NULL);
e497b16c 351}
352
624924e8 353void test_network_remote_remotes__tagopt(void)
218c88a9
CMN
354{
355 const char *opt;
356 git_config *cfg;
357
358 cl_git_pass(git_repository_config(&cfg, _repo));
359
360 git_remote_set_autotag(_remote, GIT_REMOTE_DOWNLOAD_TAGS_ALL);
361 cl_git_pass(git_remote_save(_remote));
362 cl_git_pass(git_config_get_string(&opt, cfg, "remote.test.tagopt"));
a7f8065f 363 cl_assert_equal_s("--tags", opt);
218c88a9
CMN
364
365 git_remote_set_autotag(_remote, GIT_REMOTE_DOWNLOAD_TAGS_NONE);
366 cl_git_pass(git_remote_save(_remote));
367 cl_git_pass(git_config_get_string(&opt, cfg, "remote.test.tagopt"));
a7f8065f 368 cl_assert_equal_s("--no-tags", opt);
218c88a9
CMN
369
370 git_remote_set_autotag(_remote, GIT_REMOTE_DOWNLOAD_TAGS_AUTO);
371 cl_git_pass(git_remote_save(_remote));
372 cl_assert(git_config_get_string(&opt, cfg, "remote.test.tagopt") == GIT_ENOTFOUND);
373
374 git_config_free(cfg);
375}
a2a61894 376
0b9ebb54 377void test_network_remote_remotes__can_load_with_an_empty_url(void)
a2a61894 378{
d5cf4665 379 git_remote *remote = NULL;
a2a61894 380
0b9ebb54
CMN
381 cl_git_pass(git_remote_load(&remote, _repo, "empty-remote-url"));
382
ece24ef7 383 cl_assert(remote->url == NULL);
384 cl_assert(remote->pushurl == NULL);
385
0b9ebb54
CMN
386 cl_git_fail(git_remote_connect(remote, GIT_DIRECTION_FETCH));
387
ece24ef7 388 cl_assert(giterr_last() != NULL);
389 cl_assert(giterr_last()->klass == GITERR_INVALID);
390
0b9ebb54 391 git_remote_free(remote);
a2a61894 392}
10711769 393
c9ffa84b 394void test_network_remote_remotes__can_load_with_only_an_empty_pushurl(void)
395{
396 git_remote *remote = NULL;
397
398 cl_git_pass(git_remote_load(&remote, _repo, "empty-remote-pushurl"));
399
400 cl_assert(remote->url == NULL);
401 cl_assert(remote->pushurl == NULL);
402
403 cl_git_fail(git_remote_connect(remote, GIT_DIRECTION_FETCH));
404
405 git_remote_free(remote);
406}
407
408void test_network_remote_remotes__returns_ENOTFOUND_when_neither_url_nor_pushurl(void)
409{
410 git_remote *remote = NULL;
411
412 cl_git_fail_with(
413 git_remote_load(&remote, _repo, "no-remote-url"), GIT_ENOTFOUND);
414}
415
624924e8 416void test_network_remote_remotes__check_structure_version(void)
10711769
BS
417{
418 git_transport transport = GIT_TRANSPORT_INIT;
419 const git_error *err;
420
421 git_remote_free(_remote);
d5cf4665 422 _remote = NULL;
0642c143 423 cl_git_pass(git_remote_create_inmemory(&_remote, _repo, NULL, "test-protocol://localhost"));
10711769
BS
424
425 transport.version = 0;
426 cl_git_fail(git_remote_set_transport(_remote, &transport));
427 err = giterr_last();
428 cl_assert_equal_i(GITERR_INVALID, err->klass);
429
430 giterr_clear();
431 transport.version = 1024;
432 cl_git_fail(git_remote_set_transport(_remote, &transport));
433 err = giterr_last();
434 cl_assert_equal_i(GITERR_INVALID, err->klass);
435}
f19304d2 436
2bca5b67 437void assert_cannot_create_remote(const char *name, int expected_error)
f19304d2 438{
439 git_remote *remote = NULL;
440
2bca5b67 441 cl_git_fail_with(
40b99d05 442 git_remote_create(&remote, _repo, name, "git://github.com/libgit2/libgit2"),
2bca5b67 443 expected_error);
f19304d2 444
445 cl_assert_equal_p(remote, NULL);
446}
2bca5b67 447
448void test_network_remote_remotes__cannot_create_a_remote_which_name_conflicts_with_an_existing_remote(void)
449{
450 assert_cannot_create_remote("test", GIT_EEXISTS);
451}
452
2bca5b67 453void test_network_remote_remotes__cannot_create_a_remote_which_name_is_invalid(void)
454{
455 assert_cannot_create_remote("/", GIT_EINVALIDSPEC);
456 assert_cannot_create_remote("//", GIT_EINVALIDSPEC);
457 assert_cannot_create_remote(".lock", GIT_EINVALIDSPEC);
458 assert_cannot_create_remote("a.lock", GIT_EINVALIDSPEC);
99feb988
VG
459}
460
40b99d05 461void test_network_remote_remote__git_remote_create_with_fetchspec(void)
99feb988
VG
462{
463 git_remote *remote;
464 git_strarray array;
465
40b99d05 466 cl_git_pass(git_remote_create_with_fetchspec(&remote, _repo, "test-new", "git://github.com/libgit2/libgit2", "+refs/*:refs/*"));
99feb988
VG
467 git_remote_get_fetch_refspecs(&array, remote);
468 cl_assert_equal_s("+refs/*:refs/*", array.strings[0]);
469 git_remote_free(remote);
2bca5b67 470}
bc6374ea
CMN
471
472static const char *fetch_refspecs[] = {
473 "+refs/heads/*:refs/remotes/origin/*",
474 "refs/tags/*:refs/tags/*",
475 "+refs/pull/*:refs/pull/*",
476};
477
478static const char *push_refspecs[] = {
479 "refs/heads/*:refs/heads/*",
480 "refs/tags/*:refs/tags/*",
481 "refs/notes/*:refs/notes/*",
482};
483
484void test_network_remote_remotes__query_refspecs(void)
485{
486 git_remote *remote;
487 git_strarray array;
488 int i;
489
490 cl_git_pass(git_remote_create_inmemory(&remote, _repo, NULL, "git://github.com/libgit2/libgit2"));
491
492 for (i = 0; i < 3; i++) {
493 cl_git_pass(git_remote_add_fetch(remote, fetch_refspecs[i]));
494 cl_git_pass(git_remote_add_push(remote, push_refspecs[i]));
495 }
496
497 cl_git_pass(git_remote_get_fetch_refspecs(&array, remote));
498 for (i = 0; i < 3; i++) {
499 cl_assert_equal_s(fetch_refspecs[i], array.strings[i]);
500 }
501 git_strarray_free(&array);
502
503 cl_git_pass(git_remote_get_push_refspecs(&array, remote));
504 for (i = 0; i < 3; i++) {
505 cl_assert_equal_s(push_refspecs[i], array.strings[i]);
506 }
507 git_strarray_free(&array);
508
509 git_remote_free(remote);
510}