You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reimplement ort merge engine in pure Python (no git binary, no fallback)
Replace the `git merge-tree --write-tree` subprocess (and the line-based
fallback) with a faithful port of Git's ort merge engine, ported from the
git v2.44.0 source. Output — result tree oid, conflicted blobs with markers,
and conflicted index stages — is byte-for-byte identical to
`git merge-tree --write-tree`.
New modules:
- xdiff.py: port of git's xdiff library — record classification, the
histogram diff ort hardcodes for content merges, the classic Myers
algorithm as histogram's fallback, xdl_change_compact, and the zealous
three-way xdl_merge that emits <<<<<<< / ======= / >>>>>>> markers
(CRLF and no-trailing-newline handling included).
- diffcore.py: port of diffcore-delta.c (spanhash similarity) and
diffcore-rename.c (exact, basename-driven, and inexact NxM matrix
matching with git's exact float scoring).
- mergeort.py: port of merge-ort.c — recursive three-way tree walk
(collect_merge_info), file and directory rename detection/resolution
(process_renames, get_provisional_directory_renames,
apply_directory_rename_modifications), per-path resolution
(process_entry), and streamed result-tree assembly with conflicted
index stages.
ort.py becomes a thin adapter (OrtResult API unchanged); the merge_base/
ours/theirs arguments double as conflict-marker labels exactly as the
corresponding `git merge-tree --merge-base` arguments do.
sequencer._apply_patch drops its fallback path; now-dead rename/blob-merge
helpers are removed.
Validation (vs real git 2.44): ~3.7k randomized blob merges vs
`git merge-file --diff-algorithm=histogram` and ~2k randomized whole-tree
merges vs `git merge-tree --write-tree -z`, all byte-for-byte identical;
plus tests/test_ort_parity.py covering every conflict type. Single merge
base only — recursive/virtual-ancestor merge and full submodule
fast-forward resolution are out of scope.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0 commit comments