Expand description
Variables added to every real-Git child: lock PID injection and the forward-target marker. What: The environment variables cli-git adds for every real Git it starts. Why: Native Git must write lock-owner PID files, and a wrapper must be able to notice that another wrapper selected it as “real Git”.
In TS you’d write (pseudocode):
// spawn(gitPath, args, { env: { ...process.env, ...childEnvironmentOverlay(process.env, gitPath) } });Constants§
- COUNT_
VARIABLE - Git’s count variable for environment-supplied configuration.
- FORWARD_
TARGET_ VARIABLE - What: The variable naming the executable this wrapper selected as real Git. Why: If the selected executable is itself a cli-git wrapper (for example another build that file identity cannot recognise), it finds its own path here and stops instead of forwarding back and forth forever.
Functions§
- child_
environment_ overlay - What:
Compute every variable cli-git sets for a real Git child:
the lock PID
injection plus the forward-target marker naming
real_git. Why: Every Git the wrapper starts, forwarded or queried, gets the same additions; the rest of the caller’s environment is inherited unchanged. - environment_
value - What:
Look one variable up the way C’s
getenvdoes: the first entry wins.&[(OsString, OsString)]borrows a list of name/value pairs.Option<OsString>is “an owned value or nothing”. Why: The overlay must read exactly what the Git child will read. Returning an owned copy keeps the function free of borrow bookkeeping for the caller. - environment_
with_ overlay - What:
The complete environment of a Git child that is started with a cleared environment:
the caller’s variables, with every name the overlay sets replaced by the overlay’s value.
Why:
The incumbent’s push coordination, push and manual-push probe inherit the whole process environment
(
HOME,PATH,SSH_AUTH_SOCK, the user’sGIT_*variables) plus the overlay, and a credential helper or transport needs them; the overlay alone would start Git with an almost empty environment. - lockfile_
pid_ overlay - What:
Compute the variables that append
core.lockfilePid=trueto an environment’s numbered Git configuration.Vec<(OsString, OsString)>is an owned list of name/value pairs; it is empty when nothing must change. Why: Native Git then writes an owner PID file beside each lock it takes, which lock-ownership checks rely on. Numbered entries are read beforeGIT_CONFIG_PARAMETERS, so a caller’s explicit-c core.lockfilePid=falsestill wins. A count Git would reject, or a numbered entry Git would report as missing, is left untouched so Git reports the caller’s own mistake. - parse_
config_ count - What:
Parse
GIT_CONFIG_COUNTexactly as Git 2.56.0config.cdoes withstrtoul(env, &endp, 10)followed by its*endpandINT_MAXchecks.Option<u64>isSome(count)when Git accepts the value,Nonewhen Git would report “bogus count” or “too many entries”. Why: The overlay must append after the entries Git will really read, and must leave a value Git rejects untouched so Git reports the caller’s own mistake.strtoulskips leading whitespace and accepts one sign; a negated nonzero value wraps aboveINT_MAX, so only-0survives with a minus sign.