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
63
64
65
66
67
68
69
70
71
72
|
#include "clar_libgit2.h"
#include "worktree_helpers.h"
#include "submodule/submodule_helpers.h"
#define COMMON_REPO "testrepo.git"
#define WORKTREE_REPO "worktree"
static git_repository *g_repo;
void test_worktree_bare__initialize(void)
{
g_repo = cl_git_sandbox_init(COMMON_REPO);
cl_assert_equal_i(1, git_repository_is_bare(g_repo));
cl_assert_equal_i(0, git_repository_is_worktree(g_repo));
}
void test_worktree_bare__cleanup(void)
{
cl_fixture_cleanup(WORKTREE_REPO);
cl_git_sandbox_cleanup();
}
void test_worktree_bare__list(void)
{
git_strarray wts;
cl_git_pass(git_worktree_list(&wts, g_repo));
cl_assert_equal_i(wts.count, 0);
git_strarray_dispose(&wts);
}
void test_worktree_bare__add(void)
{
git_worktree *wt;
git_repository *wtrepo;
git_strarray wts;
cl_git_pass(git_worktree_add(&wt, g_repo, "name", WORKTREE_REPO, NULL));
cl_git_pass(git_worktree_list(&wts, g_repo));
cl_assert_equal_i(wts.count, 1);
cl_git_pass(git_worktree_validate(wt));
cl_git_pass(git_repository_open(&wtrepo, WORKTREE_REPO));
cl_assert_equal_i(0, git_repository_is_bare(wtrepo));
cl_assert_equal_i(1, git_repository_is_worktree(wtrepo));
git_strarray_dispose(&wts);
git_worktree_free(wt);
git_repository_free(wtrepo);
}
void test_worktree_bare__repository_path(void)
{
git_worktree *wt;
git_repository *wtrepo;
cl_git_pass(git_worktree_add(&wt, g_repo, "name", WORKTREE_REPO, NULL));
cl_assert_equal_s(git_worktree_path(wt), cl_git_sandbox_path(0, WORKTREE_REPO, NULL));
cl_git_pass(git_repository_open(&wtrepo, WORKTREE_REPO));
cl_assert_equal_s(git_repository_path(wtrepo), cl_git_sandbox_path(1, COMMON_REPO, "worktrees", "name", NULL));
cl_assert_equal_s(git_repository_commondir(g_repo), git_repository_commondir(wtrepo));
cl_assert_equal_s(git_repository_workdir(wtrepo), cl_git_sandbox_path(1, WORKTREE_REPO, NULL));
git_repository_free(wtrepo);
git_worktree_free(wt);
}
|