anchor: Make restack and log anchor-aware#1302
Open
ed-irl wants to merge 3 commits into
Open
Conversation
Collaborator
Author
|
This change is part of the following stack: Change managed by git-spice. |
Anchor-scoping behaviors that complement the per-worktree anchor model, keeping parallel worktrees from reaching across each other's stacks and making anchors legible in the log. Reach and isolation: - 'gs repo restack' (whole repo) now also restacks stacks rooted at anchors (per-worktree trunks), which are graph roots disconnected from the canonical trunk and were previously unreachable. 'gs repo restack -w' stays scoped to the current worktree. - Restack stays within the invoking worktree's anchor: an anchor is a graph root, so downstack stops at it and upstack stops at any child anchor. This is enforced structurally; a regression test documents it. - Checking out a branch already in use by another worktree now fails with a legible 'branch X is in use by worktree <path>' error (typed git.BranchInUseError) instead of git's raw fatal. Surfacing in the log: - 'gs ll' shows another worktree's anchor-rooted stack instead of silently dropping it: the anchor pointer renders as an intermediate node under its base, tagged '[root anchor]' or '[internal anchor]', with its stack above it. '--json' gains per-branch 'anchor' and 'anchorKind' fields. Adds BranchGraph.Anchors(), a WholeRepo restack request flag, anchor-node injection in the log handler, and a worktree pre-check in Worktree.CheckoutBranch.
Fixes from adversarial review (anchor-scope layer): - 'repo restack -w' run inside an anchor worktree now restacks that worktree's anchor-rooted stack instead of doing nothing: the worktree filter admits the stack rooted at the worktree's anchor, which may have no tracked branch checked out locally (B1) - list: an internal anchor whose pinned base is filtered out of the view now roots at the display trunk instead of silently hiding its subtree (M6) - restack: correct the WholeRepo doc to match its actual behavior
a2cf5db to
a9f1685
Compare
45c0956 to
62aa054
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.
Anchors are per-worktree trunks: graph roots disconnected from the canonical trunk. This makes restack and log surface them.
gs repo restacknow also restacks stacks rooted at anchors, which an upstack-from-trunk walk never reaches.repo restack -wfrom inside an anchor worktree restacks that worktree's own anchor-rooted stack.gs llinjects an anchor display node for another worktree's anchor-rooted stack, tagged[root anchor]or[internal anchor]. JSON output gainsanchorandanchorKindfields.BranchInUseErrornaming the worktree, instead of git's raw fatal.Adds unit tests, test scripts, and a changelog entry.