pub struct Worktree { /* private fields */ }Implementations§
Source§impl Worktree
impl Worktree
Sourcepub fn add(repo_root: &Path, path: &Path, commit: &str) -> Result<Self>
pub fn add(repo_root: &Path, path: &Path, commit: &str) -> Result<Self>
Create a new detached worktree at path, checked out at commit.
commit may be any valid git revision (sha, ref name, HEAD).
The parent repository is repo_root; git -C <repo_root> worktree add --detach <path> <commit> is invoked verbatim.
On failure (path collision, locked worktree, invalid commit, dirty index) the returned error includes the captured stderr from git so the operator has an actionable detail rather than an opaque “git worktree add failed”.
§Errors
Returns an error if path contains ASCII whitespace. The
determinism harness composes path into RUSTFLAGS via
--remap-path-prefix=<path>=/anodize, and RUSTFLAGS is a
space-delimited token list with no quoting mechanism — a path
containing whitespace would be parsed as multiple arguments by
rustc and either silently misremap or hard-fail the build. Reject
at construction so the operator sees a clear “rename the
scratch dir” message instead of an opaque rustc parse error
later.