Repository navigation
diff: write a one-line add or delete range as a single number - #308
jayhemnani9910 wants to merge 1 commit into
Conversation
The normal format printed a single added or deleted line as a range, "1a2,2" and "2,2d1", where GNU diff and POSIX write "1a2" and "2d1", and -e printed "2,2d" for "2d". Changed lines already had this (see uutils#10); do the same for added and deleted ones.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
| let actual_count = result.actual.len(); | ||
| match (expected_count, actual_count) { | ||
| (0, 0) => unreachable!(), | ||
| (0, 1) => writeln!( |
There was a problem hiding this comment.
could you please run the upstream test suite on it?
TESTS=basic ./tests/run-upstream-testsuite.sh
the whole suite would be even better, it would tell us if it makes more tests pass
|
Ran the whole upstream suite on main (0019867) and on this branch: same on both, 7 pass, 22 fail, 4 skip, and no test changes its result. |
|
Ran the full upstream suite (release builds) on main and on this branch: 7 passed, 22 failed, 4 skipped on both, and every test has the same result. |
In the normal format a single added or deleted line still comes out as a range:
GNU diff writes
1a2and2d1.-ehas the same thing:2,2dinstead of2d. #11 (for #10) fixed this for changed lines (1c1); added and deleted lines were left out.This adds the one-line cases next to the existing ones in
normal_diff.rs((0, 1)and(1, 0)) anded_diff.rs((1, 0)).Tests:
test_single_line_added_or_deleted(normal) andtest_single_line_deleted(ed) check the exact output. Both fail on main.cargo test: all pass (285 on main, 289 here; the two new tests run in both the lib and the bin target), including the permutation tests that feed the output topatchanded.cargo fmt --checkis clean, andcargo clippy --all-targetsgives the same warnings as on main. I also compared the default and-eoutput with GNU diff 3.12 over 22 file pairs (single-line and multi-line adds and deletes, blank lines, missing newlines, empty files): the default format matches for all of them now except binary files.-estill writes its hunks top-down with already-shifted line numbers where GNU goes bottom-up; both scripts give the same file, so I left that alone.