diff --git a/CHANGELOG.md b/CHANGELOG.md index fc19e69a62..433d9cc7d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -70,6 +70,9 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). to fetch during clone. If present, the first matching branch is used as the working-copy parent. +* `jj status` supports hiding the list of untracked files with flag `--hide-untracked` + and config option `ui.status-hide-untracked`. + ### Fixed bugs * `jj metaedit --author-timestamp` twice with the same value no longer diff --git a/cli/src/commands/status.rs b/cli/src/commands/status.rs index 041a2cac69..d5dee2fac0 100644 --- a/cli/src/commands/status.rs +++ b/cli/src/commands/status.rs @@ -50,6 +50,10 @@ pub(crate) struct StatusArgs { /// Restrict the status display to these paths #[arg(value_name = "FILESETS", value_hint = clap::ValueHint::AnyPath)] paths: Vec, + + /// Hide untracked paths + #[arg(long)] + hide_untracked: bool, } #[instrument(skip_all)] @@ -75,13 +79,15 @@ pub(crate) fn cmd_status( ui.request_pager(); let mut formatter = ui.stdout_formatter(); let formatter = formatter.as_mut(); + let hide_untracked = + args.hide_untracked || command.settings().get_bool("ui.status-hide-untracked")?; if let Some(wc_commit) = &maybe_wc_commit { let parent_tree = wc_commit.parent_tree(repo.as_ref())?; let tree = wc_commit.tree()?; let wc_has_changes = tree.id() != parent_tree.id(); - let wc_has_untracked = !snapshot_stats.untracked_paths.is_empty(); + let wc_has_untracked = !snapshot_stats.untracked_paths.is_empty() && !hide_untracked; if !wc_has_changes && !wc_has_untracked { writeln!(formatter, "The working copy has no changes.")?; } else { diff --git a/cli/src/config-schema.json b/cli/src/config-schema.json index cf473dcd2f..255894d501 100644 --- a/cli/src/config-schema.json +++ b/cli/src/config-schema.json @@ -273,6 +273,11 @@ "committer-date-" ] } + }, + "status-hide-untracked": { + "type": "boolean", + "default": false, + "description": "Whether the status command should behave as if the --hide-untracked flag was passed." } } }, diff --git a/cli/src/config/misc.toml b/cli/src/config/misc.toml index 0a1ad432a8..d76505e6c6 100644 --- a/cli/src/config/misc.toml +++ b/cli/src/config/misc.toml @@ -38,6 +38,7 @@ conflict-marker-style = "diff" # signature verification is slow, disable by default show-cryptographic-signatures = false bookmark-list-sort-keys = ["name"] +status-hide-untracked = false [ui.movement] edit = false diff --git a/cli/tests/cli-reference@.md.snap b/cli/tests/cli-reference@.md.snap index 43724b69d1..8b318e02a4 100644 --- a/cli/tests/cli-reference@.md.snap +++ b/cli/tests/cli-reference@.md.snap @@ -2772,12 +2772,16 @@ This includes: [Conflicted bookmarks]: https://jj-vcs.github.io/jj/latest/bookmarks/#conflicts -**Usage:** `jj status [FILESETS]...` +**Usage:** `jj status [OPTIONS] [FILESETS]...` ###### **Arguments:** * `` — Restrict the status display to these paths +###### **Options:** + +* `--hide-untracked` — Hide untracked paths + ## `jj tag` diff --git a/cli/tests/test_status_command.rs b/cli/tests/test_status_command.rs index 5244202737..939e62faf6 100644 --- a/cli/tests/test_status_command.rs +++ b/cli/tests/test_status_command.rs @@ -478,3 +478,43 @@ fn test_status_untracked_files() { [EOF] "); } + +#[test] +fn test_status_hide_untracked() { + let test_env = TestEnvironment::default(); + test_env.add_config(r#"snapshot.auto-track = "none()""#); + + test_env.run_jj_in(".", ["git", "init", "repo"]).success(); + let work_dir = test_env.work_dir("repo"); + + work_dir.write_file("untracked-file", "..."); + let sub_dir = work_dir.create_dir("sub"); + sub_dir.write_file("untracked-file", "..."); + + let output = work_dir.run_jj(["status"]); + insta::assert_snapshot!(output.normalize_backslash(), @r" + Untracked paths: + ? sub/ + ? untracked-file + Working copy (@) : qpvuntsm e8849ae1 (empty) (no description set) + Parent commit (@-): zzzzzzzz 00000000 (empty) (no description set) + [EOF] + "); + + let output = work_dir.run_jj(["status", "--hide-untracked"]); + insta::assert_snapshot!(output.normalize_backslash(), @r" + The working copy has no changes. + Working copy (@) : qpvuntsm e8849ae1 (empty) (no description set) + Parent commit (@-): zzzzzzzz 00000000 (empty) (no description set) + [EOF] + "); + + test_env.add_config(r#"ui.status-hide-untracked=true"#); + let output = work_dir.run_jj(["status"]); + insta::assert_snapshot!(output.normalize_backslash(), @r" + The working copy has no changes. + Working copy (@) : qpvuntsm e8849ae1 (empty) (no description set) + Parent commit (@-): zzzzzzzz 00000000 (empty) (no description set) + [EOF] + "); +} diff --git a/docs/paid_contributors.md b/docs/paid_contributors.md index 1a79a5ac9f..c12a076262 100644 --- a/docs/paid_contributors.md +++ b/docs/paid_contributors.md @@ -44,4 +44,5 @@ contribute or not. * solson * spectral54 * steadmon +* tbodt * zygoloid