Repository navigation
WIP: sdiff -o exit status (#1441), diff/sdiff -I as BRE (#1449), tac -r empty-matching separator (#1447) - #1451
Merged
Merged
Conversation
caomengxuan666
marked this pull request as ready for review
October 30, 2026 05:51
This was referenced Oct 30, 2026
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.
Three small GNU-compat fixes for the diff family and tac, one commit each. Draft for CI adjudication — the main session closes the issues after verification.
#1441 — sdiff
-oexit status (commit 1)The
-opath unconditionally returned 0 after a completed merge, and the unit testsdiff_output_file_auto_merges_non_interactivelypinned 0 under a wrong "like GNU's completed interactive merge" comment. GNU diffutils 3.10: merging two different files exits 1 (paired, insertion-only, and deletion-only differences alike); identical inputs exit 0; trouble stays 2. The merge now reports the subsidiary diff's verdict — 1 exactly when the final edit script (after any-B/-Ihunks are dropped) still holds a non-KEEP edit. The named test's expectation and comment are corrected, as are the two sibling-otests that pinned the same wrong 0 (takes_right_for_right_only_changes,keeps_left_for_conflicting_rows), plus a new identical-inputs-opin for the 0 face. Corpus whitelist entries for cases 18/19 are updated: the exit-status divergence is gone, only the interactive%prompt divergence (by design, #1127 P1) remains.#1449 — diff/sdiff
-Iis a regular expression (commit 2)make_blank_or_matching_predicatematched the-Iargument as a literal substring (std::string::find), so any pattern with metacharacters silently failed to ignore hunks. GNU compiles each-IRE as a basic regular expression (oracle-verified:\+,\(...\),\|,\{n\}are the special forms; bare+(){}|are literal) and searches each changed line with it. The predicate now takes compiledportable_regexpatterns (the repo's shared engine,Syntax::Basic— the same choice diff already makes for--show-function-lineand tac makes for-r):-Bor matches at least one-IRE. This is GNU's per-line invisibility model; it also fixes two latent faces of the old all-blank-OR-all-match shape: a blank-only hunk is no longer dropped under-Ialone, and a mixed blank+matching hunk is now dropped under-B -I(both oracle-verified).-I/--ignore-matching-linesoptions accumulate (GNU semantics; previously only one value survived), in both diff and sdiff, collected viactx.string_occurrences(the house idiom used for-x/-X).diff: invalid regular expression '<pat>'and exit 2 (same message/exit the--show-function-linepath already uses; GNU exits 2 as well). In sdiff the compile happens after operand resolution, matching GNU sdiff's observable error order.filter_matching_lines(no callers) is converted to the same compiled patterns.Corpus case
corpus/sdiff/12-ignore-matching-lines.caseis expected to flip from EXIT_DIFF to PASS; its baseline entry is updated accordingly.#1447 — tac
-rempty-matching separator (commit 3)tac -r -s 'x*'errored out ("separator regex matches empty string") at the first zero-length match; GNU coreutils 9.4 accepts it. The regex splitter is rewritten to GNU's match model: separator matches are discovered right-to-left — at each step the match with the largest start in the not-yet-claimed prefix, longest at that start (this is what glibc's backwardre_searchin tac.c returns) — and records are the segments between consecutive match ends (default) or match starts (-b). Empty matches are ordinary separators under this model and cannot loop: each step strictly shrinks the unclaimed prefix. The model was verified byte-for-byte against the local GNU 9.4 oracle on 30+ pattern/input shapes (x*,.*,.+,..,b*,a*,[a-c]*,.*x,x.*, with and without-b), including every shape where the old forwardfind_allwalk and GNU disagree. The obsolete error string is removed with the error path; no user-visible strings are added or changed.Regression tests are added in the repo's unit-test style for all three issues, named with the issue numbers.
Refs #1441
Refs #1449
Refs #1447