Repository navigation
WIP: feat(diff): diff3/sdiff GNU alignment (#1127 P1) - #1459
Merged
Merged
Conversation
…sections, stripped-CR display - sdiff -o now runs GNU's interactive merge (sdiff.c edit loop): per-hunk display, '%' prompts, l/r choices, s/v display toggles, the e* family, q -> exit 2 with the output file partial. EOF at a prompt keeps the recorded #1127 P1 auto-merge fallback (completed-merge verdict), preserving the unit-test contract. - Side-by-side rendering and merging now walk positional sections over the raw script (new diff_engine SdiffSection renderer): -B/-I-ignored hunks rejoin the common spans and pair positionally ('('/ ')' rows), matching GNU analyze.c + side.c - the old drop_ignored_hunks realignment lost one-sided common rows. - --strip-trailing-cr now strips the display lines too (GNU strips on input in io.c); the merged output still copies the raw lines. - Goldens: sdiff corpus 21-29 (quit/help/toggles/right/delete/ insert/-B pairing/strip-CR merge) + diff3 27 (-A with -L labels); unit tests for the interactive r / q / invalid-command paths.
…ported by MSVC's std module)
…list收尾 - corpus/sdiff/22 OUT_DIFF root cause: GNU sdiff's give_help text starts directly with 'ed:' (verified byte-exact with od against diffutils 3.10); drop the spurious leading newline from kInteractHelp and from the unit expectation. - baseline.json: corpus/sdiff 11/15/18/19 flip KNOWN_DIFF -> PASS (CI run 41166929035 adjudicated), entries added for the ten new wave cases (diff3/27, sdiff/21-29), all PASS. - whitelist.txt: remove the five entries whose divergences are fixed (regressions/30, corpus/sdiff 11/15/18/19).
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.
Refs #1127 (P1 wave only — the plan issue stays open for P2–P5).
diff 家族收尾波:sdiff 的四个 KNOWN_DIFF 全部按 GNU diffutils 3.10 逐字节对齐,diff3 补 -A -L 标签金标。
sdiff -o 交互合并(原自动合并与 GNU 在
%提示上分歧,corpus 18/19 + regressions/30 因此挂 whitelist):%提示、l/r 选边、s/v 通行行展示开关、e* 家族($EDITOR,未设时 "ed",含ed的 --- / +++ 装饰头)、q → 退出码 2 且输出文件保留已合并前缀;非法命令把帮助文本打到 stderr 并重问。定位分节渲染(corpus 11 的根因):-B/-I 忽略的 hunk 不再走 drop_ignored_hunks 的 1:1 重配对(会吞掉单侧 common 行,如 f1=x/空/y/A vs f2=x/y/B 中 y 的
(行),改为在 diff_engine 新增 SdiffSection 定位渲染器:common 跨度按两文件各自原始行界位置配对(/)/(行),与 GNU analyze.c + side.c 一致。sdiff 的显示与 -o 合并共用同一分节行走。--strip-trailing-cr(corpus 15):GNU 在 io.c 读入时即剥 CR,显示行同步剥除(原实现仅比较时剥);合并输出仍逐行复制原始字节(GNU 的 line filter 直读原文件),corpus 29 钉住这一不对称。
diff3:实现已完备(前波落地),本波只补金标 27(-A + -L 标签的 ed 脚本冲突标记形状),其余 P1 选项与既有 26 例一一对应。
测试:新增 corpus 金标 sdiff 21–29、diff3 27;单元测试补交互 r/q/非法命令三例(tests/unit/sdiff)。baseline.json 已按 CI 裁定更新(11/15/18/19 翻 PASS、十条新例登记 PASS),whitelist 五条失效条目(regressions/30 + corpus/sdiff 11/15/18/19)已摘除。
CI 裁定(HEAD 0cb1d38):构建 CI run 41169462203 双架构全绿(含 ctest);差分 run 41169462185 的 oracle/compare 全绿、baseline 中 diff 家族 57 例全 PASS——全语料唯一红点是 regressions/70-env-ignore-environment-child-block(main 上既存的常设噪声,与本 PR 无关)。中途 case 22 曾 OUT_DIFF:GNU give_help 文本并无前导换行(od 逐字节核对),已随 0cb1d38 修正。
i18n:本波未改动任何用户可见字符串(--help/选项文案未动),无 catalog 影响。sdiff.cpp 头注释已按新语义订正(非用户可见)。