Returns the resolved `git` program to spawn, as a cached `&'static OsStr`. Resolution order (performed once, then cached): 1. The `GIT` environment variable, if set and non-empty (explicit override, matching git's own habit of honoring a program override). 2. An absolute path found by a which-style walk of `PATH` (+ `PATHEXT` on Windows). 3. The literal `"git"` fallback, so behavior is never wors
()
| 32 | /// Callers pass the result straight to `Command::new(..)` (both `std` and |
| 33 | /// `tokio` accept `impl AsRef<OsStr>`). |
| 34 | pub fn git_program() -> &'static OsStr { |
| 35 | static PROGRAM: OnceLock<OsString> = OnceLock::new(); |
| 36 | PROGRAM.get_or_init(resolve_git_program).as_os_str() |
| 37 | } |
| 38 | |
| 39 | fn resolve_git_program() -> OsString { |
| 40 | // 1. Explicit override wins. Empty values are ignored so an accidental |
no outgoing calls