From 9533177422e788c1bc8ada48f22b91dd0d72ce0d Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Fri, 10 Nov 2023 10:30:32 +0900 Subject: [PATCH] cli: include branch name in non-fast-forwardable error Just like the other errors. --- cli/src/commands/branch.rs | 2 +- cli/tests/test_branch_command.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cli/src/commands/branch.rs b/cli/src/commands/branch.rs index e4ef512276..12efd26f19 100644 --- a/cli/src/commands/branch.rs +++ b/cli/src/commands/branch.rs @@ -315,7 +315,7 @@ fn cmd_branch_set( } if !args.allow_backwards && !is_fast_forward(old_target) { return Err(user_error_with_hint( - "Refusing to move branch backwards or sideways.", + format!("Refusing to move branch backwards or sideways: {name}"), "Use --allow-backwards to allow it.", )); } diff --git a/cli/tests/test_branch_command.rs b/cli/tests/test_branch_command.rs index defd51c523..60d9b4e3ec 100644 --- a/cli/tests/test_branch_command.rs +++ b/cli/tests/test_branch_command.rs @@ -119,7 +119,7 @@ fn test_branch_move() { let stderr = test_env.jj_cmd_failure(&repo_path, &["branch", "set", "-r@-", "foo"]); insta::assert_snapshot!(stderr, @r###" - Error: Refusing to move branch backwards or sideways. + Error: Refusing to move branch backwards or sideways: foo Hint: Use --allow-backwards to allow it. "###); @@ -169,7 +169,7 @@ fn test_branch_move_conflicting() { let stderr = test_env.jj_cmd_failure(&repo_path, &["branch", "set", "-rdescription(C0)", "foo"]); insta::assert_snapshot!(stderr, @r###" - Error: Refusing to move branch backwards or sideways. + Error: Refusing to move branch backwards or sideways: foo Hint: Use --allow-backwards to allow it. "###);