fix: resolve BranchOnto target from git ref, not stored state#1151
Closed
ed-irl wants to merge 1 commit into
Closed
fix: resolve BranchOnto target from git ref, not stored state#1151ed-irl wants to merge 1 commit into
ed-irl wants to merge 1 commit into
Conversation
Collaborator
Author
|
This change is part of the following stack: Change managed by git-spice. |
a40644a to
979d0cd
Compare
branch merge and ci merge-guard commands
265d671 to
3e389f6
Compare
branch merge and ci merge-guard commands3e389f6 to
0d9161c
Compare
979d0cd to
3d9ac92
Compare
BranchOnto resolved the target hash from the stored state (LookupBranch.Head) for non-trunk branches, but used PeelToCommit (current git ref) for trunk. This asymmetry could cause stale target hashes when a prior operation in the same transaction modified the target branch's git ref without updating the stored state. Use PeelToCommit consistently for all target branches.
0d9161c to
19e5015
Compare
abhinav
reviewed
May 17, 2026
abhinav
left a comment
Owner
There was a problem hiding this comment.
I'm not sure this is right. The premise in the PR message is false.
LookupBranch does not use a recorded Head commit hash. Only the base hash uses recorded values:
We load storage information and current PeelToCommit:
git-spice/internal/spice/branch.go
Lines 107 to 109 in 7fbfdaf
Then we put that directly in the response:
git-spice/internal/spice/branch.go
Lines 143 to 147 in 7fbfdaf
So I think this might've been a speculative fix for something else that went wrong?
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.
When
BranchOntomoved a non-trunk target, it used the target branch'sstored
Headhash to rebase the moved branch. This stored value couldbe stale within a single transaction — for example, when
branch ontorestacks upstack branches after moving the target, each subsequent
rebase saw the pre-move hash rather than the branch's actual ref.
Resolve the target by peeling its git ref instead, which always
reflects the current state. The tracked-branch check is preserved for
non-trunk targets, but the hash itself now comes from the ref.
This issue is similar to #1150 - the
gs bmcommand will introduce the possibility of iterative changes to the stack structure during command execution, so there's a need to re-read refs during command execution.I also had some issues remembering why exactly we needed this. Claude had this somewhat more verbose explanation:
[skip changelog]: bug fix only