Skip to content

Commit 15235bf

Browse files
committed
fix: Don't assume program files folder locations
This checks where *program files* directories are located on a Windows system, which are used for a fallback check after `git` has not been found in a `PATH` search (to invoke `git` to find out information such as the location of its system config file). Previously, two hard-coded paths were used. These were correct for the vast majority of 64-bit Windows systems, but were in practice never correct on 32-bit Windows systems. Checking programmatically for the locations should thus enable detection to succeed on more systems and under more circumstances, and avoid other problems.
1 parent 98db88b commit 15235bf

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

gix-path/src/env/git.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@ use once_cell::sync::Lazy;
66

77
/// Other places to find Git in.
88
#[cfg(windows)]
9-
pub(super) static ALTERNATIVE_LOCATIONS: Lazy<Vec<PathBuf>> = Lazy::new(|| {
10-
vec![
11-
"C:/Program Files/Git/mingw64/bin".into(),
12-
"C:/Program Files (x86)/Git/mingw32/bin".into(),
13-
]
14-
});
9+
pub(super) static ALTERNATIVE_LOCATIONS: Lazy<Vec<PathBuf>> =
10+
Lazy::new(|| locations_under_program_files(|key| std::env::var_os(key)));
1511
#[cfg(not(windows))]
1612
pub(super) static ALTERNATIVE_LOCATIONS: Lazy<Vec<PathBuf>> = Lazy::new(|| vec![]);
1713

0 commit comments

Comments
 (0)