forked from mirrors/jj
squash: fail on merge commits before failing on immutable commits
This is just a little step towards reusing the helper I just extracted from `jj move`. I had to update `test_immutable_commits.rs` because it would otherwise fail because of the merge rather than failing because of the immutable commit.
This commit is contained in:
parent
ce44d46583
commit
2e3939df1c
2 changed files with 3 additions and 3 deletions
|
@ -66,12 +66,12 @@ pub(crate) fn cmd_squash(
|
|||
) -> Result<(), CommandError> {
|
||||
let mut workspace_command = command.workspace_helper(ui)?;
|
||||
let commit = workspace_command.resolve_single_rev(args.revision.as_deref().unwrap_or("@"))?;
|
||||
workspace_command.check_rewritable([&commit])?;
|
||||
let parents = commit.parents();
|
||||
if parents.len() != 1 {
|
||||
return Err(user_error("Cannot squash merge commits"));
|
||||
}
|
||||
let parent = &parents[0];
|
||||
workspace_command.check_rewritable([&commit])?;
|
||||
workspace_command.check_rewritable(&parents[..1])?;
|
||||
let matcher = workspace_command.matcher_from_values(&args.paths)?;
|
||||
let diff_selector =
|
||||
|
|
|
@ -207,9 +207,9 @@ fn test_rewrite_immutable_commands() {
|
|||
Hint: Configure the set of immutable commits via `revset-aliases.immutable_heads()`.
|
||||
"###);
|
||||
// squash
|
||||
let stderr = test_env.jj_cmd_failure(&repo_path, &["squash", "-r=main"]);
|
||||
let stderr = test_env.jj_cmd_failure(&repo_path, &["squash", "-r=description(b)"]);
|
||||
insta::assert_snapshot!(stderr, @r###"
|
||||
Error: Commit 3d14df18607e is immutable
|
||||
Error: Commit c8d4c7ca95d0 is immutable
|
||||
Hint: Configure the set of immutable commits via `revset-aliases.immutable_heads()`.
|
||||
"###);
|
||||
// unsquash
|
||||
|
|
Loading…
Reference in a new issue