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
F163159109: D51837.id.diff
Mon, Jul 20, 3:18 PM
F163147556: D51837.id161206.diff
Mon, Jul 20, 12:53 PM
Unknown Object (File)
Tue, Jul 14, 5:12 PM
Unknown Object (File)
Mon, Jul 13, 12:27 PM
Unknown Object (File)
Sun, Jul 12, 12:48 AM
Unknown Object (File)
Sun, Jul 5, 9:17 PM
Unknown Object (File)
Thu, Jul 2, 2:19 AM
Unknown Object (File)
Thu, Jul 2, 2:19 AM
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.