Skip to content

diff: write the ed script when a file lacks its final newline - #429

Open
Xnadir wants to merge 1 commit into
uutils:mainfrom
Xnadir:fix/ed-missing-newline
Open

Xnadir wants to merge 1 commit into
uutils:mainfrom
Xnadir:fix/ed-missing-newline

Conversation

@Xnadir

@Xnadir Xnadir commented Nov 20, 2026

Copy link
Copy Markdown

Closes #332.

diff -e printed only "No newline at end of file" when either file's last line had no newline, so a caller that applies or shows the script got nothing. GNU diff compares that last line as if it had its newline, writes the script, then warns on stderr (diff: FILE: No newline at end of file, then a blank line) for each such file and exits 2. This does the same, including with -q.

ed_diff::diff can no longer fail, so it now returns the script directly, and the fuzz target is updated to match. The new cases in tests/by-util/test_diff.rs match the output of GNU diff 3.12 and fail without the change.

This change was written with the help of an AI assistant (Claude); I reviewed and tested it.

🤖 Generated with Claude Code

`diff -e` printed nothing but "No newline at end of file" when either
file's last line had no newline. Like GNU diff, compare that line as if
it had its newline, write the script, then warn about each such file on
stderr and exit 2.

Closes uutils#332

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 20, 2026 14:33

Copilot AI left a comment

Copy link
Copy Markdown

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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

diff -e: no script at all when a file has no newline at the end

2 participants