Repository navigation
fix(gate): read a merge of unrelated histories as a first-parent diff - #137
Merged
Merged
Conversation
A two-parent merge whose parents share no ancestor, as a first squashed subtree add produces, made git merge-tree refuse the merge with exit 128 and failed the whole changeset check. The two-parent branch now asks git merge-base whether the parents are related: exit 1 takes the residue from the diff between the first parent and the merge commit, the rule octopus merges already use, and any other exit fails naming the command, its status and its stderr. A merge whose parents are related keeps its merge-tree residue.
Contributor
Author
|
Tests at head 426e975. CI's checks job ran build and lint for the changed package but no test task, so I ran the tests locally:
Independent adversarial review: approach kept, no P0/P1. |
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.
Written adversarial review (before the diff)
Is the approach right?
The change asks
git merge-base <first> <second>before a two-parent merge reachesgit merge-tree. Exit 0 keeps today'smergeResidue(themerge-treecall) byte for byte; exit 1 takes the residue fromgit diff-treebetween the first parent and the merge commit. Any other exit is a failure that names the command, its exit status and its stderr.Alternatives weighed:
git merge-tree --allow-unrelated-histories— rejected: a squashed subtree add's second parent holds the vendored repository's files at its own root, not under the prefix the subtree merge placed them. Merging it against an unrelated base relocates those files to the workspace root, so the residue would name root paths instead of the import — a wrong set of paths rather than a wider or narrower one.merge-tree's exit 128 as the trigger and matching its stderr — rejected: it recovers from that one message only, leaves every other 128 on the same crash path, and makes the check depend on git's English text.merge-treeexists to isolate.merge-baseexit 1 already means the two parents share no commit, so a second test can only disagree with it by being wrong.Cost: one
git merge-baseprocess per two-parent merge. The probe returns before anymerge-treework, and only two-parent merges pay it.P0/P1
None found. Checked how the change could weaken what the check guards:
changedPathsOf), and a feature-touched path is neverreleased, so residue can only move a path from release-owned to feature-owned — never the reverse. The required-intent set is monotone in the residue, so a wider residue can only make the check stricter. The end-to-end proof below shows the intent requirement still firing for a first squashed subtree add inside a published package.EvidenceCommandFailednaming the command, its exit status and its stderr, the shape every other git call in this adapter uses.mergeResiduecall, and no other line of the adapter changed. A related merge with an evil edit was re-run end to end and still reports both the merged feature change and the evil edit.Residual risk, stated plainly: a two-parent merge of unrelated histories now demands an intent for every path it introduces that a publishable member owns. That strictness is intended; it is what the check does for any other feature change.
What changed
packages/process-adapter/src/history-io.ts— the two-parent branch ofcommitOfasksgit merge-basefirst: related → themerge-treeresidue as before; unrelated → the first-parent diff; any other exit fails naming the command.docs/change-intents.md— how the check reads a merge of unrelated histories.docs/solutions/runtime-errors/merge-tree-refused-a-first-squashed-subtree-add.md— the learning record..changeset/merge-tree-reads-unrelated-histories.md— a patch intent for@systemfsoftware/process-adapter.The plan this implements is in the branch:
docs/plans/2026-11-27-1501-fix-change-intent-unrelated-history-merge-plan.md.Verification
Run at low priority (
nice -n 19 ionice -c3):pnpm typecheck --filter @systemfsoftware/process-adapterpnpm lint --filter @systemfsoftware/process-adapterpnpm test --filter @systemfsoftware/process-adapter./bin/dprint checkon the four changed filesEnd to end, against the built
changeset-managementapp and three synthetic consumer repositories (each a pnpm workspace with two publishable members):git merge-baseparentscheckverdictno publishable package changed (2 member(s))packages/a@x/apackages/b@x/aand@x/bBefore the change, the first two cases reached
git merge-treeand exited 128 withfatal: refusing to merge unrelated histories, reproduced directly against git 2.55.0. Thechange intentjob of the failing public consumer pull request has not been re-run against this branch yet; that run is the remaining proof.Tests
No test was added. The adapter's real-git suites spawn
giton the host, and this repository admits a new test only when that is asked for. The end-to-end proof above is the replacement evidence.Plan note
One assumption in the plan does not hold.
docs/plans/2026-11-27-1501-fix-change-intent-unrelated-history-merge-plan.md:78says the squashed root commit's paths are read and can make a colliding root path feature-owned. In factgit diff-tree -r -z --root --no-renames --name-status <commit>prints the commit id as its first NUL field (git 2.55.0), so the adapter's pair walk misaligns and records no changes for a root commit. Nothing in this fix depends on it: the net diff from the merge base toHEADcarries every imported path. Recorded so the plan's reasoning is not read as fact.