Expand description
Pure decision of the commit-only transform.
What:
The pure decision of the commit-only transform:
insert -o after git commit,
or
say why not.
Why:
Every commit must name the paths it includes.
Two decisions need a repository fact
(sequencer state,
index against HEAD);
this module asks for the fact by returning
a Needs... variant and the caller answers through a resolve_... function,
so no
process or file is touched here.
In TS you’d write (pseudocode):
// const rule = makeCommitOnly({ checkIndexDiffersFromHead, checkSequencerInProgress });Structs§
- Commit
Only Violation - What:
One expected rejection.
Stringis owned UTF-8 text (sibling&strborrows). Why: The message is built per invocation, so the violation owns it. - Pending
Injection - What:
What
resolve_index_stateneeds to finish the decision. Why: The first call already locatedcommitand the pathless-allowed flags.
Enums§
- Commit
Only Decision - What: The transform’s answer, or the repository fact it needs first. Why: The facts are fetched lazily: most commands are decided from arguments alone.
- Commit
Only Violation Code - What:
Stable rejection codes.
An
enumis a closed set of named alternatives. Why: Events carrycommit-only/<code>; consumers match the code, not the message.
Functions§
- decide_
commit_ only - What:
Decide from arguments alone,
or name the repository fact needed.
Result<A, B>is “either successAor failureB”. Why: The order mirrors the TypeScript rule: escape hatch, opt-out,-a, pathspec source, explicit only, modes Git owns, then the dirty-index guard. Gotcha:Errmeans Git 2.56.0 itself refuses the commit options; the caller forwards such a command unchanged so Git prints its own error. - resolve_
index_ state - What:
Finish a
NeedsIndexStatedecision.&PendingInjectionborrows the pending data. Why: An injected--onlyon a pathless amend or empty commit reusesHEAD’s tree, so a dirty index would be ignored silently; an equal or unknown index is safe to inject. - resolve_
sequencer_ state - What:
Finish a
NeedsSequencerStatedecision. Why: A pathless commit concludes a merge, cherry-pick or revert; otherwise it is refused. - violation_
code_ text - What:
The kebab-case spelling of a code.
&'static stris text baked into the program. Why: The event format predates this module and its spellings must not drift.