cli: make jj move nonexistent succeed

I think `jj move nonexistent` should not be an error. That matches how
`jj squash` works. I added tests for both commands.
This commit is contained in:
Martin von Zweigbergk 2023-04-29 08:56:31 -07:00 committed by Martin von Zweigbergk
parent 9230fd93bb
commit b6b3703800
3 changed files with 18 additions and 1 deletions

View file

@ -2220,7 +2220,7 @@ from the source will be moved into the destination.
args.interactive,
matcher.as_ref(),
)?;
if &new_parent_tree_id == parent_tree.id() {
if args.interactive && &new_parent_tree_id == parent_tree.id() {
return Err(user_error("No changes to move"));
}
let new_parent_tree = tx

View file

@ -317,6 +317,14 @@ fn test_move_partial() {
insta::assert_snapshot!(stdout, @r###"
a
"###);
// If we specify only a non-existent file, then the move still succeeds and
// creates unchanged commits.
test_env.jj_cmd_success(&repo_path, &["undo"]);
let stdout = test_env.jj_cmd_success(&repo_path, &["move", "--from", "c", "nonexistent"]);
insta::assert_snapshot!(stdout, @r###"
Working copy now at: b670567d9438 (no description set)
"###);
}
fn get_log_output(test_env: &TestEnvironment, cwd: &Path) -> String {

View file

@ -230,6 +230,15 @@ fn test_squash_partial() {
insta::assert_snapshot!(stdout, @r###"
b
"###);
// If we specify only a non-existent file, then the squash still succeeds and
// creates unchanged commits.
test_env.jj_cmd_success(&repo_path, &["undo"]);
let stdout = test_env.jj_cmd_success(&repo_path, &["squash", "-r", "b", "nonexistent"]);
insta::assert_snapshot!(stdout, @r###"
Rebased 1 descendant commits
Working copy now at: 5e297967f76c (no description set)
"###);
}
fn get_log_output(test_env: &TestEnvironment, repo_path: &Path) -> String {