From 4cd29a21303cba55c3cc4466a1ffd2fc758a02d9 Mon Sep 17 00:00:00 2001 From: Jun Wu Date: Wed, 10 Mar 2021 22:13:52 -0800 Subject: [PATCH] working_copy: avoid std::os::unix on Windows std::os::unix::fs::PermissionsExt::mode() does not exist on Windows. Treat files on Windows as regular files. --- lib/src/working_copy.rs | 3 +++ lib/tests/test_working_copy.rs | 2 ++ 2 files changed, 5 insertions(+) diff --git a/lib/src/working_copy.rs b/lib/src/working_copy.rs index 94eab7e3b..bf05e1416 100644 --- a/lib/src/working_copy.rs +++ b/lib/src/working_copy.rs @@ -254,7 +254,10 @@ impl TreeState { } else if metadata_file_type.is_symlink() { FileType::Symlink } else { + #[cfg(unix)] let mode = metadata.permissions().mode(); + #[cfg(windows)] + let mode = 0; if mode & 0o111 != 0 { FileType::Executable } else { diff --git a/lib/tests/test_working_copy.rs b/lib/tests/test_working_copy.rs index 7aec37290..844e23335 100644 --- a/lib/tests/test_working_copy.rs +++ b/lib/tests/test_working_copy.rs @@ -195,6 +195,7 @@ fn test_checkout_file_transitions(use_git: bool) { assert_eq!(maybe_metadata.is_ok(), true, "{:?} should exist", path); let metadata = maybe_metadata.unwrap(); assert_eq!(metadata.is_file(), true, "{:?} should be a file", path); + #[cfg(unix)] assert_eq!( metadata.permissions().mode() & 0o111, 0, @@ -206,6 +207,7 @@ fn test_checkout_file_transitions(use_git: bool) { assert_eq!(maybe_metadata.is_ok(), true, "{:?} should exist", path); let metadata = maybe_metadata.unwrap(); assert_eq!(metadata.is_file(), true, "{:?} should be a file", path); + #[cfg(unix)] assert_ne!( metadata.permissions().mode() & 0o111, 0,