Skip to content

Commit e0b7bf1

Browse files
committed
Assure windows home path is compared in absolute terms (#426)
In 'git', the passed path for ownership check probably is absolute for reasons, but that's not an assumption we can make in `gitoxide`. Hence we resolve the path fully before comparing one path with another. Without this, using `gitoxide` powered applications from the current working dir set to the home (probably) wouldn't work.
1 parent 85ab096 commit e0b7bf1

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

Cargo.lock

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

git-sec/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ thiserror = { version = "1.0.26", optional = true }
2626
libc = "0.2.123"
2727

2828
[target.'cfg(windows)'.dependencies]
29+
git-path = { version = "^0.1.2", path = "../git-path" }
2930
dirs = "4"
3031
windows = { version = "0.36.0", features = [ "alloc",
3132
"Win32_Foundation",

git-sec/src/identity.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@ mod impl_ {
7272
// Home is not actually owned by the corresponding user
7373
// but it can be considered de-facto owned by the user
7474
// Ignore errors here and just do the regular checks below
75-
if Some(path) == dirs::home_dir().as_deref() {
75+
if std::env::current_dir()
76+
.ok()
77+
.and_then(|cwd| git_path::realpath(path, cwd, 8).ok())
78+
== dirs::home_dir()
79+
{
7680
return Ok(true);
7781
}
7882

0 commit comments

Comments
 (0)