summaryrefslogtreecommitdiff
path: root/tests/global-reject-files
blob: a29312e6c6fe83b9aba6faf8340ab25a6219f59b (plain)
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# Copyright (C) 2009, 2011 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.

# More than one reject to the same file.

. $srcdir/test-lib.sh

require_cat
use_local_patch
use_tmpdir

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

cat > ab.diff <<EOF
--- a
+++ a
@@ -1 +1 @@
-one
+two
--- b
+++ b
@@ -1 +1 @@
-three
+four
EOF

echo one > a
echo three > b

check 'patch -p0 < ab.diff' <<EOF
patching file a
patching file b
EOF

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

check 'patch -p0 -f < ab.diff || echo "Status: $?"' <<EOF
patching file a
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file a.rej
patching file b
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file b.rej
Status: 1
EOF

check 'cat a.rej' <<EOF
--- a
+++ a
@@ -1 +1 @@
-one
+two
EOF

check 'cat b.rej' <<EOF
--- b
+++ b
@@ -1 +1 @@
-three
+four
EOF

check 'patch -p0 -f -r ab.rej < ab.diff || echo "Status: $?"' <<EOF
patching file a
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file ab.rej
patching file b
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file ab.rej
Status: 1
EOF

check 'cat ab.rej' <<EOF
--- a
+++ a
@@ -1 +1 @@
-one
+two
--- b
+++ b
@@ -1 +1 @@
-three
+four
EOF