pub fn worktrees_of(main_path: &Path) -> Vec<PathBuf>Expand description
Every matching path in a linked worktree registered under the checkout that
contains main_path.
When main_path is the checkout root, this returns linked worktree roots.
When it is a descendant (for example <main>/target), the same relative
path is appended to every linked worktree root (for example
<worktree>/target). This lets every entitlement layer share one mapping
rule instead of reimplementing worktree-relative paths independently.
Reads <main>/.git/worktrees/*/gitdir, each of which contains the path of
the worktree’s own .git file. Entries whose mapped path has been deleted
or was never created are skipped — a dead grant is not merely useless here,
it destabilizes the whole compiled sandbox profile (see
sandbox::policy::from_entitlements, Issue 16).
Returns empty for a path outside a main checkout, a linked-worktree path, a checkout with no worktrees, or an unreadable registry. Never errors: an undiscoverable worktree must degrade to “not granted” (fail-closed), never to a panic inside the gate.