]> git.proxmox.com Git - libgit2.git/blob - tests/repo/getters.c
d401bb8327f2095d816a7e067441de366ba4d0f9
[libgit2.git] / tests / repo / getters.c
1 #include "clar_libgit2.h"
2 #include "repo/repo_helpers.h"
3
4 void test_repo_getters__is_empty_correctly_deals_with_pristine_looking_repos(void)
5 {
6 git_repository *repo;
7
8 repo = cl_git_sandbox_init("empty_bare.git");
9 cl_git_remove_placeholders(git_repository_path(repo), "dummy-marker.txt");
10
11 cl_assert_equal_i(true, git_repository_is_empty(repo));
12
13 cl_git_sandbox_cleanup();
14 }
15
16 void test_repo_getters__is_empty_can_detect_used_repositories(void)
17 {
18 git_repository *repo;
19
20 cl_git_pass(git_repository_open(&repo, cl_fixture("testrepo.git")));
21
22 cl_assert_equal_i(false, git_repository_is_empty(repo));
23
24 git_repository_free(repo);
25 }
26
27 void test_repo_getters__is_empty_can_detect_repositories_with_defaultbranch_config_empty(void)
28 {
29 git_repository *repo;
30
31 create_tmp_global_config("tmp_global_path", "init.defaultBranch", "");
32
33 cl_git_pass(git_repository_open(&repo, cl_fixture("testrepo.git")));
34 cl_assert_equal_i(false, git_repository_is_empty(repo));
35
36 git_repository_free(repo);
37 }
38
39 void test_repo_getters__retrieving_the_odb_honors_the_refcount(void)
40 {
41 git_odb *odb;
42 git_repository *repo;
43
44 cl_git_pass(git_repository_open(&repo, cl_fixture("testrepo.git")));
45
46 cl_git_pass(git_repository_odb(&odb, repo));
47 cl_assert(((git_refcount *)odb)->refcount.val == 2);
48
49 git_repository_free(repo);
50 cl_assert(((git_refcount *)odb)->refcount.val == 1);
51
52 git_odb_free(odb);
53 }