mirror of
https://github.com/martinvonz/jj.git
synced 2025-02-04 10:51:37 +00:00
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.
This commit is contained in:
parent
53b458a601
commit
0ee09c9f29
1 changed files with 8 additions and 1 deletions
|
@ -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!(
|
||||
|
|
Loading…
Reference in a new issue