cli: don't allow creating multiple workspaces with the same name
It's harmless but potentially confusing to have multiple workspaces
with the same ID (it would mean that they always have the same
checkout). Let's just prevent it for now. We can add an override later
if people think of usecases for it.
@@ -3948,10 +3948,17 @@ fn cmd_workspace_add(
.unwrap()
.to_string();
let workspace_id = WorkspaceId::new(name.clone());
+ let repo = old_workspace_command.repo();
+ if repo.view().get_checkout(&workspace_id).is_some() {
+ return Err(UserError(format!(
+ "Workspace named '{}' already exists",
+ name
+ )));
+ }
let (new_workspace, repo) = Workspace::init_workspace_with_existing_repo(
ui.settings(),
destination_path.clone(),
- old_workspace_command.repo(),
+ repo,
workspace_id,
)?;
writeln!(
