summaryrefslogtreecommitdiffstats
path: root/vendor/gix-index/src/entry/mode.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/gix-index/src/entry/mode.rs')
-rw-r--r--vendor/gix-index/src/entry/mode.rs28
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