turborepo
d82c6919 - fix: Resolve git_root to worktree root in linked worktrees (#11974)

Commit
14 hours ago
fix: Resolve git_root to worktree root in linked worktrees (#11974) ## Summary - Fixes `Path X is not parent of Y` error when running turbo in a linked worktree that lives outside the main repo directory (e.g. `~/project/front-worktree/branch` alongside `~/project/front`) - The `detect_git2` code path was setting `git_root` to the main worktree root instead of the current worktree root, causing `strip_prefix` to fail when anchoring paths in the SCM layer ## Details The `git_root` field on `WorktreeInfo` is used by `SCM::new_with_git_root` as the root for all path anchoring operations (e.g. `self.root.anchor(turbo_root)`). When a linked worktree lives at a sibling path rather than inside the main repo, `strip_prefix(main_root)` on the worktree path fails. The subprocess code path (`detect_subprocess`) was already correct — it resolves `git_root` from `--show-cdup` relative to the current working directory. The `detect_git2` path incorrectly used `main_worktree_root.clone()` instead of `worktree_root.clone()`. The existing worktree tests all created worktrees *inside* the main repo directory, so `strip_prefix` would succeed even with the wrong root. Added regression tests that use sibling temp directories to reproduce the real-world layout. ## Test plan - `test_linked_worktree_outside_main_repo` — worktree detection returns `git_root == worktree_path` - `test_package_hashes_in_external_worktree` — end-to-end: detect worktree, construct SCM, hash package files in external worktree without error - All 112 existing `turborepo-scm` tests continue to pass <sub>Closes TURBO-5298</sub>
Author
Parents
Loading