diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 18:31:44 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 18:31:44 +0000 |
commit | c23a457e72abe608715ac76f076f47dc42af07a5 (patch) | |
tree | 2772049aaf84b5c9d0ed12ec8d86812f7a7904b6 /vendor/gix-index/src/entry/mode.rs | |
parent | Releasing progress-linux version 1.73.0+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-c23a457e72abe608715ac76f076f47dc42af07a5.tar.xz rustc-c23a457e72abe608715ac76f076f47dc42af07a5.zip |
Merging upstream version 1.74.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/gix-index/src/entry/mode.rs')
-rw-r--r-- | vendor/gix-index/src/entry/mode.rs | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/vendor/gix-index/src/entry/mode.rs b/vendor/gix-index/src/entry/mode.rs index 7d3fdf506..0301df438 100644 --- a/vendor/gix-index/src/entry/mode.rs +++ b/vendor/gix-index/src/entry/mode.rs @@ -1,24 +1,16 @@ use crate::entry::Mode; -#[cfg(unix)] -/// Returns whether a a file has the executable permission set. -fn is_executable(metadata: &std::fs::Metadata) -> bool { - use std::os::unix::fs::MetadataExt; - (metadata.mode() & 0o100) != 0 -} - -#[cfg(not(unix))] -/// Returns whether a a file has the executable permission set. -fn is_executable(_metadata: &std::fs::Metadata) -> bool { - false -} - impl Mode { - /// Return true if this is a sparse entry, as it points to a directory which usually isn't what an 'unsparse' index tracks. + /// Return `true` if this is a sparse entry, as it points to a directory which usually isn't what an 'unsparse' index tracks. pub fn is_sparse(&self) -> bool { *self == Self::DIR } + /// Return `true` if this is a submodule entry. + pub fn is_submodule(&self) -> bool { + *self == Self::DIR | Self::SYMLINK + } + /// Compares this mode to the file system version ([`std::fs::symlink_metadata`]) /// and returns the change needed to update this mode to match the file. /// @@ -54,13 +46,15 @@ impl Mode { Mode::SYMLINK if has_symlinks && !stat.is_symlink() => (), Mode::SYMLINK if !has_symlinks && !stat.is_file() => (), Mode::COMMIT | Mode::DIR if !stat.is_dir() => (), - Mode::FILE if executable_bit && is_executable(stat) => return Some(Change::ExecutableBit), - Mode::FILE_EXECUTABLE if executable_bit && !is_executable(stat) => return Some(Change::ExecutableBit), + Mode::FILE if executable_bit && gix_fs::is_executable(stat) => return Some(Change::ExecutableBit), + Mode::FILE_EXECUTABLE if executable_bit && !gix_fs::is_executable(stat) => { + return Some(Change::ExecutableBit) + } _ => return None, }; let new_mode = if stat.is_dir() { Mode::COMMIT - } else if executable_bit && is_executable(stat) { + } else if executable_bit && gix_fs::is_executable(stat) { Mode::FILE_EXECUTABLE } else { Mode::FILE |