Page MenuHomeFreeBSD

patch: fix pch_context() for unified diffs with no leading context
ClosedPublic

Authored by kevans on Aug 8 2025, 11:26 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Oct 11, 5:06 AM
Unknown Object (File)
Sat, Oct 11, 5:06 AM
Unknown Object (File)
Sat, Oct 11, 5:06 AM
Unknown Object (File)
Fri, Oct 10, 9:53 PM
Unknown Object (File)
Sat, Sep 20, 6:06 AM
Unknown Object (File)
Sep 17 2025, 7:59 AM
Unknown Object (File)
Sep 16 2025, 8:26 PM
Unknown Object (File)
Sep 15 2025, 9:40 PM
Subscribers

Details

Summary

When the first line of a file is a removal, we may not have any leading
context. Only adjusting p_context if context > 0 means that we
incorrectly believe that we have 100 lines of context when the reality
is that we have none.

This fixes a bug with fuzz-checking, which ends up fuzzing away the line
we're trying to replace if it's the first line in the file. We use
pch_context() to determine a reasonable max-fuzz.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

This revision is now accepted and ready to land.Aug 8 2025, 11:34 PM

FWIW, just about the best test one can make for a significant patch change is to have an exp-run over the ports tree.

In D51837#1194076, @pfg wrote:

FWIW, just about the best test one can make for a significant patch change is to have an exp-run over the ports tree.

Yeah, I noted in the thread the report came from that I'd exp-run it when I get back to this. My fear was having to fix a bunch of potentially dodgey patches because nobody really checks these things as long as patch(1) succeeds (based on past experience), but I bet the problem isn't actually as bad as I might think.