diff --git a/internal/git/git.go b/internal/git/git.go index 4e79ef12..c6bed800 100644 --- a/internal/git/git.go +++ b/internal/git/git.go @@ -442,10 +442,10 @@ func (g *Git) CommitAll(message string) error { // GitStatus represents the status of the working directory. type GitStatus struct { - Clean bool - Modified []string - Added []string - Deleted []string + Clean bool + Modified []string + Added []string + Deleted []string Untracked []string } @@ -767,6 +767,22 @@ func (g *Git) IsAncestor(ancestor, descendant string) (bool, error) { return true, nil } +// EnableParallelCheckout configures git to use parallel workers during checkout. +// This can significantly speed up worktree creation on SSDs (2-8x for large repos). +// Setting workers=0 auto-detects the number of CPU cores. +// Safe to call multiple times - git config is idempotent. +func (g *Git) EnableParallelCheckout() error { + // Auto-detect number of workers (0 = number of logical cores) + if _, err := g.run("config", "checkout.workers", "0"); err != nil { + return fmt.Errorf("setting checkout.workers: %w", err) + } + // Only parallelize when there are enough files to benefit + if _, err := g.run("config", "checkout.thresholdForParallelism", "100"); err != nil { + return fmt.Errorf("setting checkout.thresholdForParallelism: %w", err) + } + return nil +} + // WorktreeAdd creates a new worktree at the given path with a new branch. // The new branch is created from the current HEAD. // Sparse checkout is enabled to exclude .claude/ from source repos. @@ -1135,8 +1151,8 @@ type UncommittedWorkStatus struct { StashCount int UnpushedCommits int // Details for error messages - ModifiedFiles []string - UntrackedFiles []string + ModifiedFiles []string + UntrackedFiles []string } // Clean returns true if there is no uncommitted work. diff --git a/internal/rig/manager.go b/internal/rig/manager.go index 46895a8d..2a4d1ac1 100644 --- a/internal/rig/manager.go +++ b/internal/rig/manager.go @@ -13,8 +13,8 @@ import ( "github.com/steveyegge/gastown/internal/beads" "github.com/steveyegge/gastown/internal/claude" - "github.com/steveyegge/gastown/internal/constants" "github.com/steveyegge/gastown/internal/config" + "github.com/steveyegge/gastown/internal/constants" "github.com/steveyegge/gastown/internal/git" ) @@ -342,6 +342,13 @@ func (m *Manager) AddRig(opts AddRigOptions) (*Rig, error) { fmt.Printf(" ✓ Created shared bare repo\n") bareGit := git.NewGitWithDir(bareRepoPath, "") + // Enable parallel checkout for faster worktree creation on large repos. + // This is especially beneficial for repos with 10k+ files (e.g., java rig). + if err := bareGit.EnableParallelCheckout(); err != nil { + // Non-fatal: parallel checkout is an optimization, not required + fmt.Printf(" Warning: could not enable parallel checkout: %v\n", err) + } + // Determine default branch: use provided value or auto-detect from remote var defaultBranch string if opts.DefaultBranch != "" {