Skip to content

Commit 1be7064

Browse files
committed
repo: don't fail on strange win32 paths
With some paths on Win32, we cannot identify the owner because it's on a file share (WSL2 or UNC). In that case, don't fail, but identify that the current user does not own the path. This matches Git for Windows behavior.
1 parent 795758d commit 1be7064

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

src/libgit2/repository.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,9 @@ static int validate_ownership_path(bool *is_safe, const char *path)
547547
if (error == GIT_ENOTFOUND) {
548548
*is_safe = true;
549549
error = 0;
550+
} else if (error == GIT_EINVALID) {
551+
*is_safe = false;
552+
error = 0;
550553
}
551554

552555
return error;

src/util/fs_path.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1855,7 +1855,7 @@ static int file_owner_sid(PSID *out, const char *path)
18551855
PSECURITY_DESCRIPTOR descriptor = NULL;
18561856
PSID owner_sid;
18571857
DWORD ret;
1858-
int error = -1;
1858+
int error = GIT_EINVALID;
18591859

18601860
if (git_win32_path_from_utf8(path_w32, path) < 0)
18611861
return -1;

0 commit comments

Comments
 (0)