Skip to content

Support creating projects and git worktrees#99

Merged
stippi merged 5 commits intomainfrom
git-worktrees
Mar 31, 2026
Merged

Support creating projects and git worktrees#99
stippi merged 5 commits intomainfrom
git-worktrees

Conversation

@stippi
Copy link
Copy Markdown
Owner

@stippi stippi commented Mar 31, 2026

No description provided.

stippi added 5 commits March 31, 2026 15:27
Introduces crates/git/ with:
- GitRepository: main handle using git2 for fast in-process reads
- GitBinary: wrapper around system git binary for write operations
- Branch operations: list (git2), create/checkout/delete (CLI)
- Worktree operations: list/create/remove/find (CLI) with porcelain parsing
- Types: Branch, Worktree, RepoInfo
- 18 tests covering parsing, git2 reads, and CLI integration

Uses git2 0.20 with vendored-libgit2 (same approach as Zed).
Worktree path convention: ../.worktrees/<repo>/<sanitized-branch>
- Add worktree_path and branch fields to SessionConfig
- Add effective_project_path() helper that prefers worktree over init_path
- Update agent runner, sub-agent, and sandbox registration to use
  effective_project_path() for CWD resolution
- Add set_session_worktree() to SessionManager for mid-session switching
- Add BackendEvent variants: ListBranchesAndWorktrees, SwitchWorktree,
  CreateWorktree with corresponding BackendResponse types
- Implement backend handlers with git repo open, branch listing, worktree
  creation (with reuse of existing worktrees), and worktree switching
- Refactor git crate worktree operations to free functions (avoids
  git2::Repository Send/Sync issues in async contexts)
- Add git crate as dependency to code-assistant
- Handle new responses in both GPUI and terminal UI backends
- Create WorktreeSelector component (analogous to ModelSelector/SandboxSelector)
  with Local, existing worktree, and 'New worktree...' options
- Add WorktreeSelectorEvent variants: SwitchedToLocal, SwitchedToWorktree,
  CreateNewWorktreeRequested, RefreshRequested
- Integrate into InputArea layout between model and sandbox selectors
- Add InputAreaEvent variants for worktree operations
- Wire up RootView event handler to dispatch BackendEvents for
  SwitchWorktree, ListBranchesAndWorktrees
- Add TODO placeholders in GPUI response handler for updating
  WorktreeSelector when backend data arrives
@stippi stippi marked this pull request as ready for review March 31, 2026 17:37
@stippi stippi merged commit f922a35 into main Mar 31, 2026
1 check passed
@stippi stippi deleted the git-worktrees branch March 31, 2026 17:37
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.

1 participant