Skip to content

Commit 717df1a

Browse files
committed
worktree: validate worktree paths
Worktree paths need to fix within MAX_PATH always, regardless of `core.longpaths` setting.
1 parent f3bcadd commit 717df1a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/worktree.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ static int open_worktree_dir(git_worktree **out, const char *parent, const char
135135
goto out;
136136
}
137137

138+
if ((error = git_path_validate_workdir(NULL, dir)) < 0)
139+
goto out;
140+
138141
if ((wt = git__calloc(1, sizeof(*wt))) == NULL) {
139142
error = -1;
140143
goto out;
@@ -264,14 +267,14 @@ int git_worktree_validate(const git_worktree *wt)
264267
wt->commondir_path);
265268
return GIT_ERROR;
266269
}
267-
270+
268271
if (!git_path_exists(wt->worktree_path)) {
269272
git_error_set(GIT_ERROR_WORKTREE,
270273
"worktree directory '%s' does not exist",
271274
wt->worktree_path);
272275
return GIT_ERROR;
273276
}
274-
277+
275278
return 0;
276279
}
277280

0 commit comments

Comments
 (0)