Skip to content

Commit

Permalink
rebase: print "Nothing changed" when source set is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
martinvonz committed Dec 11, 2024
1 parent 942d105 commit 56f2083
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions cli/src/commands/rebase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(());
}

Expand Down Expand Up @@ -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(());
}

Expand Down
4 changes: 2 additions & 2 deletions cli/tests/test_rebase_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,15 @@ 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"]);
insta::assert_snapshot!(stderr, @r###"Error: Revset "none()" didn't resolve to any revisions"###);
// 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]
Expand Down

0 comments on commit 56f2083

Please sign in to comment.