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: report both files when -N is given and neither exists by sarankumar1325 · Pull Request #365 · uutils/diffutils

Conversation

@sarankumar1325

@sarankumar1325 sarankumar1325 commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Fixes #360

-N/--new-file (and --unidirectional-new-file for the first operand) turned every missing operand into an empty file without looking at the other operand. So diff -N missing1 missing2 compared two empty files, printed nothing and exited 0, and a typo in both paths went unnoticed.

GNU diff only treats a missing top-level operand as empty when the other one exists. compare_files now reads both operands first, and if both are missing it reports both errors and returns trouble (exit 2), like GNU:

$ diff -N missing1 missing2
diff: missing1: No such file or directory
diff: missing2: No such file or directory
$ echo $?
2

When only one operand is missing, the behaviour is the same as before.

Test: new_file_both_missing_is_an_error in tests/by-util/test_diff.rs covers -N, --new-file and --unidirectional-new-file. It fails on main and passes with this change. cargo test --test tests passes (43 tests), and cargo fmt --check and cargo clippy -- -D warnings are clean. The 16 *_permutations lib tests fail on my machine on main too, so that failure isn't caused by this change.

I used an AI assistant to write this change. I reviewed and tested it myself.

Sorry, something went wrong.

Uh oh!

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

All reactions
@sarankumar1325
diff: report both files when -N is given and neither exists
6489ef2
-N and --unidirectional-new-file turned every missing operand into an
empty file, so two missing files compared as identical and diff exited
0. Like GNU diff, a missing operand is now only treated as empty when
the other one exists; otherwise both errors are reported and diff
exits 2.

Fixes uutils#360
Copilot AI balanced review requested due to automatic review settings November 9, 2026 14:23
Copilot AI reviewed Nov 9, 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
@sarankumar1325
diff: match the Windows error text in the -N both-missing test
3126c03
Windows reports a missing file as "The system cannot find the file
specified.", so pick the expected message per platform, as
cannot_read_files in test_common.rs already does.
Copilot AI balanced review requested due to automatic review settings November 9, 2026 14:52
Copilot AI reviewed Nov 9, 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 reviewed Nov 9, 2026
View reviewed changes
Comment thread tests/by-util/test_diff.rs
let missing1 = tmp_dir.path().join("missing1");
let missing2 = tmp_dir.path().join("missing2");

#[cfg(not(windows))]

@sylvestre sylvestre Nov 9, 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.

please squash the windows fixup commit into the first one :)

Sorry, something went wrong.

Uh oh!

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

All reactions
@sarankumar1325
Merge branch 'main' of https://github.com/uutils/diffutils into fix/n…
f4dbdde
…ew-file-both-missing

Signed-off-by: sarankumar1325 <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 11, 2026 03:17
Copilot AI reviewed Nov 11, 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
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.

diff - -N exits 0 when neither file exists

Uh oh!

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

3 participants

@sarankumar1325 @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 01402520 — 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.