From e02c5b5930c2c9ba3e5423fe12e2ef0155017297 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 30 May 2024 20:31:36 +0200 Subject: Merging upstream version 1.74.1+dfsg1. Signed-off-by: Daniel Baumann --- vendor/gix-index/src/entry/mode.rs | 28 +++++++++++----------------- vendor/gix-index/src/entry/stat.rs | 4 ++-- 2 files changed, 13 insertions(+), 19 deletions(-) (limited to 'vendor/gix-index/src/entry') 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 diff --git a/vendor/gix-index/src/entry/stat.rs b/vendor/gix-index/src/entry/stat.rs index 65063dc16..7bde71763 100644 --- a/vendor/gix-index/src/entry/stat.rs +++ b/vendor/gix-index/src/entry/stat.rs @@ -95,8 +95,8 @@ impl Stat { use std::os::unix::fs::MetadataExt; #[cfg(unix)] let res = Stat { - mtime: mtime.try_into()?, - ctime: ctime.try_into()?, + mtime: mtime.try_into().unwrap_or_default(), + ctime: ctime.try_into().unwrap_or_default(), // truncating to 32 bits is fine here because // that's what the linux syscalls returns // just rust upcasts to 64 bits for some reason? -- cgit v1.2.3