diff --git a/cli/src/commands/squash.rs b/cli/src/commands/squash.rs index af6a189fe..d6f93389d 100644 --- a/cli/src/commands/squash.rs +++ b/cli/src/commands/squash.rs @@ -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 = diff --git a/cli/tests/test_immutable_commits.rs b/cli/tests/test_immutable_commits.rs index 0b016c611..e3193fb7f 100644 --- a/cli/tests/test_immutable_commits.rs +++ b/cli/tests/test_immutable_commits.rs @@ -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