Repository navigation
feat(diff3,sdiff): GNU diffutils 3.10 alignment on the shared diff engine (issue #1127 P1) - #1164
Merged
Merged
Conversation
…gine (issue #1127 P1) - diff3: rebuild on a real three-way merge (diff3.c make_3way_diff): default report with GNU's odd-one-out section rules and skew order, ed scripts for -A/-e/-E/-3/-x/-X with -i final write and dot-doubling, -m merged output (-m alone implies -A; -L labels, -T initial tab, --strip-trailing-cr, --diff-program with GNU's read_diff argv), '-' stdin operands with the common-file swap, and GNU exit statuses (0 ok / 1 conflicts / 2 trouble) plus byte-verified usage diagnostics. - sdiff: display is exactly diff --side-by-side (side.c gutter formula, |/<>/(/) markers, //\ separators for missing trailing newlines, common rows for equal inputs); -l/-s, -w/--tabsize/-t display control; ignore family forwarded into matching only with GNU semantics (-E full tab expansion, -b trailing-run drop, -Z isspace strip, -B/-I drop ignored hunks and realign positionally); -o writes an auto-merged file non-interactively (overlaps keep the left column), the documented deviation from GNU's interactive prompt (issue #1127). - diff: adopts the shared engine header (diff_engine.h); side-by-side gains GNU's row rules; -E/-B/-I match GNU semantics; the incomplete last line only compares equal to the other side's incomplete last line. - tests: diff3/sdiff suites rewritten byte-exact against GNU diffutils 3.10 (WSL oracle, 92-case harness); differential case 30 whitelisted for the -o auto-merge deviation; zh-CN catalog synced (i18n 0.6.18).
1 of 12 tasks
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.
Closes the P1 item of #1127 (partial: P1 only — diff3/sdiff GNU alignment; P2+ untouched).
What
diff3 — rebuilt on a faithful port of GNU diffutils' three-way merge (
diff3.c make_3way_diff/using_to_diff3_block):====N, content suppression for the odd file, skew order 1→3→2), adjacent-hunk folding and====conflict blocks-A/--show-all,-e/--ed,-E/--show-overlap,-3/--easy-only,-x/--overlap-only,-Xwith GNU's block-selection rules,<<<<<<</|||||||/=======/>>>>>>>bracketing, leading-dot doubling and-ifinalw/q-m/--merge(bare-mimplies-A),-L/--label(up to 3),-T/--initial-tab,-a/--text,--strip-trailing-cr,--diff-program(spawns PROGRAM with GNU's exactread_diffargv and parses its normal output)-stdin operands with GNU's common-file swap, GNU exit statuses (0 ok / 1 conflicts / 2 trouble) and byte-verified usage diagnostics (incompatible options,missing operand after '<last arg>',subsidiary program 'diff' failed)sdiff — the display is now exactly
diff --side-by-sideoutput (GNU sdiff execs diff for it):side.csemantics: gutter formula,|/</>/(/)row markers,/and\separators when a row's sides disagree on the trailing newline, common rows for equal inputs-l/--left-column,-s/--suppress-common-lines,-w/--width,-t/--expand-tabs,--tabsize-i,-E(full tab expansion),-Z(isspace line-end strip),-b(runs collapse, trailing run dropped),-W,-B/-I(ignored hunks drop from the script and their lines realign positionally),-a,--strip-trailing-cr,-d,-H,--diff-program-o/--outputwrites a merged file non-interactively (per the P1 item's 自动合并 requirement): one-sided changes take their only side, overlapping rows keep the left column; a completed merge exits 0 like GNU's completed interactive mergediff — adopts the shared engine header (
diff_engine.h): side-by-side gains GNU's row rules,-E/-B/-Imatch GNU semantics, and a final line without a newline only compares equal to the other side's incomplete last line (GNUio.cequivalence classes).Verification
-T,--strip-trailing-cr,-stdin,--diff-program, usage/compat errors) and every sdiff surface (widths 20/30/40/80/130,-l/-s, tabs/--tabsize/-t, long-line truncation, the whole ignore family,/+\no-newline rows,-omerges, missing operands). The only 5 diffs are-ocases where GNU's interactive%prompt/EOF-quit differs from this PR's auto-merge — the documented deviation requested by the issue.origin/mainbuild).regressions/30-sdiff-output-file.casewhitelisted with the-odeviation reason;corpus/sdiff/01display stays byte-identical.unixwin/winuxcmd-i18n(zh-CN) and released as 0.6.18.Notes