From 7727961a50057d2ab65646316ed90032c74b6dd7 Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Thu, 26 Sep 2024 18:22:54 +0200 Subject: [PATCH] split: do not reference file paths in warning jj split warning was potentially wrong in both interactive and non-interactive modes when everything is put into the child commit: - Non-interactive mode: "The given paths does not match any file: PATHS". The message is misleading, as the PATHS given on the command-line may match files but not match files containing changes. - Interactive mode: "The given paths does not match any file: " while if possible that no paths were given on the command line. --- CHANGELOG.md | 3 +++ cli/src/commands/split.rs | 3 +-- cli/tests/test_split_command.rs | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f37f4598a3..660bf7900e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -100,6 +100,9 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ([#2611](https://github.com/martinvonz/jj/pull/2611)) * Editing a hidden commit now makes it visible. + +* `jj split` will no longer reference the paths given on the command line when + none have been given in interactive mode. ## [0.21.0] - 2024-09-04 diff --git a/cli/src/commands/split.rs b/cli/src/commands/split.rs index 496172dac6..4351561122 100644 --- a/cli/src/commands/split.rs +++ b/cli/src/commands/split.rs @@ -118,8 +118,7 @@ the operation will be aborted. // The user selected nothing, so the first commit will be empty. writeln!( ui.warning_default(), - "The given paths do not match any file: {}", - args.paths.join(" ") + "No changes have been selected, the first commit will be empty" )?; } diff --git a/cli/tests/test_split_command.rs b/cli/tests/test_split_command.rs index 376a53844f..966fdc3ab3 100644 --- a/cli/tests/test_split_command.rs +++ b/cli/tests/test_split_command.rs @@ -129,14 +129,14 @@ fn test_split_by_paths() { test_env.set_up_fake_editor(); let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["split", "-r", "@-", "nonexistent"]); insta::assert_snapshot!(stdout, @""); - insta::assert_snapshot!(stderr, @r###" - Warning: The given paths do not match any file: nonexistent + insta::assert_snapshot!(stderr, @r#" + Warning: No changes have been selected, the first commit will be empty Rebased 1 descendant commits First part: qpvuntsm bd42f95a (empty) (no description set) Second part: lylxulpl ed55c86b (no description set) Working copy now at: zsuskuln 1e1ed741 (no description set) Parent commit : lylxulpl ed55c86b (no description set) - "###); + "#); insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###" @ zsuskulnrvyr false