commit 867f1b0462acdb84ad50de720f3b64db2d189f88
Author: Andreas Gruenbacher <agruen@suse.de>
Date:   Thu Mar 19 13:40:51 2009 +0100

    Mutiple patches to a file and patch -o

diff --git a/Makefile.in b/Makefile.in
index 6a28c7d..419c2db 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -73,6 +73,7 @@ SRCS = $(LIBSRCS) \
 	util.c version.c xmalloc.c
 TESTS = tests/corrupt-reject-files \
 	tests/crlf-handling \
+	tests/dash-o-append \
 	tests/device-special-files \
 	tests/global-reject-files \
 	tests/no-newline-triggers-assert \
diff --git a/tests/dash-o-append b/tests/dash-o-append
new file mode 100755
index 0000000..038a7a8
--- /dev/null
+++ b/tests/dash-o-append
@@ -0,0 +1,40 @@
+#! /bin/bash
+
+. $srcdir/test-lib.sh
+
+require_cat
+require_diff
+use_local_patch
+use_tmpdir
+
+# ==============================================================
+
+# IEEE Std 1003.1-2008 requires that with -o outfile, multiple patches
+# for a single file shall be applied to the intermediate versions of the
+# file created by any previous patches, and shall result in multiple,
+# concatenated versions of the file being written to outfile.
+
+cat > a.diff <<EOF
+--- a
++++ a
+@@ -1 +1 @@
+-one
++two
+--- a
++++ a
+@@ -1 +1 @@
+-two
++three
+EOF
+
+echo one > a
+
+check 'patch -o a.new a < a.diff' <<EOF
+patching file a
+patching file a
+EOF
+
+check 'cat a.new' <<EOF
+two
+four
+EOF
