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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
#include "clar_libgit2.h"
#include "git2/sys/repository.h"
void test_repo_new__has_nothing(void)
{
git_repository *repo;
#ifdef GIT_EXPERIMENTAL_SHA256
cl_git_pass(git_repository_new(&repo, GIT_OID_SHA1));
#else
cl_git_pass(git_repository_new(&repo));
#endif
cl_assert_equal_b(true, git_repository_is_bare(repo));
cl_assert_equal_p(NULL, git_repository_path(repo));
cl_assert_equal_p(NULL, git_repository_workdir(repo));
git_repository_free(repo);
}
void test_repo_new__is_bare_until_workdir_set(void)
{
git_repository *repo;
#ifdef GIT_EXPERIMENTAL_SHA256
cl_git_pass(git_repository_new(&repo, GIT_OID_SHA1));
#else
cl_git_pass(git_repository_new(&repo));
#endif
cl_assert_equal_b(true, git_repository_is_bare(repo));
cl_git_pass(git_repository_set_workdir(repo, clar_sandbox_path(), 0));
cl_assert_equal_b(false, git_repository_is_bare(repo));
git_repository_free(repo);
}
void test_repo_new__sha1(void)
{
git_repository *repo;
#ifdef GIT_EXPERIMENTAL_SHA256
cl_git_pass(git_repository_new(&repo, GIT_OID_SHA1));
#else
cl_git_pass(git_repository_new(&repo));
#endif
cl_assert_equal_i(GIT_OID_SHA1, git_repository_oid_type(repo));
git_repository_free(repo);
}
void test_repo_new__sha256(void)
{
#ifndef GIT_EXPERIMENTAL_SHA256
cl_skip();
#else
git_repository *repo;
cl_git_pass(git_repository_new(&repo, GIT_OID_SHA256));
cl_assert_equal_i(GIT_OID_SHA256, git_repository_oid_type(repo));
git_repository_free(repo);
#endif
}
|