GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — diff: write a one-line add or delete range as a single number by jayhemnani9910 · Pull Request #308 · uutils/diffutils

Conversation

@jayhemnani9910

@jayhemnani9910 jayhemnani9910 commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

In the normal format a single added or deleted line still comes out as a range:

$ printf 'a\n' > x; printf 'a\nb\n' > y
$ diffutils diff x y
1a2,2
> b
$ diffutils diff y x
2,2d1
< b
$ /usr/bin/diff x y    # GNU diff 3.12
1a2
> b

GNU diff writes 1a2 and 2d1. -e has the same thing: 2,2d instead of 2d. #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)) and ed_diff.rs ((1, 0)).

Tests: test_single_line_added_or_deleted (normal) and test_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 to patch and ed. cargo fmt --check is clean, and cargo clippy --all-targets gives the same warnings as on main. I also compared the default and -e output 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. -e still 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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Copilot AI balanced review requested due to automatic review settings October 20, 2026 05:56
Copilot AI reviewed Oct 20, 2026

Copilot AI left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
sylvestre
sylvestre reviewed Oct 20, 2026
View reviewed changes
Comment thread src/normal_diff.rs
let actual_count = result.actual.len();
match (expected_count, actual_count) {
(0, 0) => unreachable!(),
(0, 1) => writeln!(

@sylvestre sylvestre Oct 20, 2026

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@jayhemnani9910 jayhemnani9910 Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran it: the full upstream suite gives the same result on main and on this branch (7 passed, 22 failed, 4 skipped, no test changes). basic fails on both at diff -9999999999999999999999999999 a b, before the range output. Details in the comment below.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@jayhemnani9910

jayhemnani9910 commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

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. basic fails on both because of its -999999999999999999999999999999 option case, before it gets to the range output.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jayhemnani9910

jayhemnani9910 commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

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. basic fails on both at diff -9999999999999999999999999999 a b (unrecognized option), before it reaches anything this changes.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sylvestre
sylvestre force-pushed the single-line-add-delete branch from fc2b385 to a7a66e7 Compare October 24, 2026 13:00
Copilot AI balanced review requested due to automatic review settings October 24, 2026 13:00
Copilot AI reviewed Oct 24, 2026

Copilot AI left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@sylvestre sylvestre mentioned this pull request Oct 24, 2026
diff: print single-line ranges as one number in normal format #315
Closed
@jayhemnani9910 jayhemnani9910 mentioned this pull request Oct 26, 2026
diff -e: no script at all when a file has no newline at the end #332
Open
sylvestre
sylvestre reviewed Nov 2, 2026
View reviewed changes
Comment thread tests/by-util/test_diff.rs Outdated
.stdout("2d1\n< east\n4a4,5\n> up\n> down\n");

let mut cmd = cargo_bin_cmd!("diffutils");
cmd.arg("diff").arg("/dev/null").arg(&old);

@sylvestre sylvestre Nov 2, 2026

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one is a multi-line add, not a single-line range
maybe use an empty temp file instead of /dev/null? no need for the cfg!(unix) then

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@jayhemnani9910 jayhemnani9910 Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, it now compares an empty temp file with a one-line file, so the range is a real single-line 0a1, and the cfg!(unix) is gone. It prints 0a1,1 without the fix and matches GNU diff with it.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Copilot AI balanced review requested due to automatic review settings November 2, 2026 18:17
Copilot AI reviewed Nov 2, 2026

Copilot AI left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@jayhemnani9910
diff: test a single-line add with an empty file
ec0e875
@jayhemnani9910

jayhemnani9910 commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Rebased. The fix itself is already on main as 42b8ec0, so only the test change you asked for is left here.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jayhemnani9910
jayhemnani9910 force-pushed the single-line-add-delete branch from b88ab9c to ec0e875 Compare November 3, 2026 13:53
Copilot AI balanced review requested due to automatic review settings November 3, 2026 13:53
Copilot AI reviewed Nov 3, 2026

Copilot AI left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@sylvestre
sylvestre merged commit fd4147e into uutils:main Nov 7, 2026
31 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@sylvestre

sylvestre commented Nov 7, 2026

Copy link
Copy Markdown
Collaborator

Thanks for your PR

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@sylvestre sylvestre sylvestre left review comments
Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@jayhemnani9910 @sylvestre
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.