MCPcopy Index your code
hub / github.com/git/git / update_worktree_location

Function update_worktree_location

worktree.c:432–457  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

430}
431
432void update_worktree_location(struct worktree *wt, const char *path_,
433 int use_relative_paths)
434{
435 struct strbuf path = STRBUF_INIT;
436 struct strbuf dotgit = STRBUF_INIT;
437 struct strbuf gitdir = STRBUF_INIT;
438 char *wt_gitdir;
439
440 if (is_main_worktree(wt))
441 BUG("can't relocate main worktree");
442
443 wt_gitdir = repo_common_path(the_repository, "worktrees/%s/gitdir", wt->id);
444 strbuf_realpath(&gitdir, wt_gitdir, 1);
445 strbuf_realpath(&path, path_, 1);
446 strbuf_addf(&dotgit, "%s/.git", path.buf);
447 if (fspathcmp(wt->path, path.buf)) {
448 write_worktree_linking_files(dotgit.buf, gitdir.buf, use_relative_paths);
449
450 free(wt->path);
451 wt->path = strbuf_detach(&path, NULL);
452 }
453 strbuf_release(&path);
454 strbuf_release(&dotgit);
455 strbuf_release(&gitdir);
456 free(wt_gitdir);
457}
458
459int is_worktree_being_rebased(const struct worktree *wt,
460 const char *target)

Callers 1

move_worktreeFunction · 0.85

Calls 7

is_main_worktreeFunction · 0.85
repo_common_pathFunction · 0.85
strbuf_realpathFunction · 0.85
strbuf_addfFunction · 0.85
strbuf_detachFunction · 0.85
strbuf_releaseFunction · 0.85

Tested by

no test coverage detected