Expand description
Final-state and position questions over a tokenized region. What: Small read-only questions over a tokenized Git argument region. Why: Git applies options in order and the last use wins, so command modules ask for final states and positions instead of counting spellings.
In TS you’d write (pseudocode):
// lastOccurrence(parsed, id), isEnabled(parsed, id), positionalTokens(parsed, length), ...Structs§
- Wrapper
Flags - What: Wrapper-only flags found in option position, split into the command’s own escape hatch and every other flag the caller listed. Why: A rule asks “was my hatch written?”, while the caller removes all of them by position.
Functions§
- is_
enabled - What:
Whether the option is on after every use was applied.
Why:
--all --no-allleavesalloff, exactly as Git’sOPT_BOOLdoes. - is_
stated - What:
Whether the option was written at all,
in either form.
Why:
An explicit
--no-onlyis a stated choice even though it turns the option off. - last_
occurrence - What:
The final use of the option
id, or nothing.&ParsedOptionsborrows the result read-only;u16is the identifier type of table rows. Why: Git’s variables keep what the last matching option wrote. - positional_
tokens - What:
Every non-option token index in order:
those before the boundary,
then every
token after it.
lengthis the region’s token count. Why: Git hands the command both groups as its remaining arguments. Gotcha: UnderBoundary::NonOptionthe boundary token itself is positional; under--and--end-of-optionsit is not. - split_
wrapper_ flags - What:
Split the wrapper occurrences of a parse whose flag list was built as
“own escape hatch first,
then the caller’s flags”.
&[WrapperOccurrence]borrows the occurrence list of that parse. Why: Every command module builds its list that way, so the caller’s indexes are the tokenizer’s indexes minus one. - value_
bytes - What:
The exact bytes of an option value.
&[u8]borrows them fromarguments. Why: Values are compared as bytes; converting toStringwould reject non-UTF-8 text. - without_
tokens - What:
Copy
argumentswithout the tokens atremoved, which are indexes relative tooffset(the index of the first region token). Why: Wrapper-only flags are deleted by position, so an equal-looking value or path stays.