# Copyright 2009-2025 Free Software Foundation, Inc.
#
# Copying and distribution of this file, with or without modification,
# in any medium, are permitted without royalty provided the copyright
# notice and this notice are preserved.

. $srcdir/test-lib.sh

require cat
use_local_patch
use_tmpdir

# ==============================================================

cat > f.diff <<EOF
--- a
+++ b
@@ -1 +1 @@
-one
+two
--- c
+++ d
@@ -1 +1 @@
-two
+three
EOF

echo one > x

check 'patch x < f.diff' <<EOF
patching file x
patching file x
EOF

check 'cat x' <<EOF
three
EOF

# --------------------------------------------------------------

echo aa > file1

mkdir 1
cd 1
cat > g.diff <<EOF
--- file1
+++ file2
@@ -1 +1 @@
-aa
+bb
EOF

check 'patch ../file1 < g.diff' <<EOF
patching file ../file1
EOF
