diff --git a/cli/src/commands/branch.rs b/cli/src/commands/branch.rs index ea5ba7673..0ce017bf4 100644 --- a/cli/src/commands/branch.rs +++ b/cli/src/commands/branch.rs @@ -152,7 +152,6 @@ fn cmd_branch_create( let target_commit = workspace_command.resolve_single_rev(args.revision.as_deref().unwrap_or("@"), ui)?; - workspace_command.check_rewritable(&target_commit)?; let mut tx = workspace_command.start_transaction(&format!( "create {} pointing to commit {}", make_branch_term(&branch_names), @@ -183,7 +182,6 @@ fn cmd_branch_set( let target_commit = workspace_command.resolve_single_rev(args.revision.as_deref().unwrap_or("@"), ui)?; - workspace_command.check_rewritable(&target_commit)?; if !args.allow_backwards && !branch_names.iter().all(|branch_name| { is_fast_forward( diff --git a/cli/tests/test_branch_command.rs b/cli/tests/test_branch_command.rs index 1df245e0b..b655dbdcd 100644 --- a/cli/tests/test_branch_command.rs +++ b/cli/tests/test_branch_command.rs @@ -46,14 +46,20 @@ fn test_branch_multiple_names() { } #[test] -fn test_branch_forbidden_at_root() { +fn test_branch_at_root() { let test_env = TestEnvironment::default(); test_env.jj_cmd_success(test_env.env_root(), &["init", "repo", "--git"]); let repo_path = test_env.env_root().join("repo"); - let stderr = test_env.jj_cmd_failure(&repo_path, &["branch", "create", "fred", "-r=root()"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["branch", "create", "fred", "-r=root()"]); + insta::assert_snapshot!(stdout, @""); + let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["git", "export"]); + insta::assert_snapshot!(stdout, @r###" + Nothing changed. + "###); insta::assert_snapshot!(stderr, @r###" - Error: Cannot rewrite the root commit + Failed to export some branches: + fred "###); }