worktree: Add worktree commands, per-worktree trunks, and worktree-aware filtering#1165
Open
ed-irl wants to merge 1 commit into
Open
worktree: Add worktree commands, per-worktree trunks, and worktree-aware filtering#1165ed-irl wants to merge 1 commit into
ed-irl wants to merge 1 commit into
Conversation
Collaborator
Author
This was referenced May 19, 2026
Open
2f117ea to
93c644e
Compare
93c644e to
512b215
Compare
This was referenced Jun 12, 2026
512b215 to
8575070
Compare
8575070 to
b0c48d9
Compare
b0c48d9 to
e3c8701
Compare
Introduce repo-scoped integrationInfo carrying a singleton integration branch name, the upstream branch, the last pushed hash for --force-with-lease leasing, and an ordered list of tips with the hashes recorded at the last rebuild. Adds Store.Integration / Store.SetIntegration as the public API and bumps the state storage layout to VersionThree. The version is upgraded only when an integration is configured, so existing repos that never opt in keep V1 or V2. SetRemote preserves integration through remote changes; clearing the integration drops the version back to its prior level. Extends the spice.Service Store interface with Integration and SetIntegration so the service layer can read and write the configuration. spice.Service.RenameBranch now rewrites any integration tip that references the renamed branch; rename failures of the integration update are surfaced as warnings rather than aborting the primary rename. Also adds Store.PendingIntegrationRebuild, Store.SetPendingIntegrationRebuild, and Store.ClearPendingIntegrationRebuild for persisting a rebuild that was paused mid-flight (typically by a merge conflict). The handler uses this to support resuming after the user resolves conflicts in the worktree.
e3c8701 to
dbeafc0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add
gs worktree createandgs worktree list.worktree createsets up a per-worktree trunk: a local branch (named after the worktree directory, or set with --trunk) that tracks the same remote ref as the canonical trunk, so sync and restack in different worktrees never contend on a single shared trunk checkout. --no-trunk preserves the old detached-HEAD behavior, and -b stacks a new tracked branch on the worktree trunk.Introduce a persisted per-worktree trunk registry in state.Store (worktree.go): RegisterWorktreeTrunk, UnregisterWorktreeTrunk, WorktreeTrunks, TrunkFor, and IsTrunk. The registry lives under an additive, optional store key, so older repos and binaries simply see no entry. IsTrunk now treats both the canonical trunk and any registered worktree trunk as graph roots; BranchTx upsert/delete/path checks switch from
== trunkto IsTrunk.Teach BranchGraph about trunk-equivalents: it loads WorktreeTrunks from the BranchLoader, treats all of them as roots in Downstack/Bottom, and adds StacksInWorktree to enumerate complete stacks that have at least one branch checked out in a given worktree.
Wire worktree-aware behavior through the handlers:
-w/--worktreetolog short/log long, scoping output to the current worktree's stacks and rendering them under the worktree's own trunk (TrunkFor).repo restack -wlimits restacking to stacks in the current worktree.Add git.Repository.WorktreeAdd, expose GitWorktree.RootDir on spice.Service, and add spice.Service.WorktreeTrunks/TrunkFor. Includes unit tests, test scripts, regenerated docs/help, and a changelog entry.