From 56f208338e174ddb200187570ffe5dd90d368c13 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Tue, 3 Dec 2024 21:45:03 -0800 Subject: [PATCH] rebase: print "Nothing changed" when source set is empty --- cli/src/commands/rebase.rs | 2 ++ cli/tests/test_rebase_command.rs | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cli/src/commands/rebase.rs b/cli/src/commands/rebase.rs index 1d0a3817fc..0a71e74e85 100644 --- a/cli/src/commands/rebase.rs +++ b/cli/src/commands/rebase.rs @@ -389,6 +389,7 @@ fn rebase_descendants_transaction( rebase_options: &RebaseOptions, ) -> Result<(), CommandError> { if target_roots.is_empty() { + writeln!(ui.status(), "Nothing changed.")?; return Ok(()); } @@ -496,6 +497,7 @@ fn rebase_revisions_transaction( rebase_options: &RebaseOptions, ) -> Result<(), CommandError> { if target_commits.is_empty() { + writeln!(ui.status(), "Nothing changed.")?; return Ok(()); } diff --git a/cli/tests/test_rebase_command.rs b/cli/tests/test_rebase_command.rs index f2dc4b1a27..4d5ce6df4a 100644 --- a/cli/tests/test_rebase_command.rs +++ b/cli/tests/test_rebase_command.rs @@ -127,7 +127,7 @@ fn test_rebase_empty_sets() { // TODO: Make all of these say "Nothing changed"? let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["rebase", "-r=none()", "-d=b"]); insta::assert_snapshot!(stdout, @""); - insta::assert_snapshot!(stderr, @""); + insta::assert_snapshot!(stderr, @"Nothing changed."); let stderr = test_env.jj_cmd_failure(&repo_path, &["rebase", "-s=none()", "-d=b"]); insta::assert_snapshot!(stderr, @r###"Error: Revset "none()" didn't resolve to any revisions"###); let stderr = test_env.jj_cmd_failure(&repo_path, &["rebase", "-b=none()", "-d=b"]); @@ -135,7 +135,7 @@ fn test_rebase_empty_sets() { // Empty because "b..a" is empty let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["rebase", "-b=a", "-d=b"]); insta::assert_snapshot!(stdout, @""); - insta::assert_snapshot!(stderr, @""); + insta::assert_snapshot!(stderr, @"Nothing changed."); } #[test]