Commit 717df1a4 by Edward Thomson

worktree: validate worktree paths

Worktree paths need to fix within MAX_PATH always, regardless of
`core.longpaths` setting.
parent f3bcadd2
...@@ -135,6 +135,9 @@ static int open_worktree_dir(git_worktree **out, const char *parent, const char ...@@ -135,6 +135,9 @@ static int open_worktree_dir(git_worktree **out, const char *parent, const char
goto out; goto out;
} }
if ((error = git_path_validate_workdir(NULL, dir)) < 0)
goto out;
if ((wt = git__calloc(1, sizeof(*wt))) == NULL) { if ((wt = git__calloc(1, sizeof(*wt))) == NULL) {
error = -1; error = -1;
goto out; goto out;
...@@ -264,14 +267,14 @@ int git_worktree_validate(const git_worktree *wt) ...@@ -264,14 +267,14 @@ int git_worktree_validate(const git_worktree *wt)
wt->commondir_path); wt->commondir_path);
return GIT_ERROR; return GIT_ERROR;
} }
if (!git_path_exists(wt->worktree_path)) { if (!git_path_exists(wt->worktree_path)) {
git_error_set(GIT_ERROR_WORKTREE, git_error_set(GIT_ERROR_WORKTREE,
"worktree directory '%s' does not exist", "worktree directory '%s' does not exist",
wt->worktree_path); wt->worktree_path);
return GIT_ERROR; return GIT_ERROR;
} }
return 0; return 0;
} }
......
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