From 433e28d1d6417f8a7ccf4235506f381d4039872b Mon Sep 17 00:00:00 2001 From: Christian Stoitner Date: Tue, 17 Dec 2024 21:23:38 +0100 Subject: [PATCH] status: show untracked files --- cli/src/commands/status.rs | 12 +++++++++++- cli/src/config/colors.toml | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/cli/src/commands/status.rs b/cli/src/commands/status.rs index cbbac74d6a9..a27e66fd34d 100644 --- a/cli/src/commands/status.rs +++ b/cli/src/commands/status.rs @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +use std::io; + use itertools::Itertools; use jj_lib::copies::CopyRecords; use jj_lib::repo::Repo; @@ -47,7 +49,7 @@ pub(crate) fn cmd_status( command: &CommandHelper, args: &StatusArgs, ) -> Result<(), CommandError> { - let (workspace_command, _snapshot_stats) = command.workspace_helper_with_stats(ui)?; + let (workspace_command, snapshot_stats) = command.workspace_helper_with_stats(ui)?; let repo = workspace_command.repo(); let maybe_wc_commit = workspace_command .get_wc_commit_id() @@ -85,6 +87,14 @@ pub(crate) fn cmd_status( )?; } + formatter.with_label("diff", |formatter| { + for path in snapshot_stats.untracked_paths.keys() { + let ui_path = workspace_command.path_converter().format_file_path(path); + writeln!(formatter.labeled("untracked"), "? {ui_path}")?; + } + io::Result::Ok(()) + })?; + // TODO: Conflicts should also be filtered by the `matcher`. See the related // TODO on `MergedTree::conflicts()`. let conflicts = wc_commit.tree()?.conflicts().collect_vec(); diff --git a/cli/src/config/colors.toml b/cli/src/config/colors.toml index 6586de33a0e..557c1d7e64e 100644 --- a/cli/src/config/colors.toml +++ b/cli/src/config/colors.toml @@ -93,6 +93,7 @@ "diff added" = { fg = "green" } "diff token" = { underline = true } "diff modified" = "cyan" +"diff untracked" = "magenta" "diff renamed" = "cyan" "diff copied" = "green" "diff access-denied" = { bg = "red" }