Unverified Commit 045748bb by Edward Thomson Committed by GitHub

Merge pull request #5692 from rbmclean/master

Add missing worktree_dir check and test case
parents a6d151bf c8fe4da3
......@@ -259,7 +259,14 @@ int git_worktree_validate(const git_worktree *wt)
wt->commondir_path);
return GIT_ERROR;
}
if (!git_path_exists(wt->worktree_path)) {
git_error_set(GIT_ERROR_WORKTREE,
"worktree directory '%s' does not exist",
wt->worktree_path);
return GIT_ERROR;
}
return 0;
}
......
......@@ -610,3 +610,15 @@ void test_worktree_worktree__foreach_worktree_lists_all_worktrees(void)
int counter = 0;
cl_git_pass(git_repository_foreach_worktree(fixture.repo, foreach_worktree_cb, &counter));
}
void test_worktree_worktree__validate_invalid_worktreedir(void)
{
git_worktree *wt;
cl_git_pass(git_worktree_lookup(&wt, fixture.repo, "testrepo-worktree"));
p_rename("testrepo-worktree", "testrepo-worktree-tmp");
cl_git_fail(git_worktree_validate(wt));
p_rename("testrepo-worktree-tmp", "testrepo-worktree");
git_worktree_free(wt);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment