Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions gitoxide-core/src/repository/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pub struct Options {
pub statistics: bool,
pub allow_write: bool,
pub index_worktree_renames: Option<f32>,
pub untracked: Option<gix::status::UntrackedFiles>,
}

pub fn show(
Expand All @@ -58,6 +59,7 @@ pub fn show(
allow_write,
statistics,
index_worktree_renames,
untracked,
}: Options,
) -> anyhow::Result<()> {
if output_format != OutputFormat::Human {
Expand All @@ -70,9 +72,13 @@ pub fn show(
let start = std::time::Instant::now();
let prefix = repo.prefix()?.unwrap_or(Path::new(""));
let index_progress = progress.add_child("traverse index");
let mut iter = repo
let mut status = repo
.status(index_progress)?
.should_interrupt_shared(&gix::interrupt::IS_INTERRUPTED)
.should_interrupt_shared(&gix::interrupt::IS_INTERRUPTED);
if let Some(untracked) = untracked {
status = status.untracked_files(untracked);
}
let mut iter = status
.index_worktree_options_mut(|opts| {
if let Some((opts, ignored)) = opts.dirwalk_options.as_mut().zip(ignored) {
opts.set_emit_ignored(Some(match ignored {
Expand Down
55 changes: 45 additions & 10 deletions gix-index/src/entry/mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,57 @@ impl Mode {
stat: &crate::fs::Metadata,
has_symlinks: bool,
executable_bit: bool,
) -> Option<Change> {
self.change_to_match_fs_with_values(
stat.is_file(),
stat.is_dir(),
stat.is_symlink(),
stat.is_executable(),
has_symlinks,
executable_bit,
)
}

/// Like [`change_to_match_fs`](Self::change_to_match_fs) but accepts pre-extracted
/// file-type and permission bits, for callers that already have them (e.g. cached
/// metadata from a batched directory enumeration).
///
/// Note that some parameters are mutually exclusive, but inconsistency won't be a problem
/// if the source of the data is consistent.
///
/// * `is_file` is `true` if the file-system entry is a regular file.
/// * `is_dir` is `true` if the file-system entry is a directory.
/// * `is_symlink` is `true` if the file-system entry is a symbolic link.
/// * `is_executable` is `true` if the file-system entry has executable permissions.
///
/// These parameters match [`change_to_match_fs`](Self::change_to_match_fs).
///
/// * `has_symlinks` is `true` if the file system represents symbolic links faithfully.
/// * `executable_bit` is `true` if the file system represents executable permissions faithfully.
pub fn change_to_match_fs_with_values(
self,
is_file: bool,
is_dir: bool,
is_symlink: bool,
is_executable: bool,
has_symlinks: bool,
executable_bit: bool,
) -> Option<Change> {
match self {
Mode::FILE if !stat.is_file() => (),
Mode::SYMLINK if stat.is_symlink() => return None,
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 && stat.is_executable() => return Some(Change::ExecutableBit),
Mode::FILE_EXECUTABLE if executable_bit && !stat.is_executable() => return Some(Change::ExecutableBit),
Mode::FILE if !is_file => (),
Mode::SYMLINK if is_symlink => return None,
Mode::SYMLINK if has_symlinks && !is_symlink => (),
Mode::SYMLINK if !has_symlinks && !is_file => (),
Mode::COMMIT | Mode::DIR if !is_dir => (),
Mode::FILE if executable_bit && is_executable => return Some(Change::ExecutableBit),
Mode::FILE_EXECUTABLE if executable_bit && !is_executable => return Some(Change::ExecutableBit),
_ => return None,
}
let new_mode = if stat.is_dir() {
let new_mode = if is_dir {
Mode::COMMIT
} else if executable_bit && stat.is_executable() {
} else if executable_bit && is_executable {
Mode::FILE_EXECUTABLE
} else if has_symlinks && stat.is_symlink() {
} else if has_symlinks && is_symlink {
Mode::SYMLINK
} else {
Mode::FILE
Expand Down
10 changes: 10 additions & 0 deletions gix-status/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ document-features = { version = "0.2.0", optional = true }
[target.'cfg(not(target_has_atomic = "64"))'.dependencies]
portable-atomic = "1"

[target.'cfg(windows)'.dependencies]
hashbrown = "0.16.0"
windows-sys = { version = "0.61.1", features = [
"Win32_Foundation",
"Win32_Storage_FileSystem",
# Needed for `SECURITY_ATTRIBUTES` in the signature of `CreateFileW`,
# which is gated behind this windows-sys feature even when the call passes null.
"Win32_Security",
] }

[dev-dependencies]
gix-status = { path = ".", features = ["worktree-rewrites", "parallel"] }
gix-hash = { path = "../gix-hash", features = ["sha1"] }
Expand Down
Loading
Loading