]> git.proxmox.com Git - libgit2.git/blame - tests/network/fetchlocal.c
New upstream version 1.1.0+dfsg.1
[libgit2.git] / tests / network / fetchlocal.c
CommitLineData
11fabe73
BS
1#include "clar_libgit2.h"
2
3#include "buffer.h"
4#include "path.h"
5#include "remote.h"
6
5e0c3d2d
DC
7static const char* tagger_name = "Vicent Marti";
8static const char* tagger_email = "vicent@github.com";
9static const char* tagger_message = "This is my tag.\n\nThere are many tags, but this one is mine\n";
10
22a2d3d5 11static int transfer_cb(const git_indexer_progress *stats, void *payload)
11fabe73
BS
12{
13 int *callcount = (int*)payload;
14 GIT_UNUSED(stats);
15 (*callcount)++;
fe95ac1b 16 return 0;
11fabe73
BS
17}
18
7b51d675 19static void cleanup_local_repo(void *path)
600d8dbf 20{
7b51d675 21 cl_fixture_cleanup((char *)path);
600d8dbf
BS
22}
23
4adc64a8
CMN
24void test_network_fetchlocal__cleanup(void)
25{
26 cl_git_sandbox_cleanup();
27}
28
11fabe73
BS
29void test_network_fetchlocal__complete(void)
30{
11fabe73
BS
31 git_repository *repo;
32 git_remote *origin;
33 int callcount = 0;
34 git_strarray refnames = {0};
35
2ff1a0d0 36 const char *url = cl_git_fixture_url("testrepo.git");
8f0104ec 37 git_fetch_options options = GIT_FETCH_OPTIONS_INIT;
d31402a3 38
8f0104ec
CMN
39 options.callbacks.transfer_progress = transfer_cb;
40 options.callbacks.payload = &callcount;
7b51d675
VM
41
42 cl_set_cleanup(&cleanup_local_repo, "foo");
11fabe73
BS
43 cl_git_pass(git_repository_init(&repo, "foo", true));
44
29f27599 45 cl_git_pass(git_remote_create(&origin, repo, GIT_REMOTE_ORIGIN, url));
8f0104ec 46 cl_git_pass(git_remote_fetch(origin, NULL, &options, NULL));
11fabe73 47
2b562c3a 48 cl_git_pass(git_reference_list(&refnames, repo));
24cb87e2 49 cl_assert_equal_i(19, (int)refnames.count);
11fabe73
BS
50 cl_assert(callcount > 0);
51
22a2d3d5 52 git_strarray_dispose(&refnames);
11fabe73
BS
53 git_remote_free(origin);
54 git_repository_free(repo);
55}
56
b8fefcb9
L
57void test_network_fetchlocal__prune(void)
58{
59 git_repository *repo;
60 git_remote *origin;
61 int callcount = 0;
62 git_strarray refnames = {0};
63 git_reference *ref;
64 git_repository *remote_repo = cl_git_sandbox_init("testrepo.git");
65 const char *url = cl_git_path_url(git_repository_path(remote_repo));
8f0104ec 66 git_fetch_options options = GIT_FETCH_OPTIONS_INIT;
b8fefcb9 67
8f0104ec
CMN
68 options.callbacks.transfer_progress = transfer_cb;
69 options.callbacks.payload = &callcount;
b8fefcb9
L
70
71 cl_set_cleanup(&cleanup_local_repo, "foo");
72 cl_git_pass(git_repository_init(&repo, "foo", true));
73
74 cl_git_pass(git_remote_create(&origin, repo, GIT_REMOTE_ORIGIN, url));
8f0104ec 75 cl_git_pass(git_remote_fetch(origin, NULL, &options, NULL));
b8fefcb9
L
76
77 cl_git_pass(git_reference_list(&refnames, repo));
78 cl_assert_equal_i(19, (int)refnames.count);
79 cl_assert(callcount > 0);
22a2d3d5 80 git_strarray_dispose(&refnames);
b8fefcb9
L
81 git_remote_free(origin);
82
83 cl_git_pass(git_reference_lookup(&ref, remote_repo, "refs/heads/br2"));
84 cl_git_pass(git_reference_delete(ref));
85 git_reference_free(ref);
86
82eeba81 87 cl_git_pass(git_remote_lookup(&origin, repo, GIT_REMOTE_ORIGIN));
8f0104ec
CMN
88 cl_git_pass(git_remote_fetch(origin, NULL, &options, NULL));
89 cl_git_pass(git_remote_prune(origin, &options.callbacks));
b8fefcb9
L
90
91 cl_git_pass(git_reference_list(&refnames, repo));
92 cl_assert_equal_i(18, (int)refnames.count);
22a2d3d5 93 git_strarray_dispose(&refnames);
b8fefcb9
L
94 git_remote_free(origin);
95
96 cl_git_pass(git_reference_lookup(&ref, remote_repo, "refs/heads/packed"));
97 cl_git_pass(git_reference_delete(ref));
98 git_reference_free(ref);
99
82eeba81 100 cl_git_pass(git_remote_lookup(&origin, repo, GIT_REMOTE_ORIGIN));
8f0104ec
CMN
101 cl_git_pass(git_remote_fetch(origin, NULL, &options, NULL));
102 cl_git_pass(git_remote_prune(origin, &options.callbacks));
b8fefcb9
L
103
104 cl_git_pass(git_reference_list(&refnames, repo));
105 cl_assert_equal_i(17, (int)refnames.count);
22a2d3d5 106 git_strarray_dispose(&refnames);
b8fefcb9
L
107 git_remote_free(origin);
108
b8fefcb9
L
109 git_repository_free(repo);
110}
111
4aa23369
CMN
112int update_tips_fail_on_call(const char *ref, const git_oid *old, const git_oid *new, void *data)
113{
114 GIT_UNUSED(ref);
115 GIT_UNUSED(old);
116 GIT_UNUSED(new);
117 GIT_UNUSED(data);
118
119 cl_fail("update tips called");
120 return 0;
121}
122
4adc64a8
CMN
123void assert_ref_exists(git_repository *repo, const char *name)
124{
125 git_reference *ref;
126
127 cl_git_pass(git_reference_lookup(&ref, repo, name));
128 git_reference_free(ref);
129}
130
439e19f6
DC
131void test_network_fetchlocal__prune_overlapping(void)
132{
133 git_repository *repo;
134 git_remote *origin;
135 int callcount = 0;
136 git_strarray refnames = {0};
137 git_reference *ref;
439e19f6 138 git_config *config;
4adc64a8 139 git_oid target;
439e19f6
DC
140
141 git_repository *remote_repo = cl_git_sandbox_init("testrepo.git");
93d968fa 142 const char *url = cl_git_path_url(git_repository_path(remote_repo));
b91194e8 143
8f0104ec
CMN
144 git_fetch_options options = GIT_FETCH_OPTIONS_INIT;
145 options.callbacks.transfer_progress = transfer_cb;
146 options.callbacks.payload = &callcount;
439e19f6 147
4adc64a8
CMN
148 cl_git_pass(git_reference_lookup(&ref, remote_repo, "refs/heads/master"));
149 git_oid_cpy(&target, git_reference_target(ref));
150 git_reference_free(ref);
659cf202 151 cl_git_pass(git_reference_create(&ref, remote_repo, "refs/pull/42/head", &target, 1, NULL));
4adc64a8 152 git_reference_free(ref);
439e19f6
DC
153
154 cl_set_cleanup(&cleanup_local_repo, "foo");
155 cl_git_pass(git_repository_init(&repo, "foo", true));
156
157 cl_git_pass(git_remote_create(&origin, repo, GIT_REMOTE_ORIGIN, url));
439e19f6
DC
158
159 cl_git_pass(git_repository_config(&config, repo));
26186b15 160 cl_git_pass(git_config_set_bool(config, "remote.origin.prune", true));
439e19f6 161 cl_git_pass(git_config_set_multivar(config, "remote.origin.fetch", "^$", "refs/pull/*/head:refs/remotes/origin/pr/*"));
439e19f6 162
4adc64a8 163 git_remote_free(origin);
82eeba81 164 cl_git_pass(git_remote_lookup(&origin, repo, GIT_REMOTE_ORIGIN));
8f0104ec 165 cl_git_pass(git_remote_fetch(origin, NULL, &options, NULL));
439e19f6 166
4adc64a8
CMN
167 assert_ref_exists(repo, "refs/remotes/origin/master");
168 assert_ref_exists(repo, "refs/remotes/origin/pr/42");
439e19f6
DC
169 cl_git_pass(git_reference_list(&refnames, repo));
170 cl_assert_equal_i(20, (int)refnames.count);
22a2d3d5 171 git_strarray_dispose(&refnames);
439e19f6
DC
172
173 cl_git_pass(git_config_delete_multivar(config, "remote.origin.fetch", "refs"));
174 cl_git_pass(git_config_set_multivar(config, "remote.origin.fetch", "^$", "refs/pull/*/head:refs/remotes/origin/pr/*"));
175 cl_git_pass(git_config_set_multivar(config, "remote.origin.fetch", "^$", "refs/heads/*:refs/remotes/origin/*"));
176
4adc64a8 177 git_remote_free(origin);
82eeba81 178 cl_git_pass(git_remote_lookup(&origin, repo, GIT_REMOTE_ORIGIN));
8f0104ec
CMN
179 options.callbacks.update_tips = update_tips_fail_on_call;
180 cl_git_pass(git_remote_fetch(origin, NULL, &options, NULL));
439e19f6 181
4adc64a8
CMN
182 assert_ref_exists(repo, "refs/remotes/origin/master");
183 assert_ref_exists(repo, "refs/remotes/origin/pr/42");
439e19f6
DC
184 cl_git_pass(git_reference_list(&refnames, repo));
185 cl_assert_equal_i(20, (int)refnames.count);
22a2d3d5 186 git_strarray_dispose(&refnames);
93d968fa 187
7b6e1e4c
CMN
188 cl_git_pass(git_config_delete_multivar(config, "remote.origin.fetch", "refs"));
189 cl_git_pass(git_config_set_multivar(config, "remote.origin.fetch", "^$", "refs/heads/*:refs/remotes/origin/*"));
190 cl_git_pass(git_config_set_multivar(config, "remote.origin.fetch", "^$", "refs/pull/*/head:refs/remotes/origin/pr/*"));
4adc64a8
CMN
191
192 git_remote_free(origin);
7b6e1e4c 193 cl_git_pass(git_remote_lookup(&origin, repo, GIT_REMOTE_ORIGIN));
8f0104ec
CMN
194 options.callbacks.update_tips = update_tips_fail_on_call;
195 cl_git_pass(git_remote_fetch(origin, NULL, &options, NULL));
7b6e1e4c 196
b91194e8 197 git_config_free(config);
22a2d3d5 198 git_strarray_dispose(&refnames);
b91194e8 199 git_remote_free(origin);
93d968fa 200 git_repository_free(repo);
439e19f6
DC
201}
202
b8fefcb9
L
203void test_network_fetchlocal__fetchprune(void)
204{
205 git_repository *repo;
206 git_remote *origin;
207 int callcount = 0;
208 git_strarray refnames = {0};
209 git_reference *ref;
210 git_config *config;
211 git_repository *remote_repo = cl_git_sandbox_init("testrepo.git");
212 const char *url = cl_git_path_url(git_repository_path(remote_repo));
8f0104ec 213 git_fetch_options options = GIT_FETCH_OPTIONS_INIT;
b8fefcb9 214
8f0104ec
CMN
215 options.callbacks.transfer_progress = transfer_cb;
216 options.callbacks.payload = &callcount;
b8fefcb9
L
217
218 cl_set_cleanup(&cleanup_local_repo, "foo");
219 cl_git_pass(git_repository_init(&repo, "foo", true));
220
221 cl_git_pass(git_remote_create(&origin, repo, GIT_REMOTE_ORIGIN, url));
8f0104ec 222 cl_git_pass(git_remote_fetch(origin, NULL, &options, NULL));
b8fefcb9
L
223
224 cl_git_pass(git_reference_list(&refnames, repo));
225 cl_assert_equal_i(19, (int)refnames.count);
226 cl_assert(callcount > 0);
22a2d3d5 227 git_strarray_dispose(&refnames);
b8fefcb9
L
228 git_remote_free(origin);
229
230 cl_git_pass(git_reference_lookup(&ref, remote_repo, "refs/heads/br2"));
231 cl_git_pass(git_reference_delete(ref));
232 git_reference_free(ref);
233
82eeba81 234 cl_git_pass(git_remote_lookup(&origin, repo, GIT_REMOTE_ORIGIN));
8f0104ec
CMN
235 cl_git_pass(git_remote_fetch(origin, NULL, &options, NULL));
236 cl_git_pass(git_remote_prune(origin, &options.callbacks));
b8fefcb9
L
237
238 cl_git_pass(git_reference_list(&refnames, repo));
239 cl_assert_equal_i(18, (int)refnames.count);
22a2d3d5 240 git_strarray_dispose(&refnames);
b8fefcb9
L
241 git_remote_free(origin);
242
243 cl_git_pass(git_reference_lookup(&ref, remote_repo, "refs/heads/packed"));
244 cl_git_pass(git_reference_delete(ref));
245 git_reference_free(ref);
246
247 cl_git_pass(git_repository_config(&config, repo));
248 cl_git_pass(git_config_set_bool(config, "remote.origin.prune", 1));
249 git_config_free(config);
82eeba81 250 cl_git_pass(git_remote_lookup(&origin, repo, GIT_REMOTE_ORIGIN));
b8fefcb9 251 cl_assert_equal_i(1, git_remote_prune_refs(origin));
8f0104ec 252 cl_git_pass(git_remote_fetch(origin, NULL, &options, NULL));
b8fefcb9
L
253
254 cl_git_pass(git_reference_list(&refnames, repo));
255 cl_assert_equal_i(17, (int)refnames.count);
22a2d3d5 256 git_strarray_dispose(&refnames);
b8fefcb9
L
257 git_remote_free(origin);
258
b8fefcb9
L
259 git_repository_free(repo);
260}
261
5e0c3d2d
DC
262void test_network_fetchlocal__prune_tag(void)
263{
264 git_repository *repo;
265 git_remote *origin;
266 int callcount = 0;
267 git_reference *ref;
268 git_config *config;
269 git_oid tag_id;
270 git_signature *tagger;
271 git_object *obj;
272
273 git_repository *remote_repo = cl_git_sandbox_init("testrepo.git");
274 const char *url = cl_git_path_url(git_repository_path(remote_repo));
8f0104ec 275 git_fetch_options options = GIT_FETCH_OPTIONS_INIT;
5e0c3d2d 276
8f0104ec
CMN
277 options.callbacks.transfer_progress = transfer_cb;
278 options.callbacks.payload = &callcount;
5e0c3d2d
DC
279
280 cl_set_cleanup(&cleanup_local_repo, "foo");
281 cl_git_pass(git_repository_init(&repo, "foo", true));
282
283 cl_git_pass(git_remote_create(&origin, repo, GIT_REMOTE_ORIGIN, url));
8f0104ec 284 cl_git_pass(git_remote_fetch(origin, NULL, &options, NULL));
4adc64a8 285 git_remote_free(origin);
5e0c3d2d
DC
286
287 cl_git_pass(git_revparse_single(&obj, repo, "origin/master"));
288
659cf202 289 cl_git_pass(git_reference_create(&ref, repo, "refs/remotes/origin/fake-remote", git_object_id(obj), 1, NULL));
4adc64a8 290 git_reference_free(ref);
5e0c3d2d
DC
291
292 /* create signature */
293 cl_git_pass(git_signature_new(&tagger, tagger_name, tagger_email, 123456789, 60));
294
295 cl_git_pass(
296 git_tag_create(&tag_id, repo,
297 "some-tag", obj, tagger, tagger_message, 0)
298 );
4adc64a8 299 git_signature_free(tagger);
5e0c3d2d
DC
300
301 cl_git_pass(git_repository_config(&config, repo));
302 cl_git_pass(git_config_set_bool(config, "remote.origin.prune", 1));
303 git_config_free(config);
304 cl_git_pass(git_remote_lookup(&origin, repo, GIT_REMOTE_ORIGIN));
305 cl_assert_equal_i(1, git_remote_prune_refs(origin));
8f0104ec 306 cl_git_pass(git_remote_fetch(origin, NULL, &options, NULL));
5e0c3d2d 307
4adc64a8
CMN
308 assert_ref_exists(repo, "refs/tags/some-tag");
309 cl_git_fail_with(GIT_ENOTFOUND, git_reference_lookup(&ref, repo, "refs/remotes/origin/fake-remote"));
5e0c3d2d
DC
310
311 git_object_free(obj);
312 git_remote_free(origin);
313
5e0c3d2d
DC
314 git_repository_free(repo);
315}
316
11fabe73
BS
317void test_network_fetchlocal__partial(void)
318{
319 git_repository *repo = cl_git_sandbox_init("partial-testrepo");
11fabe73
BS
320 git_remote *origin;
321 int callcount = 0;
322 git_strarray refnames = {0};
2ff1a0d0 323 const char *url;
8f0104ec 324 git_fetch_options options = GIT_FETCH_OPTIONS_INIT;
d31402a3 325
8f0104ec
CMN
326 options.callbacks.transfer_progress = transfer_cb;
327 options.callbacks.payload = &callcount;
11fabe73 328
2b562c3a 329 cl_git_pass(git_reference_list(&refnames, repo));
a8122b5d 330 cl_assert_equal_i(1, (int)refnames.count);
11fabe73 331
2ff1a0d0 332 url = cl_git_fixture_url("testrepo.git");
29f27599 333 cl_git_pass(git_remote_create(&origin, repo, GIT_REMOTE_ORIGIN, url));
8f0104ec 334 cl_git_pass(git_remote_fetch(origin, NULL, &options, NULL));
11fabe73 335
22a2d3d5 336 git_strarray_dispose(&refnames);
4e547eee 337
2b562c3a 338 cl_git_pass(git_reference_list(&refnames, repo));
24cb87e2 339 cl_assert_equal_i(20, (int)refnames.count); /* 18 remote + 1 local */
11fabe73
BS
340 cl_assert(callcount > 0);
341
22a2d3d5 342 git_strarray_dispose(&refnames);
11fabe73 343 git_remote_free(origin);
11fabe73 344}
b2067248 345
6812afaf
CMN
346static int remote_mirror_cb(git_remote **out, git_repository *repo,
347 const char *name, const char *url, void *payload)
b2067248 348{
6812afaf 349 int error;
b2067248 350 git_remote *remote;
b2067248 351
6812afaf
CMN
352 GIT_UNUSED(payload);
353
77254990 354 if ((error = git_remote_create_with_fetchspec(&remote, repo, name, url, "+refs/*:refs/*")) < 0)
6812afaf 355 return error;
b2067248 356
6812afaf
CMN
357 *out = remote;
358 return 0;
359}
360
361void test_network_fetchlocal__clone_into_mirror(void)
362{
363 git_clone_options opts = GIT_CLONE_OPTIONS_INIT;
364 git_repository *repo;
a8792767 365 git_reference *ref;
6812afaf
CMN
366
367 opts.bare = true;
368 opts.remote_cb = remote_mirror_cb;
369 cl_git_pass(git_clone(&repo, cl_git_fixture_url("testrepo.git"), "./foo.git", &opts));
b2067248 370
a8792767 371 cl_git_pass(git_reference_lookup(&ref, repo, "HEAD"));
ac3d33df 372 cl_assert_equal_i(GIT_REFERENCE_SYMBOLIC, git_reference_type(ref));
a8792767
CMN
373 cl_assert_equal_s("refs/heads/master", git_reference_symbolic_target(ref));
374
375 git_reference_free(ref);
376 cl_git_pass(git_reference_lookup(&ref, repo, "refs/remotes/test/master"));
377
378 git_reference_free(ref);
379 git_repository_free(repo);
380 cl_fixture_cleanup("./foo.git");
381}
382
383void test_network_fetchlocal__all_refs(void)
384{
385 git_repository *repo;
386 git_remote *remote;
387 git_reference *ref;
388 char *allrefs = "+refs/*:refs/*";
389 git_strarray refspecs = {
390 &allrefs,
391 1,
392 };
393
394 cl_git_pass(git_repository_init(&repo, "./foo.git", true));
395 cl_git_pass(git_remote_create_anonymous(&remote, repo, cl_git_fixture_url("testrepo.git")));
396 cl_git_pass(git_remote_fetch(remote, &refspecs, NULL, NULL));
397
398 cl_git_pass(git_reference_lookup(&ref, repo, "refs/remotes/test/master"));
399 git_reference_free(ref);
400
401 cl_git_pass(git_reference_lookup(&ref, repo, "refs/tags/test"));
402 git_reference_free(ref);
b2067248 403
a8792767 404 git_remote_free(remote);
b2067248 405 git_repository_free(repo);
b2067248
CMN
406 cl_fixture_cleanup("./foo.git");
407}
8deea589
L
408
409void test_network_fetchlocal__multi_remotes(void)
410{
411 git_repository *repo = cl_git_sandbox_init("testrepo.git");
412 git_remote *test, *test2;
413 git_strarray refnames = {0};
8f0104ec 414 git_fetch_options options = GIT_FETCH_OPTIONS_INIT;
8deea589 415
8f0104ec 416 options.callbacks.transfer_progress = transfer_cb;
22261344 417 cl_git_pass(git_remote_set_url(repo, "test", cl_git_fixture_url("testrepo.git")));
209425ce 418 cl_git_pass(git_remote_lookup(&test, repo, "test"));
8f0104ec 419 cl_git_pass(git_remote_fetch(test, NULL, &options, NULL));
8deea589
L
420
421 cl_git_pass(git_reference_list(&refnames, repo));
22a2d3d5
UG
422 cl_assert_equal_i(33, (int)refnames.count);
423 git_strarray_dispose(&refnames);
8deea589 424
22261344 425 cl_git_pass(git_remote_set_url(repo, "test_with_pushurl", cl_git_fixture_url("testrepo.git")));
209425ce 426 cl_git_pass(git_remote_lookup(&test2, repo, "test_with_pushurl"));
8f0104ec 427 cl_git_pass(git_remote_fetch(test2, NULL, &options, NULL));
8deea589
L
428
429 cl_git_pass(git_reference_list(&refnames, repo));
22a2d3d5 430 cl_assert_equal_i(45, (int)refnames.count);
8deea589 431
22a2d3d5 432 git_strarray_dispose(&refnames);
8deea589
L
433 git_remote_free(test);
434 git_remote_free(test2);
8deea589 435}
3ded7f28
CMN
436
437static int sideband_cb(const char *str, int len, void *payload)
438{
439 int *count = (int *) payload;
440
441 GIT_UNUSED(str);
442 GIT_UNUSED(len);
443
444 (*count)++;
445 return 0;
446}
447
448void test_network_fetchlocal__call_progress(void)
449{
450 git_repository *repo;
451 git_remote *remote;
8f0104ec 452 git_fetch_options options = GIT_FETCH_OPTIONS_INIT;
3ded7f28
CMN
453 int callcount = 0;
454
455 cl_git_pass(git_repository_init(&repo, "foo.git", true));
456 cl_set_cleanup(cleanup_local_repo, "foo.git");
457
458 cl_git_pass(git_remote_create_with_fetchspec(&remote, repo, "origin", cl_git_fixture_url("testrepo.git"), "+refs/heads/*:refs/heads/*"));
459
8f0104ec
CMN
460 options.callbacks.sideband_progress = sideband_cb;
461 options.callbacks.payload = &callcount;
3ded7f28 462
8f0104ec 463 cl_git_pass(git_remote_fetch(remote, NULL, &options, NULL));
3ded7f28
CMN
464 cl_assert(callcount != 0);
465
466 git_remote_free(remote);
467 git_repository_free(repo);
468}
1ef3f0ce
DC
469
470void test_network_fetchlocal__prune_load_remote_prune_config(void)
471{
472 git_repository *repo;
473 git_remote *origin;
de4a75f9 474 git_config *config;
1ef3f0ce
DC
475 git_repository *remote_repo = cl_git_sandbox_init("testrepo.git");
476 const char *url = cl_git_path_url(git_repository_path(remote_repo));
477
478 cl_set_cleanup(&cleanup_local_repo, "foo");
479 cl_git_pass(git_repository_init(&repo, "foo", true));
480
481 cl_git_pass(git_repository_config(&config, repo));
482 cl_git_pass(git_config_set_bool(config, "remote.origin.prune", 1));
483
484 cl_git_pass(git_remote_create(&origin, repo, GIT_REMOTE_ORIGIN, url));
485 cl_assert_equal_i(1, git_remote_prune_refs(origin));
486
487 git_config_free(config);
488 git_remote_free(origin);
489 git_repository_free(repo);
490}
491
492void test_network_fetchlocal__prune_load_fetch_prune_config(void)
493{
494 git_repository *repo;
495 git_remote *origin;
66b71ea5 496 git_config *config;
1ef3f0ce
DC
497 git_repository *remote_repo = cl_git_sandbox_init("testrepo.git");
498 const char *url = cl_git_path_url(git_repository_path(remote_repo));
499
500 cl_set_cleanup(&cleanup_local_repo, "foo");
501 cl_git_pass(git_repository_init(&repo, "foo", true));
502
503 cl_git_pass(git_repository_config(&config, repo));
504 cl_git_pass(git_config_set_bool(config, "fetch.prune", 1));
505
506 cl_git_pass(git_remote_create(&origin, repo, GIT_REMOTE_ORIGIN, url));
507 cl_assert_equal_i(1, git_remote_prune_refs(origin));
508
509 git_config_free(config);
510 git_remote_free(origin);
511 git_repository_free(repo);
512}