<feed xmlns='http://www.w3.org/2005/Atom'>
<title>src/usr.bin/patch/pch.c, branch release/13.1.0</title>
<subtitle>FreeBSD source tree</subtitle>
<id>https://cgit-dev.freebsd.org/src/atom?h=release%2F13.1.0</id>
<link rel='self' href='https://cgit-dev.freebsd.org/src/atom?h=release%2F13.1.0'/>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/'/>
<updated>2020-08-16T23:55:23Z</updated>
<entry>
<title>Remove heuristic for dealing with trailing newlines being truncated by mailers.</title>
<updated>2020-08-16T23:55:23Z</updated>
<author>
<name>Warner Losh</name>
<email>imp@FreeBSD.org</email>
</author>
<published>2020-08-16T23:55:23Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=c7cddf955f7a643abe6f999632e005ad9d834885'/>
<id>urn:sha1:c7cddf955f7a643abe6f999632e005ad9d834885</id>
<content type='text'>
Every version of patch since the first one posted to mod.sources in 1985 have
included a heuristic for coping with the state of email messaging at the
time. This heuristic would add up to 4 blank lines to a patch if it thought it
needed it. The trouble is, though this causes at least one bug.

The bug in my case is that if you have a context diff whose last hunk only
deletes 3 or fewer lines, then if you try to reverse apply it with -R, it will
fail. The reason for this is the heuristic builds an internal representation
that includes those blank lines. However, it should really replicate the lines
from the pattern lines line it would any other time, not assume they are blank
lines. Removing this heuristic will prevent patch from misapplying the lines
removed after applying a 'fuzz' factor to the previous blank line in the file. I
believe this will only affect 'new-style' 4.3BSD context diffs and not the
older-style 4.2BSD diffs and plain, non-context diffs. It won't affect any of
the newer formats, since they don't use the 'omitted' construct in the same way.

Since this heuristic was put into patch at a time when email / etc ate trailing
white space on a regular basis, and since it's clear that this heuristic is the
wrong thing to do at least some of the time, it's better to remove it
entirely. It's not been needed for maybe 20 years since patch files are not
usually corrupted. If there are a small number of patch files that would benefit
from this corruption fixing, those already-currupt patches can be fixed by the
addition of blank lines. I'd wager that no one will ever come to me with an
example of a once-working patch file that breaks with this change. However, I
have 2 patches from the first 195 patches to 2.11BSD that are affected by this
bug, suggesting that the relative frequency of the issue has changed
signficantly since the original heuristic was put into place.

Reviewed by: phk@
Differential Revision: https://reviews.freebsd.org/D26081
</content>
</entry>
<entry>
<title>patch(1): give /dev/null patches special treatment</title>
<updated>2019-11-04T03:07:01Z</updated>
<author>
<name>Kyle Evans</name>
<email>kevans@FreeBSD.org</email>
</author>
<published>2019-11-04T03:07:01Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=50dacbf6c2a3d32f7e3f20ca98cda23f38817e7f'/>
<id>urn:sha1:50dacbf6c2a3d32f7e3f20ca98cda23f38817e7f</id>
<content type='text'>
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
</content>
</entry>
<entry>
<title>patch(1): Exit successfully if we're fed a 0-length patch</title>
<updated>2019-03-01T01:20:21Z</updated>
<author>
<name>Kyle Evans</name>
<email>kevans@FreeBSD.org</email>
</author>
<published>2019-03-01T01:20:21Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=ef30b5a80910bd877f582248004200065eeb3ef5'/>
<id>urn:sha1:ef30b5a80910bd877f582248004200065eeb3ef5</id>
<content type='text'>
This change is made in the name of GNU patch compatibility. If GNU patch is
fed a zero-length patch, it will exit successfully with no output. This is
used in at least one port to date (comms/wsjtx), and we break on this usage.

It seems unlikely that anyone relies on patch(1) calling their completely
empty patch garbage and failing, and GNU compatibility is a plus if it helps
with porting, so make the switch.

Reported by:	db
MFC after:	2 weeks
</content>
</entry>
<entry>
<title>patch: further cleanup to git-style diffs.</title>
<updated>2017-12-21T16:25:33Z</updated>
<author>
<name>Pedro F. Giffuni</name>
<email>pfg@FreeBSD.org</email>
</author>
<published>2017-12-21T16:25:33Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=76df519fe099c90ba2188cd1ca6846181b24b4b2'/>
<id>urn:sha1:76df519fe099c90ba2188cd1ca6846181b24b4b2</id>
<content type='text'>
Fix adding and removing files with git-style a/ b/ diffs: only skip
six letters if they actually match "--- a/" and "+++ b/" instead of
laxer checks.

Obtained from:	OpenBSD (CVS 1.59)
</content>
</entry>
<entry>
<title>patch(1): Don't overrun line buffer in some cases</title>
<updated>2017-10-09T14:50:02Z</updated>
<author>
<name>Kyle Evans</name>
<email>kevans@FreeBSD.org</email>
</author>
<published>2017-10-09T14:50:02Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=4835edfa0d452a9d75eeb73c3414d563ec9909f9'/>
<id>urn:sha1:4835edfa0d452a9d75eeb73c3414d563ec9909f9</id>
<content type='text'>
Patches like file.txt attached to PR 190195 with a final line formed
like "&gt;(EOL)" could cause a copy past the end of the current line buffer. In the
case of PR 191641, this caused a duplicate line to be copied into the resulting
file.

Instead of running past the end, treat it as if it were a blank line.

PR:		191641
Reviewed by:	cem, emaste, pfg
Approved by:	emaste (mentor)
Differential Revision:	https://reviews.freebsd.org/D12609
</content>
</entry>
<entry>
<title>patch(1): add support for git generated diffs.</title>
<updated>2017-07-02T21:00:30Z</updated>
<author>
<name>Pedro F. Giffuni</name>
<email>pfg@FreeBSD.org</email>
</author>
<published>2017-07-02T21:00:30Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=85823a601c1ede44a844edde4f1d18643903ce54'/>
<id>urn:sha1:85823a601c1ede44a844edde4f1d18643903ce54</id>
<content type='text'>
Sometimes patches coming from other places have extra a/ and b/
directories prepended to filenames.

Obtained from:	OpenBSD (CVS rev. 1.57, 1.58)
</content>
</entry>
<entry>
<title>patch: if reading fails, do not go into infinite loop asking for a filename.</title>
<updated>2017-06-08T03:15:08Z</updated>
<author>
<name>Pedro F. Giffuni</name>
<email>pfg@FreeBSD.org</email>
</author>
<published>2017-06-08T03:15:08Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=12300d3aa0168f532d29242ce9a47afb630a348c'/>
<id>urn:sha1:12300d3aa0168f532d29242ce9a47afb630a348c</id>
<content type='text'>
This can happen if no tty is available.

Obtained from:	OpenBSD (CVS rev 1.54)
MFC after:	5 days
</content>
</entry>
<entry>
<title>Revert r311106:</title>
<updated>2017-01-02T18:23:31Z</updated>
<author>
<name>Pedro F. Giffuni</name>
<email>pfg@FreeBSD.org</email>
</author>
<published>2017-01-02T18:23:31Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=4f548c1916e86995b61b678743c91d689bba8581'/>
<id>urn:sha1:4f548c1916e86995b61b678743c91d689bba8581</id>
<content type='text'>
patch(1): extend the maximum length of a line from USHRT_MAX to UINT_MAX.

This doesn't really work for 32 bit platforms.

Pointed out by:	kib
</content>
</entry>
<entry>
<title>patch(1): extend the maximum length of a line from USHRT_MAX to UINT_MAX.</title>
<updated>2017-01-02T17:12:14Z</updated>
<author>
<name>Pedro F. Giffuni</name>
<email>pfg@FreeBSD.org</email>
</author>
<published>2017-01-02T17:12:14Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=ad8469feec8a84469d38b4a1237fd39abea16198'/>
<id>urn:sha1:ad8469feec8a84469d38b4a1237fd39abea16198</id>
<content type='text'>
We can handle such "big data" without much trouble.
Try to do a better job at detecting the rejection cause while here.

MFC after:	2 weeks
</content>
</entry>
<entry>
<title>patch(1): avoid signed integer overflow when debugging.</title>
<updated>2016-04-24T04:08:36Z</updated>
<author>
<name>Pedro F. Giffuni</name>
<email>pfg@FreeBSD.org</email>
</author>
<published>2016-04-24T04:08:36Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=2c4eed4723c3a739b85102d1ff911f06fe826fbc'/>
<id>urn:sha1:2c4eed4723c3a739b85102d1ff911f06fe826fbc</id>
<content type='text'>
Integer i is used to index p_end of type LINENUM (actually long).

Match the types.

MFC after:	5 days
</content>
</entry>
</feed>
