[PATCH] patch patch

Rob Landley rob at landley.net
Mon Aug 15 01:41:14 UTC 2011


Commit 8027a202a89b31b, from me, was broken.  I'm an idiot sometimes.

Patch needs to be able to create new files.  It's got some header magic
to indicate a file didn't used ot exist (either a name /dev/null or a
file date around "The epoch" I.E. unix time zero).

But _within_ the new file, it's got one big hunk with no leading or
trailing context lines.  The logic of this boils down to modifying an
empty file where it needs to match the start of the file _and_ the end
of the file.  The test for matching the end of the file is "less
trailing context lines than leading context lines".  (Same amount before
and after is a normal interstitial hunk.)

Except zero leading context lines means you can't have LESS than that at
the end, meaning zero is a special case.

Add zero as a special case, restoring patch's ability to create files.

We didn't have a test case for this?  Nobody noticed since November of
last year?

Sigh.  Fix attached,  Blah blah blah signed-of-by me.  It's one line and
two unrelated whitespace fixes to make it consistent with the rest of
the file.

Rob
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.patch
Type: text/x-patch
Size: 1159 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20110814/389b0074/attachment.bin>


More information about the busybox mailing list