Use rebase to align checkpoint branch with remote#863
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR changes the checkpoint-metadata sync behavior during push retries to prefer a linear history by rebasing local metadata commits onto the remote tip, rather than creating merge commits.
Changes:
- Replace the previous fetch+merge recovery with a fetch+rebase (cherry-pick) approach for the metadata branch when a push is rejected.
- Add helpers to compute merge-base / collect commit ranges and apply them as linear commits.
- Add unit tests for diverged/fast-forward/legacy-merge-history scenarios and update an integration test to assert linear history.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
cmd/entire/cli/strategy/push_common.go |
Switch non-fast-forward recovery from merge to rebase-like cherry-picking; add merge-base/rev-list helpers. |
cmd/entire/cli/strategy/push_common_test.go |
Add unit tests validating linearization + preservation of checkpoint data under several divergence scenarios. |
cmd/entire/cli/integration_test/remote_operations_test.go |
Update concurrent push integration test to expect rebased (non-merge) metadata history. |
gtrrz-victor
previously approved these changes
Apr 8, 2026
The merge-base changed after approval.
When syncing diverged entire/checkpoints/v1 branches (e.g. after cloning an Entire-enabled repo), cherry-pick local commits onto remote tip instead of creating a merge commit. This keeps the metadata branch history linear. Assisted-by: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Paulo Gomes <paulo@entire.io> Entire-Checkpoint: 9ba33d6ea655
The first-parent walk missed commits reachable through merge parents, causing ancestors older than the true merge-base to be replayed. This could resurrect deleted checkpoint shards. Switch to git rev-list --reverse --topo-order <exclude>..<tip> which correctly enumerates only commits reachable from local but not from remote. Assisted-by: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Paulo Gomes <paulo@entire.io> Entire-Checkpoint: 59c5d9a87fcb
… origin IsMetadataDisconnected and ReconcileDisconnectedMetadataBranch previously hardcoded refs/remotes/origin/<branch> as the remote ref. This broke reconciliation when the remote was not named "origin" or when the target was a URL (fetched to a temporary ref). Parameterize the remote ref so callers pass the correct one. Assisted-by: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Paulo Gomes <paulo@entire.io> Entire-Checkpoint: 5375bfd946d3
cherryPickOnto computes each commit's delta against its first parent, so replaying merge commits would incorrectly re-apply changes that arrived via non-first-parent history (e.g. resurrecting remotely deleted checkpoints). Filter merges out with --no-merges and a belt-and-suspenders parent count check. Assisted-by: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Paulo Gomes <paulo@entire.io> Entire-Checkpoint: 00147fce93da
Soph
approved these changes
Apr 9, 2026
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.
Replace merge commits with rebase, making the checkpoint history linear.
Manually testing on fresh single-branch clones without the metadata branch before the changes:

After the changes:

Note
Medium Risk
Changes the non-fast-forward recovery path for pushing checkpoint metadata, replacing merge commits with a rebase/cherry-pick flow that uses
git merge-base/git rev-list; mistakes here could lose or resurrect checkpoint shards during sync.Overview
Checkpoint push conflict recovery now prefers a linear history. When pushing
entire/checkpoints/v1fails with non-fast-forward, the CLI now fetches and rebases local checkpoint commits onto the remote tip (with fast-forward shortcuts) instead of creating merge commits.This adds merge-base/commit-range computation via
git merge-baseandgit rev-listto identify and replay only local-only commits onto the remote, aiming to avoid replaying older ancestors (e.g., previously merged history) and keeping remote deletions intact.Tests were updated/expanded: the integration concurrent-push test now asserts a single-parent tip, and new unit tests cover diverged branches, local-behind fast-forward, and the “merge-base on second parent” scenario to ensure no unintended ancestor replay.
Reviewed by Cursor Bugbot for commit 6e192c6. Configure here.