]> git.proxmox.com Git - libgit2.git/blame - tests/libgit2/refs/listall.c
Merge https://salsa.debian.org/debian/libgit2 into proxmox/bullseye
[libgit2.git] / tests / libgit2 / refs / listall.c
CommitLineData
99abb79d 1#include "clar_libgit2.h"
2#include "posix.h"
3
4static git_repository *repo;
5static git_strarray ref_list;
6
7static void ensure_no_refname_starts_with_a_forward_slash(const char *path)
8{
90e6c620 9 size_t i;
99abb79d 10
11 cl_git_pass(git_repository_open(&repo, path));
2b562c3a 12 cl_git_pass(git_reference_list(&ref_list, repo));
99abb79d 13
14 cl_assert(ref_list.count > 0);
15
16 for (i = 0; i < ref_list.count; i++)
17 cl_assert(git__prefixcmp(ref_list.strings[i], "/") != 0);
18
22a2d3d5 19 git_strarray_dispose(&ref_list);
99abb79d 20 git_repository_free(repo);
21}
22
23void test_refs_listall__from_repository_opened_through_workdir_path(void)
24{
25 cl_fixture_sandbox("status");
26 cl_git_pass(p_rename("status/.gitted", "status/.git"));
27
28 ensure_no_refname_starts_with_a_forward_slash("status");
29
30 cl_fixture_cleanup("status");
31}
32
33void test_refs_listall__from_repository_opened_through_gitdir_path(void)
34{
35 ensure_no_refname_starts_with_a_forward_slash(cl_fixture("testrepo.git"));
36}
5c7b77c4
SG
37
38void test_refs_listall__from_repository_with_no_trailing_newline(void)
39{
40 cl_git_pass(git_repository_open(&repo, cl_fixture("bad_tag.git")));
2b562c3a 41 cl_git_pass(git_reference_list(&ref_list, repo));
5c7b77c4
SG
42
43 cl_assert(ref_list.count > 0);
44
22a2d3d5 45 git_strarray_dispose(&ref_list);
5c7b77c4
SG
46 git_repository_free(repo);
47}