MCPcopy Create free account
hub / github.com/dtormoen/tsk-tsk / find_worktree_root

Function find_worktree_root

src/repo_utils.rs:139–147  ·  view source on GitHub ↗

Find the worktree root directory from a starting path. Uses `git rev-parse` to determine if the path is inside a git worktree. Returns the worktree directory if so, or `None` if it's a normal repository.

(start_path: &Path)

Source from the content-addressed store, hash-verified

137/// Uses `git rev-parse` to determine if the path is inside a git worktree.
138/// Returns the worktree directory if so, or `None` if it's a normal repository.
139pub fn find_worktree_root(start_path: &Path) -> Result<Option<PathBuf>, Box<dyn Error>> {
140 let info = detect_git_repo(start_path)?;
141
142 if info.is_worktree {
143 Ok(Some(info.toplevel))
144 } else {
145 Ok(None)
146 }
147}
148
149#[cfg(test)]
150mod tests {

Callers 4

executeMethod · 0.85

Calls 1

detect_git_repoFunction · 0.85