pub fn create_worktree(
spec_id: &str,
branch: &str,
project_name: Option<&str>,
) -> Result<PathBuf>Expand description
Creates a new git worktree for the given spec.
This function is serialized to prevent concurrent git worktree add calls from
racing on git’s internal locks. If worktree creation fails due to a lock error,
it will retry once after a short delay.
§Arguments
spec_id- The specification ID (used to create unique worktree paths)branch- The branch name to create in the worktreeproject_name- Optional project name to namespace the worktree path
§Returns
The absolute path to the created worktree directory.
§Errors
Returns an error if:
- Git worktree creation fails after retry
- Directory cleanup/creation fails