Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/commands/worktree/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub(crate) fn handle_add(args: AddArgs, verbose: bool, json: bool, strict: bool)
if repo_specs.iter().any(|r| r.alias == ".") {
anyhow::bail!(
"Cannot add '.' to an existing worktree. The meta repo root can only be established at create time.\n\
Use 'meta worktree destroy {name}' then 'meta worktree create {name} --repo . ...' instead."
Use 'meta worktree remove {name}' then 'meta worktree create {name} --repo . ...' instead."
);
}

Expand Down
5 changes: 4 additions & 1 deletion src/commands/worktree/cli_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ pub enum WorktreeCommands {
/// Add a repo to an existing worktree set
Add(AddArgs),
/// Remove a worktree set
Remove(DestroyArgs),
/// Remove a worktree set (alias for remove)
#[command(hide = true)]
Destroy(DestroyArgs),
/// List all worktree sets
List(ListArgs),
Expand Down Expand Up @@ -151,7 +154,7 @@ pub struct ExecArgs {
#[arg(long)]
pub parallel: bool,

/// Atomic create+exec+destroy (requires --all or --repo, and -- <cmd>)
/// Atomic create+exec+remove (requires --all or --repo, and -- <cmd>)
#[arg(long)]
pub ephemeral: bool,

Expand Down
2 changes: 1 addition & 1 deletion src/commands/worktree/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub(crate) fn handle_create(
let wt_dir = worktree_root.join(name);
if wt_dir.exists() {
anyhow::bail!(
"Worktree '{}' already exists at {}. Use 'meta worktree destroy {}' first.",
"Worktree '{}' already exists at {}. Use 'meta worktree remove {}' first.",
name,
wt_dir.display(),
name
Expand Down
11 changes: 5 additions & 6 deletions src/commands/worktree/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn build_loop_config(
}
}

/// RAII guard that destroys an ephemeral worktree on drop.
/// RAII guard that removes an ephemeral worktree on drop.
/// Ensures cleanup even if the exec command panics.
struct EphemeralGuard {
name: String,
Expand All @@ -54,22 +54,21 @@ struct EphemeralGuard {
impl Drop for EphemeralGuard {
fn drop(&mut self) {
if self.verbose {
eprintln!("Destroying ephemeral worktree '{}'...", self.name);
eprintln!("Removing ephemeral worktree '{}'...", self.name);
}
let destroy_args = DestroyArgs {
name: self.name.clone(),
force: true,
};
// Ephemeral cleanup uses strict=false to ensure best-effort cleanup
if let Err(e) = super::destroy::handle_destroy(destroy_args, self.verbose, self.json, false)
{
if let Err(e) = super::remove::handle_remove(destroy_args, self.verbose, self.json, false) {
eprintln!(
"{} Failed to destroy ephemeral worktree '{}': {e}",
"{} Failed to remove ephemeral worktree '{}': {e}",
"warning:".yellow().bold(),
self.name
);
eprintln!(
" Run 'meta worktree destroy {} --force' or 'meta worktree prune' to clean up.",
" Run 'meta worktree remove {} --force' or 'meta worktree prune' to clean up.",
self.name
);
}
Expand Down
12 changes: 6 additions & 6 deletions src/commands/worktree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
mod add;
pub(crate) mod cli_types;
mod create;
mod destroy;
mod diff;
mod exec;
mod list;
mod prune;
mod remove;
mod status;

use anyhow::Result;
Expand Down Expand Up @@ -93,8 +93,8 @@ fn handle_worktree_command(
match command {
WorktreeCommands::Create(args) => create::handle_create(args, verbose, json, global_strict),
WorktreeCommands::Add(args) => add::handle_add(args, verbose, json, global_strict),
WorktreeCommands::Destroy(args) => {
destroy::handle_destroy(args, verbose, json, global_strict)
WorktreeCommands::Remove(args) | WorktreeCommands::Destroy(args) => {
remove::handle_remove(args, verbose, json, global_strict)
}
WorktreeCommands::List(args) => list::handle_list(args, verbose, json),
WorktreeCommands::Status(args) => status::handle_status(args, verbose, json),
Expand Down Expand Up @@ -159,7 +159,7 @@ fn write_worktree_help(w: &mut dyn std::io::Write) {
let _ = writeln!(w, "COMMANDS:");
let _ = writeln!(w, " create Create a new worktree set");
let _ = writeln!(w, " add Add a repo to an existing worktree set");
let _ = writeln!(w, " destroy Remove a worktree set");
let _ = writeln!(w, " remove Remove a worktree set");
let _ = writeln!(w, " list List all worktree sets");
let _ = writeln!(w, " status Show detailed status of a worktree set");
let _ = writeln!(w, " diff Show cross-repo diff vs base branch");
Expand Down Expand Up @@ -188,7 +188,7 @@ fn write_worktree_help(w: &mut dyn std::io::Write) {
);
let _ = writeln!(w, " --meta <KEY=VALUE> Store custom metadata");
let _ = writeln!(w);
let _ = writeln!(w, "DESTROY OPTIONS:");
let _ = writeln!(w, "REMOVE OPTIONS:");
let _ = writeln!(
w,
" --force Remove even with uncommitted changes"
Expand All @@ -198,7 +198,7 @@ fn write_worktree_help(w: &mut dyn std::io::Write) {
let _ = writeln!(w, " --include <REPOS> Only run in specified repos");
let _ = writeln!(w, " --exclude <REPOS> Skip specified repos");
let _ = writeln!(w, " --parallel Run commands concurrently");
let _ = writeln!(w, " --ephemeral Atomic create+exec+destroy");
let _ = writeln!(w, " --ephemeral Atomic create+exec+remove");
let _ = writeln!(w);
let _ = writeln!(w, "DIFF OPTIONS:");
let _ = writeln!(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use meta_git_lib::worktree::types::*;

use super::cli_types::DestroyArgs;

pub(crate) fn handle_destroy(
pub(crate) fn handle_remove(
args: DestroyArgs,
verbose: bool,
json: bool,
Expand Down Expand Up @@ -73,7 +73,7 @@ pub(crate) fn handle_destroy(
};
println!("{}", serde_json::to_string_pretty(&output)?);
} else {
println!("{} Destroyed worktree '{}'", "✓".green(), name.bold());
println!("{} Removed worktree '{}'", "✓".green(), name.bold());
}
Ok(())
}
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ fn main() {
"git worktree".to_string(),
"git worktree create".to_string(),
"git worktree add".to_string(),
"git worktree remove".to_string(),
"git worktree destroy".to_string(),
"git worktree list".to_string(),
"git worktree status".to_string(),
Expand Down