summaryrefslogtreecommitdiff
path: root/tests/create-delete
blob: 17f38bf6726a91da96dee40b623d6ab6aa740298 (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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# Copyright (C) 2009 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
require_sed
use_local_patch
use_tmpdir

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

# Bug #25970: intuit_diff_type: Assertion `i0 != NONE' failed.

cat > f.diff <<EOF
--- f
+++ f
@@ -1 +0,0 @@
-one
EOF
echo one > f

check 'patch -f -p1 < f.diff || echo "Status: $?"' <<EOF
can't find file to patch at input line 3
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|--- f
|+++ f
--------------------------
No file to patch.  Skipping patch.
1 out of 1 hunk ignored
Status: 1
EOF

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

cat > f.diff <<EOF
--- /dev/null
+++ f
@@ -0,0 +1 @@
+one
EOF
echo one > f

check 'patch -f < f.diff || echo "Status: $?"' <<EOF
The next patch would create the file f,
which already exists!  Applying it anyway.
patching file f
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file f.rej
Status: 1
EOF

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

cat > f.diff <<EOF
--- f
+++ /dev/null
@@ -1 +0,0 @@
-one
EOF
rm -f f

preserve_trailing_blank=

check 'patch -p0 < f.diff || echo "Status: $?"' <<EOF
The next patch would delete the file f,
which does not exist!  Assume -R? [n] $preserve_trailing_blank
Apply anyway? [n] $preserve_trailing_blank
Skipping patch.
1 out of 1 hunk ignored
Status: 1
EOF

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

rm -f f

check 'patch -p0 -f < f.diff || echo "Status: $?"' <<EOF
The next patch would delete the file f,
which does not exist!  Applying it anyway.
patching file f
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file f.rej
Status: 1
EOF

# --------------------------------------------------------------
# Check the file mode of backups of new files

umask 022
rm -f f

check 'patch -f f < f.diff || echo "Status: $?"' <<EOF
The next patch would delete the file f,
which does not exist!  Applying it anyway.
patching file f
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file f.rej
Status: 1
EOF

check 'ls -l f.orig | sed "s,\(..........\).*,\1,"' <<EOF
-rw-r--r--
EOF

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

cat > f.diff <<EOF
--- f.orig
+++ f
@@ -1 +0,0 @@
-f
EOF
echo f > f.orig
: > f

check 'patch -f < f.diff || echo "Status: $?"' <<EOF
The next patch would empty out the file f,
which is already empty!  Applying it anyway.
patching file f
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file f.rej
Status: 1
EOF

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

cat > f.diff <<EOF
--- f
+++ f.orig
@@ -1 +0,0 @@
-f
EOF
rm -f f.orig
: > f

check 'patch -p0 -t < f.diff || echo "Status: $?"' <<EOF
The next patch would empty out the file f,
which is already empty!  Assuming -R.
patching file f
EOF

check 'cat f' <<EOF
f
EOF

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

cat > f.diff <<EOF
--- f
+++ /dev/null
@@ -1 +0,0 @@
-f
EOF
rm -f f.orig
: > f

# FIXME: "The next patch would delete the file f" would be better here
check 'patch -p0 -t < f.diff || echo "Status: $?"' <<EOF
The next patch would empty out the file f,
which is already empty!  Assuming -R.
patching file f
EOF

check 'cat f' <<EOF
f
EOF