Skip to content

Commit 8b0ffdc

Browse files
punkymaniacethomson
authored andcommitted
Add test for git_worktree_add no checkout
1 parent 5845175 commit 8b0ffdc

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/worktree/worktree.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,27 @@ void test_worktree_worktree__add_with_explicit_branch(void)
292292
git_worktree_free(wt);
293293
}
294294

295+
void test_worktree_worktree__add_no_checkout(void)
296+
{
297+
git_worktree *wt;
298+
git_repository *wtrepo;
299+
git_index *index;
300+
git_buf path = GIT_BUF_INIT;
301+
git_worktree_add_options opts = GIT_WORKTREE_ADD_OPTIONS_INIT;
302+
303+
opts.checkout_opts.checkout_strategy = GIT_CHECKOUT_NONE;
304+
305+
cl_git_pass(git_buf_joinpath(&path, fixture.repo->workdir, "../worktree-no-checkout"));
306+
cl_git_pass(git_worktree_add(&wt, fixture.repo, "worktree-no-checkout", path.ptr, &opts));
307+
308+
cl_git_pass(git_repository_open(&wtrepo, path.ptr));
309+
cl_git_pass(git_repository_index(&index, wtrepo));
310+
cl_assert_equal_i(git_index_entrycount(index), 0);
311+
312+
git_buf_dispose(&path);
313+
git_worktree_free(wt);
314+
git_repository_free(wtrepo);
315+
}
295316

296317
void test_worktree_worktree__init_existing_worktree(void)
297318
{

0 commit comments

Comments
 (0)