Skip to content

Use rebase to align checkpoint branch with remote#863

Merged
pjbgf merged 4 commits intomainfrom
pjbgf/rebase
Apr 9, 2026
Merged

Use rebase to align checkpoint branch with remote#863
pjbgf merged 4 commits intomainfrom
pjbgf/rebase

Conversation

@pjbgf
Copy link
Copy Markdown
Member

@pjbgf pjbgf commented Apr 7, 2026

Replace merge commits with rebase, making the checkpoint history linear.

Manually testing on fresh single-branch clones without the metadata branch before the changes:
image

After the changes:
image


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/v1 fails 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-base and git rev-list to 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.

Copilot AI review requested due to automatic review settings April 7, 2026 22:10
@pjbgf pjbgf requested a review from a team as a code owner April 7, 2026 22:10
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
gtrrz-victor previously approved these changes Apr 8, 2026
@pjbgf pjbgf dismissed gtrrz-victor’s stale review April 8, 2026 15:28

The merge-base changed after approval.

pjbgf added 4 commits April 9, 2026 15:06
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
@pjbgf pjbgf merged commit 00ae879 into main Apr 9, 2026
3 checks passed
@pjbgf pjbgf deleted the pjbgf/rebase branch April 9, 2026 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants