This allows to control how untracked files are folded, but also can completely turn dirwalking off.
Unified · Split
| @@ -41,6 +41,7 @@ pub struct Options { · 40 unmodified lines | ||
| 41 | 41 | pub statistics: bool, |
| 42 | 42 | pub allow_write: bool, |
| 43 | 43 | pub index_worktree_renames: Option<f32>, |
| 44 | + pub untracked: Option<gix::status::UntrackedFiles>, | |
| 44 | 45 | } |
| 45 | 46 | |
| 46 | 47 | pub fn show( |
| @@ -58,6 +59,7 @@ pub fn show( · 11 unmodified lines | ||
| 58 | 59 | allow_write, |
| 59 | 60 | statistics, |
| 60 | 61 | index_worktree_renames, |
| 62 | + untracked, | |
| 61 | 63 | }: Options, |
| 62 | 64 | ) -> anyhow::Result<()> { |
| 63 | 65 | if output_format != OutputFormat::Human { |
| @@ -70,9 +72,13 @@ pub fn show( · 6 unmodified lines | ||
| 70 | 72 | let start = std::time::Instant::now(); |
| 71 | 73 | let prefix = repo.prefix()?.unwrap_or(Path::new("")); |
| 72 | 74 | let index_progress = progress.add_child("traverse index"); |
| 73 | − let mut iter = repo | |
| 75 | + let mut status = repo | |
| 74 | 76 | .status(index_progress)? |
| 75 | − .should_interrupt_shared(&gix::interrupt::IS_INTERRUPTED) | |
| 77 | + .should_interrupt_shared(&gix::interrupt::IS_INTERRUPTED); | |
| 78 | + if let Some(untracked) = untracked { | |
| 79 | + status = status.untracked_files(untracked); | |
| 80 | + } | |
| 81 | + let mut iter = status | |
| 76 | 82 | .index_worktree_options_mut(|opts| { |
| 77 | 83 | if let Some((opts, ignored)) = opts.dirwalk_options.as_mut().zip(ignored) { |
| 78 | 84 | opts.set_emit_ignored(Some(match ignored { |
| @@ -390,6 +390,7 @@ pub fn main() -> Result<()> { · 389 unmodified lines | ||
| 390 | 390 | ), |
| 391 | 391 | Subcommands::Status(crate::plumbing::options::status::Platform { |
| 392 | 392 | ignored, |
| 393 | + untracked, | |
| 393 | 394 | format: status_format, |
| 394 | 395 | statistics, |
| 395 | 396 | submodules, |
| @@ -428,6 +429,13 @@ pub fn main() -> Result<()> { · 32 unmodified lines | ||
| 428 | 429 | core::repository::status::Ignored::Collapsed |
| 429 | 430 | } |
| 430 | 431 | }), |
| 432 | + untracked: untracked.map(|mode| match mode.unwrap_or_default() { | |
| 433 | + crate::plumbing::options::status::Untracked::No => gix::status::UntrackedFiles::None, | |
| 434 | + crate::plumbing::options::status::Untracked::Normal => { | |
| 435 | + gix::status::UntrackedFiles::Collapsed | |
| 436 | + } | |
| 437 | + crate::plumbing::options::status::Untracked::All => gix::status::UntrackedFiles::Files, | |
| 438 | + }), | |
| 431 | 439 | output_format: format, |
| 432 | 440 | statistics, |
| 433 | 441 | thread_limit: thread_limit.or(cfg!(target_os = "macos").then_some(3)), // TODO: make this a configurable when in `gix`, this seems to be optimal on MacOS, linux scales though! MacOS also scales if reading a lot of files for refresh index |
| @@ -290,6 +290,17 @@ pub mod status { · 289 unmodified lines | ||
| 290 | 290 | // allowing to ignore directories, naturally traversing the entire content. |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | + #[derive(Default, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, clap::ValueEnum)] | |
| 294 | + pub enum Untracked { | |
| 295 | + /// Do not show untracked files. | |
| 296 | + No, | |
| 297 | + /// Collapse untracked directories when possible. | |
| 298 | + Normal, | |
| 299 | + /// Show individual untracked files. | |
| 300 | + #[default] | |
| 301 | + All, | |
| 302 | + } | |
| 303 | + | |
| 293 | 304 | #[derive(Default, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, clap::ValueEnum)] |
| 294 | 305 | pub enum Format { |
| 295 | 306 | /// A basic format that is easy to read, and useful for a first glimpse as flat list. |
| @@ -308,6 +319,9 @@ pub mod status { · 12 unmodified lines | ||
| 308 | 319 | /// If enabled, show ignored files and directories. |
| 309 | 320 | #[clap(long)] |
| 310 | 321 | pub ignored: Option<Option<Ignored>>, |
| 322 | + /// Define how to show untracked files. If set without a value, show all individual untracked files. | |
| 323 | + #[clap(long, short = 'u', require_equals = true)] | |
| 324 | + pub untracked: Option<Option<Untracked>>, | |
| 311 | 325 | /// Define how to display the submodule status. Defaults to git configuration if unset. |
| 312 | 326 | #[clap(long)] |
| 313 | 327 | pub submodules: Option<Submodules>, |