Skip to content

Commit

Permalink
split: do not reference file paths in warning
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
samueltardieu committed Sep 27, 2024
1 parent 0058c4f commit 98c16c4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions cli/src/commands/split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, so the first commit will be empty"
)?;
}

Expand Down
6 changes: 3 additions & 3 deletions cli/tests/test_split_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, so 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
Expand Down

0 comments on commit 98c16c4

Please sign in to comment.