MCPcopy Index your code
hub / github.com/AI45Lab/Code / create_worktree

Function create_worktree

core/src/git.rs:582–600  ·  view source on GitHub ↗

Create a new worktree.

(
    repo_path: &Path,
    branch: &str,
    path: &Path,
    new_branch: bool,
)

Source from the content-addressed store, hash-verified

580
581/// Create a new worktree.
582pub fn create_worktree(
583 repo_path: &Path,
584 branch: &str,
585 path: &Path,
586 new_branch: bool,
587) -> Result<()> {
588 let path_str = path.display().to_string();
589 let args: Vec<&str> = if new_branch {
590 vec!["worktree", "add", "-b", branch, &path_str]
591 } else {
592 vec!["worktree", "add", &path_str, branch]
593 };
594
595 let (success, _, stderr) = run_git(repo_path, &args)?;
596 if !success {
597 return Err(anyhow!("Failed to create worktree: {}", stderr));
598 }
599 Ok(())
600}
601
602/// Remove a worktree.
603pub fn remove_worktree(repo_path: &Path, path: &Path, force: bool) -> Result<()> {

Callers 1

create_worktreeMethod · 0.85

Calls 1

run_gitFunction · 0.85

Tested by

no test coverage detected