Skip to main content

Module wrapper_invocation

Module wrapper_invocation 

Source
Expand description

Removal of every wrapper control from one invocation, by position. What: Remove every wrapper control from one invocation, before and after the subcommand, and say how the command’s own arguments were read. Why: Detecting a control and removing it must be one act. This module is the only place that removes wrapper tokens: positions come from Git’s own option table of the command where one is ported, and are deleted by position, so a control never reaches Git and a message, value or path that spells a control is never removed.

In TS you’d write (pseudocode):

// const { args, controls, reading } = stripWrapperControls(rawArgs);

Structs§

StrippedInvocation
What: One invocation with its wrapper controls taken out. A struct is a record with named fields; Vec<OsString> is an owned argument list. Why: Every later stage reads these arguments, which hold nothing Git does not know, and reads the controls’ effect from controls.

Enums§

RegionReading
What: How the tokens after the subcommand were read. An enum is a closed set of named alternatives; Refused carries Git’s refusal. #[derive(...)] asks the compiler to generate copying, debug printing and ==. Why: The caller must know whether controls were found with Git’s own grammar, only at the start of the region, or not at all because Git refuses the command.

Functions§

command_region
What: The tokens after the command word of an invocation that names a command. &[OsString] borrows those tokens. Why: The refusal frontier and the push gate both read the command’s own options; taking the region from one function keeps the two from reading different tokens.
command_word
What: The raw bytes of the command word of an invocation that names a command. &StrippedInvocation borrows the invocation; &[u8] borrows the word’s bytes. Why: Every later decision starts from the command word, read in one place. Gotcha: The caller must have seen that the invocation names a command; without one there is no word and this function panics.
strip_wrapper_controls
What: Remove every wrapper control from one invocation. &[OsString] borrows the arguments after the program name. Why: Controls before the subcommand go first, because Git’s global-option reader would otherwise report them as unknown options and every policy decision built on it would leave the command alone. Then the command’s own table, when ported and when Git accepts the region, says where the remaining controls sit.