]> git.proxmox.com Git - libgit2.git/blob - tests/libgit2/refs/list.c
New upstream version 1.5.0+ds
[libgit2.git] / tests / libgit2 / refs / list.c
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
28 cl_git_pass(git_reference_list(&ref_list, g_repo));
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 12 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 */
39 cl_assert_equal_i((int)ref_list.count, 19);
40
41 git_strarray_dispose(&ref_list);
42 }
43
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
53 cl_git_pass(git_reference_list(&ref_list, g_repo));
54 cl_assert_equal_i((int)ref_list.count, 19);
55
56 git_strarray_dispose(&ref_list);
57 }