Skip to content

feat(stack): repair checked-out worktree branches#19

Merged
kitlangton merged 2 commits into
kitlangton:mainfrom
aryasaatvik:feat/worktree-aware-repair
Jun 30, 2026
Merged

feat(stack): repair checked-out worktree branches#19
kitlangton merged 2 commits into
kitlangton:mainfrom
aryasaatvik:feat/worktree-aware-repair

Conversation

@aryasaatvik

Copy link
Copy Markdown
Contributor

Summary

  • discover Git worktrees and dirty state through the Git service
  • replay checked-out branches from their owning clean worktree instead of force-moving them from another checkout
  • fail Stack sync/merge before repair side effects when a branch that needs repair is checked out in a dirty worktree
  • fail with a precise message when deleting a local branch that is checked out in another worktree

Behavior Matrix

Case Behavior
Current worktree dirty Existing behavior stays: mutating sync/merge fails before mutation with worktree is dirty.
Target branch checked out in another clean worktree Stack repairs that branch from the owning worktree, leaves it checked out there, and avoids git branch -f from the current checkout.
Target branch checked out in another dirty worktree Stack fails before backup/replay/push with the branch, worktree path, and dirty files.
Merge would need to repair a dirty descendant worktree Stack fails before retargeting, backing up, or merging the root.
Root branch to delete is checked out elsewhere after merge Stack fails with a precise branch/worktree path message instead of detaching or deleting implicitly.

Validation

  • bun run typecheck
  • bun run test
  • bun run format:check
  • bun run lint
  • bun src/cli.ts --help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants