diff --git a/CHANGELOG.md b/CHANGELOG.md index 9006ddb879..bbcc7012f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * New `jj op abandon` command is added to clean up the operation history. If GC is implemented, Git refs and commit objects can be compacted. +* `jj branch rename` will now warn if the renamed branch has a remote branch, since + those will have to be manually renamed outside of `jj`. + ### Fixed bugs diff --git a/cli/src/commands/branch.rs b/cli/src/commands/branch.rs index d8a975f1ce..94656d2762 100644 --- a/cli/src/commands/branch.rs +++ b/cli/src/commands/branch.rs @@ -350,6 +350,20 @@ fn cmd_branch_rename( return Err(user_error(format!("Branch already exists: {new_branch}"))); } + if view + .remote_branches_matching( + &StringPattern::exact(old_branch), + &StringPattern::everything(), + ) + .any(|(_, remote_ref)| remote_ref.is_tracking()) + { + writeln!( + ui.warning(), + "warning: Branch: {}, has remote branches which will not be renamed", + old_branch + )?; + } + let mut tx = workspace_command.start_transaction(); tx.mut_repo() .set_local_branch_target(new_branch, ref_target); @@ -363,6 +377,7 @@ fn cmd_branch_rename( make_branch_term(&[new_branch]), ), )?; + Ok(()) }