git_index/entry/
mode.rs

1use bitflags::bitflags;
2bitflags! {
3    /// The kind of file of an entry.
4    pub struct Mode: u32 {
5        /// directory (only used for sparse checkouts), equivalent to a tree, which is _excluded_ from the index via
6        /// cone-mode.
7        const DIR = 0o040000;
8        /// regular file
9        const FILE = 0o100644;
10        /// regular file, executable
11        const FILE_EXECUTABLE = 0o100755;
12        /// Symbolic link
13        const SYMLINK = 0o120000;
14        /// A git commit for submodules
15        const COMMIT = 0o160000;
16    }
17}
18
19impl Mode {
20    /// Return true if this is a sparse entry, as it points to a directory which usually isn't what an unsparse index tracks.
21    pub fn is_sparse(&self) -> bool {
22        *self == Self::DIR
23    }
24}