Skip to content

Commit 2fffc50

Browse files
authored
Merge pull request GitoxideLabs#2134 from EliahKagan/user-program-files
Extend `ALTERNATIVE_LOCATIONS` for per-user installations
2 parents e365244 + 7e77d40 commit 2fffc50

File tree

4 files changed

+396
-57
lines changed

4 files changed

+396
-57
lines changed

Cargo.lock

Lines changed: 0 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gix-path/Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ gix-testtools = { path = "../tests/tools" }
2929
serial_test = { version = "3.1.0", default-features = false }
3030

3131
[target.'cfg(windows)'.dev-dependencies]
32-
known-folders = "1.3.1"
33-
windows = { version = "0.61.3", features = ["Win32_System_Threading"] }
32+
windows = { version = "0.61.3", features = [
33+
"Win32_System_Com",
34+
"Win32_System_Threading",
35+
"Win32_UI_Shell",
36+
] }
3437
winreg = "0.55.0"

gix-path/src/env/git/mod.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,21 @@ where
3838
// known. So the situation where a process only passes down `ProgramFiles` sometimes happens.
3939
let varname_current = "ProgramFiles";
4040

41+
// Should give the user's local application data path on any system. If a user program files
42+
// directory exists for this user, then it should be the `Programs` subdirectory of this. If it
43+
// doesn't exist, or on a future or extremely strangely configured Windows setup where it is
44+
// somewhere else, it should still be safe to attempt to use it. (This differs from global
45+
// program files paths, which are usually subdirectories of the root of the system drive, which
46+
// limited user accounts can usually create their own arbitrarily named directories inside.)
47+
let varname_user_appdata_local = "LocalAppData";
48+
4149
// 64-bit relative bin dirs. So far, this is always `mingw64` or `clangarm64`, not `urct64` or
4250
// `clang64`. We check `clangarm64` before `mingw64`, because in the strange case that both are
4351
// available, we don't want to skip over a native ARM64 executable for an emulated x86_64 one.
44-
let suffixes_64 = [r"Git\clangarm64\bin", r"Git\mingw64\bin"].as_slice();
52+
let suffixes_64 = &[r"Git\clangarm64\bin", r"Git\mingw64\bin"][..];
4553

4654
// 32-bit relative bin dirs. So far, this is only ever `mingw32`, not `clang32`.
47-
let suffixes_32 = [r"Git\mingw32\bin"].as_slice();
55+
let suffixes_32 = &[r"Git\mingw32\bin"][..];
4856

4957
// Whichever of the 64-bit or 32-bit relative bin better matches this process's architecture.
5058
// Unlike the system architecture, the process architecture is always known at compile time.
@@ -53,7 +61,15 @@ where
5361
#[cfg(target_pointer_width = "32")]
5462
let suffixes_current = suffixes_32;
5563

64+
// Bin dirs relative to a user's local application data directory. We try each architecture.
65+
let suffixes_user = &[
66+
r"Programs\Git\clangarm64\bin",
67+
r"Programs\Git\mingw64\bin",
68+
r"Programs\Git\mingw32\bin",
69+
][..];
70+
5671
let rules = [
72+
(varname_user_appdata_local, suffixes_user),
5773
(varname_64bit, suffixes_64),
5874
(varname_x86, suffixes_32),
5975
(varname_current, suffixes_current),

0 commit comments

Comments
 (0)