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 4, 2024
1 parent 17cfc69 commit 1ed9bf9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 2 additions & 0 deletions cli/src/commands/rebase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,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 @@ -495,6 +496,7 @@ fn rebase_revisions_transaction(
rebase_options: &RebaseOptions,
) -> Result<(), CommandError> {
if target_commits.is_empty() {
writeln!(ui.status(), "Nothing changed.")?;
return Ok(());
}

Expand Down
9 changes: 4 additions & 5 deletions cli/tests/test_rebase_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,20 +125,19 @@ fn test_rebase_empty_sets() {
create_commit(&test_env, &repo_path, "a", &[]);
create_commit(&test_env, &repo_path, "b", &["a"]);

// TODO: Make all of these say "Nothing changed" instead?
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 (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["rebase", "-s=none()", "-d=b"]);
insta::assert_snapshot!(stdout, @"");
insta::assert_snapshot!(stderr, @"");
insta::assert_snapshot!(stderr, @"Nothing changed.");
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["rebase", "-b=none()", "-d=b"]);
insta::assert_snapshot!(stdout, @"");
insta::assert_snapshot!(stderr, @"");
insta::assert_snapshot!(stderr, @"Nothing changed.");
// 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 1ed9bf9

Please sign in to comment.