]>
Commit | Line | Data |
---|---|---|
00a48934 BS |
1 | #include "clar_libgit2.h" |
2 | ||
3 | #include "repository.h" | |
4 | #include "git2/reflog.h" | |
5 | #include "reflog.h" | |
6 | ||
7 | static git_repository *g_repo; | |
8 | ||
9 | ||
10 | ||
11 | void test_refs_list__initialize(void) | |
12 | { | |
13 | g_repo = cl_git_sandbox_init("testrepo"); | |
14 | } | |
15 | ||
16 | void test_refs_list__cleanup(void) | |
17 | { | |
18 | cl_git_sandbox_cleanup(); | |
19 | } | |
20 | ||
21 | ||
22 | ||
23 | void test_refs_list__all(void) | |
24 | { | |
25 | // try to list all the references in our test repo | |
26 | git_strarray ref_list; | |
27 | ||
4fbd1c00 | 28 | cl_git_pass(git_reference_list(&ref_list, g_repo, GIT_REF_LISTALL)); |
00a48934 BS |
29 | |
30 | /*{ | |
31 | unsigned short i; | |
32 | for (i = 0; i < ref_list.count; ++i) | |
33 | printf("# %s\n", ref_list.strings[i]); | |
34 | }*/ | |
35 | ||
36 | /* We have exactly 9 refs in total if we include the packed ones: | |
37 | * there is a reference that exists both in the packfile and as | |
38 | * loose, but we only list it once */ | |
e9ca852e | 39 | cl_assert_equal_i((int)ref_list.count, 10); |
00a48934 BS |
40 | |
41 | git_strarray_free(&ref_list); | |
42 | } | |
43 | ||
44 | void test_refs_list__symbolic_only(void) | |
45 | { | |
46 | // try to list only the symbolic references | |
47 | git_strarray ref_list; | |
48 | ||
4fbd1c00 | 49 | cl_git_pass(git_reference_list(&ref_list, g_repo, GIT_REF_SYMBOLIC)); |
00a48934 BS |
50 | cl_assert(ref_list.count == 0); /* no symrefs in the test repo */ |
51 | ||
52 | git_strarray_free(&ref_list); | |
53 | } |