Expand description
Git worktree management for parallel Ralph loops.
Provides filesystem isolation for concurrent loops using git worktrees.
Each parallel loop gets its own working directory with full filesystem
isolation, sharing only .git history. Conflicts are resolved at merge time.
§Example
use ralph_core::worktree::{Worktree, WorktreeConfig, create_worktree, remove_worktree, list_worktrees};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = WorktreeConfig::default();
// Create worktree for a parallel loop
let worktree = create_worktree(".", "ralph-20250124-a3f2", &config)?;
println!("Created worktree at: {}", worktree.path.display());
// List all worktrees
let worktrees = list_worktrees(".")?;
for wt in worktrees {
println!(" {}: {}", wt.branch, wt.path.display());
}
// Clean up when done
remove_worktree(".", &worktree.path)?;
Ok(())
}Structs§
- Sync
Stats - Statistics about files synced to a worktree.
- Worktree
- Information about a git worktree.
- Worktree
Config - Configuration for worktree operations.
Enums§
- Worktree
Error - Errors that can occur during worktree operations.
Functions§
- create_
worktree - Create a new worktree for a parallel Ralph loop.
- ensure_
gitignore - Ensure the worktree directory is in
.gitignore. - list_
ralph_ worktrees - Get the list of Ralph-specific worktrees (those with
ralph/branches). - list_
worktrees - List all git worktrees in the repository.
- remove_
worktree - Remove a worktree and optionally its branch.
- sync_
working_ directory_ to_ worktree - Sync untracked and unstaged files from the main repo to a worktree.
- worktree_
exists - Check if a worktree exists for the given loop ID.