ok/jj
1
0
Fork 0
forked from mirrors/jj

cli: make jj rebase default to -b @ (#168)

Closes #168.
This commit is contained in:
Martin von Zweigbergk 2022-04-13 23:53:35 -07:00 committed by Martin von Zweigbergk
parent 30f5471fc3
commit 3c71ae3c76
5 changed files with 10 additions and 9 deletions

View file

@ -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 <revision>` 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.

View file

@ -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(())
}

View file

@ -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"]);

View file

@ -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###"
<<<<<<<

View file

@ -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