tests: worktree/bare: fix git_worktree_validate
diff --git a/src/worktree.c b/src/worktree.c
index 591df1c..aa5c810 100644
--- a/src/worktree.c
+++ b/src/worktree.c
@@ -248,7 +248,7 @@ int git_worktree_validate(const git_worktree *wt)
goto out;
}
- if (!git_path_exists(wt->parent_path)) {
+ if (wt->parent_path && !git_path_exists(wt->parent_path)) {
giterr_set(GITERR_WORKTREE,
"Worktree parent directory ('%s') does not exist ",
wt->parent_path);
diff --git a/tests/worktree/bare.c b/tests/worktree/bare.c
index 7fda3b5..04060c0 100644
--- a/tests/worktree/bare.c
+++ b/tests/worktree/bare.c
@@ -42,6 +42,8 @@ void test_worktree_bare__add(void)
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));