Commit graph

11 commits

Author SHA1 Message Date
Kyle Evans
fb37e38fbe Revert "patch: fix pch_context() for unified diffs with no leading context"
This reverts commit f97b6a8f84, as it
turns out our fuzz implementation is just too naive.  We can have more
leading context than trailing context and vice-versa, so we can't really
assume they're the same.

Restore the previous bug and we can work on it post-branch.

Reported by:	cy
2025-08-30 17:02:35 -05:00
Kyle Evans
cc36624b2a patch: test for unified diffs with spaces in filenames
The older GNU patch that we had in base did not properly handle spaces
in filenames in unified diffs, but bsdpatch seems to have handled this
fine at least since the version we imported into base initially.  Add a
test with spaces in the filename specifically to be sure.

PR:		181272
2025-08-29 14:24:35 -05:00
Kyle Evans
f97b6a8f84 patch: fix pch_context() for unified diffs with no leading context
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.

PR:		250511
Reviewed by:	pfg
Differential Revision:	https://reviews.freebsd.org/D51837
2025-08-29 14:24:35 -05:00
Simon J. Gerraty
a64729f507 Update Makefile.depend files
After building packages we have a number of new
and updated Makefile.depend files

Reviewed by:	stevek
2024-10-14 10:26:17 -07:00
Warner Losh
e9ac41698b Remove residual blank line at start of Makefile
This is a residual of the $FreeBSD$ removal.

MFC After: 3 days (though I'll just run the command on the branches)
Sponsored by: Netflix
2024-07-15 16:43:39 -06:00
Dag-Erling Smørgrav
851a9da38f patch: Support long context lines.
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D43850
2024-02-12 19:26:13 +01:00
Warner Losh
d0b2dbfa0e Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:55:03 -06:00
Warner Losh
4d846d260e spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix
2023-05-12 10:44:03 -06:00
Kyle Evans
50dacbf6c2 patch(1): give /dev/null patches special treatment
We have a bad habit of duplicating contents of files that are sourced from
/dev/null and applied more than once... take the more sane (in most ways)
GNU route and complain if the file exists and offer reversal options.

This still falls short a little bit as selecting "don't reverse, apply
anyway" will still give you duplicated file contents. There's probably other
issues as well, but awareness is the first step to happiness.

MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D21535
2019-11-04 03:07:01 +00:00
Kyle Evans
89b5571e0b patch(1): fix the file removal test, strengthen it a bit
To remain compatible with GNU patch, we should ensure that once we're
removing empty files after a reversed /dev/null patch we don't remove files
that have been modified. GNU patch leaves these intact and just reverses the
hunk that created the file, effectively implying --remove-empty-files for
reversed /dev/null patches.
2019-09-05 15:35:57 +00:00
Kyle Evans
b27524973c patch(1): add some basic tests
Summary:
- basic: test application of patches created by diff -u at the
  beginning/middle/end of file, which have differing amounts of context
  before and after chunks being added
- limited_ctx: stems from PR 74127 in which a rogue line was getting added
  when the patch should have been rejected. Similar behavior was
  reproducible with larger contexts near the beginning/end of a file. See
  r326084 for details
- file_creation: patch sourced from /dev/null should create the file
- file_nodupe: said patch sourced from /dev/null shouldn't dupe the contents
  when re-applied (personal vendetta, WIP, see comment)
- file_removal: this follows from nodupe; the reverse of a patch sourced
  from /dev/null is most naturally deleting the file, as is expected based
  on GNU patch behavior (WIP)
2019-09-05 03:16:14 +00:00