Expand description
Wrapper self-exclusion for one PATH candidate.
What:
Decide whether one PATH candidate is real Git,
a cli-git wrapper,
or unusable.
Why:
The wrapper shadows git on PATH and must never select itself,
a copy of
itself,
or a script that starts the TypeScript wrapper.
In TS you’d write (pseudocode):
// classifyCandidate('/usr/bin/git', ownExecutable) === 'real-git'Enums§
- Candidate
Kind - What:
The three verdicts for one candidate path.
#[derive(...)]generates copying, debug printing and==. Why: The resolver counts skipped wrappers separately from unusable entries so its failure message can say why nothing was selected.
Constants§
- MAX_
SCRIPT_ INSPECTION_ BYTES - What:
Largest script inspected for wrapper markers,
64 kibibytes.
usizeis the platform’s index and length type (siblingsu32,u64). Why: Generated command shims are tiny launchers; a fixed bound keeps an arbitrary PATH file from controlling how much the resolver reads.usizematches the buffer lengths it is compared with.
Functions§
- classify_
candidate - What: Classify one candidate against this wrapper’s own executable. Why: This is the whole self-exclusion decision: the same file (any link or spelling), an identical copy, or a TypeScript-wrapper launcher is a wrapper; any other executable regular file is Git.
- has_
wrapper_ marker - What: Report whether script bytes contain a TypeScript-wrapper marker. Why: This is the version-independent recognition of the other wrapper’s launchers.
- identical_
content - What: Report whether two files have the same length and the same bytes. Why: A copy of this executable under another name or directory is still this wrapper, although its inode differs. Lengths are compared first, so real Git is never read in full for this check.
- is_
executable - What:
Report whether file metadata says the file can be run.
#[cfg(unix)]and#[cfg(not(unix))]each compile one of the two inner blocks. Why: PATH lookup only runs executable files; a non-executablegitis skipped. On Unix this checks the mode bits, not the calling user’s access asaccess(2)would. Other systems have no execute bit: every regular file named by PATHEXT can run. The Markdown policy’s linter lookup applies the same test. - is_
native_ header - What: Report whether the bytes begin with a native executable signature. Why: Native candidates skip the script-marker search entirely.
- same_
file - What: Report whether two paths name the same existing file. Why: Self-exclusion must hold through symbolic links, hard links, relative spellings and repeated PATH directories. Either check alone suffices; an inspection failure means “not proven the same”.