MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / git_program

Function git_program

tests/common/mod.rs:434–453  ·  view source on GitHub ↗

Resolves the `git` executable to an absolute path exactly once per process. Under heavy parallel test load (nextest spawns one process per test, each spawning several `git` subprocesses), a bare `Command::new("git")` PATH lookup can transiently fail the spawn with `ENOENT` ("No such file or directory") even though git is installed. Resolving to an absolute path up front — with an optional `GIT` e

()

Source from the content-addressed store, hash-verified

432/// front — with an optional `GIT` env override — removes the per-spawn PATH
433/// walk and makes the lookup deterministic.
434pub fn git_program() -> std::ffi::OsString {
435 use std::sync::OnceLock;
436 static GIT: OnceLock<std::ffi::OsString> = OnceLock::new();
437 GIT.get_or_init(|| {
438 if let Some(explicit) = std::env::var_os("GIT") {
439 return explicit;
440 }
441 let exe_name = if cfg!(windows) { "git.exe" } else { "git" };
442 if let Some(paths) = std::env::var_os("PATH") {
443 for dir in std::env::split_paths(&paths) {
444 let candidate = dir.join(exe_name);
445 if candidate.is_file() {
446 return candidate.into_os_string();
447 }
448 }
449 }
450 std::ffi::OsString::from("git")
451 })
452 .clone()
453}
454
455#[cfg(unix)]
456pub fn daemon_socket_path(home: &Path) -> PathBuf {

Callers 6

gitFunction · 0.50
run_gitFunction · 0.50
rev_listFunction · 0.50
commit_logMethod · 0.50
run_gitFunction · 0.50
gitFunction · 0.50

Calls

no outgoing calls

Tested by 2

gitFunction · 0.40
run_gitFunction · 0.40