Attmpt to work around patches missing "No newline at end of file" markers.
Review Request #14175 — Created Sept. 19, 2024 and updated
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.