Fix for replaying amended parent commits during rebase - #333
Open
skarim wants to merge 1 commit into
Open
Conversation
Preserve a branch's last valid base when its parent is rewritten, and only use verified ancestor commits as rebase boundaries. Recover previously corrupted metadata from the parent reflog when possible, otherwise stop safely instead of replaying superseded parent commits.
skarim
force-pushed
the
skarim/rebase-onto-amended-commits
branch
from
July 28, 2026 06:26
346396d to
6dca4c9
Compare
skarim
marked this pull request as ready for review
July 28, 2026 06:30
Contributor
There was a problem hiding this comment.
Pull request overview
Prevents amended parent commits from being replayed during stacked rebases by preserving safe base metadata and recovering boundaries from reflogs.
Changes:
- Validates recorded rebase boundaries before updating or using them.
- Adds
git merge-base --fork-pointsupport. - Adds unit and real-Git regression coverage for issue #250.
Show a summary per file
| File | Description |
|---|---|
internal/git/mock_ops.go |
Adds fork-point mocking support. |
internal/git/gitops.go |
Implements the fork-point Git operation. |
internal/git/git.go |
Exposes the fork-point wrapper. |
cmd/utils.go |
Preserves and resolves safe rebase boundaries. |
cmd/utils_test.go |
Tests base preservation. |
cmd/sync_test.go |
Updates sync fork-point coverage. |
cmd/rebase_test.go |
Adds rebase unit and integration regressions. |
Review details
- Files reviewed: 7/7 changed files
- Comments generated: 0
- Review effort level: Medium
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.
gh stack rebaseduplicates an amended downstack commit after pushing #250Amending a lower branch and then running
gh stack pushcould overwrite itschild's recorded base with a commit the child did not contain. The next
rebasewould replay the old parent commit into the child, creating duplicatehistory or unnecessary conflicts.
This preserves the last valid recorded base and only uses validated ancestor
commits as
rebase --ontoboundaries. Existing corrupted metadata can berecovered from the parent reflog; when no safe boundary is available, the
command stops instead of guessing and rewriting history incorrectly.
Testing
go vet ./...go test -race -count=1 ./...Stack created with GitHub Stacks CLI • Give Feedback 💬