Attempt to work around patches missing "No newline at end of file" markers.

Review Request #14175 — Created Sept. 19, 2024 and submitted

Information

Review Board
release-7.x

Reviewers

Some old (but still widely in use) versions of GNU diff have a bug where
they may at times fail to generate a \ No newline at end of file
marker for files that lack a trailing newline. Modern GNU Patch does not
work around this case, and fails with an error.

We now attempt to work around this issue. If a patch fails to apply, we
begin to investigate the diff. If it lacks a trailing newline, and we
don't see this marker anywhere in the diff, we will attempt to add a
newline and patch again.

This is not always guaranteed to work. It's a best-effort attempt at
working around a problem with how the diff is generated. We never hit it
unless we've already failed to patch, though.

Unit tests pass.

Summary ID
Attmpt to work around patches missing "No newline at end of file" markers.
Some old (but still widely in use) versions of GNU diff have a bug where they may at times fail to generate a ``\ No newline at end of file` marker for files that lack a trailing newline. Modern GNU Patch does not work around this case, and fails with an error. We now attempt to work around this issue. If a patch fails to apply, we begin to investigate the diff. If it lacks a trailing newline, and we don't see this marker anywhere in the diff, we will attempt to add a newline and patch again. This is not always guaranteed to work. It's a best-effort attempt at working around a problem with how the diff is generated. We never hit it unless we've already failed to patch, though.
41e6b3e0b624318580e1e465b1e649b3e27d74f3
Description From Last Updated

Typo in summary: Attmpt -> Attempt

daviddavid

Typo in description around "No newline at end of file"

daviddavid
maubin
  1. Ship It!
  2. 
      
david
  1. 
      
  2. Show all issues

    Typo in summary: Attmpt -> Attempt

  3. Show all issues

    Typo in description around "No newline at end of file"

  4. 
      
chipx86
david
  1. Ship It!
  2. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to release-7.x (4d9b850)