How to apply an svn diff

Scot Hetzel swhetzel at
Wed Jan 9 07:06:48 UTC 2013

On Tue, Jan 8, 2013 at 5:32 PM, Stephen Montgomery-Smith
<stephen at> wrote:
> While we are on the subject of patch, has anyone else noticed the
> following annoyance?
> Suppose you create a patch against a non-existent file (using diff
> - -N), and let's suppose the old file is dir-orig/xxx, and the new file
> is dir/xxx.
> Then if I apply the patch to dir, and dir-orig doesn't exist, then
> patch issues all kinds of horrible error messages, and the new file is
> installed in the current directory rather than dir.
> I'm not sure if it is a bug or a feature.  But it has bitten me more
> than once.
According to the man page for patch(1):

"not specifying -p at all just gives you "blurfl.c", unless all of the
directories in the leading path (u/howard/src/blurfl) exist and that
path is relative, in which case you get the entire  pathname

So to have patch put the new files in the correct locations use:

patch -E -p0 < patchfile

Note: -E removes empty files.


No electrons were maimed while sending this message. Only slightly bruised.

More information about the freebsd-ports mailing list