check that path is viable location for worktree */
| 315 | |
| 316 | /* check that path is viable location for worktree */ |
| 317 | static void check_candidate_path(const char *path, |
| 318 | int force, |
| 319 | struct worktree **worktrees, |
| 320 | const char *cmd) |
| 321 | { |
| 322 | struct worktree *wt; |
| 323 | int locked; |
| 324 | |
| 325 | if (file_exists(path) && !is_empty_dir(path)) |
| 326 | die(_("'%s' already exists"), path); |
| 327 | |
| 328 | wt = find_worktree_by_path(worktrees, path); |
| 329 | if (!wt) |
| 330 | return; |
| 331 | |
| 332 | locked = !!worktree_lock_reason(wt); |
| 333 | if ((!locked && force) || (locked && force > 1)) { |
| 334 | if (delete_git_dir(wt->id)) |
| 335 | die(_("unusable worktree destination '%s'"), path); |
| 336 | return; |
| 337 | } |
| 338 | |
| 339 | if (locked) |
| 340 | die(_("'%s' is a missing but locked worktree;\nuse '%s -f -f' to override, or 'unlock' and 'prune' or 'remove' to clear"), path, cmd); |
| 341 | else |
| 342 | die(_("'%s' is a missing but already registered worktree;\nuse '%s -f' to override, or 'prune' or 'remove' to clear"), path, cmd); |
| 343 | } |
| 344 | |
| 345 | static void copy_sparse_checkout(const char *worktree_git_dir) |
| 346 | { |
no test coverage detected