worktree: Added worktree_dir check Fixes #5280
diff --git a/src/worktree.c b/src/worktree.c
index fda9b0b..ea5a403 100644
--- a/src/worktree.c
+++ b/src/worktree.c
@@ -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;
}