feat: Add worktree commands with per-worktree trunks#1249
Open
ed-irl wants to merge 2 commits into
Open
Conversation
Collaborator
Author
This was referenced Jun 12, 2026
Open
f59037a to
70afff3
Compare
70afff3 to
0460c55
Compare
Introduces restack.Options{AutoResolve} and threads an opts *Options
parameter through the high-level restack entry points (RestackBranch,
RestackStack, RestackDownstack) and the merge/sync RestackHandler
interfaces, with all current callers passing nil.
This is foundational plumbing for the restack auto-resolve feature.
Landing it on a branch below the consuming stacks lets every branch
inherit the 3-arg signature, rather than the signature change living
on a branch parallel to its callers.
Adds doc/src/guide/scripts.md as the single source of truth for the
shared protocol that ties together three soon-to-be-aligned features:
- spice.message.generator (commit message generation)
- spice.restack.resolver (restack auto-resolve)
- spice.integration.resolver (integration-rebuild auto-resolve)
Documents:
- Invocation shape (shebang vs sh -c, working dir, args forwarding).
- Shared env contract: GS_OPERATION, GS_BRANCH, GS_BASE, plus the
table of all GS_OPERATION values across the three features. Lists
message-feature-specific extras (GS_MESSAGE_*, GS_TITLE, GS_BODY).
- JSON output schema (the union of fields across all three features).
- Assumptions logging, the questions Q&A loop, and termination rules.
- .spice/resolutions/<feature>.json layout for persistent Q&A.
- spice.scriptResolve.maxIterations cap.
- Worked examples and error-handling expectations.
This commit is a prerequisite for the implementation work landing on
ed-irl/scriptrun and the three feature branches above it. Registering
the page in doc/mkdocs.yml's User Guide section.
0460c55 to
253532c
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, backed by a per-worktree trunk registry, plus worktree-aware filtering forlogandrepo restack.Per-worktree trunks:
worktree-trunksstore key (additive/optional, so olderrepos and binaries are unaffected) registering local branches that
are trunk-equivalents — each tracks the same remote ref as the
canonical trunk. Store gains IsTrunk, TrunkFor, WorktreeTrunks, and
Register/UnregisterWorktreeTrunk; branch transactions now treat any
registered trunk as a graph root.
Downstack, Bottom, and Stack traversals stop at any trunk. Adds
StacksInWorktree to enumerate stacks touching a given worktree.
Commands:
worktree create <path>: by default creates a local trunk branch(named after the directory, or --trunk) tracking the remote trunk,
so sync and restack in different worktrees never contend on one
shared checkout. --no-trunk keeps detached-HEAD behavior; -b stacks
a tracked branch on the worktree trunk.
worktree list: shows each worktree, its branch, and stack.Worktree-aware filtering:
log short -wandrepo restack -wscope to stacks with a branchchecked out in the current worktree; -w implies --all for log.
fast-forwarding the local trunk from the canonical remote ref.
Includes unit tests, test scripts, regenerated docs/help, and a
changelog entry.