diff --git a/cli/src/commands/branch/create.rs b/cli/src/commands/branch/create.rs index 42cd8ee955..2fd0b5d831 100644 --- a/cli/src/commands/branch/create.rs +++ b/cli/src/commands/branch/create.rs @@ -16,7 +16,6 @@ use clap::builder::NonEmptyStringValueParser; use jj_lib::object_id::ObjectId as _; use jj_lib::op_store::RefTarget; -use super::make_branch_term; use crate::cli_util::{CommandHelper, RevisionArg}; use crate::command_error::{user_error_with_hint, CommandError}; use crate::ui::Ui; @@ -69,9 +68,9 @@ pub fn cmd_branch_create( tx.finish( ui, format!( - "create {} pointing to commit {}", - make_branch_term(branch_names), - target_commit.id().hex() + "create branches {names} pointing to commit {id}", + names = branch_names.join(", "), + id = target_commit.id().hex() ), )?; Ok(()) diff --git a/cli/src/commands/branch/delete.rs b/cli/src/commands/branch/delete.rs index 10ab822231..e549d19b52 100644 --- a/cli/src/commands/branch/delete.rs +++ b/cli/src/commands/branch/delete.rs @@ -15,7 +15,7 @@ use jj_lib::op_store::RefTarget; use jj_lib::str_util::StringPattern; -use super::{find_local_branches, make_branch_term}; +use super::find_local_branches; use crate::cli_util::CommandHelper; use crate::command_error::CommandError; use crate::ui::Ui; @@ -46,7 +46,7 @@ pub fn cmd_branch_delete( tx.mut_repo() .set_local_branch_target(branch_name, RefTarget::absent()); } - tx.finish(ui, format!("delete {}", make_branch_term(&names)))?; + tx.finish(ui, format!("delete branches {}", names.join(", ")))?; writeln!(ui.status(), "Deleted {} branches.", names.len())?; Ok(()) } diff --git a/cli/src/commands/branch/forget.rs b/cli/src/commands/branch/forget.rs index 9a2249ef29..16a3f057b8 100644 --- a/cli/src/commands/branch/forget.rs +++ b/cli/src/commands/branch/forget.rs @@ -15,7 +15,7 @@ use jj_lib::str_util::StringPattern; use jj_lib::view::View; -use super::{find_branches_with, make_branch_term}; +use super::find_branches_with; use crate::cli_util::CommandHelper; use crate::command_error::CommandError; use crate::ui::Ui; @@ -48,7 +48,7 @@ pub fn cmd_branch_forget( for branch_name in names.iter() { tx.mut_repo().remove_branch(branch_name); } - tx.finish(ui, format!("forget {}", make_branch_term(&names)))?; + tx.finish(ui, format!("forget branches {}", names.join(", ")))?; writeln!(ui.status(), "Forgot {} branches.", names.len())?; Ok(()) } diff --git a/cli/src/commands/branch/mod.rs b/cli/src/commands/branch/mod.rs index dfd6a29f3b..b61444def5 100644 --- a/cli/src/commands/branch/mod.rs +++ b/cli/src/commands/branch/mod.rs @@ -22,8 +22,6 @@ mod set; mod track; mod untrack; -use std::fmt; - use itertools::Itertools as _; use jj_lib::backend::CommitId; use jj_lib::op_store::{RefTarget, RemoteRef}; @@ -87,13 +85,6 @@ pub fn cmd_branch( } } -fn make_branch_term(branch_names: &[impl fmt::Display]) -> String { - match branch_names { - [branch_name] => format!("branch {}", branch_name), - branch_names => format!("branches {}", branch_names.iter().join(", ")), - } -} - fn find_local_branches( view: &View, name_patterns: &[StringPattern], diff --git a/cli/src/commands/branch/move.rs b/cli/src/commands/branch/move.rs index e0cd00348c..a02fc1b5fa 100644 --- a/cli/src/commands/branch/move.rs +++ b/cli/src/commands/branch/move.rs @@ -17,7 +17,7 @@ use jj_lib::object_id::ObjectId as _; use jj_lib::op_store::RefTarget; use jj_lib::str_util::StringPattern; -use super::{find_branches_with, is_fast_forward, make_branch_term}; +use super::{find_branches_with, is_fast_forward}; use crate::cli_util::{CommandHelper, RevisionArg}; use crate::command_error::{user_error_with_hint, CommandError}; use crate::ui::Ui; @@ -125,9 +125,9 @@ pub fn cmd_branch_move( tx.finish( ui, format!( - "point {} to commit {}", - make_branch_term(&branch_names), - target_commit.id().hex() + "point branches {names} to commit {id}", + names = branch_names.join(", "), + id = target_commit.id().hex() ), )?; diff --git a/cli/src/commands/branch/rename.rs b/cli/src/commands/branch/rename.rs index b2eb66ab21..a589778575 100644 --- a/cli/src/commands/branch/rename.rs +++ b/cli/src/commands/branch/rename.rs @@ -15,7 +15,6 @@ use jj_lib::op_store::RefTarget; use jj_lib::str_util::StringPattern; -use super::make_branch_term; use crate::cli_util::CommandHelper; use crate::command_error::{user_error, CommandError}; use crate::ui::Ui; @@ -55,14 +54,7 @@ pub fn cmd_branch_rename( .set_local_branch_target(new_branch, ref_target); tx.mut_repo() .set_local_branch_target(old_branch, RefTarget::absent()); - tx.finish( - ui, - format!( - "rename {} to {}", - make_branch_term(&[old_branch]), - make_branch_term(&[new_branch]), - ), - )?; + tx.finish(ui, format!("rename branch {old_branch} to {new_branch}"))?; let view = workspace_command.repo().view(); if view diff --git a/cli/src/commands/branch/set.rs b/cli/src/commands/branch/set.rs index 3757fc8106..4cc3b28820 100644 --- a/cli/src/commands/branch/set.rs +++ b/cli/src/commands/branch/set.rs @@ -16,7 +16,7 @@ use clap::builder::NonEmptyStringValueParser; use jj_lib::object_id::ObjectId as _; use jj_lib::op_store::RefTarget; -use super::{is_fast_forward, make_branch_term}; +use super::is_fast_forward; use crate::cli_util::{CommandHelper, RevisionArg}; use crate::command_error::{user_error_with_hint, CommandError}; use crate::ui::Ui; @@ -77,9 +77,9 @@ pub fn cmd_branch_set( tx.finish( ui, format!( - "point {} to commit {}", - make_branch_term(branch_names), - target_commit.id().hex() + "point branches {names} to commit {id}", + names = branch_names.join(", "), + id = target_commit.id().hex() ), )?; diff --git a/cli/src/commands/branch/track.rs b/cli/src/commands/branch/track.rs index a4af030aaf..f4455a5854 100644 --- a/cli/src/commands/branch/track.rs +++ b/cli/src/commands/branch/track.rs @@ -14,7 +14,9 @@ use std::collections::HashMap; -use super::{find_remote_branches, make_branch_term}; +use itertools::Itertools as _; + +use super::find_remote_branches; use crate::cli_util::{CommandHelper, RemoteBranchNamePattern}; use crate::command_error::CommandError; use crate::commit_templater::{CommitTemplateLanguage, RefName}; @@ -61,7 +63,10 @@ pub fn cmd_branch_track( tx.mut_repo() .track_remote_branch(&name.branch, &name.remote); } - tx.finish(ui, format!("track remote {}", make_branch_term(&names)))?; + tx.finish( + ui, + format!("track remote branches {}", names.iter().join(", ")), + )?; if !names.is_empty() { writeln!( ui.status(), diff --git a/cli/src/commands/branch/untrack.rs b/cli/src/commands/branch/untrack.rs index 94e8f72e15..506ab6ac5f 100644 --- a/cli/src/commands/branch/untrack.rs +++ b/cli/src/commands/branch/untrack.rs @@ -12,9 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. +use itertools::Itertools as _; use jj_lib::git; -use super::{find_remote_branches, make_branch_term}; +use super::find_remote_branches; use crate::cli_util::{CommandHelper, RemoteBranchNamePattern}; use crate::command_error::CommandError; use crate::ui::Ui; @@ -65,7 +66,10 @@ pub fn cmd_branch_untrack( tx.mut_repo() .untrack_remote_branch(&name.branch, &name.remote); } - tx.finish(ui, format!("untrack remote {}", make_branch_term(&names)))?; + tx.finish( + ui, + format!("untrack remote branches {}", names.iter().join(", ")), + )?; if !names.is_empty() { writeln!( ui.status(),