Commit 205456e
Close ort correctness gaps vs C Git: recursive merge, dir-rename relevance, submodules, attributes
Bring the pure-Python ort engine to byte-for-byte parity with C Git (v2.44)
across the result-affecting behaviors that the single-base implementation
previously diverged on.
Recursive merge (virtual merge base):
- Port merge_ort_internal/merge_incore_recursive: compute all merge bases and
recursively merge them into a virtual ancestor (mergeort.merge_recursive),
exposed via ort.merge_commits and used by `git merge` (porcelain_merge).
Matches `git merge-tree <a> <b>` (no --merge-base) on criss-cross histories.
- Implement every call_depth>0 behavior: modify/delete uses the base stage,
distinct-types/symlink use the merge-base version, binary merge takes the
ancestor (virtual_ancestor), and content-merge marker size grows with depth.
- Rewrite merge.merge_bases as a faithful paint_down_to_common
(date-ordered priority walk with insertion-order tie-breaking) plus
remove_redundant, so merge bases come back in C Git's exact order — which
the virtual-ancestor construction (and its stage-1 blob) depends on.
Directory rename detection:
- Track dir_rename_mask through collect_merge_info with the per-directory 0x07
flip, computing rename-source relevance (content_relevant || location_relevant)
and removed-dir relevance (RELEVANT_FOR_SELF/ANCESTOR/NOT_RELEVANT).
- Cull non-relevant sources from inexact/basename rename matching in diffcore
(matching diffcore_rename_extended) so rename *pairings* match git, and only
count dir renames from relevant sources. Fixes nested, split, transitive, and
"rename whose source the other side left untouched" cases.
Submodules: port merge_submodule fast-forward (descendant wins when the
submodule object store is available; conflict otherwise, like git).
Config/attributes: honor merge.conflictStyle (merge/diff3/zdiff3) and the
working-tree .gitattributes merge / conflict-marker-size attributes (incl.
merge=union), matching how git's attr stack reads them for merge-tree.
Validated byte-for-byte vs git 2.44 over thousands of randomized cases
(blob merges, criss-cross/recursive merges, mixed and nested directory
renames) plus new pytest parity tests; full suite 127 passing.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent fc3740f commit 205456e
9 files changed
Lines changed: 1003 additions & 190 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
266 | 266 | | |
267 | 267 | | |
268 | 268 | | |
269 | | - | |
270 | | - | |
271 | | - | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
272 | 274 | | |
273 | 275 | | |
274 | | - | |
| 276 | + | |
275 | 277 | | |
276 | 278 | | |
277 | 279 | | |
278 | 280 | | |
279 | 281 | | |
280 | 282 | | |
281 | | - | |
| 283 | + | |
| 284 | + | |
282 | 285 | | |
283 | 286 | | |
284 | | - | |
| 287 | + | |
285 | 288 | | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
294 | 301 | | |
295 | 302 | | |
296 | 303 | | |
| |||
405 | 412 | | |
406 | 413 | | |
407 | 414 | | |
408 | | - | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | | - | |
413 | | - | |
414 | | - | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
415 | 424 | | |
416 | 425 | | |
417 | 426 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
| 215 | + | |
215 | 216 | | |
216 | 217 | | |
217 | 218 | | |
218 | 219 | | |
219 | 220 | | |
220 | 221 | | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
221 | 226 | | |
222 | 227 | | |
223 | 228 | | |
| |||
304 | 309 | | |
305 | 310 | | |
306 | 311 | | |
| 312 | + | |
| 313 | + | |
307 | 314 | | |
308 | 315 | | |
309 | 316 | | |
| |||
321 | 328 | | |
322 | 329 | | |
323 | 330 | | |
324 | | - | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
325 | 334 | | |
326 | 335 | | |
327 | 336 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
62 | 75 | | |
63 | | - | |
64 | | - | |
65 | | - | |
| 76 | + | |
66 | 77 | | |
67 | | - | |
| 78 | + | |
68 | 79 | | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
73 | 123 | | |
74 | 124 | | |
75 | 125 | | |
76 | 126 | | |
77 | 127 | | |
78 | | - | |
79 | | - | |
| 128 | + | |
80 | 129 | | |
81 | 130 | | |
82 | 131 | | |
| |||
0 commit comments