Skip to content

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

Merged
sylvestre merged 1 commit into
uutils:mainfrom
Xnadir:fix/ed-missing-newline
Nov 21, 2026
Merged

sylvestre merged 1 commit into
uutils:mainfrom
Xnadir:fix/ed-missing-newline

Conversation

@Xnadir

@Xnadir Xnadir commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

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

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.

@sylvestre

Copy link
Copy Markdown
Collaborator

sorry but it needs to be rebased

`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 <noreply@anthropic.com>
@Xnadir
Xnadir force-pushed the fix/ed-missing-newline branch from 5d797b3 to 49fde05 Compare November 21, 2026 13:19
Copilot AI balanced review requested due to automatic review settings November 21, 2026 13:19

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.

@sylvestre
sylvestre merged commit 5a933d7 into uutils:main Nov 21, 2026
31 checks passed
@sylvestre

Copy link
Copy Markdown
Collaborator

Thanks for your PR

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

3 participants