Skip to main content

Module command_reset

Module command_reset 

Source
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'])) === true

Structs§

ResetRegion
What: Facts of one git reset region. Option<ResetMode> is “a mode or none stated”. Why: With no mode option Git uses mixed, which leaves worktree files alone.

Enums§

ResetMode
What: The reset mode Git ends up with. An enum is a closed set of named alternatives. Why: Hard, Merge and Keep rewrite worktree files; Mixed and Soft do not.

Constants§

HARD
--hard.
KEEP
--keep.
MERGE
--merge.
MIXED
--mixed.
RESET_TABLE
What: Rows of options[] in cmd_reset (builtin/reset.c:350-382), in source order. &[OptionSpec] is a borrowed table baked into the program. Why: The five modes are PARSE_OPT_NONEG; --recurse-submodules takes 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 success A or failure B”. 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. &ResetRegion borrows the facts. Why: Only these three modes set opts.update, which lets Git write worktree files (reset_index, builtin/reset.c:79-95).