]>
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 | { | |
ac3d33df | 25 | /* try to list all the references in our test repo */ |
00a48934 BS |
26 | git_strarray ref_list; |
27 | ||
2b562c3a | 28 | cl_git_pass(git_reference_list(&ref_list, g_repo)); |
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 | ||
7604ddbf | 36 | /* We have exactly 12 refs in total if we include the packed ones: |
00a48934 BS |
37 | * there is a reference that exists both in the packfile and as |
38 | * loose, but we only list it once */ | |
22a2d3d5 | 39 | cl_assert_equal_i((int)ref_list.count, 19); |
00a48934 | 40 | |
22a2d3d5 | 41 | git_strarray_dispose(&ref_list); |
00a48934 BS |
42 | } |
43 | ||
c2948c77 | 44 | void test_refs_list__do_not_retrieve_references_which_name_end_with_a_lock_extension(void) |
45 | { | |
46 | git_strarray ref_list; | |
47 | ||
48 | /* Create a fake locked reference */ | |
49 | cl_git_mkfile( | |
50 | "./testrepo/.git/refs/heads/hanwen.lock", | |
51 | "144344043ba4d4a405da03de3844aa829ae8be0e\n"); | |
52 | ||
2b562c3a | 53 | cl_git_pass(git_reference_list(&ref_list, g_repo)); |
22a2d3d5 | 54 | cl_assert_equal_i((int)ref_list.count, 19); |
c2948c77 | 55 | |
22a2d3d5 | 56 | git_strarray_dispose(&ref_list); |
c2948c77 | 57 | } |