Skip to main content

Module real_git

Module real_git 

Source
Expand description

PATH resolution of the real Git executable. What: Find the real Git executable on PATH without ever selecting this wrapper. Why: The wrapper is installed as git ahead of real Git; forwarding needs the first usable candidate that is not a cli-git wrapper.

In TS you’d write (pseudocode):

// const gitPath = resolveRealGit(processResolutionInputs()); // '/usr/bin/git'

Structs§

RealGitNotFound
What: The failure when no PATH candidate can act as real Git. usize counts items; it is the length type of every Rust list. Why: The counts tell the user whether Git is missing or only wrappers were found.
ResolutionInputs
What: Everything resolution reads from the process, gathered into one value. Vec<PathBuf> is an owned list of owned paths. Why: Tests inject a disposable PATH and executable identity instead of mutating the real process environment.

Enums§

Platform
What: Which operating-system family’s lookup rules apply. #[derive(...)] generates copying, debug printing and ==. Why: Executable names, conventional install locations and path identity differ by family; passing the family as a value keeps every branch testable on one host.

Constants§

DEFAULT_WINDOWS_PATH_EXTENSIONS
Windows executable extensions in shell lookup order when PATHEXT is unset.

Functions§

candidate_sequence
What: Build the ordered, de-duplicated list of absolute candidates. Why: Every PATH directory contributes each executable name in order; conventional locations that PATH exposes are promoted to the front in their PATH spelling. Relative PATH entries are resolved against the current directory, as a shell does.
common_git_paths
What: List conventional Git install locations for a platform. &[(OsString, OsString)] borrows the environment as name/value pairs. Why: A conventional location wins over an earlier PATH entry, so a stray git script early on PATH cannot displace the system Git. Windows roots come from the environment; a trailing separator on a root is dropped before joining.
executable_names
What: List the file names PATH lookup tries, in order. Why: Unix runs git; Windows tries git plus each PATHEXT extension, adding a missing leading dot. An extension that is not UTF-8 cannot name a file portably and is skipped.
host_platform
What: The lookup rules of the platform this executable was compiled for. cfg!(...) is a compile-time true/false about the target platform. Why: Production uses the host’s rules; tests pass a platform explicitly.
process_resolution_inputs
What: Gather resolution inputs from the running process. std::io::Result<T> is Result<T, std::io::Error>. Why: The wrapper must know its own executable to exclude it; if the operating system cannot report it (or the current directory), resolution fails rather than risk selecting itself.
resolve_real_git
What: Select the first candidate that is real Git. Result<PathBuf, RealGitNotFound> is the selected path or the typed failure. Why: Wrappers are skipped and counted, unusable entries are skipped, and the first remaining candidate in priority order is forwarded to.