File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -259,7 +259,14 @@ int git_worktree_validate(const git_worktree *wt)
259259 wt -> commondir_path );
260260 return GIT_ERROR ;
261261 }
262-
262+
263+ if (!git_path_exists (wt -> worktree_path )) {
264+ git_error_set (GIT_ERROR_WORKTREE ,
265+ "worktree directory '%s' does not exist" ,
266+ wt -> worktree_path );
267+ return GIT_ERROR ;
268+ }
269+
263270 return 0 ;
264271}
265272
Original file line number Diff line number Diff line change @@ -610,3 +610,15 @@ void test_worktree_worktree__foreach_worktree_lists_all_worktrees(void)
610610 int counter = 0 ;
611611 cl_git_pass (git_repository_foreach_worktree (fixture .repo , foreach_worktree_cb , & counter ));
612612}
613+
614+ void test_worktree_worktree__validate_invalid_worktreedir (void )
615+ {
616+ git_worktree * wt ;
617+
618+ cl_git_pass (git_worktree_lookup (& wt , fixture .repo , "testrepo-worktree" ));
619+ p_rename ("testrepo-worktree" , "testrepo-worktree-tmp" );
620+ cl_git_fail (git_worktree_validate (wt ));
621+ p_rename ("testrepo-worktree-tmp" , "testrepo-worktree" );
622+
623+ git_worktree_free (wt );
624+ }
You can’t perform that action at this time.
0 commit comments