Documentation
¶
Overview ¶
Package gitroot resolves the repository root that a sandbox should cover.
The distinction this package exists for: `git rev-parse --show-toplevel` run from inside a *linked worktree* returns the worktree directory, not the main checkout. pi-go spawns subagents whose working directory is a linked worktree (`.pi-go/tasks/<id>`, `.worktrees/<branch>`), and each spawned pi process derives its own PI_SANDBOX_ROOT. Using the toplevel there roots the sandbox at the worktree, so every read or edit of a path elsewhere in the repo is rejected as escaping the sandbox — which is what made /run workers fall back to shelling out instead of using the file tools.
Detect resolves the main checkout instead, so a worker in a worktree can still reach the whole repository.
Index ¶
Constants ¶
const CmdTimeout = 5 * time.Second
CmdTimeout bounds every git subprocess this package spawns so a stalled repository (blocked hook, lock contention, unreachable network mount) cannot hang initialization indefinitely.
Variables ¶
This section is empty.
Functions ¶
func Detect ¶
Detect returns the main checkout of the repository containing dir, or "" when dir is not inside a repository.
For an ordinary checkout this is the same as `git rev-parse --show-toplevel`. For a linked worktree it is the main checkout the worktree belongs to, resolved through the common git directory.
Types ¶
This section is empty.