feat: record base SHA at gw new --stack for a deletion-proof restack - #51
Merged
Conversation
The pre-PR restack hint (StackedBaseMerged) used the base branch NAME as the `git rebase --onto` boundary. But a child with no PR yet isn't protected by the cleanup guard (#49 only sees open child PRs), so the base branch may be deleted before the child opens its PR — leaving the name unresolvable. gw new --stack now also records the base tip SHA (branch.<child>.gwBaseSha), which equals the fork point since --stack branches off the current HEAD. The StackedBaseMerged hint prefers that SHA as the `--onto` boundary, so it still resolves after the base branch is gone. gw sync clears both keys on restack; branch deletion clears the rest. - git: branch_base_sha / set_branch_base_sha; unset_branch_base clears both keys - new: record gwBaseSha alongside gwBase - next_action/status: thread recorded_base_sha into StackedBaseMerged's hint Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
zawakin
added a commit
that referenced
this pull request
Jun 29, 2026
Reflect the stacked-PR work (#48-#51) in the skill's stacking section: gw sync restacks with rebase --onto (replaying only the child's commits, not the merged parent's), gw status guides the pre-PR case, and gw cleanup keeps a base branch alive while an open child PR still targets it. Adds a note on why --onto is required after a squash merge. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
What
Step 4 (final) of the stacked-restack package.
gw new --stacknow records the base tip SHA inbranch.<child>.gwBaseSha, and the pre-PRStackedBaseMergedhint uses it as thegit rebase --ontoboundary.Why
The pre-PR restack hint used the base branch name as the
--ontoboundary. But a child that has no PR yet isn't protected by the cleanup guard (#49 only sees open child PRs), so the base branch can be deleted before the child opens its PR — leaving the name unresolvable.The recorded SHA equals the fork point (since
--stackbranches off the current HEAD) and still resolves after the base branch is gone, so the suggestedgit rebase --onto origin/main <sha>keeps working.Changes
git:branch_base_sha/set_branch_base_sha;unset_branch_basenow clears bothgwBaseandgwBaseSha(used bygw syncon restack).new: recordgwBaseShaalongsidegwBaseunder--stack.next_action/status: threadrecorded_base_shathroughDetectContextinto theStackedBaseMergedhint, which prefers the SHA over the branch name.Test
next_action:test_recorded_base_merged_carries_recorded_sha.tests/new_test.rs:--stackrecordsgwBaseSha== the parent's HEAD.mise run verifypasses.Note / known edge
The recorded SHA is the base tip at stack time. If the base later advances and the child re-stacks onto the newer tip, the SHA is a stale boundary; while the base branch still exists,
gw syncusesorigin/<base>(the live ref) which handles that correctly. The SHA is the fallback for the base-deleted, pre-PR case.This completes the stacked-PR package (#48 hint, #49 cleanup guard, #50 sync --onto, this).
🤖 Generated with Claude Code