1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
# Copyright (C) 2009, 2011-2012 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
# ==============================================================
# Bug #25969: Patch replaces unmodified files
#
# When a patch doesn't actually modify a file (i.e., only rejects),
# the file is still replaced.
cat > a.diff <<EOF
--- a
+++ a
@@ -1 +1 @@
-one
+two
EOF
echo three > a
ln a a.first
check 'patch -b -B backup/ a < a.diff || echo "Status: $?"' <<EOF
patching file a
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file a.rej
Status: 1
EOF
ncheck 'test a -ef a.first'
check 'cat backup/a' <<EOF
three
EOF
# ==============================================================
# When applying an empty patch to a file with -o, copy the input file.
cat > a.diff <<EOF
EOF
echo three > a
check 'patch -o b a < a.diff' <<EOF
patching file b (read from a)
EOF
check 'cat b' <<EOF
three
EOF
|