diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f28bfd91..acd8e61e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * `jj rebase` now accepts a `--branch/-b ` argument, which can be used instead of `-r` or `-s` to specify which commits to rebase. It will rebase the - whole branch, relative to the destination. + whole branch, relative to the destination. The default mode has changed from + `-r @` to `-b @`. * The new `jj print` command prints the contents of a file in a revision. diff --git a/src/commands.rs b/src/commands.rs index c63a28476..3183db7bc 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -1389,7 +1389,7 @@ struct MergeArgs { /// There are three different ways of specifying which revisions to rebase: /// `-b` to rebase a whole branch, `-s` to rebase a revision and its /// descendants, and `-r` to rebase a single commit. If none if them is -/// specified, it defaults to `-r @`. +/// specified, it defaults to `-b @`. /// /// With `-b`, it rebases the whole branch containing the specified revision. /// Unlike `-s` and `-r`, the `-b` mode takes the destination into account @@ -3635,13 +3635,13 @@ fn cmd_rebase(ui: &mut Ui, command: &CommandHelper, args: &RebaseArgs) -> Result let destination = workspace_command.resolve_single_rev(ui, revision_str)?; new_parents.push(destination); } - if let Some(branch_str) = &args.branch { - rebase_branch(ui, &mut workspace_command, &new_parents, branch_str)?; + if let Some(rev_str) = &args.revision { + rebase_revision(ui, &mut workspace_command, &new_parents, rev_str)?; } else if let Some(source_str) = &args.source { rebase_descendants(ui, &mut workspace_command, &new_parents, source_str)?; } else { - let rev_str = args.revision.as_deref().unwrap_or("@"); - rebase_revision(ui, &mut workspace_command, &new_parents, rev_str)?; + let branch_str = args.branch.as_deref().unwrap_or("@"); + rebase_branch(ui, &mut workspace_command, &new_parents, branch_str)?; } Ok(()) } diff --git a/tests/test_git_push.rs b/tests/test_git_push.rs index fab2ee9fb..892329c88 100644 --- a/tests/test_git_push.rs +++ b/tests/test_git_push.rs @@ -54,7 +54,7 @@ fn test_git_push() { std::fs::write(workspace_root.join("file"), "second").unwrap(); test_env.jj_cmd_success(&workspace_root, &["close", "-m", "second"]); std::fs::write(workspace_root.join("file"), "third").unwrap(); - test_env.jj_cmd_success(&workspace_root, &["rebase", "-d", "@--"]); + test_env.jj_cmd_success(&workspace_root, &["rebase", "-r", "@", "-d", "@--"]); test_env.jj_cmd_success(&workspace_root, &["branch", "my-branch"]); test_env.jj_cmd_success(&workspace_root, &["close", "-m", "third"]); let stderr = test_env.jj_cmd_failure(&workspace_root, &["git", "push"]); diff --git a/tests/test_print_command.rs b/tests/test_print_command.rs index 9201adff4..c0c3ae8cf 100644 --- a/tests/test_print_command.rs +++ b/tests/test_print_command.rs @@ -52,7 +52,7 @@ fn test_print() { // Can print a conflict test_env.jj_cmd_success(&repo_path, &["new"]); std::fs::write(repo_path.join("file1"), "c\n").unwrap(); - test_env.jj_cmd_success(&repo_path, &["rebase", "-d", "@--"]); + test_env.jj_cmd_success(&repo_path, &["rebase", "-r", "@", "-d", "@--"]); let stdout = test_env.jj_cmd_success(&repo_path, &["print", "file1"]); insta::assert_snapshot!(stdout, @r###" <<<<<<< diff --git a/tests/test_rebase_command.rs b/tests/test_rebase_command.rs index 3054d8f24..485b6ee11 100644 --- a/tests/test_rebase_command.rs +++ b/tests/test_rebase_command.rs @@ -159,7 +159,7 @@ fn test_rebase_branch_with_merge() { "###); test_env.jj_cmd_success(&repo_path, &["undo"]); - let stdout = test_env.jj_cmd_success(&repo_path, &["rebase", "-b", "e", "-d", "b"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["rebase", "-d", "b"]); insta::assert_snapshot!(stdout, @r###" Rebased 4 commits Working copy now at: a15dfb947f3f