Expand description
Per-command handling: the option grammar of each Git command the wrapper understands, and the rules that rewrite, refuse or hint at a command. What: Per-command handling: the option grammar of each Git command the wrapper understands, and the rules that rewrite, refuse or hint at a command. Why: The wrapper judges commands one by one, so everything that is about a single Git command lives together.
In TS you’d write (pseudocode):
// command/index.ts: one `export * from './file'` per module below.Modules§
- command_
add - The Git 2.56.0 option table of
git addand its bulk-staging facts. What: The completegit addoption table of Git 2.56.0 and the bulk-staging facts read from it. Why: The add-explicit policy rejects staging that names no explicit path. Git accepts-Ainside any cluster (-vA), by abbreviation (--al) and through--no-ignore-removal; a list of exact tokens misses those. - command_
branch_ create - Branch-creation facts of
git branch,git checkoutandgit switch. What: Branch-creation facts ofgit branch,git checkoutandgit switchregions, read as Git 2.56.0 reads them. Why: The branch-worktree policy rejects creating a branch in the current worktree. It needs the explicit forms and the name Git may turn into a new local branch by matching a remote branch, for every spelling Git accepts. Gotcha: The facts read option names and argument counts only. Where Git later refuses for an option value, a combination of options, configuration or repository state, the answer stays “creates”: it errs toward the policy seeing the command. - command_
branch_ table - The complete Git 2.56.0 option table of
git branch. What: The complete option table ofgit branchin Git 2.56.0. Why: Whethergit branch <name>creates a branch depends on which action options were given, and whether a token is a name depends on each option’s arity. Rows followoptions[]incmd_branch(builtin/branch.c:992-1050) in source order. - command_
checkout_ table - The complete Git 2.56.0 option tables of
git checkoutandgit switch. What: The complete option tables ofgit checkoutandgit switchin Git 2.56.0. Why: Both commands create branches explicitly (-b,-c,--orphan,--track) and implicitly (a name that matches one remote branch). The tables are assembled as Git assembles them: the command’s own rows, then the shared groups (builtin/checkout.c:1786-1847, 2118-2129, 2170-2179). - command_
clean - The Git 2.56.0 option table of
git cleanand its deletion facts. What: The completegit cleanoption table of Git 2.56.0 and the deletion facts read from it. Why: The linked-worktree policy guards a clean that can delete files. Git’s last--dry-run/--no-dry-runwins, in clusters (-ndX) and abbreviations (--dry). - command_
commit - Facts about the arguments after
git commit. What: Facts about the arguments aftergit commit, read as Git 2.56.0 reads them. Why: The commit-only transform, the dry-run check and the commit transaction all decide from these facts. Every fact is the final state after Git applied each option in order, so--all --no-allreportsalloff, exactly asgit commitwould act. - command_
commit_ table - The complete Git 2.56.0 option table of
git commit. What: The complete option table ofgit commitin Git 2.56.0. Why: Declaring every option Git accepts removes the guess about whether an undeclared option consumes the next token. Rows followbuiltin_commit_options(builtin/commit.c:1705-1785) in source order, which the completion control compares. - command_
config - The form and file scope of a
git configregion. What: The form and file scope of agit configregion, read as Git 2.56.0 reads it. Why: The require-root policy exemptsgit configwhen it works on the per-user or system file, or lists. Whether--globalis that option or a value being stored depends on the form:git config user.name --globalwrites the text--globalinto the repository’s own configuration. - command_
config_ table - The Git 2.56.0 option groups of
git config. What: The option groups ofgit configin Git 2.56.0, one constant per group. Why: Git builds eachgit configsubcommand’s table from shared groups (CONFIG_LOCATION_OPTIONS,CONFIG_TYPE_OPTIONS,CONFIG_DISPLAY_OPTIONS, builtin/config.c:67-117) plus a few rows of its own. Keeping the same groups keeps one copy of every row. - command_
discard - The commands that can overwrite or delete uncommitted state, read as Git reads them.
What:
Which regions of
git checkout,git switch,git restore,git rm,git mv,git checkout-index,git read-treeand the--abortforms ofmerge,rebase,cherry-pick,revertandamcan overwrite or delete uncommitted state. Why: The linked-worktree policy confines such commands: it rejects them in the main worktree and, once the worktree holds uncommitted state, in a linked worktree too. Each region is read as Git 2.56.0 reads it, so a spelling Git accepts as--forceis not missed and a value that looks like a flag is not mistaken for one. Gotcha: Where Git itself refuses the region the answer is the refusal; the caller lets Git say so. - command_
options - Git 2.56.0
parse-optionstokenization of one command’s argument region. What: Read one Git command’s arguments the way Git 2.56.0parse-options.creads them. Why: A policy that guesses which token is an option, a value or a path can be bypassed by a spelling Git accepts. Every per-command module declares Git’s own option table and this module walks the arguments exactly once with Git’s rules. - command_
options_ query - 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.
- command_
push - The Git 2.56.0 option table of
git pushand its facts. What: The completegit pushoption table of Git 2.56.0 and the facts read from it. Why: The atomic-push transform must know whether the caller already chose atomicity, and the manual-push gate whether the push is a dry run; both in every spelling Git accepts (--at,--no-at,-nf), which a list of exact tokens misses. - command_
reset - The Git 2.56.0 option table of
git resetand its mode. What: The completegit resetoption table of Git 2.56.0 and the mode read from it. Why: The linked-worktree policy guards resets that rewrite worktree files:--hard,--mergeand--keep. The five mode options write one variable, so only the last one counts, in any abbreviation Git accepts. - command_
stash git stashsubcommand dispatch and wrapper-flag positions. What: Whichgit stashsubcommand a region runs in Git 2.56.0, and where wrapper-only flags sit in it. Why: The linked-worktree policy guards stash; its escape hatch must be found in option position of the subcommand that actually reads the arguments, so a message or a path that spells the hatch is forwarded untouched.- command_
stash_ table - The Git 2.56.0 option tables of every
git stashsubcommand. What: The option tables of everygit stashsubcommand in Git 2.56.0. Why:git stashdispatches to subcommands that each parse their own options with their own flags (builtin/stash.c); whether a token is an option value depends on which subcommand reads it. - command_
status - The Git 2.56.0 option table of
git status, its facts and the advice-key reading. What: The completegit statusoption table of Git 2.56.0, the machine-readable fact read from it, and the reading ofadvice.statusHintsset before the subcommand. Why: The status-hints transform must not override an explicit caller choice, and the wrapper adds no note to output a program will parse. - command_
worktree - Whether a
git worktreeinvocation changes worktree registrations (an add or a move). What: The one fact the wrapper needs aboutgit worktree: whether the invocation changes worktree registrations. Why: The worktree-copy opt-out is written aftergit worktree addorgit worktree move, so the flag is recognized after that second word; only an add is a source of ignored-state synchronization. - rule_
add_ explicit - Pure decision of the add-explicit policy.
What:
Pure decision of the add-explicit policy:
git addnames the paths it stages. Why:git add .,git add -Aandgit add -usweep up every changed path, including ones the caller never looked at, so one commit stops describing one change. The policy rejects those forms. This file decides from the arguments alone; it reads no file and starts no process. - rule_
argument_ rewrite - The shared result and builder of transforms that add tokens to a command line. What: The shared result and builder of fixed transforms that add tokens to a command line. Why: A transform either leaves the caller’s arguments alone or returns a new owned list; saying which lets the caller keep the original vector without comparing contents.
- rule_
atomic_ push - Pure decision of the atomic-push transform.
What:
The pure decision of the atomic-push transform:
insert
--atomicaftergit pushunless the caller already chose. Why: An atomic push updates every ref on the remote or none, which prevents partially applied pushes. - rule_
branch_ worktree - Pure decision of the branch-worktree-only policy and its one-query remote guess.
What:
Pure decision of the branch-worktree-only policy:
a new branch starts in its own
linked worktree,
not in the current one.
Why:
git branch <name>,git checkout -b,git switch -cand Git’s guess of a remote branch all create a branch in the current worktree. The policy rejects them and points atgit worktree add -b. This file decides from the arguments alone, names the one repository query the guess needs, and reads that query’s answer. It starts no process. - rule_
linked_ worktree - Pure decision of the linked-worktree-only policy.
What:
Pure decision of the linked-worktree-only policy:
commands that can discard uncommitted state never run in the main worktree, and run in a linked worktree
only while it is clean.
Why:
git stashthat changes state, a deletinggit clean, agit resetthat is not--soft,git restore,git checkoutandgit switchforms that overwrite files, a forcedrm,mv, orcheckout-index,read-tree --resetand an--abortcan throw away work, and the loss leaves no record. This file decides from the arguments alone whether the command is guarded and when, and from the worktree kind and dirtiness the caller measured whether to reject it. It starts no process. - rule_
linked_ worktree_ messages - The rejection texts of the linked-worktree-only policy.
What:
The rejection texts of the linked-worktree policy: outside any worktree, in the main worktree, and in a
worktree that holds uncommitted state.
Why:
Each text names the command, says what it could destroy, guesses what the person was trying to do, and names a
sanctioned way to do that without losing work; the deliberate way to discard anyway comes last. Every
alternative named here is run through the built executable by
binary_discard_tests.rs, and the README lists each form with the same alternatives. - rule_
require_ root - Pure decision of the require-root policy. What: Pure decision of the require-root policy: commands run from the repository root. Why: Running Git from a subdirectory makes pathspecs mean something else. The policy rejects that, except for commands that need no repository. This file decides from the argument list alone which commands are exempt, and from two paths the caller measured whether the directory is the root. It reads no file and starts no process.
- rule_
status_ hints - Pure decision of the status-hints transform.
What:
The pure decision of the status-hints transform:
insert
-c advice.statusHints=falsebeforegit statusunless the caller set that key. Why: Git’s stock status hints suggestgit add <file>...andgit commit -a, forms the wrapper’s policies reject; the wrapper prints accurate guidance instead. - rule_
worktree_ dirty - The query and reading of “does this worktree hold uncommitted state?”. What: The question “does this worktree hold uncommitted state?” as one Git query and its reading. Why: A command that can discard uncommitted state is judged by whether any exists: a clean linked worktree has nothing to lose, a dirty one does. Tracked changes (staged or not) always count; untracked files count only for the commands that delete them.