Expand description
Pure decision of the linked-worktree-only policy.
What:
Pure decision of the linked-worktree-only policy:
commands that can discard uncommitted state never run in the main worktree, and run in a linked worktree
only while it is clean.
Why:
git stash that changes state,
a deleting git clean,
a git reset that is not --soft,
git restore,
git checkout and git switch forms that overwrite files,
a forced rm,
mv,
or checkout-index,
read-tree --reset and an --abort can throw away work, and the loss leaves no record.
This file decides from the arguments alone whether the command is guarded and when,
and from the worktree kind and dirtiness 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' }Re-exports§
pub use super::rule_linked_worktree_messages::dirty_worktree_message;pub use super::rule_linked_worktree_messages::main_worktree_message;pub use super::rule_linked_worktree_messages::outside_worktree_message;
Enums§
- Guarded
Command - What:
The forms the policy guards.
An
enumis a closed set of named alternatives.#[derive(...)]asks the compiler to generate copying, debug printing and==. Why: Each form has its own rejection text, because the same subcommand serves different intents:restore --stagedunstages whilerestore <path>reverts a file. - 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. - dirty_
scope - What:
The files that count as uncommitted state for a guarded command.
Why:
A
cleandeletes untracked files, so they count for it; every other form loses tracked changes only. - resolve_
linked_ worktree - What: Decide from the measured worktree kind: the rejection text, or nothing to let the command through for now. Why: The main worktree and a place without a worktree reject at once; a linked worktree and an allowlisted tool cache pass this step, and a linked worktree is then judged by its dirtiness.