diff options
| author | Patrick Steinhardt <ps@pks.im> | 2015-10-21 12:02:31 +0200 |
|---|---|---|
| committer | Patrick Steinhardt <ps@pks.im> | 2017-02-13 10:28:15 +0100 |
| commit | d3bc09e81687ca132226e93ce69b9a28b8d3c66b (patch) | |
| tree | fd1c69feb7f9cc665ac995ed4f30c45212c8b419 /tests/worktree | |
| parent | 45f2b7a43ffe77bac3acbf21a041b56f03842ba8 (diff) | |
| download | libgit2-d3bc09e81687ca132226e93ce69b9a28b8d3c66b.tar.gz | |
worktree: introduce `struct git_worktree`
Introduce a new `struct git_worktree`, which holds information
about a possible working tree connected to a repository.
Introduce functions to allow opening working trees for a
repository.
Diffstat (limited to 'tests/worktree')
| -rw-r--r-- | tests/worktree/worktree.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/tests/worktree/worktree.c b/tests/worktree/worktree.c index 3acae886e..28d88993d 100644 --- a/tests/worktree/worktree.c +++ b/tests/worktree/worktree.c @@ -1,8 +1,8 @@ #include "clar_libgit2.h" #include "worktree_helpers.h" -#include "git2/worktree.h" #include "repository.h" +#include "worktree.h" #define COMMON_REPO "testrepo" #define WORKTREE_REPO "testrepo-worktree" @@ -105,3 +105,29 @@ void test_worktree_worktree__list_without_worktrees(void) git_repository_free(repo); } + +void test_worktree_worktree__lookup(void) +{ + git_worktree *wt; + git_buf gitdir_path = GIT_BUF_INIT; + + cl_git_pass(git_worktree_lookup(&wt, fixture.repo, "testrepo-worktree")); + + git_buf_printf(&gitdir_path, "%s/worktrees/%s", fixture.repo->commondir, "testrepo-worktree"); + + cl_assert_equal_s(wt->gitdir_path, gitdir_path.ptr); + cl_assert_equal_s(wt->parent_path, fixture.repo->path_repository); + cl_assert_equal_s(wt->gitlink_path, fixture.worktree->path_gitlink); + cl_assert_equal_s(wt->commondir_path, fixture.repo->commondir); + + git_buf_free(&gitdir_path); + git_worktree_free(wt); +} + +void test_worktree_worktree__lookup_nonexistent_worktree(void) +{ + git_worktree *wt; + + cl_git_fail(git_worktree_lookup(&wt, fixture.repo, "nonexistent")); + cl_assert_equal_p(wt, NULL); +} |
