$ tree -f -a .
.
|-- ./Foo
| `-- ./Foo/one.txt
|-- ./Foo-new
| |-- ./Foo-new/one.txt
| `-- ./Foo-new/two.txt
`-- ./Foo-old
`-- ./Foo-old/one.txt
3 directories, 4 files
####
$ cat Foo-new.patch
diff -Npurd Foo-old/one.txt Foo-new/one.txt
--- Foo-old/one.txt 2012-08-16 08:21:35.609375000 -0700
+++ Foo-new/one.txt 2012-08-16 08:19:45.859375000 -0700
@@ -1 +1 @@
-hi there
+hello there
diff -Npurd Foo-old/two.txt Foo-new/two.txt
--- Foo-old/two.txt 1969-12-31 16:00:00.000000000 -0800
+++ Foo-new/two.txt 2012-08-16 08:19:25.500000000 -0700
@@ -0,0 +1 @@
+new file
####
$ cd Foo
$ patch -p1 -i../Foo-new.patch
patching file one.txt
patching file two.txt
####
$ patch -p0 -i../Foo-new.patch
can't find file to patch at input line 4
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -Npurd Foo-old/one.txt Foo-new/one.txt
|--- Foo-old/one.txt 2012-08-16 08:21:35.609375000 -0700
|+++ Foo-new/one.txt 2012-08-16 08:19:45.859375000 -0700
--------------------------
File to patch:
Skip this patch? [y]
Skipping patch.
1 out of 1 hunk ignored
patching file Foo-old/two.txt
$ tree -f -a .
.
|-- ./Foo-old
| `-- ./Foo-old/two.txt
`-- ./one.txt
1 directory, 2 files
####
diff -Npurd emptyDir tmpFoo > tmpFoo.patch
####
diff -Npurd emptyDir/Foo/one.txt tmpFoo/Foo/one.txt
--- emptyDir/Foo/one.txt 1969-12-31 16:00:00.000000000 -0800
+++ tmpFoo/Foo/one.txt 2012-08-16 08:21:35.609375000 -0700
@@ -0,0 +1 @@
+hi there
diff -Npurd emptyDir/Foo-new/one.txt tmpFoo/Foo-new/one.txt
--- emptyDir/Foo-new/one.txt 1969-12-31 16:00:00.000000000 -0800
+++ tmpFoo/Foo-new/one.txt 2012-08-16 08:19:45.859375000 -0700
@@ -0,0 +1 @@
+hello there
diff -Npurd emptyDir/Foo-new/two.txt tmpFoo/Foo-new/two.txt
--- emptyDir/Foo-new/two.txt 1969-12-31 16:00:00.000000000 -0800
+++ tmpFoo/Foo-new/two.txt 2012-08-16 08:19:25.500000000 -0700
@@ -0,0 +1 @@
+new file
diff -Npurd emptyDir/Foo-old/one.txt tmpFoo/Foo-old/one.txt
--- emptyDir/Foo-old/one.txt 1969-12-31 16:00:00.000000000 -0800
+++ tmpFoo/Foo-old/one.txt 2012-08-16 08:21:35.609375000 -0700
@@ -0,0 +1 @@
+hi there
####
$ cd tmp2Foo
$ patch -i ../tmpFoo.patch
The next patch would create the file one.txt,
which already exists! Assume -R? [n]
Apply anyway? [n]
Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file one.txt.rej
The next patch would create the file one.txt,
which already exists! Assume -R? [n]
Apply anyway? [n]
Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file one.txt.rej
The next patch would create the file two.txt,
which already exists! Assume -R? [n]
Apply anyway? [n]
Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file two.txt.rej
The next patch would create the file one.txt,
which already exists! Assume -R? [n]
Apply anyway? [n]
Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file one.txt.rej
$ tree -f -a .
.
|-- ./one.txt
|-- ./one.txt.rej
|-- ./two.txt
`-- ./two.txt.rej
0 directories, 4 files
####
$ patch -p1 -i ../tmpFoo.patch
patching file Foo/one.txt
patching file Foo-new/one.txt
patching file Foo-new/two.txt
patching file Foo-old/one.txt
$ tree -f -a .
.
|-- ./Foo
| `-- ./Foo/one.txt
|-- ./Foo-new
| |-- ./Foo-new/one.txt
| `-- ./Foo-new/two.txt
`-- ./Foo-old
`-- ./Foo-old/one.txt
3 directories, 4 files
####
$ patch -p0 -i ../tmpFoo.patch
patching file tmpFoo/Foo/one.txt
patching file tmpFoo/Foo-new/one.txt
patching file tmpFoo/Foo-new/two.txt
patching file tmpFoo/Foo-old/one.txt
$ tree -f -a
.
|-- ./Foo
| `-- ./Foo/one.txt
|-- ./Foo-new
| |-- ./Foo-new/one.txt
| `-- ./Foo-new/two.txt
|-- ./Foo-old
| `-- ./Foo-old/one.txt
`-- ./tmpFoo
|-- ./tmpFoo/Foo
| `-- ./tmpFoo/Foo/one.txt
|-- ./tmpFoo/Foo-new
| |-- ./tmpFoo/Foo-new/one.txt
| `-- ./tmpFoo/Foo-new/two.txt
`-- ./tmpFoo/Foo-old
`-- ./tmpFoo/Foo-old/one.txt
7 directories, 8 files
####
$ patch -p0 -R -i ../tmpFoo.patch
patching file tmpFoo/Foo/one.txt
patching file tmpFoo/Foo-new/one.txt
patching file tmpFoo/Foo-new/two.txt
patching file tmpFoo/Foo-old/one.txt
$ tree -f -a
.
|-- ./Foo
| `-- ./Foo/one.txt
|-- ./Foo-new
| |-- ./Foo-new/one.txt
| `-- ./Foo-new/two.txt
`-- ./Foo-old
`-- ./Foo-old/one.txt
3 directories, 4 files