pub struct WorktreeModePolicy {
pub trust_filemode: bool,
pub has_symlinks: bool,
}Expand description
What the worktree filesystem can express about a tracked path’s mode.
Git records these capabilities per repository as core.filemode (is the executable bit
meaningful?) and core.symlinks (can the checkout hold symbolic links?). Both default to
true; git init/git clone write false when probing the filesystem fails, which is the
norm on Windows. When a capability is missing, the worktree cannot show that aspect of a
path, so the mode already recorded in the index wins over what lstat reports.
Use WorktreeModePolicy::index_mode_for_worktree whenever a worktree mode is compared
with or written over an index entry: staging, status and worktree diffs all share it.
Fields§
§trust_filemode: boolcore.filemode: the worktree’s executable bit is meaningful.
has_symlinks: boolcore.symlinks: the worktree can hold symbolic links.
Implementations§
Source§impl WorktreeModePolicy
impl WorktreeModePolicy
Sourcepub fn from_config(config: &ConfigSet) -> Self
pub fn from_config(config: &ConfigSet) -> Self
Read core.filemode and core.symlinks from config, defaulting each to true when
unset or not a boolean.
Sourcepub fn index_mode_for_worktree(
self,
worktree_mode: u32,
recorded_mode: Option<u32>,
) -> u32
pub fn index_mode_for_worktree( self, worktree_mode: u32, recorded_mode: Option<u32>, ) -> u32
The mode to record for a path given its worktree mode and the mode currently recorded.
Rules, in order:
- Without symlink support, a regular file standing in for a recorded symlink
(
MODE_SYMLINK) stays a symlink: the file holds the link target. - Without a trusted executable bit, a regular file over a recorded regular file keeps the
recorded
100644/100755. - Otherwise the worktree mode wins (including real type changes such as a directory, a symlink on a symlink-capable checkout, or a gitlink).
§Parameters
worktree_mode— Git mode derived fromlstat(seecrate::diff::mode_from_metadata).recorded_mode— the index entry’s mode, orNonefor a path not yet tracked (the worktree mode is then returned unchanged).
§Returns
The Git mode to compare against or store in the index.
Sourcepub fn worktree_mode_matches(
self,
worktree_mode: u32,
recorded_mode: u32,
) -> bool
pub fn worktree_mode_matches( self, worktree_mode: u32, recorded_mode: u32, ) -> bool
Whether a worktree mode is indistinguishable from recorded_mode under this policy.
Equivalent to index_mode_for_worktree(worktree_mode, Some(recorded_mode)) == recorded_mode.
Trait Implementations§
Source§impl Clone for WorktreeModePolicy
impl Clone for WorktreeModePolicy
impl Copy for WorktreeModePolicy
Source§impl Debug for WorktreeModePolicy
impl Debug for WorktreeModePolicy
Source§impl Default for WorktreeModePolicy
impl Default for WorktreeModePolicy
impl Eq for WorktreeModePolicy
Source§impl PartialEq for WorktreeModePolicy
impl PartialEq for WorktreeModePolicy
impl StructuralPartialEq for WorktreeModePolicy
Auto Trait Implementations§
impl Freeze for WorktreeModePolicy
impl RefUnwindSafe for WorktreeModePolicy
impl Send for WorktreeModePolicy
impl Sync for WorktreeModePolicy
impl Unpin for WorktreeModePolicy
impl UnsafeUnpin for WorktreeModePolicy
impl UnwindSafe for WorktreeModePolicy
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.