pub struct GitWorktreeBackend { /* private fields */ }Expand description
A workspace backend implementation using git worktree.
Implementations§
Trait Implementations§
Source§impl WorkspaceBackend for GitWorktreeBackend
impl WorkspaceBackend for GitWorktreeBackend
Source§fn destroy(&self, name: &WorkspaceId) -> Result<(), Self::Error>
fn destroy(&self, name: &WorkspaceId) -> Result<(), Self::Error>
Destroy a workspace by removing its git worktree.
This is atomic and idempotent:
- If the workspace doesn’t exist (already destroyed), returns Ok(()).
- Step 1:
git worktree remove --force <path>(handles dirty worktrees) - Step 2: If that fails, remove the directory manually and prune.
- Step 3:
git worktree pruneto clean up stale references.
Each step is individually idempotent, so a crash at any point can be retried safely.
Source§fn list(&self) -> Result<Vec<WorkspaceInfo>, Self::Error>
fn list(&self) -> Result<Vec<WorkspaceInfo>, Self::Error>
List all workspaces managed by this backend.
Parses git worktree list --porcelain and filters to worktrees directly
under the ws/ directory. The main worktree (repo root) and any
non-ws/ worktrees are excluded.
Staleness is determined by comparing each workspace’s HEAD against
refs/manifold/epoch/current. If the epoch ref doesn’t exist
(Manifold not yet initialized), all workspaces are reported as Active.
Source§fn status(&self, name: &WorkspaceId) -> Result<WorkspaceStatus, Self::Error>
fn status(&self, name: &WorkspaceId) -> Result<WorkspaceStatus, Self::Error>
Get the current status of a workspace.
Reports dirty files (modified, added, deleted, untracked) by running
git status --porcelain inside the worktree directory.
Staleness is determined by comparing the workspace’s HEAD (the epoch
it was created at) against refs/manifold/epoch/current.
Source§fn snapshot(&self, name: &WorkspaceId) -> Result<SnapshotResult, Self::Error>
fn snapshot(&self, name: &WorkspaceId) -> Result<SnapshotResult, Self::Error>
Scan a workspace’s working directory for changes relative to the base epoch.
Detects added, modified, and deleted files by comparing the workspace’s working tree against the epoch commit. Also picks up untracked files as additions.
§Implementation
The diff base is the epoch (from refs/manifold/epoch/current), NOT
the workspace’s HEAD. Agents may commit changes inside a workspace,
which advances HEAD beyond the epoch. If we diffed against HEAD, those
committed changes would be invisible and the merge engine would see an
empty workspace.
git diff --name-status <epoch>— all changes (committed + uncommitted)git ls-files --others --exclude-standard— untracked files