Merge union-merge paths with git's own union merge - #32
Merged
Merged
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
[repair] union_mergepaths are now merged by git's own union merge. Before, a union-merged path was rebuilt line by line: the whole base-side file, then the pull request's new lines appended at the end, with repeated lines collapsed and CRLF line endings lost. git'smerge=unionworks hunk by hunk instead: inside each conflicting hunk it keeps the pull request's lines and then the base branch's, in place, and it keeps everything else exactly as git's ordinary merge would. Because the two results differed, a union-merged step could never equal the tree from a tree provider (or from agit merge) that computes git's union.How:
union_stepstill runs git's merge first. When every conflicted path is a configured union path (and both sides still have the file), git runs the merge again withmerge=uniondeclared for exactly those paths. The declaration is added to the.gitattributesof each path's directory, after whatever that file already declares, in an attribute tree built from the base side's tree. That tree is passed asattr.treeand never committed. So the result is byte for byte whatgit mergegives when.gitattributesdeclaresmerge=unionfor the path, using the same diff algorithm, the same virtual merge bases and the same handling of trailing newlines. Conflict handling is unchanged: a conflict on any other path, or a union path deleted on one side, still conflicts.merge-treeoutput is now read with-z, and file contents stay bytes.rules.union_linesis replaced byrules.union_attributes, the pure function that writes those attribute lines: names are anchored and their pattern characters escaped, and a name with whitespace or quotes becomes a quoted pattern. Theunion-mergerule now maps to it. The Lean modelunionLinesand its theorems are unchanged.Union.lean's module text andproofs/README.mdnow say thatunionLinesmodels the set of lines a union keeps, not git's exact byte order. The train doesn't depend on that order, because it compares the landed tree with the gated tree byte for byte.Tests come first (
test: ...).tests/test_union_merge.pycompares the union step's file with two references:git merge-file --unionon the three versions, and a git merge withmerge=uniondeclared in a separate repository. The cases cover insertions at the same spot, interleaved hunks, clean hunks next to a union hunk, deletions, repeated lines, an emptied file, four trailing-newline variants, CRLF and mixed line endings, bytes that aren't valid UTF-8, a file added on both sides, a path with pattern characters and spaces, a directory.gitattributesthat declares another merge, and 40 seeded random cases against git's own merge. Two existing expectations changed to git's order:test_history's repair now expectsa, lane, main, and the oldunion_linesunit test is replaced byunion_attributestests. Runningmake testgives 364 tests passing;lake buildfor the proofs passes.