Expand description
Pure decision of the linked-worktree-only policy.
What:
Pure decision of the linked-worktree-only policy:
commands that can discard
worktree state run only in a linked worktree.
Why:
git stash,
a deleting git clean and a git reset that rewrites files can throw
away work in the primary checkout.
The policy confines them to linked worktrees.
This file decides from the arguments alone whether the command is guarded,
and
from the worktree kind the caller measured whether to reject it.
It starts no
process.
In TS you’d write (pseudocode):
// decideLinkedWorktree(['clean', '-fd']) => { kind: 'needs-effective-target', command: 'clean' }Enums§
- Guarded
Command - What:
The commands the policy guards.
An
enumis a closed set of named alternatives.#[derive(...)]asks the compiler to generate copying, debug printing and==. Why: Each has its own rejection text. - Linked
Worktree Decision - What: The outcome of looking at the argument list only. Why: Most commands are not guarded and need no repository query at all.
Constants§
- LINKED_
WORKTREE_ REQUIRED_ CODE - What:
The finding code of a linked-worktree rejection.
&stris borrowed text baked into the program. Why: Callers identify the finding by this stable code.
Functions§
- decide_
linked_ worktree - What:
Decide from the argument list.
&[OsString]borrows the arguments, already free of wrapper controls. Why: A command that is not guarded, or that Git itself refuses, needs no measurement. - main_
worktree_ message - What: The rejection text for a command run in the main worktree. Why: The text says what the command could destroy and where to run it instead.
- outside_
worktree_ message - What:
The rejection text for a command run where there is no worktree.
&'static stris text baked into the program. Why: The text says what the command could destroy and how to run it safely. - resolve_
linked_ worktree - What: Decide from the measured worktree kind: the rejection text, or nothing to let the command through. Why: A linked worktree and an allowlisted tool cache are the two places where these commands may run.