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 26, 2024
1 parent 0058c4f commit 7727961
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
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, 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, 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 7727961

Please sign in to comment.