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 | pub statistics: bool, | 41 | pub statistics: bool, |
| 42 | pub allow_write: bool, | 42 | pub allow_write: bool, |
| 43 | pub index_worktree_renames: Option<f32>, | 43 | pub index_worktree_renames: Option<f32>, |
| 44 | pub untracked: Option<gix::status::UntrackedFiles>, | ||
| 44 | } | 45 | } |
| 45 | 46 | ||
| 46 | pub fn show( | 47 | pub fn show( |
| @@ -58,6 +59,7 @@ pub fn show( · 11 unmodified lines | |||
| 58 | allow_write, | 59 | allow_write, |
| 59 | statistics, | 60 | statistics, |
| 60 | index_worktree_renames, | 61 | index_worktree_renames, |
| 62 | untracked, | ||
| 61 | }: Options, | 63 | }: Options, |
| 62 | ) -> anyhow::Result<()> { | 64 | ) -> anyhow::Result<()> { |
| 63 | if output_format != OutputFormat::Human { | 65 | if output_format != OutputFormat::Human { |
| @@ -70,9 +72,13 @@ pub fn show( · 6 unmodified lines | |||
| 70 | let start = std::time::Instant::now(); | 72 | let start = std::time::Instant::now(); |
| 71 | let prefix = repo.prefix()?.unwrap_or(Path::new("")); | 73 | let prefix = repo.prefix()?.unwrap_or(Path::new("")); |
| 72 | let index_progress = progress.add_child("traverse index"); | 74 | let index_progress = progress.add_child("traverse index"); |
| 73 | let mut iter = repo | 75 | let mut status = repo |
| 74 | .status(index_progress)? | 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 | .index_worktree_options_mut(|opts| { | 82 | .index_worktree_options_mut(|opts| { |
| 77 | if let Some((opts, ignored)) = opts.dirwalk_options.as_mut().zip(ignored) { | 83 | if let Some((opts, ignored)) = opts.dirwalk_options.as_mut().zip(ignored) { |
| 78 | opts.set_emit_ignored(Some(match ignored { | 84 | opts.set_emit_ignored(Some(match ignored { |
| @@ -390,6 +390,7 @@ pub fn main() -> Result<()> { · 389 unmodified lines | |||
| 390 | ), | 390 | ), |
| 391 | Subcommands::Status(crate::plumbing::options::status::Platform { | 391 | Subcommands::Status(crate::plumbing::options::status::Platform { |
| 392 | ignored, | 392 | ignored, |
| 393 | untracked, | ||
| 393 | format: status_format, | 394 | format: status_format, |
| 394 | statistics, | 395 | statistics, |
| 395 | submodules, | 396 | submodules, |
| @@ -428,6 +429,13 @@ pub fn main() -> Result<()> { · 32 unmodified lines | |||
| 428 | core::repository::status::Ignored::Collapsed | 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 | output_format: format, | 439 | output_format: format, |
| 432 | statistics, | 440 | statistics, |
| 433 | 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 | 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 | // allowing to ignore directories, naturally traversing the entire content. | 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 | #[derive(Default, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, clap::ValueEnum)] | 304 | #[derive(Default, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, clap::ValueEnum)] |
| 294 | pub enum Format { | 305 | pub enum Format { |
| 295 | /// A basic format that is easy to read, and useful for a first glimpse as flat list. | 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 | /// If enabled, show ignored files and directories. | 319 | /// If enabled, show ignored files and directories. |
| 309 | #[clap(long)] | 320 | #[clap(long)] |
| 310 | pub ignored: Option<Option<Ignored>>, | 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 | /// Define how to display the submodule status. Defaults to git configuration if unset. | 325 | /// Define how to display the submodule status. Defaults to git configuration if unset. |
| 312 | #[clap(long)] | 326 | #[clap(long)] |
| 313 | pub submodules: Option<Submodules>, | 327 | pub submodules: Option<Submodules>, |