Skip to content

Commit

Permalink
fix: Don't assume program files folder locations
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
EliahKagan committed Jul 14, 2024
1 parent 98db88b commit 15235bf
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions gix-path/src/env/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@ use once_cell::sync::Lazy;

/// Other places to find Git in.
#[cfg(windows)]
pub(super) static ALTERNATIVE_LOCATIONS: Lazy<Vec<PathBuf>> = Lazy::new(|| {
vec![
"C:/Program Files/Git/mingw64/bin".into(),
"C:/Program Files (x86)/Git/mingw32/bin".into(),
]
});
pub(super) static ALTERNATIVE_LOCATIONS: Lazy<Vec<PathBuf>> =
Lazy::new(|| locations_under_program_files(|key| std::env::var_os(key)));
#[cfg(not(windows))]
pub(super) static ALTERNATIVE_LOCATIONS: Lazy<Vec<PathBuf>> = Lazy::new(|| vec![]);

Expand Down

0 comments on commit 15235bf

Please sign in to comment.