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'

Re-exports§

pub use crate::real_git_resolution::RecordedGit;
pub use crate::real_git_resolution::ResolvedGit;
pub use crate::real_git_resolution::resolve_real_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. Vec<SearchedCandidate> is an owned list of owned records (siblings: &[T], a borrowed view). Why: The counts tell the user whether Git is missing or only wrappers were found, and the list and the PATH value name what was searched. The record owns text, so it is not Copy.
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.
SearchedCandidate
What: One PATH candidate the search examined and what it found. CandidateKind is the verdict (real Git, wrapper, unusable). Why: The failure message lists every candidate with its verdict, so the person can see which entries led back to cli-git and which were not executable files at all.

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.
search_path_for_real_git
What: Select the first PATH 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. This is the search of PATH alone; every start of Git goes through resolve_real_git, which adds the recorded fallback.