MCPcopy Create free account
hub / github.com/AI45Lab/Code / create_worktree

Method create_worktree

core/src/workspace/local.rs:428–457  ·  view source on GitHub ↗
(
        &self,
        request: WorkspaceGitCreateWorktreeRequest,
    )

Source from the content-addressed store, hash-verified

426 }
427
428 async fn create_worktree(
429 &self,
430 request: WorkspaceGitCreateWorktreeRequest,
431 ) -> Result<WorkspaceGitWorktreeMutation> {
432 let branch = request.branch;
433 let path = request
434 .path
435 .map(|path| {
436 let path = PathBuf::from(path);
437 if path.is_absolute() {
438 path
439 } else {
440 self.root.join(path)
441 }
442 })
443 .unwrap_or_else(|| default_local_worktree_path(&self.root, &branch));
444 let display_path = path.display().to_string();
445 let new_branch = request.new_branch;
446 let branch_for_git = branch.clone();
447
448 self.run_blocking_git(move |root| {
449 crate::git::create_worktree(&root, &branch_for_git, &path, new_branch)
450 })
451 .await?;
452
453 Ok(WorkspaceGitWorktreeMutation {
454 path: display_path,
455 branch: Some(branch),
456 })
457 }
458
459 async fn remove_worktree(
460 &self,

Callers

nothing calls this directly

Calls 4

create_worktreeFunction · 0.85
run_blocking_gitMethod · 0.80
cloneMethod · 0.45

Tested by

no test coverage detected