]> git.proxmox.com Git - libgit2.git/blame - tests-clar/refs/listall.c
Allow peeled references without trailing newline at end of file
[libgit2.git] / tests-clar / 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));
4fbd1c00 12 cl_git_pass(git_reference_list(&ref_list, repo, GIT_REF_LISTALL));
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
19 git_strarray_free(&ref_list);
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}