diff options
author | Patrick Steinhardt <ps@pks.im> | 2016-11-08 12:13:59 +0100 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2017-02-13 11:10:58 +0100 |
commit | 6f6dd17cb280d7d0f45f48fb618cc02df18b868a (patch) | |
tree | 838cc8d8e1dd366ce1848fdc6601c7383d4d5201 | |
parent | 1fd6e035ddb27a0271c5cc734698835317e93249 (diff) | |
download | libgit2-6f6dd17cb280d7d0f45f48fb618cc02df18b868a.tar.gz |
worktree: test creating and opening submodule worktrees
-rw-r--r-- | tests/worktree/worktree.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/worktree/worktree.c b/tests/worktree/worktree.c index 959c56520..f0c423599 100644 --- a/tests/worktree/worktree.c +++ b/tests/worktree/worktree.c @@ -1,5 +1,6 @@ #include "clar_libgit2.h" #include "worktree_helpers.h" +#include "submodule/submodule_helpers.h" #include "checkout.h" #include "repository.h" @@ -289,6 +290,33 @@ void test_worktree_worktree__init_existing_path(void) git_buf_free(&path); } +void test_worktree_worktree__init_submodule(void) +{ + git_repository *repo, *sm, *wt; + git_worktree *worktree; + git_buf path = GIT_BUF_INIT; + + cleanup_fixture_worktree(&fixture); + repo = setup_fixture_submod2(); + + cl_git_pass(git_buf_joinpath(&path, repo->workdir, "sm_unchanged")); + cl_git_pass(git_repository_open(&sm, path.ptr)); + cl_git_pass(git_buf_joinpath(&path, repo->workdir, "../worktree/")); + cl_git_pass(git_worktree_add(&worktree, sm, "repo-worktree", path.ptr)); + cl_git_pass(git_repository_open_from_worktree(&wt, worktree)); + + cl_assert_equal_s(path.ptr, wt->workdir); + cl_assert_equal_s(sm->commondir, wt->commondir); + + cl_git_pass(git_buf_joinpath(&path, sm->gitdir, "worktrees/repo-worktree/")); + cl_assert_equal_s(path.ptr, wt->gitdir); + + git_buf_free(&path); + git_worktree_free(worktree); + git_repository_free(sm); + git_repository_free(wt); +} + void test_worktree_worktree__validate(void) { git_worktree *wt; |