MCPcopy Create free account
hub / github.com/git/git / check_candidate_path

Function check_candidate_path

builtin/worktree.c:317–343  ·  view source on GitHub ↗

check that path is viable location for worktree */

Source from the content-addressed store, hash-verified

315
316/* check that path is viable location for worktree */
317static 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
345static void copy_sparse_checkout(const char *worktree_git_dir)
346{

Callers 2

add_worktreeFunction · 0.85
move_worktreeFunction · 0.85

Calls 6

file_existsFunction · 0.85
is_empty_dirFunction · 0.85
find_worktree_by_pathFunction · 0.85
worktree_lock_reasonFunction · 0.85
delete_git_dirFunction · 0.85
dieFunction · 0.50

Tested by

no test coverage detected