~ubuntu-branches/ubuntu/trusty/patch/trusty-security

1.2.3 by Christoph Berg
Import upstream version 2.7.1
1
# Copyright (C) 2009, 2011-2012 Free Software Foundation, Inc.
1.1.2 by Christoph Berg
Import upstream version 2.6
2
#
3
# Copying and distribution of this file, with or without modification,
4
# in any medium, are permitted without royalty provided the copyright
5
# notice and this notice are preserved.
6
7
. $srcdir/test-lib.sh
8
9
require_cat
10
use_local_patch
11
use_tmpdir
12
13
# ==============================================================
14
15
# Bug #25969: Patch replaces unmodified files
16
#
17
# When a patch doesn't actually modify a file (i.e., only rejects),
18
# the file is still replaced.
19
20
cat > a.diff <<EOF
21
--- a
22
+++ a
23
@@ -1 +1 @@
24
-one
25
+two
26
EOF
27
28
echo three > a
29
ln a a.first
30
31
check 'patch -b -B backup/ a < a.diff || echo "Status: $?"' <<EOF
32
patching file a
33
Hunk #1 FAILED at 1.
34
1 out of 1 hunk FAILED -- saving rejects to file a.rej
35
Status: 1
36
EOF
37
38
ncheck 'test a -ef a.first'
39
40
check 'cat backup/a' <<EOF
41
three
42
EOF
43
44
# ==============================================================
45
46
# When applying an empty patch to a file with -o, copy the input file.
47
48
cat > a.diff <<EOF
49
EOF
50
51
echo three > a
52
53
check 'patch -o b a < a.diff' <<EOF
1.2.2 by Christoph Berg
Import upstream version 2.6.1.136-31a7
54
patching file b (read from a)
1.1.2 by Christoph Berg
Import upstream version 2.6
55
EOF
56
57
check 'cat b' <<EOF
58
three
59
EOF