Expand description
What git add would stage,
and the worktree files a direct command selects.
What:
The two candidate sources that need a private index:
what git add would stage,
and the worktree files a direct git cli-git check or fix selects.
Why:
Both are answered before Git touches the real index.
git add is replayed on a
private copy of the index,
and the candidates are the entries the replay changed,
as the installed wrapper’s add-policy-facts.ts and add-staged-delta.ts define
them.
A direct command stages its scope with git add --all on a private copy,
as direct-check-facts.ts does,
and every selected entry is a candidate.
Either
way the bytes are blobs Git hashed from the worktree at that moment,
read through
the one object reader,
so the number of Git processes does not grow with the
number of files.
In TS you’d write (pseudocode):
// await using prepared = await prepareCandidates(git, { kind: 'add', region: ['--', 'a.txt'] });
// for (const candidate of prepared.version.candidates) await prepared.store.bytes(candidate);Structs§
- Prepared
Candidates - What: Prepared candidates: the store that reads their bytes, the version that lists them, and the private index the store is bound to. Fields are dropped in the order written, so the store’s object reader ends before the private directory is removed. Why: The store keeps reading blobs after preparation; the private index must outlive it.
- Pushed
Scope - What: The commits and trees a manual push scans. Why: A pushed commit contributes its own delta, and a tip with no known base contributes its tree; both are listed without staging anything.
Enums§
- Candidate
Request - What:
What a lifecycle asks for.
An
enumis a closed set of named alternatives; each carries the arguments it needs.#[derive(...)]generates cloning, debug printing and==. Why: The two sources differ only in what is staged on the private copy and in which entries become candidates.
Constants§
- INDEX_
FILE_ VARIABLE - The environment variable that points Git at a different index file.
- PATHSPEC_
CHUNK_ SIZE - What:
The most pathspecs one
git diff-indexreceives.usizeis the type of counts. Why: The installed wrapper passes candidate paths 2,048 at a time (commit-transaction-candidate-batch.ts), far below any platform’s argument limit; one process per 2,048 changed paths keeps the count bounded.
Functions§
- prepare_
candidates - What:
Prepare the candidates of one request.
real_git,global_prefixandoverlayare the Git executable, the caller’s arguments before the subcommand and the child environment additions, exactly as every other Git query receives them. Why: The real index is copied first, so nothing below can change it. Forgit addthe store’s own listings add--no-literal-pathspecsafter the caller’s prefix: they rely on pathspec magic (:/,:(top,literal)), which literal pathspec mode, fromGIT_LITERAL_PATHSPECSor--literal-pathspecs, would turn into names that match nothing, leaving every change unchecked. The replay keeps the caller’s mode.