worktree: Add management commands, per-worktree trunks, and worktree-aware filtering#1222
Draft
ed-irl wants to merge 1 commit into
Draft
worktree: Add management commands, per-worktree trunks, and worktree-aware filtering#1222ed-irl wants to merge 1 commit into
ed-irl wants to merge 1 commit into
Conversation
This was referenced Jun 2, 2026
Draft
13fcb5b to
ce6c1aa
Compare
Collaborator
Author
|
This change is part of the following stack:
Change managed by git-spice. |
This was referenced Jun 2, 2026
d42cd46 to
e683e4f
Compare
5582ec7 to
ee1f597
Compare
bc2d528 to
5228b63
Compare
ee1f597 to
9f8657d
Compare
d270ec2 to
0a8ca42
Compare
1113e5d to
312db25
Compare
0a8ca42 to
03fafd4
Compare
312db25 to
6ab1da8
Compare
03fafd4 to
1f477e3
Compare
6ab1da8 to
167cca4
Compare
1f477e3 to
7241e23
Compare
167cca4 to
d049480
Compare
f84f05d to
c2cb662
Compare
41864dd to
93682d9
Compare
Until now shamhub's inline comments hard-coded Outdated:false; the
boolean flowed through to the JSON output but never told the truth.
Real forges (GitHub, GitLab) compute outdated as "the line this
comment was anchored to no longer matches the current head diff" —
without that, the VSCode extension's stale-comment surface has
nothing to render against in tests.
Plumb the same shape end-to-end in shamhub:
- shamComment.CommitSHA: captured at post time via 'git rev-parse'
on the change's head branch. The forge now knows the exact
commit each comment was anchored to.
- diffmap.Mapper.LineModified: given an already-parsed unified
diff, ask whether a path:line on the LEFT or RIGHT side was
touched. The RIGHT/OLD mapping is documented inline — comment
anchors are on the RIGHT side of the original PR diff (the
post-commit's version), which becomes the OLD side of the
post-commit..head diff used for stale detection.
- handleListInlineComments: for each comment, run
'git diff --unified=0 commitSHA..head -- path' against the
bare repo, parse the result with diffmap, and report stale if
the anchored line falls into a modified hunk. Comments without
a captured CommitSHA fall through to the existing Outdated
override (test seeds + the new shamhub -outdated flag).
- shamhub 'comment edit -outdated=true|false' force-sets the
stale flag for tests that don't want to set up divergent
commits.
The new test script (branch_comment_stale.txt) covers the full
flow: post two comments on the same head, amend the file so one
anchor line changes and the other doesn't, push the new head, and
verify only the touched comment reports outdated.
This is the prerequisite the extension-json commit's stale field
was waiting on.
c2cb662 to
63cfc0c
Compare
93682d9 to
e8e87b4
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 by default: a localbranch (named after the worktree directory, or set with --trunk) that
tracks the same remote ref as the canonical trunk. Stacks created in
the worktree are based on this branch, so
repo syncand restacks indifferent worktrees never contend on a single shared trunk checkout.
Use -b to also create a tracked branch stacked on the worktree trunk,
or --no-trunk for the legacy detached-HEAD behavior.
The state store gains a per-worktree trunk registry (an additive,
optional key, so older repositories and binaries are unaffected).
Trunk-equivalence now flows through the branch graph and branch
transactions: any registered worktree trunk is treated as a graph
root, so traversals stop at it and it cannot itself be tracked.
Add -w/--worktree to
log shortandrepo restackto scopeoperations to stacks with at least one branch checked out in the
current worktree, and resolve the displayed/synced trunk per worktree
via Store.TrunkFor.
Includes unit tests for the registry and graph behavior, plus test
scripts covering worktree create/list, worktree-aware filtering, and
branch create/restack when the trunk is checked out elsewhere.