summaryrefslogtreecommitdiff
path: root/tests-clar/repo/getters.c
blob: 299a2cb42682be3dd151f66e596b7af2f3bebd4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "clar_libgit2.h"

void test_repo_getters__empty(void)
{
	git_repository *repo_empty, *repo_normal;

	cl_git_pass(git_repository_open(&repo_normal, cl_fixture("testrepo.git")));
	cl_assert(git_repository_is_empty(repo_normal) == 0);
	git_repository_free(repo_normal);

	cl_git_pass(git_repository_open(&repo_empty, cl_fixture("empty_bare.git")));
	cl_assert(git_repository_is_empty(repo_empty) == 1);
	git_repository_free(repo_empty);
}

void test_repo_getters__retrieving_the_odb_honors_the_refcount(void)
{
	git_odb *odb;
	git_repository *repo;

	cl_git_pass(git_repository_open(&repo, cl_fixture("testrepo.git")));

	cl_git_pass(git_repository_odb(&odb, repo));
	cl_assert(((git_refcount *)odb)->refcount == 2);

	git_repository_free(repo);
	cl_assert(((git_refcount *)odb)->refcount == 1);

	git_odb_free(odb);
}