summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpunkymaniac <punkymaniac@protonmail.ch>2021-11-08 17:23:27 +0100
committerEdward Thomson <ethomson@edwardthomson.com>2021-12-23 14:21:49 -0600
commit8b0ffdcb7b115e8f578303d6d5acbf923cd5c811 (patch)
treea9d10100f2895c8d118d18e299c9ce1b3f76d30d
parent58451759c2fd728149aad6dc91cb0c3e774f68c7 (diff)
downloadlibgit2-8b0ffdcb7b115e8f578303d6d5acbf923cd5c811.tar.gz
Add test for `git_worktree_add` no checkout
-rw-r--r--tests/worktree/worktree.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/worktree/worktree.c b/tests/worktree/worktree.c
index 6f14b17f1..c57592079 100644
--- a/tests/worktree/worktree.c
+++ b/tests/worktree/worktree.c
@@ -292,6 +292,27 @@ void test_worktree_worktree__add_with_explicit_branch(void)
git_worktree_free(wt);
}
+void test_worktree_worktree__add_no_checkout(void)
+{
+ git_worktree *wt;
+ git_repository *wtrepo;
+ git_index *index;
+ git_buf path = GIT_BUF_INIT;
+ git_worktree_add_options opts = GIT_WORKTREE_ADD_OPTIONS_INIT;
+
+ opts.checkout_opts.checkout_strategy = GIT_CHECKOUT_NONE;
+
+ cl_git_pass(git_buf_joinpath(&path, fixture.repo->workdir, "../worktree-no-checkout"));
+ cl_git_pass(git_worktree_add(&wt, fixture.repo, "worktree-no-checkout", path.ptr, &opts));
+
+ cl_git_pass(git_repository_open(&wtrepo, path.ptr));
+ cl_git_pass(git_repository_index(&index, wtrepo));
+ cl_assert_equal_i(git_index_entrycount(index), 0);
+
+ git_buf_dispose(&path);
+ git_worktree_free(wt);
+ git_repository_free(wtrepo);
+}
void test_worktree_worktree__init_existing_worktree(void)
{