Skip to content

feat: add worktree management commands, per-worktree trunks, and worktree-aware filtering#1164

Open
ed-irl wants to merge 1 commit into
branch-comment-commandsfrom
branch-comment-tests
Open

feat: add worktree management commands, per-worktree trunks, and worktree-aware filtering#1164
ed-irl wants to merge 1 commit into
branch-comment-commandsfrom
branch-comment-tests

Conversation

@ed-irl

@ed-irl ed-irl commented May 14, 2026

Copy link
Copy Markdown
Collaborator

Adds a gs worktree command group and the per-worktree trunk machinery that lets stacks in different worktrees sync and restack without contending on a single shared trunk checkout.

Commands

  • gs worktree create <path> (alias wtc): creates a worktree with its own local trunk branch that tracks the same remote ref as the canonical trunk. The trunk is named after the worktree directory or set with --trunk. -b/--branch also creates a tracked branch stacked on the worktree trunk; --no-trunk keeps the legacy detached-HEAD behavior.
  • gs worktree list (alias wtls): lists worktrees with their checked-out branch and stack.

Worktree-aware filtering

  • gs log short/log long gain -w/--worktree to show only stacks with a branch checked out in the current worktree (implies --all).
  • gs repo restack gains -w/--worktree to restack only those stacks. The restack handler grows a WorktreeFilter and a SkipCheckout option.

State and graph

  • New per-worktree trunk registry in the state store (worktree.go): persisted under an additive, optional worktree-trunks key so older binaries and pre-feature repos are unaffected. Adds RegisterWorktreeTrunk/UnregisterWorktreeTrunk, TrunkFor, WorktreeTrunks, and an IsTrunk check used by the branch transaction.
  • BranchGraph treats every registered worktree trunk as a graph root, so downstack and bottom traversals stop there.
  • BranchGraph.StacksInWorktree returns the full stacks touching a given worktree, backing both filters.
  • git.Repository.WorktreeAdd wraps git worktree add; spice.GitWorktree exposes RootDir.

Sync resolves the local trunk to pull into via TrunkFor while still fetching from the canonical remote ref, so a linked worktree updates its own trunk.

@ed-irl ed-irl force-pushed the branch-comment-commands branch from 75c2b68 to bed2fb1 Compare June 2, 2026 18:58
@ed-irl ed-irl force-pushed the branch-comment-tests branch from 47a7eed to d42cd46 Compare June 2, 2026 18:58
@ed-irl ed-irl force-pushed the branch-comment-commands branch from bed2fb1 to 55e79ed Compare June 2, 2026 20:17
@ed-irl ed-irl force-pushed the branch-comment-tests branch 2 times, most recently from e683e4f to bc2d528 Compare June 2, 2026 22:31
@ed-irl ed-irl force-pushed the branch-comment-commands branch from c1b7235 to 631867a Compare June 2, 2026 22:33
@ed-irl ed-irl added the skip changelog PRs that don't need a changelog. label Jun 6, 2026
@ed-irl ed-irl force-pushed the branch-comment-commands branch from cc6ba9a to a4057f6 Compare June 8, 2026 10:18
@ed-irl ed-irl force-pushed the branch-comment-tests branch 2 times, most recently from d270ec2 to 0a8ca42 Compare June 8, 2026 11:15
@ed-irl ed-irl force-pushed the branch-comment-commands branch from fa75bd3 to b8b5295 Compare June 12, 2026 20:07
@ed-irl ed-irl force-pushed the branch-comment-tests branch from 0a8ca42 to 03fafd4 Compare June 12, 2026 20:07
@ed-irl ed-irl force-pushed the branch-comment-commands branch from b8b5295 to 6f87470 Compare June 13, 2026 13:39
@ed-irl ed-irl force-pushed the branch-comment-tests branch from 03fafd4 to 1f477e3 Compare June 13, 2026 13:39
@ed-irl ed-irl force-pushed the branch-comment-commands branch from 6f87470 to f6588c8 Compare June 15, 2026 09:52
@ed-irl ed-irl force-pushed the branch-comment-tests branch from 1f477e3 to 7241e23 Compare June 15, 2026 09:52
@ed-irl ed-irl force-pushed the branch-comment-commands branch from 7170265 to f86efce Compare June 19, 2026 01:03
@ed-irl ed-irl changed the title branch comment: add inline review comment commands and forge support feat: add worktree management commands, per-worktree trunks, and worktree-aware filtering Jun 19, 2026
@ed-irl ed-irl force-pushed the branch-comment-tests branch from f84f05d to c2cb662 Compare June 19, 2026 01:03
Add test scripts covering the core comment workflows:
- stage and submit staged comments as a review
- add an inline comment immediately
- list comments (text and `--json` output)
- resolve a review thread
- edit a staged comment

Also fixes a nil pointer dereference when no staged comments
exist for a branch, and includes thread IDs in list output
for use with resolve/unresolve commands.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip changelog PRs that don't need a changelog.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant