MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / resolve_worktree

Function resolve_worktree

src/daemon/git_watch.rs:712–721  ·  view source on GitHub ↗

Resolves a `worktrees/ ` leaf to `(worktree_root, branch)` by reading its `gitdir` file and the linked HEAD.

(common: &Path, name: &str)

Source from the content-addressed store, hash-verified

710/// Resolves a `worktrees/<name>` leaf to `(worktree_root, branch)` by reading
711/// its `gitdir` file and the linked HEAD.
712fn resolve_worktree(common: &Path, name: &str) -> Option<(PathBuf, String)> {
713 let wt_meta = common.join("worktrees").join(name);
714 let gitdir_file = wt_meta.join("gitdir");
715 let gitdir_raw = std::fs::read_to_string(&gitdir_file).ok()?;
716 // `gitdir` points at `<worktree>/.git`; the worktree root is its parent.
717 let gitdir = PathBuf::from(gitdir_raw.trim());
718 let wt_root = gitdir.parent()?.to_path_buf();
719 let branch = crate::branch::current_branch(&wt_root)?;
720 Some((wt_root, branch))
721}
722
723/// Runs branch-store GC for a project, logging what it removed.
724///

Callers 1

execute_planFunction · 0.85

Calls 1

current_branchFunction · 0.85

Tested by

no test coverage detected