Skip to main content

Module commit_args

Module commit_args 

Source
Expand description

Argument transforms of native preparation: normalisation, global split, -a removal and private arguments. What: Argument transforms of native preparation: the normalised commit argument region, the split of global options from the commit region, the removal of -a/--all, and the arguments of the real git commit that run against the complete private index. Why: Native git commit must see the policy-settled index, not worktree bytes again, so selection controls and pathspecs are removed once the private index already holds them (src/policy-engine/commit-preparation-native.ts, commit-transaction-selection.ts, src/parser/commit-normalise.ts). The removals match the incumbent token for token, including its use of lastIndexOf, so a -m value equal to a pathspec is removed from the same position.

In TS you’d write (pseudocode):

const invocation = splitCommitInvocation({ args, subcommandIndex });
const commitArgs = withoutAllFlag(invocation.commitArgs);

Functions§

normalise_commit_args
What: Normalises the post-commit argument region, keeping the pathspec tail verbatim. Why: Later transforms recognize separated values only, and the pathspec tail after -- must not change.
private_explicit_commit_args
What: Removes the pathspec-file controls and the explicit pathspecs, then the -- separator and -o/--only, from the commit region. Why: The private index already holds the selected paths, so the real commit names none of them. The pathspec removal runs from the last pathspec backwards with lastIndexOf, as the incumbent does.
private_selection_commit_args
What: Removes the selection controls once the private index holds the exact user choice. Why: -i, -p, --include, --interactive and --patch already ran against the private index.
resolve_private_commit_args
What: Chooses the arguments of the real git commit for the commit mode. Why: Explicit-path commits drop their pathspecs; index commits drop selection controls only when selection ran privately.
split_commit_invocation
What: Splits a transformed argument list into the kept global options and the commit region. Why: Redirecting options (-C, --git-dir, --work-tree, --bare) would send native commit elsewhere, so they are dropped with their values, and every other global option is kept in order.
without_all_flag
What: Removes -a/--all from the commit region, keeping clustered short options. Why: The private index already holds every tracked change, so native commit must not restage worktree bytes.