Skip to content

fix: pick the same parent on a full tie whatever the branch order - #24

Merged
pablospe merged 1 commit into
mainfrom
fix/deterministic-tie
Nov 20, 2026
Merged

pablospe merged 1 commit into
mainfrom
fix/deterministic-tie

Conversation

@pablospe

Copy link
Copy Markdown
Owner

When a branch is equally close to two candidate parents, wt-sync breaks the tie by the newer merge-base commit. If those timestamps are equal too, which is common when commits land in the same second or the candidates share a merge-base, the first candidate in the branch list won. That list order isn't stable, so the pick could flip between runs: one wt sync rebases onto a, the next onto b. This is what made branch_with_merge_commits_is_not_flattened flaky before #23.

The last tie now goes to the default branch, then to the first name alphabetically, and the "equidistant parents" warning lists the candidates sorted. The new test runs inference over the same repo with three branch orders and checks they all pick the same parent.

When two candidate parents were equally close and their merge-bases had the same committer timestamp, the first one in the branch list won, and that order isn't stable, so one sync could rebase onto a and the next onto b. Break the remaining tie by preferring the default branch, then the first name alphabetically, and list the tied candidates sorted.
@pablospe
pablospe merged commit c33ea82 into main Nov 20, 2026
2 checks passed
@pablospe
pablospe deleted the fix/deterministic-tie branch November 20, 2026 23:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant