From 9364f274d7189ec9f39fee6e6b056434dca13b54 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Fri, 5 May 2017 09:40:38 +0200 Subject: remote: test creating and fetching detached remotes --- tests/online/remotes.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'tests/online') diff --git a/tests/online/remotes.c b/tests/online/remotes.c index 3a483f79c..d79eb1f59 100644 --- a/tests/online/remotes.c +++ b/tests/online/remotes.c @@ -87,3 +87,41 @@ void test_online_remotes__detached_remote_fails_pushing(void) git_remote_free(remote); } + +void test_online_remotes__detached_remote_succeeds_ls(void) +{ + const char *refs[] = { + "HEAD", + "refs/heads/first-merge", + "refs/heads/master", + "refs/heads/no-parent", + "refs/tags/annotated_tag", + "refs/tags/annotated_tag^{}", + "refs/tags/blob", + "refs/tags/commit_tree", + "refs/tags/nearly-dangling", + }; + const git_remote_head **heads; + git_remote *remote; + size_t i, j, n; + + cl_git_pass(git_remote_create_detached(&remote, URL)); + cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL, NULL, NULL)); + cl_git_pass(git_remote_ls(&heads, &n, remote)); + + cl_assert_equal_sz(n, 9); + for (i = 0; i < n; i++) { + char found = false; + + for (j = 0; j < ARRAY_SIZE(refs); j++) { + if (!strcmp(heads[i]->name, refs[j])) { + found = true; + break; + } + } + + cl_assert_(found, heads[i]->name); + } + + git_remote_free(remote); +} -- cgit v1.2.1