Expand description
The Git 2.56.0 option table of git reset and its mode.
What:
The complete git reset option table of Git 2.56.0 and the mode read from it.
Why:
The linked-worktree policy guards resets that rewrite worktree files:
--hard,
--merge and --keep.
The five mode options write one variable,
so only the
last one counts,
in any abbreviation Git accepts.
In TS you’d write (pseudocode):
// resetChangesWorktree(parseResetRegion(['--har', 'HEAD~1'])) === trueStructs§
- Reset
Region - What:
Facts of one
git resetregion.Option<ResetMode>is “a mode or none stated”. Why: With no mode option Git uses mixed, which leaves worktree files alone.
Enums§
- Reset
Mode - What:
The reset mode Git ends up with.
An
enumis a closed set of named alternatives. Why:Hard,MergeandKeeprewrite worktree files;MixedandSoftdo not.
Constants§
- HARD
--hard.- KEEP
--keep.- MERGE
--merge.- MIXED
--mixed.- RESET_
TABLE - What:
Rows of
options[]incmd_reset(builtin/reset.c:350-382), in source order.&[OptionSpec]is a borrowed table baked into the program. Why: The five modes arePARSE_OPT_NONEG;--recurse-submodulestakes an optional value, so a token after it is a revision or path. - SOFT
--soft.
Functions§
- parse_
reset_ region - What:
Parse the region after
reset.Result<A, B>is “either successAor failureB”. Why: A region Git itself would refuse yields the refusal; Git then resets nothing. - reset_
changes_ worktree - What:
Whether the reset can rewrite worktree files.
&ResetRegionborrows the facts. Why: Only these three modes setopts.update, which lets Git write worktree files (reset_index, builtin/reset.c:79-95).