Blame


1 e9ce266e 2022-03-07 op #!/bin/sh
2 e9ce266e 2022-03-07 op #
3 e9ce266e 2022-03-07 op # Copyright (c) 2022 Omar Polo <op@openbsd.org>
4 e9ce266e 2022-03-07 op #
5 e9ce266e 2022-03-07 op # Permission to use, copy, modify, and distribute this software for any
6 e9ce266e 2022-03-07 op # purpose with or without fee is hereby granted, provided that the above
7 e9ce266e 2022-03-07 op # copyright notice and this permission notice appear in all copies.
8 e9ce266e 2022-03-07 op #
9 e9ce266e 2022-03-07 op # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 e9ce266e 2022-03-07 op # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 e9ce266e 2022-03-07 op # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 e9ce266e 2022-03-07 op # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 e9ce266e 2022-03-07 op # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 e9ce266e 2022-03-07 op # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 e9ce266e 2022-03-07 op # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 e9ce266e 2022-03-07 op
17 e9ce266e 2022-03-07 op . ./common.sh
18 e9ce266e 2022-03-07 op
19 57b1c3f2 2022-08-01 op test_patch_basic() {
20 57b1c3f2 2022-08-01 op local testroot=`test_init patch_basic`
21 e9ce266e 2022-03-07 op
22 e9ce266e 2022-03-07 op got checkout $testroot/repo $testroot/wt > /dev/null
23 e9ce266e 2022-03-07 op ret=$?
24 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
25 e9ce266e 2022-03-07 op test_done $testroot $ret
26 e9ce266e 2022-03-07 op return 1
27 e9ce266e 2022-03-07 op fi
28 e9ce266e 2022-03-07 op
29 57b1c3f2 2022-08-01 op jot 100 > $testroot/wt/numbers
30 57b1c3f2 2022-08-01 op (cd $testroot/wt && got add numbers && got commit -m +numbers) \
31 57b1c3f2 2022-08-01 op >/dev/null
32 e9ce266e 2022-03-07 op ret=$?
33 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
34 57b1c3f2 2022-08-01 op test_done "$testroot" $ret
35 e9ce266e 2022-03-07 op return 1
36 e9ce266e 2022-03-07 op fi
37 e9ce266e 2022-03-07 op
38 e9ce266e 2022-03-07 op cat <<EOF > $testroot/wt/patch
39 e9ce266e 2022-03-07 op --- alpha
40 e9ce266e 2022-03-07 op +++ alpha
41 e9ce266e 2022-03-07 op @@ -1 +1 @@
42 e9ce266e 2022-03-07 op -alpha
43 e9ce266e 2022-03-07 op +alpha is my favourite character
44 57b1c3f2 2022-08-01 op --- beta
45 57b1c3f2 2022-08-01 op +++ /dev/null
46 57b1c3f2 2022-08-01 op @@ -1 +0,0 @@
47 57b1c3f2 2022-08-01 op -beta
48 57b1c3f2 2022-08-01 op --- gamma/delta
49 57b1c3f2 2022-08-01 op +++ gamma/delta
50 e9ce266e 2022-03-07 op @@ -1 +1,2 @@
51 57b1c3f2 2022-08-01 op +this is:
52 57b1c3f2 2022-08-01 op delta
53 57b1c3f2 2022-08-01 op --- /dev/null
54 57b1c3f2 2022-08-01 op +++ eta
55 57b1c3f2 2022-08-01 op @@ -0,0 +5,5 @@
56 57b1c3f2 2022-08-01 op +1
57 57b1c3f2 2022-08-01 op +2
58 57b1c3f2 2022-08-01 op +3
59 57b1c3f2 2022-08-01 op +4
60 57b1c3f2 2022-08-01 op +5
61 e9ce266e 2022-03-07 op --- numbers
62 e9ce266e 2022-03-07 op +++ numbers
63 e9ce266e 2022-03-07 op @@ -3,7 +3,7 @@
64 e9ce266e 2022-03-07 op 3
65 e9ce266e 2022-03-07 op 4
66 e9ce266e 2022-03-07 op 5
67 e9ce266e 2022-03-07 op -6
68 57b1c3f2 2022-08-01 op +six
69 e9ce266e 2022-03-07 op 7
70 e9ce266e 2022-03-07 op 8
71 e9ce266e 2022-03-07 op 9
72 e9ce266e 2022-03-07 op @@ -57,7 +57,7 @@
73 e9ce266e 2022-03-07 op 57
74 e9ce266e 2022-03-07 op 58
75 e9ce266e 2022-03-07 op 59
76 e9ce266e 2022-03-07 op -60
77 57b1c3f2 2022-08-01 op +sixty
78 e9ce266e 2022-03-07 op 61
79 e9ce266e 2022-03-07 op 62
80 e9ce266e 2022-03-07 op 63
81 e9ce266e 2022-03-07 op @@ -98,3 +98,6 @@
82 e9ce266e 2022-03-07 op 98
83 e9ce266e 2022-03-07 op 99
84 e9ce266e 2022-03-07 op 100
85 e9ce266e 2022-03-07 op +101
86 e9ce266e 2022-03-07 op +102
87 57b1c3f2 2022-08-01 op +103
88 e9ce266e 2022-03-07 op EOF
89 e9ce266e 2022-03-07 op
90 9cda65e5 2022-10-15 stsp (cd $testroot/wt && got patch < patch) > $testroot/stdout
91 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
92 57b1c3f2 2022-08-01 op test_done "$testroot" $ret
93 e9ce266e 2022-03-07 op return 1
94 e9ce266e 2022-03-07 op fi
95 e9ce266e 2022-03-07 op
96 57b1c3f2 2022-08-01 op echo 'M alpha' > $testroot/stdout.expected
97 57b1c3f2 2022-08-01 op echo 'D beta' >> $testroot/stdout.expected
98 57b1c3f2 2022-08-01 op echo 'M gamma/delta' >> $testroot/stdout.expected
99 57b1c3f2 2022-08-01 op echo 'A eta' >> $testroot/stdout.expected
100 57b1c3f2 2022-08-01 op echo 'M numbers' >> $testroot/stdout.expected
101 57b1c3f2 2022-08-01 op
102 e9ce266e 2022-03-07 op cmp -s $testroot/stdout.expected $testroot/stdout
103 e9ce266e 2022-03-07 op ret=$?
104 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
105 e9ce266e 2022-03-07 op diff -u $testroot/stdout.expected $testroot/stdout
106 e9ce266e 2022-03-07 op test_done $testroot $ret
107 e9ce266e 2022-03-07 op return 1
108 e9ce266e 2022-03-07 op fi
109 e9ce266e 2022-03-07 op
110 57b1c3f2 2022-08-01 op echo 'alpha is my favourite character' > $testroot/wt/alpha.expected
111 57b1c3f2 2022-08-01 op cmp -s $testroot/wt/alpha.expected $testroot/wt/alpha
112 e9ce266e 2022-03-07 op ret=$?
113 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
114 57b1c3f2 2022-08-01 op diff -u $testroot/wt/alpha.expected $testroot/wt/alpha
115 57b1c3f2 2022-08-01 op test_done "$testroot" $ret
116 57b1c3f2 2022-08-01 op return 1
117 e9ce266e 2022-03-07 op fi
118 e9ce266e 2022-03-07 op
119 57b1c3f2 2022-08-01 op if [ -f "$testroot/wt/beta" ]; then
120 57b1c3f2 2022-08-01 op echo "beta was not deleted!" >&2
121 57b1c3f2 2022-08-01 op test_done "$testroot" 1
122 e9ce266e 2022-03-07 op return 1
123 e9ce266e 2022-03-07 op fi
124 e9ce266e 2022-03-07 op
125 57b1c3f2 2022-08-01 op echo 'this is:' > $testroot/wt/gamma/delta.expected
126 57b1c3f2 2022-08-01 op echo 'delta' >> $testroot/wt/gamma/delta.expected
127 57b1c3f2 2022-08-01 op cmp -s $testroot/wt/gamma/delta.expected $testroot/wt/gamma/delta
128 e9ce266e 2022-03-07 op ret=$?
129 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
130 57b1c3f2 2022-08-01 op diff -u $testroot/wt/gamma/delta.expected $testroot/wt/gamma/delta
131 57b1c3f2 2022-08-01 op test_done "$testroot" $ret
132 e9ce266e 2022-03-07 op return 1
133 e9ce266e 2022-03-07 op fi
134 e9ce266e 2022-03-07 op
135 57b1c3f2 2022-08-01 op jot 5 > $testroot/wt/eta.expected
136 57b1c3f2 2022-08-01 op cmp -s $testroot/wt/eta.expected $testroot/wt/eta
137 e9ce266e 2022-03-07 op ret=$?
138 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
139 57b1c3f2 2022-08-01 op diff -u $testroot/wt/eta.expected $testroot/wt/eta
140 57b1c3f2 2022-08-01 op test_done "$testroot" $ret
141 e9ce266e 2022-03-07 op return 1
142 e9ce266e 2022-03-07 op fi
143 e9ce266e 2022-03-07 op
144 57b1c3f2 2022-08-01 op jot 103 | sed -e 's/^6$/six/' -e 's/60/sixty/' \
145 57b1c3f2 2022-08-01 op > $testroot/wt/numbers.expected
146 57b1c3f2 2022-08-01 op cmp -s $testroot/wt/numbers.expected $testroot/wt/numbers
147 57b1c3f2 2022-08-01 op ret=$?
148 57b1c3f2 2022-08-01 op if [ $ret -ne 0 ]; then
149 57b1c3f2 2022-08-01 op diff -u $testroot/wt/numbers.expected $testroot/wt/numbers
150 57b1c3f2 2022-08-01 op fi
151 57b1c3f2 2022-08-01 op test_done $testroot $ret
152 e9ce266e 2022-03-07 op }
153 e9ce266e 2022-03-07 op
154 e9ce266e 2022-03-07 op test_patch_dont_apply() {
155 e9ce266e 2022-03-07 op local testroot=`test_init patch_dont_apply`
156 e9ce266e 2022-03-07 op
157 e9ce266e 2022-03-07 op got checkout $testroot/repo $testroot/wt > /dev/null
158 e9ce266e 2022-03-07 op ret=$?
159 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
160 e9ce266e 2022-03-07 op test_done $testroot $ret
161 e9ce266e 2022-03-07 op return 1
162 e9ce266e 2022-03-07 op fi
163 e9ce266e 2022-03-07 op
164 5b67f96e 2022-03-13 op jot 100 > $testroot/wt/numbers
165 5b67f96e 2022-03-13 op (cd $testroot/wt && got add numbers && got commit -m 'add numbers') \
166 5b67f96e 2022-03-13 op >/dev/null
167 5b67f96e 2022-03-13 op ret=$?
168 5b67f96e 2022-03-13 op if [ $ret -ne 0 ]; then
169 5b67f96e 2022-03-13 op test_done $testroot $ret
170 5b67f96e 2022-03-13 op return 1
171 5b67f96e 2022-03-13 op fi
172 5b67f96e 2022-03-13 op
173 5b67f96e 2022-03-13 op cat <<EOF > $testroot/wt/patch
174 60aa1fa0 2022-03-17 op --- alpha
175 60aa1fa0 2022-03-17 op +++ alpha
176 60aa1fa0 2022-03-17 op @@ -1 +1,2 @@
177 60aa1fa0 2022-03-17 op +hatsuseno
178 60aa1fa0 2022-03-17 op alpha something
179 5b67f96e 2022-03-13 op --- numbers
180 5b67f96e 2022-03-13 op +++ /dev/null
181 5b67f96e 2022-03-13 op @@ -1,9 +0,0 @@
182 5b67f96e 2022-03-13 op -1
183 5b67f96e 2022-03-13 op -2
184 5b67f96e 2022-03-13 op -3
185 5b67f96e 2022-03-13 op -4
186 5b67f96e 2022-03-13 op -5
187 5b67f96e 2022-03-13 op -6
188 5b67f96e 2022-03-13 op -7
189 5b67f96e 2022-03-13 op -8
190 5b67f96e 2022-03-13 op -9
191 5b67f96e 2022-03-13 op EOF
192 5b67f96e 2022-03-13 op
193 60aa1fa0 2022-03-17 op (cd $testroot/wt && got patch patch) > $testroot/stdout 2> /dev/null
194 5b67f96e 2022-03-13 op ret=$?
195 5b67f96e 2022-03-13 op if [ $ret -eq 0 ]; then # should fail
196 5b67f96e 2022-03-13 op test_done $testroot 1
197 e9ce266e 2022-03-07 op return 1
198 e9ce266e 2022-03-07 op fi
199 e9ce266e 2022-03-07 op
200 60aa1fa0 2022-03-17 op cat <<EOF > $testroot/stdout.expected
201 60aa1fa0 2022-03-17 op # alpha
202 60aa1fa0 2022-03-17 op @@ -1,1 +1,2 @@ hunk failed to apply
203 60aa1fa0 2022-03-17 op # numbers
204 60aa1fa0 2022-03-17 op @@ -1,9 +0,0 @@ hunk failed to apply
205 60aa1fa0 2022-03-17 op EOF
206 60aa1fa0 2022-03-17 op
207 60aa1fa0 2022-03-17 op cmp -s $testroot/stdout.expected $testroot/stdout
208 5b67f96e 2022-03-13 op ret=$?
209 5b67f96e 2022-03-13 op if [ $ret -ne 0 ]; then
210 60aa1fa0 2022-03-17 op diff -u $testroot/stdout.expected $testroot/stdout
211 5b67f96e 2022-03-13 op fi
212 e9ce266e 2022-03-07 op test_done $testroot $ret
213 e9ce266e 2022-03-07 op }
214 e9ce266e 2022-03-07 op
215 e9ce266e 2022-03-07 op test_patch_malformed() {
216 e9ce266e 2022-03-07 op local testroot=`test_init patch_malformed`
217 e9ce266e 2022-03-07 op
218 e9ce266e 2022-03-07 op got checkout $testroot/repo $testroot/wt > /dev/null
219 e9ce266e 2022-03-07 op ret=$?
220 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
221 e9ce266e 2022-03-07 op test_done $testroot $ret
222 e9ce266e 2022-03-07 op return 1
223 e9ce266e 2022-03-07 op fi
224 e9ce266e 2022-03-07 op
225 e9ce266e 2022-03-07 op # missing "@@"
226 e9ce266e 2022-03-07 op cat <<EOF > $testroot/wt/patch
227 e9ce266e 2022-03-07 op --- alpha
228 e9ce266e 2022-03-07 op +++ alpha
229 e9ce266e 2022-03-07 op @@ -1 +1,2
230 e9ce266e 2022-03-07 op +hatsuseno
231 e9ce266e 2022-03-07 op alpha
232 e9ce266e 2022-03-07 op EOF
233 e9ce266e 2022-03-07 op
234 e9ce266e 2022-03-07 op echo -n > $testroot/stdout.expected
235 e9ce266e 2022-03-07 op echo "got: malformed patch" > $testroot/stderr.expected
236 e9ce266e 2022-03-07 op
237 e9ce266e 2022-03-07 op (cd $testroot/wt && got patch patch) \
238 e9ce266e 2022-03-07 op > $testroot/stdout \
239 e9ce266e 2022-03-07 op 2> $testroot/stderr
240 e9ce266e 2022-03-07 op ret=$?
241 bfbccd0a 2022-03-08 op if [ $ret -eq 0 ]; then
242 e9ce266e 2022-03-07 op echo "got managed to apply an invalid patch"
243 e9ce266e 2022-03-07 op test_done $testroot 1
244 e9ce266e 2022-03-07 op return 1
245 e9ce266e 2022-03-07 op fi
246 e9ce266e 2022-03-07 op
247 e9ce266e 2022-03-07 op cmp -s $testroot/stdout.expected $testroot/stdout
248 e9ce266e 2022-03-07 op ret=$?
249 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
250 e9ce266e 2022-03-07 op diff -u $testroot/stdout.expected $testroot/stdout
251 e9ce266e 2022-03-07 op test_done $testroot $ret
252 e9ce266e 2022-03-07 op return 1
253 e9ce266e 2022-03-07 op fi
254 e9ce266e 2022-03-07 op
255 e9ce266e 2022-03-07 op cmp -s $testroot/stderr.expected $testroot/stderr
256 e9ce266e 2022-03-07 op ret=$?
257 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
258 e9ce266e 2022-03-07 op diff -u $testroot/stderr.expected $testroot/stderr
259 e9ce266e 2022-03-07 op test_done $testroot $ret
260 e9ce266e 2022-03-07 op return 1
261 e9ce266e 2022-03-07 op fi
262 e9ce266e 2022-03-07 op
263 e9ce266e 2022-03-07 op # wrong first character
264 e9ce266e 2022-03-07 op cat <<EOF > $testroot/wt/patch
265 e9ce266e 2022-03-07 op --- alpha
266 e9ce266e 2022-03-07 op +++ alpha
267 e9ce266e 2022-03-07 op @@ -1 +1,2 @@
268 e9ce266e 2022-03-07 op +hatsuseno
269 e9ce266e 2022-03-07 op alpha
270 be33dff7 2022-05-13 op EOF
271 be33dff7 2022-05-13 op
272 be33dff7 2022-05-13 op (cd $testroot/wt && got patch patch) \
273 be33dff7 2022-05-13 op > $testroot/stdout \
274 be33dff7 2022-05-13 op 2> $testroot/stderr
275 be33dff7 2022-05-13 op ret=$?
276 be33dff7 2022-05-13 op if [ $ret -eq 0 ]; then
277 be33dff7 2022-05-13 op echo "got managed to apply an invalid patch"
278 be33dff7 2022-05-13 op test_done $testroot 1
279 be33dff7 2022-05-13 op return 1
280 be33dff7 2022-05-13 op fi
281 be33dff7 2022-05-13 op
282 be33dff7 2022-05-13 op cmp -s $testroot/stdout.expected $testroot/stdout
283 be33dff7 2022-05-13 op ret=$?
284 be33dff7 2022-05-13 op if [ $ret -ne 0 ]; then
285 be33dff7 2022-05-13 op diff -u $testroot/stdout.expected $testroot/stdout
286 be33dff7 2022-05-13 op test_done $testroot $ret
287 be33dff7 2022-05-13 op return 1
288 be33dff7 2022-05-13 op fi
289 be33dff7 2022-05-13 op
290 be33dff7 2022-05-13 op cmp -s $testroot/stderr.expected $testroot/stderr
291 be33dff7 2022-05-13 op ret=$?
292 be33dff7 2022-05-13 op if [ $ret -ne 0 ]; then
293 be33dff7 2022-05-13 op diff -u $testroot/stderr.expected $testroot/stderr
294 be33dff7 2022-05-13 op test_done $testroot $ret
295 be33dff7 2022-05-13 op return 1
296 be33dff7 2022-05-13 op fi
297 be33dff7 2022-05-13 op
298 be33dff7 2022-05-13 op # empty hunk
299 be33dff7 2022-05-13 op cat <<EOF > $testroot/wt/patch
300 be33dff7 2022-05-13 op diff --git a/alpha b/iota
301 be33dff7 2022-05-13 op --- a/alpha
302 be33dff7 2022-05-13 op +++ b/iota
303 be33dff7 2022-05-13 op @@ -0,0 +0,0 @@
304 e9ce266e 2022-03-07 op EOF
305 e9ce266e 2022-03-07 op
306 e9ce266e 2022-03-07 op (cd $testroot/wt && got patch patch) \
307 e9ce266e 2022-03-07 op > $testroot/stdout \
308 e9ce266e 2022-03-07 op 2> $testroot/stderr
309 e9ce266e 2022-03-07 op ret=$?
310 bfbccd0a 2022-03-08 op if [ $ret -eq 0 ]; then
311 e9ce266e 2022-03-07 op echo "got managed to apply an invalid patch"
312 e9ce266e 2022-03-07 op test_done $testroot 1
313 e9ce266e 2022-03-07 op return 1
314 e9ce266e 2022-03-07 op fi
315 e9ce266e 2022-03-07 op
316 e9ce266e 2022-03-07 op cmp -s $testroot/stdout.expected $testroot/stdout
317 e9ce266e 2022-03-07 op ret=$?
318 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
319 e9ce266e 2022-03-07 op diff -u $testroot/stdout.expected $testroot/stdout
320 e9ce266e 2022-03-07 op test_done $testroot $ret
321 e9ce266e 2022-03-07 op return 1
322 e9ce266e 2022-03-07 op fi
323 e9ce266e 2022-03-07 op
324 e9ce266e 2022-03-07 op cmp -s $testroot/stderr.expected $testroot/stderr
325 e9ce266e 2022-03-07 op ret=$?
326 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
327 e9ce266e 2022-03-07 op diff -u $testroot/stderr.expected $testroot/stderr
328 e9ce266e 2022-03-07 op test_done $testroot $ret
329 e9ce266e 2022-03-07 op return 1
330 e9ce266e 2022-03-07 op fi
331 e9ce266e 2022-03-07 op
332 e9ce266e 2022-03-07 op test_done $testroot $ret
333 e9ce266e 2022-03-07 op }
334 e9ce266e 2022-03-07 op
335 e9ce266e 2022-03-07 op test_patch_no_patch() {
336 e9ce266e 2022-03-07 op local testroot=`test_init patch_no_patch`
337 e9ce266e 2022-03-07 op
338 e9ce266e 2022-03-07 op got checkout $testroot/repo $testroot/wt > /dev/null
339 e9ce266e 2022-03-07 op ret=$?
340 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
341 e9ce266e 2022-03-07 op test_done $testroot $ret
342 e9ce266e 2022-03-07 op return 1
343 e9ce266e 2022-03-07 op fi
344 e9ce266e 2022-03-07 op
345 e9ce266e 2022-03-07 op cat <<EOF > $testroot/wt/patch
346 e9ce266e 2022-03-07 op hello world!
347 e9ce266e 2022-03-07 op ...
348 e9ce266e 2022-03-07 op
349 e9ce266e 2022-03-07 op some other nonsense
350 e9ce266e 2022-03-07 op ...
351 e9ce266e 2022-03-07 op
352 e9ce266e 2022-03-07 op there's no patch in here!
353 e9ce266e 2022-03-07 op EOF
354 e9ce266e 2022-03-07 op
355 e9ce266e 2022-03-07 op echo -n > $testroot/stdout.expected
356 e9ce266e 2022-03-07 op echo "got: no patch found" > $testroot/stderr.expected
357 e9ce266e 2022-03-07 op
358 e9ce266e 2022-03-07 op (cd $testroot/wt && got patch patch) \
359 e9ce266e 2022-03-07 op > $testroot/stdout \
360 e9ce266e 2022-03-07 op 2> $testroot/stderr
361 e9ce266e 2022-03-07 op ret=$?
362 bfbccd0a 2022-03-08 op if [ $ret -eq 0 ]; then # should fail
363 e9ce266e 2022-03-07 op test_done $testroot 1
364 e9ce266e 2022-03-07 op return 1
365 e9ce266e 2022-03-07 op fi
366 3313bcd8 2022-04-19 op
367 e9ce266e 2022-03-07 op cmp -s $testroot/stdout.expected $testroot/stdout
368 e9ce266e 2022-03-07 op ret=$?
369 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
370 e9ce266e 2022-03-07 op diff -u $testroot/stdout.expected $testroot/stdout
371 e9ce266e 2022-03-07 op test_done $testroot $ret
372 e9ce266e 2022-03-07 op return 1
373 e9ce266e 2022-03-07 op fi
374 e9ce266e 2022-03-07 op
375 e9ce266e 2022-03-07 op cmp -s $testroot/stderr.expected $testroot/stderr
376 e9ce266e 2022-03-07 op ret=$?
377 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
378 e9ce266e 2022-03-07 op diff -u $testroot/stderr.expected $testroot/stderr
379 e9ce266e 2022-03-07 op test_done $testroot $ret
380 e9ce266e 2022-03-07 op return 1
381 e9ce266e 2022-03-07 op fi
382 e9ce266e 2022-03-07 op
383 e9ce266e 2022-03-07 op test_done $testroot $ret
384 e9ce266e 2022-03-07 op }
385 e9ce266e 2022-03-07 op
386 e9ce266e 2022-03-07 op test_patch_equals_for_context() {
387 f1d6cebb 2022-04-23 op local testroot=`test_init patch_equals_for_context`
388 e9ce266e 2022-03-07 op
389 e9ce266e 2022-03-07 op got checkout $testroot/repo $testroot/wt > /dev/null
390 e9ce266e 2022-03-07 op ret=$?
391 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
392 e9ce266e 2022-03-07 op test_done $testroot $ret
393 e9ce266e 2022-03-07 op return 1
394 e9ce266e 2022-03-07 op fi
395 e9ce266e 2022-03-07 op
396 e9ce266e 2022-03-07 op cat <<EOF > $testroot/wt/patch
397 e9ce266e 2022-03-07 op --- alpha
398 e9ce266e 2022-03-07 op +++ alpha
399 e9ce266e 2022-03-07 op @@ -1 +1,2 @@
400 e9ce266e 2022-03-07 op +hatsuseno
401 e9ce266e 2022-03-07 op =alpha
402 e9ce266e 2022-03-07 op EOF
403 e9ce266e 2022-03-07 op
404 e9ce266e 2022-03-07 op echo "M alpha" > $testroot/stdout.expected
405 e9ce266e 2022-03-07 op
406 e9ce266e 2022-03-07 op (cd $testroot/wt && got patch patch) > $testroot/stdout
407 e9ce266e 2022-03-07 op ret=$?
408 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
409 e9ce266e 2022-03-07 op test_done $testroot $ret
410 e9ce266e 2022-03-07 op return 1
411 e9ce266e 2022-03-07 op fi
412 e9ce266e 2022-03-07 op
413 e9ce266e 2022-03-07 op cmp -s $testroot/stdout.expected $testroot/stdout
414 e9ce266e 2022-03-07 op ret=$?
415 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
416 e9ce266e 2022-03-07 op diff -u $testroot/stdout.expected $testroot/stdout
417 e9ce266e 2022-03-07 op test_done $testroot $ret
418 e9ce266e 2022-03-07 op return 1
419 e9ce266e 2022-03-07 op fi
420 e9ce266e 2022-03-07 op
421 e9ce266e 2022-03-07 op echo hatsuseno > $testroot/wt/alpha.expected
422 e9ce266e 2022-03-07 op echo alpha >> $testroot/wt/alpha.expected
423 e9ce266e 2022-03-07 op cmp -s $testroot/wt/alpha.expected $testroot/wt/alpha
424 e9ce266e 2022-03-07 op ret=$?
425 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
426 e9ce266e 2022-03-07 op diff -u $testroot/wt/alpha.expected $testroot/wt/alpha
427 e9ce266e 2022-03-07 op fi
428 e9ce266e 2022-03-07 op test_done $testroot $ret
429 e9ce266e 2022-03-07 op }
430 6e96b326 2022-03-12 op
431 6e96b326 2022-03-12 op test_patch_rename() {
432 6e96b326 2022-03-12 op local testroot=`test_init patch_rename`
433 6e96b326 2022-03-12 op
434 6e96b326 2022-03-12 op got checkout $testroot/repo $testroot/wt > /dev/null
435 6e96b326 2022-03-12 op ret=$?
436 6e96b326 2022-03-12 op if [ $ret -ne 0 ]; then
437 6e96b326 2022-03-12 op test_done $testroot $ret
438 6e96b326 2022-03-12 op return 1
439 6e96b326 2022-03-12 op fi
440 6e96b326 2022-03-12 op
441 6e96b326 2022-03-12 op cat <<EOF > $testroot/wt/patch
442 4379a9aa 2022-05-02 op diff --git a/beta b/iota
443 4379a9aa 2022-05-02 op similarity index 100%
444 4379a9aa 2022-05-02 op rename from beta
445 4379a9aa 2022-05-02 op rename to iota
446 7a30b5cb 2022-03-20 op diff --git a/alpha b/eta
447 7a30b5cb 2022-03-20 op --- a/alpha
448 7a30b5cb 2022-03-20 op +++ b/eta
449 4379a9aa 2022-05-02 op @@ -1 +1 @@
450 4379a9aa 2022-05-02 op -alpha
451 4379a9aa 2022-05-02 op +eta
452 6e96b326 2022-03-12 op EOF
453 e9ce266e 2022-03-07 op
454 4379a9aa 2022-05-02 op echo 'D beta' > $testroot/stdout.expected
455 4379a9aa 2022-05-02 op echo 'A iota' >> $testroot/stdout.expected
456 4379a9aa 2022-05-02 op echo 'D alpha' >> $testroot/stdout.expected
457 4379a9aa 2022-05-02 op echo 'A eta' >> $testroot/stdout.expected
458 6e96b326 2022-03-12 op
459 6e96b326 2022-03-12 op (cd $testroot/wt && got patch patch) > $testroot/stdout
460 6e96b326 2022-03-12 op ret=$?
461 6e96b326 2022-03-12 op if [ $ret -ne 0 ]; then
462 6e96b326 2022-03-12 op test_done $testroot $ret
463 6e96b326 2022-03-12 op return 1
464 6e96b326 2022-03-12 op fi
465 6e96b326 2022-03-12 op
466 6e96b326 2022-03-12 op cmp -s $testroot/stdout.expected $testroot/stdout
467 6e96b326 2022-03-12 op ret=$?
468 6e96b326 2022-03-12 op if [ $ret -ne 0 ]; then
469 6e96b326 2022-03-12 op diff -u $testroot/stdout.expected $testroot/stdout
470 6e96b326 2022-03-12 op test_done $testroot $ret
471 6e96b326 2022-03-12 op return 1
472 6e96b326 2022-03-12 op fi
473 6e96b326 2022-03-12 op
474 4379a9aa 2022-05-02 op if [ -f $testroot/wt/alpha -o -f $testroot/wt/beta ]; then
475 4379a9aa 2022-05-02 op echo "alpha or beta were not removed" >&2
476 6e96b326 2022-03-12 op test_done $testroot 1
477 6e96b326 2022-03-12 op return 1
478 6e96b326 2022-03-12 op fi
479 4379a9aa 2022-05-02 op if [ ! -f $testroot/wt/iota -o ! -f $testroot/wt/eta ]; then
480 4379a9aa 2022-05-02 op echo "iota or eta were not created" >&2
481 6e96b326 2022-03-12 op test_done $testroot 1
482 6e96b326 2022-03-12 op return 1
483 6e96b326 2022-03-12 op fi
484 6e96b326 2022-03-12 op
485 4379a9aa 2022-05-02 op echo beta > $testroot/wt/iota.expected
486 4379a9aa 2022-05-02 op cmp -s $testroot/wt/iota.expected $testroot/wt/iota
487 6e96b326 2022-03-12 op ret=$?
488 6e96b326 2022-03-12 op if [ $ret -ne 0 ]; then
489 4379a9aa 2022-05-02 op diff -u $testroot/wt/iota.expected $testroot/wt/iota
490 6e96b326 2022-03-12 op test_done $testroot $ret
491 6e96b326 2022-03-12 op return 1
492 6e96b326 2022-03-12 op fi
493 6e96b326 2022-03-12 op
494 4379a9aa 2022-05-02 op echo eta > $testroot/wt/eta.expected
495 4379a9aa 2022-05-02 op cmp -s $testroot/wt/eta.expected $testroot/wt/eta
496 6e96b326 2022-03-12 op ret=$?
497 6e96b326 2022-03-12 op if [ $ret -ne 0 ]; then
498 4379a9aa 2022-05-02 op diff -u $testroot/wt/eta.expected $testroot/wt/eta
499 6e96b326 2022-03-12 op test_done $testroot $ret
500 6e96b326 2022-03-12 op return 1
501 6e96b326 2022-03-12 op fi
502 6e96b326 2022-03-12 op
503 6e96b326 2022-03-12 op test_done $testroot $ret
504 6e96b326 2022-03-12 op }
505 dbda770b 2022-03-13 op
506 dbda770b 2022-03-13 op test_patch_illegal_status() {
507 dbda770b 2022-03-13 op local testroot=`test_init patch_illegal_status`
508 dbda770b 2022-03-13 op
509 dbda770b 2022-03-13 op got checkout $testroot/repo $testroot/wt > /dev/null
510 dbda770b 2022-03-13 op ret=$?
511 dbda770b 2022-03-13 op if [ $ret -ne 0 ]; then
512 dbda770b 2022-03-13 op test_done $testroot $ret
513 dbda770b 2022-03-13 op return 1
514 dbda770b 2022-03-13 op fi
515 dbda770b 2022-03-13 op
516 60aa1fa0 2022-03-17 op # try to patch an obstructed file, add a versioned one, edit a
517 60aa1fa0 2022-03-17 op # non existent file and an unversioned one, and remove a
518 60aa1fa0 2022-03-17 op # non existent file.
519 dbda770b 2022-03-13 op cat <<EOF > $testroot/wt/patch
520 60aa1fa0 2022-03-17 op --- alpha
521 60aa1fa0 2022-03-17 op +++ alpha
522 60aa1fa0 2022-03-17 op @@ -1 +1,2 @@
523 60aa1fa0 2022-03-17 op alpha
524 60aa1fa0 2022-03-17 op +was edited
525 60aa1fa0 2022-03-17 op --- /dev/null
526 60aa1fa0 2022-03-17 op +++ beta
527 60aa1fa0 2022-03-17 op @@ -0,0 +1 @@
528 60aa1fa0 2022-03-17 op +beta
529 dbda770b 2022-03-13 op --- iota
530 dbda770b 2022-03-13 op +++ iota
531 dbda770b 2022-03-13 op @@ -1 +1 @@
532 60aa1fa0 2022-03-17 op -iota
533 60aa1fa0 2022-03-17 op +IOTA
534 60aa1fa0 2022-03-17 op --- kappa
535 60aa1fa0 2022-03-17 op +++ kappa
536 60aa1fa0 2022-03-17 op @@ -1 +1 @@
537 60aa1fa0 2022-03-17 op -kappa
538 60aa1fa0 2022-03-17 op +KAPPA
539 60aa1fa0 2022-03-17 op --- lambda
540 60aa1fa0 2022-03-17 op +++ /dev/null
541 60aa1fa0 2022-03-17 op @@ -1 +0,0 @@
542 60aa1fa0 2022-03-17 op -lambda
543 dbda770b 2022-03-13 op EOF
544 6e96b326 2022-03-12 op
545 60aa1fa0 2022-03-17 op echo kappa > $testroot/wt/kappa
546 dbda770b 2022-03-13 op rm $testroot/wt/alpha
547 dbda770b 2022-03-13 op mkdir $testroot/wt/alpha
548 dbda770b 2022-03-13 op
549 60aa1fa0 2022-03-17 op (cd $testroot/wt && got patch patch) > $testroot/stdout \
550 dbda770b 2022-03-13 op 2> $testroot/stderr
551 dbda770b 2022-03-13 op ret=$?
552 dbda770b 2022-03-13 op if [ $ret -eq 0 ]; then
553 dbda770b 2022-03-13 op echo "edited a missing file" >&2
554 a19f439c 2022-06-03 op test_done $testroot 1
555 dbda770b 2022-03-13 op return 1
556 dbda770b 2022-03-13 op fi
557 dbda770b 2022-03-13 op
558 60aa1fa0 2022-03-17 op cat <<EOF > $testroot/stdout.expected
559 60aa1fa0 2022-03-17 op # alpha
560 60aa1fa0 2022-03-17 op # beta
561 60aa1fa0 2022-03-17 op # iota
562 60aa1fa0 2022-03-17 op # kappa
563 60aa1fa0 2022-03-17 op # lambda
564 60aa1fa0 2022-03-17 op EOF
565 dbda770b 2022-03-13 op
566 60aa1fa0 2022-03-17 op cat <<EOF > $testroot/stderr.expected
567 60aa1fa0 2022-03-17 op got: alpha: file has unexpected status
568 60aa1fa0 2022-03-17 op got: beta: file has unexpected status
569 60aa1fa0 2022-03-17 op got: iota: No such file or directory
570 60aa1fa0 2022-03-17 op got: kappa: file has unexpected status
571 60aa1fa0 2022-03-17 op got: lambda: No such file or directory
572 60aa1fa0 2022-03-17 op got: patch failed to apply
573 dbda770b 2022-03-13 op EOF
574 dbda770b 2022-03-13 op
575 60aa1fa0 2022-03-17 op cmp -s $testroot/stdout.expected $testroot/stdout
576 dbda770b 2022-03-13 op ret=$?
577 60aa1fa0 2022-03-17 op if [ $ret -ne 0 ]; then
578 60aa1fa0 2022-03-17 op diff -u $testroot/stdout.expected $testroot/stdout
579 dbda770b 2022-03-13 op test_done $testroot $ret
580 dbda770b 2022-03-13 op return 1
581 dbda770b 2022-03-13 op fi
582 dbda770b 2022-03-13 op
583 dbda770b 2022-03-13 op cmp -s $testroot/stderr.expected $testroot/stderr
584 dbda770b 2022-03-13 op ret=$?
585 60aa1fa0 2022-03-17 op if [ $ret -ne 0 ]; then
586 dbda770b 2022-03-13 op diff -u $testroot/stderr.expected $testroot/stderr
587 78f5ac24 2022-03-19 op test_done $testroot $ret
588 78f5ac24 2022-03-19 op return 1
589 dbda770b 2022-03-13 op fi
590 78f5ac24 2022-03-19 op
591 78f5ac24 2022-03-19 op (cd $testroot/wt && got status) > $testroot/stdout
592 78f5ac24 2022-03-19 op cat <<EOF > $testroot/stdout.expected
593 78f5ac24 2022-03-19 op ~ alpha
594 78f5ac24 2022-03-19 op ? kappa
595 78f5ac24 2022-03-19 op ? patch
596 78f5ac24 2022-03-19 op EOF
597 78f5ac24 2022-03-19 op
598 78f5ac24 2022-03-19 op cmp -s $testroot/stdout.expected $testroot/stdout
599 78f5ac24 2022-03-19 op ret=$?
600 78f5ac24 2022-03-19 op if [ $ret -ne 0 ]; then
601 78f5ac24 2022-03-19 op diff -u $testroot/stdout.expected $testroot/stdout
602 78f5ac24 2022-03-19 op fi
603 899fcfdf 2022-03-13 op test_done $testroot $ret
604 899fcfdf 2022-03-13 op }
605 899fcfdf 2022-03-13 op
606 899fcfdf 2022-03-13 op test_patch_nop() {
607 899fcfdf 2022-03-13 op local testroot=`test_init patch_nop`
608 899fcfdf 2022-03-13 op
609 899fcfdf 2022-03-13 op got checkout $testroot/repo $testroot/wt > /dev/null
610 899fcfdf 2022-03-13 op ret=$?
611 899fcfdf 2022-03-13 op if [ $ret -ne 0 ]; then
612 899fcfdf 2022-03-13 op test_done $testroot $ret
613 899fcfdf 2022-03-13 op return 1
614 899fcfdf 2022-03-13 op fi
615 899fcfdf 2022-03-13 op
616 899fcfdf 2022-03-13 op cat <<EOF > $testroot/wt/patch
617 899fcfdf 2022-03-13 op --- alpha
618 899fcfdf 2022-03-13 op +++ alpha
619 899fcfdf 2022-03-13 op @@ -1 +1 @@
620 899fcfdf 2022-03-13 op -alpha
621 899fcfdf 2022-03-13 op +cafe alpha
622 899fcfdf 2022-03-13 op --- beta
623 899fcfdf 2022-03-13 op +++ /dev/null
624 899fcfdf 2022-03-13 op @@ -1 +0,0 @@
625 899fcfdf 2022-03-13 op -beta
626 7a30b5cb 2022-03-20 op diff --git a/gamma/delta b/gamma/delta.new
627 899fcfdf 2022-03-13 op --- gamma/delta
628 899fcfdf 2022-03-13 op +++ gamma/delta.new
629 899fcfdf 2022-03-13 op @@ -1 +1 @@
630 899fcfdf 2022-03-13 op -delta
631 899fcfdf 2022-03-13 op +delta updated and renamed!
632 899fcfdf 2022-03-13 op EOF
633 899fcfdf 2022-03-13 op
634 899fcfdf 2022-03-13 op (cd $testroot/wt && got patch -n patch)
635 899fcfdf 2022-03-13 op ret=$?
636 899fcfdf 2022-03-13 op if [ $ret -ne 0 ]; then
637 899fcfdf 2022-03-13 op test_done $testroot $ret
638 899fcfdf 2022-03-13 op return 1
639 dbda770b 2022-03-13 op fi
640 899fcfdf 2022-03-13 op
641 899fcfdf 2022-03-13 op # remove the patch to avoid the ? entry
642 899fcfdf 2022-03-13 op rm $testroot/wt/patch
643 899fcfdf 2022-03-13 op
644 899fcfdf 2022-03-13 op (cd $testroot/wt && got status) > $testroot/stdout
645 899fcfdf 2022-03-13 op ret=$?
646 899fcfdf 2022-03-13 op if [ $ret -ne 0 ]; then
647 899fcfdf 2022-03-13 op test_done $testroot $ret
648 899fcfdf 2022-03-13 op return 1
649 899fcfdf 2022-03-13 op fi
650 899fcfdf 2022-03-13 op
651 899fcfdf 2022-03-13 op echo -n > $testroot/stdout.expected
652 899fcfdf 2022-03-13 op cmp -s $testroot/stdout.expected $testroot/stdout
653 899fcfdf 2022-03-13 op ret=$?
654 899fcfdf 2022-03-13 op if [ $ret -ne 0 ]; then
655 899fcfdf 2022-03-13 op diff -u $testroot/stdout.expected $testroot/stdout
656 899fcfdf 2022-03-13 op fi
657 dbda770b 2022-03-13 op test_done $testroot $ret
658 2be5e1a2 2022-03-16 op }
659 2be5e1a2 2022-03-16 op
660 2be5e1a2 2022-03-16 op test_patch_preserve_perm() {
661 2be5e1a2 2022-03-16 op local testroot=`test_init patch_preserve_perm`
662 2be5e1a2 2022-03-16 op
663 2be5e1a2 2022-03-16 op got checkout $testroot/repo $testroot/wt > /dev/null
664 2be5e1a2 2022-03-16 op ret=$?
665 2be5e1a2 2022-03-16 op if [ $ret -ne 0 ]; then
666 2be5e1a2 2022-03-16 op test_done $testroot $ret
667 2be5e1a2 2022-03-16 op return 1
668 2be5e1a2 2022-03-16 op fi
669 2be5e1a2 2022-03-16 op
670 2be5e1a2 2022-03-16 op chmod +x $testroot/wt/alpha
671 2be5e1a2 2022-03-16 op (cd $testroot/wt && got commit -m 'alpha executable') > /dev/null
672 2be5e1a2 2022-03-16 op ret=$?
673 2be5e1a2 2022-03-16 op if [ $ret -ne 0 ]; then
674 2be5e1a2 2022-03-16 op test_done $testroot $ret
675 2be5e1a2 2022-03-16 op return 1
676 2be5e1a2 2022-03-16 op fi
677 2be5e1a2 2022-03-16 op
678 2be5e1a2 2022-03-16 op cat <<EOF > $testroot/wt/patch
679 2be5e1a2 2022-03-16 op --- alpha
680 2be5e1a2 2022-03-16 op +++ alpha
681 2be5e1a2 2022-03-16 op @@ -1 +1,2 @@
682 2be5e1a2 2022-03-16 op alpha
683 2be5e1a2 2022-03-16 op +was edited
684 2be5e1a2 2022-03-16 op EOF
685 2be5e1a2 2022-03-16 op
686 2be5e1a2 2022-03-16 op (cd $testroot/wt && got patch patch) > /dev/null
687 2be5e1a2 2022-03-16 op ret=$?
688 2be5e1a2 2022-03-16 op if [ $ret -ne 0 ]; then
689 2be5e1a2 2022-03-16 op test_done $testroot $ret
690 2be5e1a2 2022-03-16 op return 1
691 2be5e1a2 2022-03-16 op fi
692 2be5e1a2 2022-03-16 op
693 2be5e1a2 2022-03-16 op if [ ! -x $testroot/wt/alpha ]; then
694 2be5e1a2 2022-03-16 op echo "alpha is no more executable!" >&2
695 2be5e1a2 2022-03-16 op test_done $testroot 1
696 95d68340 2022-03-16 op return 1
697 95d68340 2022-03-16 op fi
698 95d68340 2022-03-16 op test_done $testroot 0
699 95d68340 2022-03-16 op }
700 95d68340 2022-03-16 op
701 95d68340 2022-03-16 op test_patch_create_dirs() {
702 95d68340 2022-03-16 op local testroot=`test_init patch_create_dirs`
703 95d68340 2022-03-16 op
704 95d68340 2022-03-16 op got checkout $testroot/repo $testroot/wt > /dev/null
705 95d68340 2022-03-16 op ret=$?
706 95d68340 2022-03-16 op if [ $ret -ne 0 ]; then
707 95d68340 2022-03-16 op test_done $testroot $ret
708 95d68340 2022-03-16 op return 1
709 95d68340 2022-03-16 op fi
710 95d68340 2022-03-16 op
711 95d68340 2022-03-16 op cat <<EOF > $testroot/wt/patch
712 95d68340 2022-03-16 op --- /dev/null
713 95d68340 2022-03-16 op +++ iota/kappa/lambda
714 95d68340 2022-03-16 op @@ -0,0 +1 @@
715 95d68340 2022-03-16 op +lambda
716 95d68340 2022-03-16 op EOF
717 95d68340 2022-03-16 op
718 95d68340 2022-03-16 op (cd $testroot/wt && got patch patch) > $testroot/stdout
719 95d68340 2022-03-16 op ret=$?
720 95d68340 2022-03-16 op if [ $ret -ne 0 ]; then
721 95d68340 2022-03-16 op test_done $testroot $ret
722 2be5e1a2 2022-03-16 op return 1
723 2be5e1a2 2022-03-16 op fi
724 95d68340 2022-03-16 op
725 95d68340 2022-03-16 op echo 'A iota/kappa/lambda' >> $testroot/stdout.expected
726 95d68340 2022-03-16 op cmp -s $testroot/stdout.expected $testroot/stdout
727 95d68340 2022-03-16 op ret=$?
728 95d68340 2022-03-16 op if [ $ret -ne 0 ]; then
729 95d68340 2022-03-16 op diff -u $testroot/stdout.expected $testroot/stdout
730 95d68340 2022-03-16 op test_done $testroot $ret
731 95d68340 2022-03-16 op return 1
732 95d68340 2022-03-16 op fi
733 95d68340 2022-03-16 op
734 95d68340 2022-03-16 op if [ ! -f $testroot/wt/iota/kappa/lambda ]; then
735 95d68340 2022-03-16 op echo "file not created!" >&2
736 95d68340 2022-03-16 op test_done $testroot $ret
737 95d68340 2022-03-16 op return 1
738 95d68340 2022-03-16 op fi
739 2be5e1a2 2022-03-16 op test_done $testroot 0
740 dbda770b 2022-03-13 op }
741 dbda770b 2022-03-13 op
742 60aa1fa0 2022-03-17 op test_patch_with_offset() {
743 60aa1fa0 2022-03-17 op local testroot=`test_init patch_with_offset`
744 60aa1fa0 2022-03-17 op
745 60aa1fa0 2022-03-17 op got checkout $testroot/repo $testroot/wt > /dev/null
746 60aa1fa0 2022-03-17 op ret=$?
747 60aa1fa0 2022-03-17 op if [ $ret -ne 0 ]; then
748 60aa1fa0 2022-03-17 op test_done $testroot $ret
749 60aa1fa0 2022-03-17 op return 1
750 60aa1fa0 2022-03-17 op fi
751 60aa1fa0 2022-03-17 op
752 60aa1fa0 2022-03-17 op cat <<EOF > $testroot/wt/patch
753 60aa1fa0 2022-03-17 op --- numbers
754 60aa1fa0 2022-03-17 op +++ numbers
755 60aa1fa0 2022-03-17 op @@ -47,7 +47,7 @@
756 60aa1fa0 2022-03-17 op 47
757 60aa1fa0 2022-03-17 op 48
758 60aa1fa0 2022-03-17 op 49
759 60aa1fa0 2022-03-17 op -50
760 60aa1fa0 2022-03-17 op +midway tru it!
761 60aa1fa0 2022-03-17 op 51
762 60aa1fa0 2022-03-17 op 52
763 60aa1fa0 2022-03-17 op 53
764 60aa1fa0 2022-03-17 op @@ -87,7 +87,7 @@
765 60aa1fa0 2022-03-17 op 87
766 60aa1fa0 2022-03-17 op 88
767 60aa1fa0 2022-03-17 op 89
768 60aa1fa0 2022-03-17 op -90
769 60aa1fa0 2022-03-17 op +almost there!
770 60aa1fa0 2022-03-17 op 91
771 60aa1fa0 2022-03-17 op 92
772 60aa1fa0 2022-03-17 op 93
773 60aa1fa0 2022-03-17 op EOF
774 60aa1fa0 2022-03-17 op
775 60aa1fa0 2022-03-17 op jot 100 > $testroot/wt/numbers
776 5f94a4e0 2022-11-18 op ed -s "$testroot/wt/numbers" <<EOF
777 60aa1fa0 2022-03-17 op 1,10d
778 60aa1fa0 2022-03-17 op 50r !jot 20
779 60aa1fa0 2022-03-17 op w
780 60aa1fa0 2022-03-17 op q
781 60aa1fa0 2022-03-17 op EOF
782 60aa1fa0 2022-03-17 op
783 60aa1fa0 2022-03-17 op (cd $testroot/wt && got add numbers && got commit -m '+numbers') \
784 60aa1fa0 2022-03-17 op > /dev/null
785 60aa1fa0 2022-03-17 op ret=$?
786 60aa1fa0 2022-03-17 op if [ $ret -ne 0 ]; then
787 60aa1fa0 2022-03-17 op test_done $testroot $ret
788 60aa1fa0 2022-03-17 op return 1
789 60aa1fa0 2022-03-17 op fi
790 60aa1fa0 2022-03-17 op
791 60aa1fa0 2022-03-17 op (cd $testroot/wt && got patch patch) > $testroot/stdout
792 60aa1fa0 2022-03-17 op ret=$?
793 60aa1fa0 2022-03-17 op if [ $ret -ne 0 ]; then
794 60aa1fa0 2022-03-17 op test_done $testroot/wt $ret
795 60aa1fa0 2022-03-17 op return 1
796 60aa1fa0 2022-03-17 op fi
797 60aa1fa0 2022-03-17 op
798 60aa1fa0 2022-03-17 op cat <<EOF > $testroot/stdout.expected
799 60aa1fa0 2022-03-17 op M numbers
800 60aa1fa0 2022-03-17 op @@ -47,7 +47,7 @@ applied with offset -10
801 60aa1fa0 2022-03-17 op @@ -87,7 +87,7 @@ applied with offset 10
802 7a30b5cb 2022-03-20 op EOF
803 7a30b5cb 2022-03-20 op
804 7a30b5cb 2022-03-20 op cmp -s $testroot/stdout.expected $testroot/stdout
805 7a30b5cb 2022-03-20 op ret=$?
806 7a30b5cb 2022-03-20 op if [ $ret -ne 0 ]; then
807 7a30b5cb 2022-03-20 op diff -u $testroot/stdout.expected $testroot/stdout
808 7a30b5cb 2022-03-20 op fi
809 7a30b5cb 2022-03-20 op test_done $testroot $ret
810 7a30b5cb 2022-03-20 op }
811 7a30b5cb 2022-03-20 op
812 7a30b5cb 2022-03-20 op test_patch_prefer_new_path() {
813 7a30b5cb 2022-03-20 op local testroot=`test_init patch_orig`
814 7a30b5cb 2022-03-20 op
815 7a30b5cb 2022-03-20 op got checkout $testroot/repo $testroot/wt > /dev/null
816 7a30b5cb 2022-03-20 op ret=$?
817 7a30b5cb 2022-03-20 op if [ $ret -ne 0 ]; then
818 7a30b5cb 2022-03-20 op test_done $testroot $ret
819 7a30b5cb 2022-03-20 op return 1
820 7a30b5cb 2022-03-20 op fi
821 7a30b5cb 2022-03-20 op
822 7a30b5cb 2022-03-20 op cat <<EOF > $testroot/wt/patch
823 7a30b5cb 2022-03-20 op --- alpha.orig
824 7a30b5cb 2022-03-20 op +++ alpha
825 7a30b5cb 2022-03-20 op @@ -1 +1,2 @@
826 7a30b5cb 2022-03-20 op alpha
827 7a30b5cb 2022-03-20 op +was edited
828 60aa1fa0 2022-03-17 op EOF
829 60aa1fa0 2022-03-17 op
830 7a30b5cb 2022-03-20 op (cd $testroot/wt && got patch patch) > $testroot/stdout
831 7a30b5cb 2022-03-20 op ret=$?
832 7a30b5cb 2022-03-20 op if [ $ret -ne 0 ]; then
833 7a30b5cb 2022-03-20 op test_done $testroot $ret
834 7a30b5cb 2022-03-20 op return 1
835 7a30b5cb 2022-03-20 op fi
836 7a30b5cb 2022-03-20 op
837 3313bcd8 2022-04-19 op echo 'M alpha' > $testroot/stdout.expected
838 60aa1fa0 2022-03-17 op cmp -s $testroot/stdout.expected $testroot/stdout
839 60aa1fa0 2022-03-17 op ret=$?
840 60aa1fa0 2022-03-17 op if [ $ret -ne 0 ]; then
841 60aa1fa0 2022-03-17 op diff -u $testroot/stdout.expected $testroot/stdout
842 60aa1fa0 2022-03-17 op fi
843 60aa1fa0 2022-03-17 op test_done $testroot $ret
844 60aa1fa0 2022-03-17 op }
845 60aa1fa0 2022-03-17 op
846 b3c57ab2 2022-03-22 op test_patch_no_newline() {
847 b3c57ab2 2022-03-22 op local testroot=`test_init patch_no_newline`
848 b3c57ab2 2022-03-22 op
849 b3c57ab2 2022-03-22 op got checkout $testroot/repo $testroot/wt > /dev/null
850 b3c57ab2 2022-03-22 op ret=$?
851 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
852 b3c57ab2 2022-03-22 op test_done $testroot $ret
853 b3c57ab2 2022-03-22 op return 1
854 b3c57ab2 2022-03-22 op fi
855 b3c57ab2 2022-03-22 op
856 b3c57ab2 2022-03-22 op cat <<EOF > $testroot/wt/patch
857 b3c57ab2 2022-03-22 op --- /dev/null
858 b3c57ab2 2022-03-22 op +++ eta
859 b3c57ab2 2022-03-22 op @@ -0,0 +1 @@
860 b3c57ab2 2022-03-22 op +eta
861 b3c57ab2 2022-03-22 op \ No newline at end of file
862 b3c57ab2 2022-03-22 op EOF
863 b3c57ab2 2022-03-22 op
864 b3c57ab2 2022-03-22 op (cd $testroot/wt && got patch patch) > $testroot/stdout
865 b3c57ab2 2022-03-22 op ret=$?
866 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
867 b3c57ab2 2022-03-22 op test_done $testroot $ret
868 b3c57ab2 2022-03-22 op return 1
869 b3c57ab2 2022-03-22 op fi
870 b3c57ab2 2022-03-22 op
871 b3c57ab2 2022-03-22 op echo "A eta" > $testroot/stdout.expected
872 b3c57ab2 2022-03-22 op cmp -s $testroot/stdout.expected $testroot/stdout
873 b3c57ab2 2022-03-22 op ret=$?
874 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
875 b3c57ab2 2022-03-22 op diff -u $testroot/stdout.expected $testroot/stdout
876 b3c57ab2 2022-03-22 op test_done $testroot $ret
877 b3c57ab2 2022-03-22 op return 1
878 b3c57ab2 2022-03-22 op fi
879 b3c57ab2 2022-03-22 op
880 b3c57ab2 2022-03-22 op echo -n eta > $testroot/wt/eta.expected
881 b3c57ab2 2022-03-22 op cmp -s $testroot/wt/eta.expected $testroot/wt/eta
882 b3c57ab2 2022-03-22 op ret=$?
883 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
884 b3c57ab2 2022-03-22 op diff -u $testroot/wt/eta.expected $testroot/wt/eta
885 b3c57ab2 2022-03-22 op test_done $testroot $ret
886 b3c57ab2 2022-03-22 op return 1
887 b3c57ab2 2022-03-22 op fi
888 b3c57ab2 2022-03-22 op
889 b3c57ab2 2022-03-22 op (cd $testroot/wt && got commit -m 'add eta') > /dev/null
890 b3c57ab2 2022-03-22 op ret=$?
891 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
892 b3c57ab2 2022-03-22 op test_done $testroot $ret
893 b3c57ab2 2022-03-22 op return 1
894 b3c57ab2 2022-03-22 op fi
895 b3c57ab2 2022-03-22 op
896 b3c57ab2 2022-03-22 op cat <<EOF > $testroot/wt/patch
897 b3c57ab2 2022-03-22 op --- eta
898 b3c57ab2 2022-03-22 op +++ eta
899 b3c57ab2 2022-03-22 op @@ -1 +1 @@
900 b3c57ab2 2022-03-22 op -eta
901 b3c57ab2 2022-03-22 op \ No newline at end of file
902 b3c57ab2 2022-03-22 op +ETA
903 b3c57ab2 2022-03-22 op \ No newline at end of file
904 b3c57ab2 2022-03-22 op EOF
905 b3c57ab2 2022-03-22 op
906 b3c57ab2 2022-03-22 op (cd $testroot/wt && got patch patch) > $testroot/stdout
907 b3c57ab2 2022-03-22 op ret=$?
908 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
909 b3c57ab2 2022-03-22 op test_done $testroot $ret
910 b3c57ab2 2022-03-22 op return 1
911 b3c57ab2 2022-03-22 op fi
912 b3c57ab2 2022-03-22 op
913 b3c57ab2 2022-03-22 op echo "M eta" > $testroot/stdout.expected
914 b3c57ab2 2022-03-22 op cmp -s $testroot/stdout.expected $testroot/stdout
915 b3c57ab2 2022-03-22 op ret=$?
916 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
917 b3c57ab2 2022-03-22 op diff -u $testroot/stdout.expected $testroot/stdout
918 b3c57ab2 2022-03-22 op test_done $testroot $ret
919 b3c57ab2 2022-03-22 op return 1
920 b3c57ab2 2022-03-22 op fi
921 b3c57ab2 2022-03-22 op
922 b3c57ab2 2022-03-22 op echo -n ETA > $testroot/wt/eta.expected
923 b3c57ab2 2022-03-22 op cmp -s $testroot/wt/eta.expected $testroot/wt/eta
924 b3c57ab2 2022-03-22 op ret=$?
925 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
926 b3c57ab2 2022-03-22 op diff -u $testroot/wt/eta.expected $testroot/wt/eta
927 b3c57ab2 2022-03-22 op test_done $testroot $ret
928 b3c57ab2 2022-03-22 op return 1
929 b3c57ab2 2022-03-22 op fi
930 b3c57ab2 2022-03-22 op
931 b3c57ab2 2022-03-22 op (cd $testroot/wt && got commit -m 'edit eta') > /dev/null
932 b3c57ab2 2022-03-22 op ret=$?
933 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
934 b3c57ab2 2022-03-22 op test_done $testroot $ret
935 b3c57ab2 2022-03-22 op return 1
936 b3c57ab2 2022-03-22 op fi
937 b3c57ab2 2022-03-22 op
938 b3c57ab2 2022-03-22 op cat <<EOF > $testroot/wt/patch
939 b3c57ab2 2022-03-22 op --- eta
940 b3c57ab2 2022-03-22 op +++ eta
941 b3c57ab2 2022-03-22 op @@ -1 +1 @@
942 b3c57ab2 2022-03-22 op -ETA
943 b3c57ab2 2022-03-22 op \ No newline at end of file
944 b3c57ab2 2022-03-22 op +eta
945 b3c57ab2 2022-03-22 op EOF
946 b3c57ab2 2022-03-22 op
947 b3c57ab2 2022-03-22 op (cd $testroot/wt && got patch patch) > $testroot/stdout
948 b3c57ab2 2022-03-22 op ret=$?
949 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
950 b3c57ab2 2022-03-22 op test_done $testroot $ret
951 b3c57ab2 2022-03-22 op return 1
952 b3c57ab2 2022-03-22 op fi
953 b3c57ab2 2022-03-22 op
954 b3c57ab2 2022-03-22 op echo "M eta" > $testroot/stdout.expected
955 b3c57ab2 2022-03-22 op cmp -s $testroot/stdout.expected $testroot/stdout
956 b3c57ab2 2022-03-22 op ret=$?
957 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
958 b3c57ab2 2022-03-22 op diff -u $testroot/stdout.expected $testroot/stdout
959 b3c57ab2 2022-03-22 op test_done $testroot $ret
960 b3c57ab2 2022-03-22 op return 1
961 b3c57ab2 2022-03-22 op fi
962 b3c57ab2 2022-03-22 op
963 b3c57ab2 2022-03-22 op echo eta > $testroot/wt/eta.expected
964 b3c57ab2 2022-03-22 op cmp -s $testroot/wt/eta.expected $testroot/wt/eta
965 b3c57ab2 2022-03-22 op ret=$?
966 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
967 b3c57ab2 2022-03-22 op diff -u $testroot/wt/eta.expected $testroot/wt/eta
968 b3c57ab2 2022-03-22 op fi
969 b3c57ab2 2022-03-22 op test_done $testroot $ret
970 b3c57ab2 2022-03-22 op }
971 b3c57ab2 2022-03-22 op
972 9d6cabd5 2022-04-07 op test_patch_strip() {
973 9d6cabd5 2022-04-07 op local testroot=`test_init patch_strip`
974 9d6cabd5 2022-04-07 op
975 9d6cabd5 2022-04-07 op got checkout $testroot/repo $testroot/wt > /dev/null
976 9d6cabd5 2022-04-07 op ret=$?
977 9d6cabd5 2022-04-07 op if [ $ret -ne 0 ]; then
978 9d6cabd5 2022-04-07 op test_done $testroot $ret
979 9d6cabd5 2022-04-07 op return 1
980 9d6cabd5 2022-04-07 op fi
981 9d6cabd5 2022-04-07 op
982 9d6cabd5 2022-04-07 op cat <<EOF > $testroot/wt/patch
983 9d6cabd5 2022-04-07 op --- foo/bar/alpha.orig
984 9d6cabd5 2022-04-07 op +++ foo/bar/alpha
985 9d6cabd5 2022-04-07 op @@ -1 +1 @@
986 9d6cabd5 2022-04-07 op -alpha
987 9d6cabd5 2022-04-07 op +ALPHA
988 9d6cabd5 2022-04-07 op EOF
989 9d6cabd5 2022-04-07 op
990 9d6cabd5 2022-04-07 op (cd $testroot/wt && got patch -p2 patch) > $testroot/stdout
991 9d6cabd5 2022-04-07 op ret=$?
992 9d6cabd5 2022-04-07 op if [ $ret -ne 0 ]; then
993 9d6cabd5 2022-04-07 op test_done $testroot $ret
994 9d6cabd5 2022-04-07 op return 1
995 9d6cabd5 2022-04-07 op fi
996 9d6cabd5 2022-04-07 op
997 9d6cabd5 2022-04-07 op echo "M alpha" >> $testroot/stdout.expected
998 9d6cabd5 2022-04-07 op cmp -s $testroot/stdout.expected $testroot/stdout
999 9d6cabd5 2022-04-07 op ret=$?
1000 9d6cabd5 2022-04-07 op if [ $ret -ne 0 ]; then
1001 9d6cabd5 2022-04-07 op diff -u $testroot/stdout.expected $testroot/stdout
1002 9d6cabd5 2022-04-07 op test_done $testroot $ret
1003 9d6cabd5 2022-04-07 op return 1
1004 9d6cabd5 2022-04-07 op fi
1005 9d6cabd5 2022-04-07 op
1006 9d6cabd5 2022-04-07 op (cd $testroot/wt && got revert alpha) > /dev/null 2>&1
1007 9d6cabd5 2022-04-07 op ret=$?
1008 9d6cabd5 2022-04-07 op if [ $ret -ne 0 ]; then
1009 9d6cabd5 2022-04-07 op test_done $testroot $ret
1010 9d6cabd5 2022-04-07 op return 1
1011 9d6cabd5 2022-04-07 op fi
1012 9d6cabd5 2022-04-07 op
1013 9d6cabd5 2022-04-07 op (cd $testroot/wt && got patch -p3 patch) \
1014 9d6cabd5 2022-04-07 op 2> $testroot/stderr
1015 9d6cabd5 2022-04-07 op ret=$?
1016 9d6cabd5 2022-04-07 op if [ $ret -eq 0 ]; then
1017 9d6cabd5 2022-04-07 op echo "stripped more components than available!"
1018 9d6cabd5 2022-04-07 op test_done $testroot 1
1019 9d6cabd5 2022-04-07 op return 1
1020 9d6cabd5 2022-04-07 op fi
1021 9d6cabd5 2022-04-07 op
1022 9d6cabd5 2022-04-07 op cat <<EOF > $testroot/stderr.expected
1023 9d6cabd5 2022-04-07 op got: can't strip 1 path-components from foo/bar/alpha: bad path
1024 9d6cabd5 2022-04-07 op EOF
1025 9d6cabd5 2022-04-07 op
1026 9d6cabd5 2022-04-07 op cmp -s $testroot/stderr.expected $testroot/stderr
1027 9d6cabd5 2022-04-07 op ret=$?
1028 9d6cabd5 2022-04-07 op if [ $ret -ne 0 ]; then
1029 9d6cabd5 2022-04-07 op diff -u $testroot/stderr.expected $testroot/stderr
1030 9d6cabd5 2022-04-07 op fi
1031 9d6cabd5 2022-04-07 op test_done $testroot 0
1032 a92a2042 2022-07-02 op }
1033 a92a2042 2022-07-02 op
1034 a92a2042 2022-07-02 op test_patch_whitespace() {
1035 a92a2042 2022-07-02 op local testroot=`test_init patch_whitespace`
1036 a92a2042 2022-07-02 op
1037 a92a2042 2022-07-02 op got checkout $testroot/repo $testroot/wt > /dev/null
1038 a92a2042 2022-07-02 op ret=$?
1039 a92a2042 2022-07-02 op if [ $ret -ne 0 ]; then
1040 a92a2042 2022-07-02 op test_done $testroot $ret
1041 a92a2042 2022-07-02 op return 1
1042 a92a2042 2022-07-02 op fi
1043 a92a2042 2022-07-02 op
1044 a92a2042 2022-07-02 op trailing=" "
1045 a92a2042 2022-07-02 op
1046 a92a2042 2022-07-02 op cat <<EOF > $testroot/wt/hello.c
1047 a92a2042 2022-07-02 op #include <stdio.h>
1048 a92a2042 2022-07-02 op
1049 a92a2042 2022-07-02 op int
1050 a92a2042 2022-07-02 op main(void)
1051 a92a2042 2022-07-02 op {
1052 a92a2042 2022-07-02 op /* the trailing whitespace is on purpose */
1053 a92a2042 2022-07-02 op printf("hello, world\n");$trailing
1054 a92a2042 2022-07-02 op return 0;
1055 a92a2042 2022-07-02 op }
1056 a92a2042 2022-07-02 op EOF
1057 a92a2042 2022-07-02 op
1058 a92a2042 2022-07-02 op (cd $testroot/wt && got add hello.c && got ci -m '+hello.c') \
1059 a92a2042 2022-07-02 op > /dev/null
1060 a92a2042 2022-07-02 op ret=$?
1061 a92a2042 2022-07-02 op if [ $ret -ne 0 ]; then
1062 a92a2042 2022-07-02 op test_done $testroot $ret
1063 a92a2042 2022-07-02 op return 1
1064 a92a2042 2022-07-02 op fi
1065 a92a2042 2022-07-02 op
1066 a92a2042 2022-07-02 op # test with a diff with various whitespace corruptions
1067 a92a2042 2022-07-02 op cat <<EOF > $testroot/wt/patch
1068 a92a2042 2022-07-02 op --- hello.c
1069 a92a2042 2022-07-02 op +++ hello.c
1070 a92a2042 2022-07-02 op @@ -5,5 +5,5 @@
1071 a92a2042 2022-07-02 op {
1072 a92a2042 2022-07-02 op /* the trailing whitespace is on purpose */
1073 a92a2042 2022-07-02 op printf("hello, world\n");
1074 a92a2042 2022-07-02 op - return 0;
1075 a92a2042 2022-07-02 op + return 5; /* always fails */
1076 a92a2042 2022-07-02 op }
1077 a92a2042 2022-07-02 op EOF
1078 a92a2042 2022-07-02 op
1079 a92a2042 2022-07-02 op (cd $testroot/wt && got patch patch) \
1080 a92a2042 2022-07-02 op 2>$testroot/stderr >$testroot/stdout
1081 a92a2042 2022-07-02 op ret=$?
1082 a92a2042 2022-07-02 op if [ $ret -ne 0 ]; then
1083 a92a2042 2022-07-02 op echo "failed to apply diff" >&2
1084 a92a2042 2022-07-02 op test_done $testroot $ret
1085 a92a2042 2022-07-02 op return 1
1086 a92a2042 2022-07-02 op fi
1087 a92a2042 2022-07-02 op
1088 a92a2042 2022-07-02 op echo 'M hello.c' > $testroot/stdout.expected
1089 a92a2042 2022-07-02 op echo '@@ -5,5 +5,5 @@ hunk contains mangled whitespace' \
1090 a92a2042 2022-07-02 op >> $testroot/stdout.expected
1091 a92a2042 2022-07-02 op cmp -s $testroot/stdout.expected $testroot/stdout
1092 a92a2042 2022-07-02 op ret=$?
1093 a92a2042 2022-07-02 op if [ $ret -ne 0 ]; then
1094 a92a2042 2022-07-02 op diff -u $testroot/stdout.expected $testroot/stdout
1095 a92a2042 2022-07-02 op test_done $testroot $ret
1096 a92a2042 2022-07-02 op return 1
1097 a92a2042 2022-07-02 op fi
1098 a92a2042 2022-07-02 op
1099 a92a2042 2022-07-02 op cat <<EOF > $testroot/wt/hello.c.expected
1100 a92a2042 2022-07-02 op #include <stdio.h>
1101 a92a2042 2022-07-02 op
1102 a92a2042 2022-07-02 op int
1103 a92a2042 2022-07-02 op main(void)
1104 a92a2042 2022-07-02 op {
1105 a92a2042 2022-07-02 op /* the trailing whitespace is on purpose */
1106 a92a2042 2022-07-02 op printf("hello, world\n");$trailing
1107 a92a2042 2022-07-02 op return 5; /* always fails */
1108 a92a2042 2022-07-02 op }
1109 a92a2042 2022-07-02 op EOF
1110 a92a2042 2022-07-02 op
1111 a92a2042 2022-07-02 op cmp -s $testroot/wt/hello.c.expected $testroot/wt/hello.c
1112 a92a2042 2022-07-02 op ret=$?
1113 a92a2042 2022-07-02 op if [ $ret -ne 0 ]; then
1114 a92a2042 2022-07-02 op diff -u $testroot/wt/hello.c.expected $testroot/wt/hello.c
1115 a92a2042 2022-07-02 op fi
1116 a92a2042 2022-07-02 op test_done $testroot $ret
1117 9d6cabd5 2022-04-07 op }
1118 ed3bff83 2022-04-23 op
1119 ed3bff83 2022-04-23 op test_patch_relative_paths() {
1120 f1d6cebb 2022-04-23 op local testroot=`test_init patch_relative_paths`
1121 ed3bff83 2022-04-23 op
1122 ed3bff83 2022-04-23 op got checkout $testroot/repo $testroot/wt > /dev/null
1123 ed3bff83 2022-04-23 op ret=$?
1124 ed3bff83 2022-04-23 op if [ $ret -ne 0 ]; then
1125 ed3bff83 2022-04-23 op test_done $testroot $ret
1126 ed3bff83 2022-04-23 op return 1
1127 ed3bff83 2022-04-23 op fi
1128 9d6cabd5 2022-04-07 op
1129 ed3bff83 2022-04-23 op cat <<EOF > $testroot/wt/gamma/patch
1130 ed3bff83 2022-04-23 op --- delta
1131 ed3bff83 2022-04-23 op +++ delta
1132 ed3bff83 2022-04-23 op @@ -1 +1 @@
1133 ed3bff83 2022-04-23 op -delta
1134 ed3bff83 2022-04-23 op +DELTA
1135 ed3bff83 2022-04-23 op --- /dev/null
1136 ed3bff83 2022-04-23 op +++ eta
1137 ed3bff83 2022-04-23 op @@ -0,0 +1 @@
1138 ed3bff83 2022-04-23 op +eta
1139 ed3bff83 2022-04-23 op EOF
1140 ed3bff83 2022-04-23 op
1141 ed3bff83 2022-04-23 op (cd $testroot/wt/gamma && got patch patch) > $testroot/stdout
1142 ed3bff83 2022-04-23 op ret=$?
1143 ed3bff83 2022-04-23 op if [ $ret -ne 0 ]; then
1144 ed3bff83 2022-04-23 op test_done $testroot $ret
1145 ed3bff83 2022-04-23 op return 1
1146 ed3bff83 2022-04-23 op fi
1147 ed3bff83 2022-04-23 op
1148 ed3bff83 2022-04-23 op echo 'M gamma/delta' > $testroot/stdout.expected
1149 ed3bff83 2022-04-23 op echo 'A gamma/eta' >> $testroot/stdout.expected
1150 15e1bda6 2022-04-23 op
1151 15e1bda6 2022-04-23 op cmp -s $testroot/stdout.expected $testroot/stdout
1152 15e1bda6 2022-04-23 op ret=$?
1153 15e1bda6 2022-04-23 op if [ $ret -ne 0 ]; then
1154 15e1bda6 2022-04-23 op diff -u $testroot/stdout.expected $testroot/stdout
1155 15e1bda6 2022-04-23 op fi
1156 15e1bda6 2022-04-23 op test_done $testroot $ret
1157 15e1bda6 2022-04-23 op }
1158 15e1bda6 2022-04-23 op
1159 15e1bda6 2022-04-23 op test_patch_with_path_prefix() {
1160 15e1bda6 2022-04-23 op local testroot=`test_init patch_with_path_prefix`
1161 15e1bda6 2022-04-23 op
1162 15e1bda6 2022-04-23 op got checkout -p gamma $testroot/repo $testroot/wt > /dev/null
1163 15e1bda6 2022-04-23 op ret=$?
1164 15e1bda6 2022-04-23 op if [ $ret -ne 0 ]; then
1165 15e1bda6 2022-04-23 op test_done $testroot $ret
1166 15e1bda6 2022-04-23 op return 1
1167 15e1bda6 2022-04-23 op fi
1168 15e1bda6 2022-04-23 op
1169 15e1bda6 2022-04-23 op cat <<EOF > $testroot/wt/patch
1170 15e1bda6 2022-04-23 op --- delta
1171 15e1bda6 2022-04-23 op +++ delta
1172 15e1bda6 2022-04-23 op @@ -1 +1 @@
1173 15e1bda6 2022-04-23 op -delta
1174 15e1bda6 2022-04-23 op +DELTA
1175 15e1bda6 2022-04-23 op --- /dev/null
1176 15e1bda6 2022-04-23 op +++ eta
1177 15e1bda6 2022-04-23 op @@ -0,0 +1 @@
1178 15e1bda6 2022-04-23 op +eta
1179 15e1bda6 2022-04-23 op EOF
1180 15e1bda6 2022-04-23 op
1181 15e1bda6 2022-04-23 op (cd $testroot/wt && got patch patch) > $testroot/stdout
1182 15e1bda6 2022-04-23 op ret=$?
1183 15e1bda6 2022-04-23 op if [ $ret -ne 0 ]; then
1184 15e1bda6 2022-04-23 op test_done $testroot $ret
1185 15e1bda6 2022-04-23 op return 1
1186 15e1bda6 2022-04-23 op fi
1187 15e1bda6 2022-04-23 op
1188 15e1bda6 2022-04-23 op echo 'M delta' > $testroot/stdout.expected
1189 15e1bda6 2022-04-23 op echo 'A eta' >> $testroot/stdout.expected
1190 15e1bda6 2022-04-23 op
1191 15e1bda6 2022-04-23 op cmp -s $testroot/stdout.expected $testroot/stdout
1192 15e1bda6 2022-04-23 op ret=$?
1193 15e1bda6 2022-04-23 op if [ $ret -ne 0 ]; then
1194 15e1bda6 2022-04-23 op diff -u $testroot/stdout.expected $testroot/stdout
1195 15e1bda6 2022-04-23 op fi
1196 15e1bda6 2022-04-23 op test_done $testroot $ret
1197 15e1bda6 2022-04-23 op }
1198 ed3bff83 2022-04-23 op
1199 15e1bda6 2022-04-23 op test_patch_relpath_with_path_prefix() {
1200 15e1bda6 2022-04-23 op local testroot=`test_init patch_relpaths_with_path_prefix`
1201 15e1bda6 2022-04-23 op
1202 15e1bda6 2022-04-23 op got checkout -p gamma $testroot/repo $testroot/wt > /dev/null
1203 15e1bda6 2022-04-23 op ret=$?
1204 15e1bda6 2022-04-23 op if [ $ret -ne 0 ]; then
1205 15e1bda6 2022-04-23 op test_done $testroot $ret
1206 15e1bda6 2022-04-23 op return 1
1207 15e1bda6 2022-04-23 op fi
1208 15e1bda6 2022-04-23 op
1209 15e1bda6 2022-04-23 op mkdir -p $testroot/wt/epsilon/zeta/
1210 15e1bda6 2022-04-23 op
1211 15e1bda6 2022-04-23 op cat <<EOF > $testroot/wt/patch
1212 15e1bda6 2022-04-23 op --- /dev/null
1213 15e1bda6 2022-04-23 op +++ zeta/theta
1214 15e1bda6 2022-04-23 op @@ -0,0 +1 @@
1215 15e1bda6 2022-04-23 op +theta
1216 15e1bda6 2022-04-23 op EOF
1217 15e1bda6 2022-04-23 op
1218 15e1bda6 2022-04-23 op (cd $testroot/wt/epsilon/zeta && got patch -p1 $testroot/wt/patch) \
1219 15e1bda6 2022-04-23 op > $testroot/stdout
1220 15e1bda6 2022-04-23 op ret=$?
1221 15e1bda6 2022-04-23 op if [ $ret -ne 0 ]; then
1222 15e1bda6 2022-04-23 op test_done $testroot $ret
1223 15e1bda6 2022-04-23 op return 1
1224 15e1bda6 2022-04-23 op fi
1225 15e1bda6 2022-04-23 op
1226 15e1bda6 2022-04-23 op echo 'A epsilon/zeta/theta' >> $testroot/stdout.expected
1227 15e1bda6 2022-04-23 op
1228 ed3bff83 2022-04-23 op cmp -s $testroot/stdout.expected $testroot/stdout
1229 ed3bff83 2022-04-23 op ret=$?
1230 ed3bff83 2022-04-23 op if [ $ret -ne 0 ]; then
1231 ed3bff83 2022-04-23 op diff -u $testroot/stdout.expected $testroot/stdout
1232 15e1bda6 2022-04-23 op test_done $testroot $ret
1233 15e1bda6 2022-04-23 op return 1
1234 ed3bff83 2022-04-23 op fi
1235 15e1bda6 2022-04-23 op
1236 15e1bda6 2022-04-23 op echo 'theta' > $testroot/theta.expected
1237 15e1bda6 2022-04-23 op cmp -s $testroot/wt/epsilon/zeta/theta $testroot/theta.expected
1238 15e1bda6 2022-04-23 op ret=$?
1239 15e1bda6 2022-04-23 op if [ $ret -ne 0 ]; then
1240 15e1bda6 2022-04-23 op diff -u $testroot/wt/epsilon/zeta/theta $testroot/theta.expected
1241 15e1bda6 2022-04-23 op fi
1242 ed3bff83 2022-04-23 op test_done $testroot $ret
1243 ed3bff83 2022-04-23 op }
1244 bad961bf 2022-04-23 op
1245 bad961bf 2022-04-23 op test_patch_reverse() {
1246 bad961bf 2022-04-23 op local testroot=`test_init patch_reverse`
1247 bad961bf 2022-04-23 op
1248 bad961bf 2022-04-23 op got checkout $testroot/repo $testroot/wt > /dev/null
1249 bad961bf 2022-04-23 op ret=$?
1250 bad961bf 2022-04-23 op if [ $ret -ne 0 ]; then
1251 bad961bf 2022-04-23 op test_done $testroot $ret
1252 bad961bf 2022-04-23 op return 1
1253 bad961bf 2022-04-23 op fi
1254 bad961bf 2022-04-23 op
1255 bad961bf 2022-04-23 op cat <<EOF > $testroot/wt/patch
1256 bad961bf 2022-04-23 op --- alpha
1257 bad961bf 2022-04-23 op +++ alpha
1258 bad961bf 2022-04-23 op @@ -1 +1 @@
1259 bad961bf 2022-04-23 op -ALPHA
1260 bad961bf 2022-04-23 op \ No newline at end of file
1261 bad961bf 2022-04-23 op +alpha
1262 bad961bf 2022-04-23 op EOF
1263 ed3bff83 2022-04-23 op
1264 bad961bf 2022-04-23 op (cd $testroot/wt && got patch -R patch) > $testroot/stdout
1265 bad961bf 2022-04-23 op ret=$?
1266 bad961bf 2022-04-23 op if [ $ret -ne 0 ]; then
1267 bad961bf 2022-04-23 op test_done $testroot $ret
1268 bad961bf 2022-04-23 op return 1
1269 bad961bf 2022-04-23 op fi
1270 bad961bf 2022-04-23 op
1271 bad961bf 2022-04-23 op echo "M alpha" > $testroot/stdout.expected
1272 bad961bf 2022-04-23 op cmp -s $testroot/stdout.expected $testroot/stdout
1273 bad961bf 2022-04-23 op ret=$?
1274 bad961bf 2022-04-23 op if [ $ret -ne 0 ]; then
1275 bad961bf 2022-04-23 op diff -u $testroot/stdout.expected $testroot/stdout
1276 bad961bf 2022-04-23 op test_done $testroot $ret
1277 bad961bf 2022-04-23 op return 1
1278 bad961bf 2022-04-23 op fi
1279 bad961bf 2022-04-23 op
1280 bad961bf 2022-04-23 op echo -n ALPHA > $testroot/wt/alpha.expected
1281 bad961bf 2022-04-23 op cmp -s $testroot/wt/alpha.expected $testroot/wt/alpha
1282 bad961bf 2022-04-23 op ret=$?
1283 bad961bf 2022-04-23 op if [ $ret -ne 0 ]; then
1284 bad961bf 2022-04-23 op diff -u $testroot/wt/alpha.expected $testroot/wt/alpha
1285 55e9459f 2022-06-19 op fi
1286 55e9459f 2022-06-19 op test_done $testroot $ret
1287 55e9459f 2022-06-19 op }
1288 55e9459f 2022-06-19 op
1289 55e9459f 2022-06-19 op test_patch_merge_simple() {
1290 55e9459f 2022-06-19 op local testroot=`test_init patch_merge_simple`
1291 55e9459f 2022-06-19 op
1292 55e9459f 2022-06-19 op got checkout $testroot/repo $testroot/wt > /dev/null
1293 55e9459f 2022-06-19 op ret=$?
1294 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1295 55e9459f 2022-06-19 op test_done $testroot $ret
1296 55e9459f 2022-06-19 op return 1
1297 55e9459f 2022-06-19 op fi
1298 55e9459f 2022-06-19 op
1299 55e9459f 2022-06-19 op jot 10 > $testroot/wt/numbers
1300 5dffb1a1 2022-07-02 op chmod +x $testroot/wt/numbers
1301 55e9459f 2022-06-19 op (cd $testroot/wt && got add numbers && got commit -m +numbers) \
1302 55e9459f 2022-06-19 op > /dev/null
1303 55e9459f 2022-06-19 op ret=$?
1304 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1305 55e9459f 2022-06-19 op test_done $testroot $ret
1306 55e9459f 2022-06-19 op return 1
1307 55e9459f 2022-06-19 op fi
1308 55e9459f 2022-06-19 op
1309 55e9459f 2022-06-19 op jot 10 | sed 's/4/four/g' > $testroot/wt/numbers
1310 55e9459f 2022-06-19 op
1311 55e9459f 2022-06-19 op (cd $testroot/wt && got diff > $testroot/old.diff \
1312 55e9459f 2022-06-19 op && got revert numbers) >/dev/null
1313 55e9459f 2022-06-19 op ret=$?
1314 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1315 55e9459f 2022-06-19 op test_done $testroot $ret
1316 55e9459f 2022-06-19 op return 1
1317 55e9459f 2022-06-19 op fi
1318 55e9459f 2022-06-19 op
1319 55e9459f 2022-06-19 op jot 10 | sed 's/6/six/g' > $testroot/wt/numbers
1320 55e9459f 2022-06-19 op (cd $testroot/wt && got commit -m 'edit numbers') \
1321 55e9459f 2022-06-19 op > /dev/null
1322 55e9459f 2022-06-19 op ret=$?
1323 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1324 55e9459f 2022-06-19 op test_done $testroot $ret
1325 55e9459f 2022-06-19 op return 1
1326 55e9459f 2022-06-19 op fi
1327 55e9459f 2022-06-19 op
1328 55e9459f 2022-06-19 op (cd $testroot/wt && got patch $testroot/old.diff) \
1329 9802c41c 2022-06-21 op > $testroot/stdout
1330 55e9459f 2022-06-19 op ret=$?
1331 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1332 9802c41c 2022-06-21 op test_done $testroot $ret
1333 9802c41c 2022-06-21 op return 1
1334 9802c41c 2022-06-21 op fi
1335 9802c41c 2022-06-21 op
1336 9802c41c 2022-06-21 op echo 'G numbers' > $testroot/stdout.expected
1337 9802c41c 2022-06-21 op cmp -s $testroot/stdout $testroot/stdout.expected
1338 9802c41c 2022-06-21 op ret=$?
1339 9802c41c 2022-06-21 op if [ $ret -ne 0 ]; then
1340 9802c41c 2022-06-21 op diff -u $testroot/stdout $testroot/stdout.expected
1341 55e9459f 2022-06-19 op test_done $testroot $ret
1342 55e9459f 2022-06-19 op return 1
1343 55e9459f 2022-06-19 op fi
1344 55e9459f 2022-06-19 op
1345 55e9459f 2022-06-19 op jot 10 | sed -e s/4/four/ -e s/6/six/ > $testroot/wt/numbers.expected
1346 55e9459f 2022-06-19 op cmp -s $testroot/wt/numbers $testroot/wt/numbers.expected
1347 55e9459f 2022-06-19 op ret=$?
1348 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1349 55e9459f 2022-06-19 op diff -u $testroot/wt/numbers $testroot/wt/numbers.expected
1350 5dffb1a1 2022-07-02 op test_done $testroot $ret
1351 5dffb1a1 2022-07-02 op return 1
1352 db0dfdd7 2022-06-27 op fi
1353 5dffb1a1 2022-07-02 op
1354 5dffb1a1 2022-07-02 op test -x $testroot/wt/numbers
1355 5dffb1a1 2022-07-02 op ret=$?
1356 5dffb1a1 2022-07-02 op if [ $ret -ne 0 ]; then
1357 5dffb1a1 2022-07-02 op echo "numbers lost the executable bit" >&2
1358 5dffb1a1 2022-07-02 op fi
1359 db0dfdd7 2022-06-27 op test_done $testroot $ret
1360 db0dfdd7 2022-06-27 op }
1361 db0dfdd7 2022-06-27 op
1362 db0dfdd7 2022-06-27 op test_patch_merge_gitdiff() {
1363 db0dfdd7 2022-06-27 op local testroot=`test_init patch_merge_gitdiff`
1364 db0dfdd7 2022-06-27 op
1365 db0dfdd7 2022-06-27 op jot 10 > $testroot/repo/numbers
1366 db0dfdd7 2022-06-27 op (cd $testroot/repo && git add numbers && \
1367 db0dfdd7 2022-06-27 op git_commit $testroot/repo -m "nums")
1368 db0dfdd7 2022-06-27 op ret=$?
1369 db0dfdd7 2022-06-27 op if [ $ret -ne 0 ]; then
1370 db0dfdd7 2022-06-27 op test_done $testroot $ret
1371 db0dfdd7 2022-06-27 op return 1
1372 db0dfdd7 2022-06-27 op fi
1373 db0dfdd7 2022-06-27 op
1374 db0dfdd7 2022-06-27 op jot 10 | sed 's/4/four/g' > $testroot/repo/numbers
1375 db0dfdd7 2022-06-27 op (cd $testroot/repo && git diff > $testroot/old.diff)
1376 db0dfdd7 2022-06-27 op ret=$?
1377 db0dfdd7 2022-06-27 op if [ $ret -ne 0 ]; then
1378 db0dfdd7 2022-06-27 op test_done $testroot $ret
1379 db0dfdd7 2022-06-27 op return 1
1380 db0dfdd7 2022-06-27 op fi
1381 db0dfdd7 2022-06-27 op
1382 db0dfdd7 2022-06-27 op # restore numbers
1383 db0dfdd7 2022-06-27 op jot 10 > $testroot/repo/numbers
1384 db0dfdd7 2022-06-27 op
1385 db0dfdd7 2022-06-27 op jot 10 | sed 's/6/six/g' > $testroot/repo/numbers
1386 db0dfdd7 2022-06-27 op (cd $testroot/repo && git add numbers && \
1387 db0dfdd7 2022-06-27 op git_commit $testroot/repo -m "edit")
1388 db0dfdd7 2022-06-27 op ret=$?
1389 db0dfdd7 2022-06-27 op if [ $ret -ne 0 ]; then
1390 db0dfdd7 2022-06-27 op test_done $testroot $ret
1391 db0dfdd7 2022-06-27 op return 1
1392 db0dfdd7 2022-06-27 op fi
1393 db0dfdd7 2022-06-27 op
1394 db0dfdd7 2022-06-27 op # now work with got:
1395 db0dfdd7 2022-06-27 op got checkout $testroot/repo $testroot/wt > /dev/null
1396 db0dfdd7 2022-06-27 op ret=$?
1397 db0dfdd7 2022-06-27 op if [ $ret -ne 0 ]; then
1398 db0dfdd7 2022-06-27 op test_done $testroot $ret
1399 db0dfdd7 2022-06-27 op return 1
1400 db0dfdd7 2022-06-27 op fi
1401 db0dfdd7 2022-06-27 op
1402 db0dfdd7 2022-06-27 op (cd $testroot/wt && got patch $testroot/old.diff) > $testroot/stdout
1403 db0dfdd7 2022-06-27 op ret=$?
1404 db0dfdd7 2022-06-27 op if [ $ret -ne 0 ]; then
1405 db0dfdd7 2022-06-27 op test_done $testroot $ret
1406 db0dfdd7 2022-06-27 op return 1
1407 55e9459f 2022-06-19 op fi
1408 db0dfdd7 2022-06-27 op
1409 db0dfdd7 2022-06-27 op echo 'G numbers' > $testroot/stdout.expected
1410 db0dfdd7 2022-06-27 op cmp -s $testroot/stdout $testroot/stdout.expected
1411 db0dfdd7 2022-06-27 op ret=$?
1412 db0dfdd7 2022-06-27 op if [ $ret -ne 0 ]; then
1413 db0dfdd7 2022-06-27 op diff -u $testroot/stdout $testroot/stdout.expected
1414 db0dfdd7 2022-06-27 op fi
1415 55e9459f 2022-06-19 op test_done $testroot $ret
1416 55e9459f 2022-06-19 op }
1417 5f56d41e 2022-07-28 op
1418 5f56d41e 2022-07-28 op test_patch_merge_base_provided() {
1419 5f56d41e 2022-07-28 op local testroot=`test_init patch_merge_base_provided`
1420 5f56d41e 2022-07-28 op
1421 5f56d41e 2022-07-28 op got checkout $testroot/repo $testroot/wt >/dev/null
1422 5f56d41e 2022-07-28 op ret=$?
1423 5f56d41e 2022-07-28 op if [ $ret -ne 0 ]; then
1424 5f56d41e 2022-07-28 op test_done $testroot $ret
1425 5f56d41e 2022-07-28 op return 1
1426 5f56d41e 2022-07-28 op fi
1427 5f56d41e 2022-07-28 op
1428 5f56d41e 2022-07-28 op jot 10 > $testroot/wt/numbers
1429 5f56d41e 2022-07-28 op (cd $testroot/wt && got add numbers && got commit -m +numbers) \
1430 5f56d41e 2022-07-28 op >/dev/null
1431 5f56d41e 2022-07-28 op ret=$?
1432 5f56d41e 2022-07-28 op if [ $ret -ne 0 ]; then
1433 5f56d41e 2022-07-28 op test_done $testroot $ret
1434 5f56d41e 2022-07-28 op return 1
1435 5f56d41e 2022-07-28 op fi
1436 55e9459f 2022-06-19 op
1437 5f56d41e 2022-07-28 op local commit_id=`git_show_head $testroot/repo`
1438 5f56d41e 2022-07-28 op
1439 5f56d41e 2022-07-28 op jot 10 | sed s/4/four/ > $testroot/wt/numbers
1440 5f56d41e 2022-07-28 op
1441 5f56d41e 2022-07-28 op # get rid of the metadata
1442 5f56d41e 2022-07-28 op (cd $testroot/wt && got diff | sed -n '/^---/,$p' > patch) \
1443 5f56d41e 2022-07-28 op >/dev/null
1444 5f56d41e 2022-07-28 op
1445 5f56d41e 2022-07-28 op jot 10 | sed s/6/six/ > $testroot/wt/numbers
1446 5f56d41e 2022-07-28 op (cd $testroot/wt && got commit -m 'edit numbers') >/dev/null
1447 5f56d41e 2022-07-28 op ret=$?
1448 5f56d41e 2022-07-28 op if [ $ret -ne 0 ]; then
1449 5f56d41e 2022-07-28 op test_done $testroot $ret
1450 5f56d41e 2022-07-28 op return 1
1451 5f56d41e 2022-07-28 op fi
1452 5f56d41e 2022-07-28 op
1453 5f56d41e 2022-07-28 op (cd $testroot/wt && got patch -c $commit_id patch) >$testroot/stdout
1454 5f56d41e 2022-07-28 op ret=$?
1455 5f56d41e 2022-07-28 op if [ $ret -ne 0 ]; then
1456 5f56d41e 2022-07-28 op test_done $testroot $ret
1457 5f56d41e 2022-07-28 op return 1
1458 5f56d41e 2022-07-28 op fi
1459 5f56d41e 2022-07-28 op
1460 5f56d41e 2022-07-28 op echo 'G numbers' > $testroot/stdout.expected
1461 5f56d41e 2022-07-28 op cmp -s $testroot/stdout $testroot/stdout.expected
1462 5f56d41e 2022-07-28 op ret=$?
1463 5f56d41e 2022-07-28 op if [ $ret -ne 0 ]; then
1464 5f56d41e 2022-07-28 op diff -u $testroot/stdout $testroot/stdout.expected
1465 5f56d41e 2022-07-28 op test_done $testroot $ret
1466 5f56d41e 2022-07-28 op return 1
1467 5f56d41e 2022-07-28 op fi
1468 5f56d41e 2022-07-28 op
1469 5f56d41e 2022-07-28 op jot 10 | sed -e s/4/four/ -e s/6/six/ > $testroot/wt/numbers.expected
1470 5f56d41e 2022-07-28 op cmp -s $testroot/wt/numbers $testroot/wt/numbers.expected
1471 5f56d41e 2022-07-28 op ret=$?
1472 5f56d41e 2022-07-28 op if [ $ret -ne 0 ]; then
1473 5f56d41e 2022-07-28 op diff -u $testroot/wt/numbers $testroot/wt/numbers.expected
1474 5f56d41e 2022-07-28 op fi
1475 5f56d41e 2022-07-28 op test_done $testroot $ret
1476 5f56d41e 2022-07-28 op }
1477 5f56d41e 2022-07-28 op
1478 55e9459f 2022-06-19 op test_patch_merge_conflict() {
1479 55e9459f 2022-06-19 op local testroot=`test_init patch_merge_conflict`
1480 55e9459f 2022-06-19 op
1481 55e9459f 2022-06-19 op got checkout $testroot/repo $testroot/wt > /dev/null
1482 55e9459f 2022-06-19 op ret=$?
1483 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1484 55e9459f 2022-06-19 op test_done $testroot $ret
1485 55e9459f 2022-06-19 op return 1
1486 55e9459f 2022-06-19 op fi
1487 55e9459f 2022-06-19 op
1488 55e9459f 2022-06-19 op jot 10 > $testroot/wt/numbers
1489 55e9459f 2022-06-19 op (cd $testroot/wt && got add numbers && got commit -m +numbers) \
1490 55e9459f 2022-06-19 op > /dev/null
1491 55e9459f 2022-06-19 op ret=$?
1492 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1493 55e9459f 2022-06-19 op test_done $testroot $ret
1494 55e9459f 2022-06-19 op return 1
1495 55e9459f 2022-06-19 op fi
1496 d8b5af43 2022-06-19 op
1497 d8b5af43 2022-06-19 op local commit_id=`git_show_head $testroot/repo`
1498 55e9459f 2022-06-19 op
1499 55e9459f 2022-06-19 op jot 10 | sed 's/6/six/g' > $testroot/wt/numbers
1500 acf749fc 2022-07-02 op echo ALPHA > $testroot/wt/alpha
1501 55e9459f 2022-06-19 op
1502 55e9459f 2022-06-19 op (cd $testroot/wt && got diff > $testroot/old.diff \
1503 acf749fc 2022-07-02 op && got revert alpha numbers) >/dev/null
1504 55e9459f 2022-06-19 op ret=$?
1505 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1506 55e9459f 2022-06-19 op test_done $testroot $ret
1507 55e9459f 2022-06-19 op return 1
1508 55e9459f 2022-06-19 op fi
1509 55e9459f 2022-06-19 op
1510 55e9459f 2022-06-19 op jot 10 | sed 's/6/3+3/g' > $testroot/wt/numbers
1511 acf749fc 2022-07-02 op jot -c 3 a > $testroot/wt/alpha
1512 acf749fc 2022-07-02 op (cd $testroot/wt && got commit -m 'edit alpha and numbers') \
1513 55e9459f 2022-06-19 op > /dev/null
1514 55e9459f 2022-06-19 op ret=$?
1515 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1516 55e9459f 2022-06-19 op test_done $testroot $ret
1517 55e9459f 2022-06-19 op return 1
1518 bad961bf 2022-04-23 op fi
1519 55e9459f 2022-06-19 op
1520 55e9459f 2022-06-19 op (cd $testroot/wt && got patch $testroot/old.diff) \
1521 9802c41c 2022-06-21 op > $testroot/stdout 2>/dev/null
1522 55e9459f 2022-06-19 op ret=$?
1523 55e9459f 2022-06-19 op if [ $ret -eq 0 ]; then
1524 55e9459f 2022-06-19 op echo "got patch merged a diff that should conflict" >&2
1525 55e9459f 2022-06-19 op test_done $testroot 0
1526 55e9459f 2022-06-19 op return 1
1527 55e9459f 2022-06-19 op fi
1528 55e9459f 2022-06-19 op
1529 acf749fc 2022-07-02 op echo 'C alpha' > $testroot/stdout.expected
1530 acf749fc 2022-07-02 op echo 'C numbers' >> $testroot/stdout.expected
1531 9802c41c 2022-06-21 op cmp -s $testroot/stdout $testroot/stdout.expected
1532 9802c41c 2022-06-21 op ret=$?
1533 9802c41c 2022-06-21 op if [ $ret -ne 0 ]; then
1534 9802c41c 2022-06-21 op diff -u $testroot/stdout $testroot/stdout.expected
1535 9802c41c 2022-06-21 op test_done $testroot $ret
1536 9802c41c 2022-06-21 op return 1
1537 9802c41c 2022-06-21 op fi
1538 9802c41c 2022-06-21 op
1539 55e9459f 2022-06-19 op # XXX: prefixing every line with a tab otherwise got thinks
1540 55e9459f 2022-06-19 op # the file has conflicts in it.
1541 acf749fc 2022-07-02 op cat <<-EOF > $testroot/wt/alpha.expected
1542 acf749fc 2022-07-02 op <<<<<<< --- alpha
1543 acf749fc 2022-07-02 op ALPHA
1544 acf749fc 2022-07-02 op ||||||| commit $commit_id
1545 acf749fc 2022-07-02 op alpha
1546 acf749fc 2022-07-02 op =======
1547 acf749fc 2022-07-02 op a
1548 acf749fc 2022-07-02 op b
1549 acf749fc 2022-07-02 op c
1550 acf749fc 2022-07-02 op >>>>>>> +++ alpha
1551 acf749fc 2022-07-02 op EOF
1552 acf749fc 2022-07-02 op
1553 55e9459f 2022-06-19 op cat <<-EOF > $testroot/wt/numbers.expected
1554 55e9459f 2022-06-19 op 1
1555 55e9459f 2022-06-19 op 2
1556 55e9459f 2022-06-19 op 3
1557 55e9459f 2022-06-19 op 4
1558 55e9459f 2022-06-19 op 5
1559 55e9459f 2022-06-19 op <<<<<<< --- numbers
1560 55e9459f 2022-06-19 op six
1561 d8b5af43 2022-06-19 op ||||||| commit $commit_id
1562 55e9459f 2022-06-19 op 6
1563 55e9459f 2022-06-19 op =======
1564 55e9459f 2022-06-19 op 3+3
1565 55e9459f 2022-06-19 op >>>>>>> +++ numbers
1566 55e9459f 2022-06-19 op 7
1567 55e9459f 2022-06-19 op 8
1568 55e9459f 2022-06-19 op 9
1569 55e9459f 2022-06-19 op 10
1570 55e9459f 2022-06-19 op EOF
1571 55e9459f 2022-06-19 op
1572 acf749fc 2022-07-02 op cmp -s $testroot/wt/alpha $testroot/wt/alpha.expected
1573 acf749fc 2022-07-02 op ret=$?
1574 acf749fc 2022-07-02 op if [ $ret -ne 0 ]; then
1575 acf749fc 2022-07-02 op diff -u $testroot/wt/alpha $testroot/wt/alpha.expected
1576 acf749fc 2022-07-02 op test_done $testroot $ret
1577 acf749fc 2022-07-02 op return 1
1578 acf749fc 2022-07-02 op fi
1579 acf749fc 2022-07-02 op
1580 55e9459f 2022-06-19 op cmp -s $testroot/wt/numbers $testroot/wt/numbers.expected
1581 55e9459f 2022-06-19 op ret=$?
1582 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1583 55e9459f 2022-06-19 op diff -u $testroot/wt/numbers $testroot/wt/numbers.expected
1584 55e9459f 2022-06-19 op fi
1585 bad961bf 2022-04-23 op test_done $testroot $ret
1586 bad961bf 2022-04-23 op }
1587 bad961bf 2022-04-23 op
1588 55e9459f 2022-06-19 op test_patch_merge_unknown_blob() {
1589 55e9459f 2022-06-19 op local testroot=`test_init patch_merge_unknown_blob`
1590 55e9459f 2022-06-19 op
1591 55e9459f 2022-06-19 op got checkout $testroot/repo $testroot/wt > /dev/null
1592 55e9459f 2022-06-19 op ret=$?
1593 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1594 55e9459f 2022-06-19 op test_done $testroot $ret
1595 55e9459f 2022-06-19 op return 1
1596 55e9459f 2022-06-19 op fi
1597 55e9459f 2022-06-19 op
1598 55e9459f 2022-06-19 op cat <<EOF > $testroot/wt/patch
1599 55e9459f 2022-06-19 op I've got a
1600 dbc68eed 2022-06-21 op diff aaaabbbbccccddddeeeeffff0000111122223333 foo/bar
1601 dbc68eed 2022-06-21 op with a
1602 55e9459f 2022-06-19 op blob - aaaabbbbccccddddeeeeffff0000111122223333
1603 55e9459f 2022-06-19 op and also a
1604 dbc68eed 2022-06-21 op blob + 0000111122223333444455556666777788889999
1605 55e9459f 2022-06-19 op for this dummy diff
1606 55e9459f 2022-06-19 op --- alpha
1607 55e9459f 2022-06-19 op +++ alpha
1608 55e9459f 2022-06-19 op @@ -1 +1 @@
1609 55e9459f 2022-06-19 op -alpha
1610 55e9459f 2022-06-19 op +ALPHA
1611 55e9459f 2022-06-19 op will it work?
1612 55e9459f 2022-06-19 op EOF
1613 55e9459f 2022-06-19 op
1614 55e9459f 2022-06-19 op (cd $testroot/wt/ && got patch patch) > $testroot/stdout
1615 55e9459f 2022-06-19 op ret=$?
1616 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1617 55e9459f 2022-06-19 op test_done $testroot $ret
1618 55e9459f 2022-06-19 op return 1
1619 55e9459f 2022-06-19 op fi
1620 55e9459f 2022-06-19 op
1621 55e9459f 2022-06-19 op echo 'M alpha' > $testroot/stdout.expected
1622 55e9459f 2022-06-19 op cmp -s $testroot/stdout.expected $testroot/stdout
1623 55e9459f 2022-06-19 op ret=$?
1624 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1625 55e9459f 2022-06-19 op diff -u $testroot/stdout.expected $testroot/stdout
1626 dbc68eed 2022-06-21 op test_done $testroot $ret
1627 dbc68eed 2022-06-21 op return 1
1628 55e9459f 2022-06-19 op fi
1629 dbc68eed 2022-06-21 op
1630 dbc68eed 2022-06-21 op # try again without a `diff' header
1631 dbc68eed 2022-06-21 op
1632 dbc68eed 2022-06-21 op cat <<EOF > $testroot/wt/patch
1633 dbc68eed 2022-06-21 op I've got a
1634 dbc68eed 2022-06-21 op blob - aaaabbbbccccddddeeeeffff0000111122223333
1635 dbc68eed 2022-06-21 op and also a
1636 dbc68eed 2022-06-21 op blob + 0000111122223333444455556666777788889999
1637 dbc68eed 2022-06-21 op for this dummy diff
1638 dbc68eed 2022-06-21 op --- alpha
1639 dbc68eed 2022-06-21 op +++ alpha
1640 dbc68eed 2022-06-21 op @@ -1 +1 @@
1641 dbc68eed 2022-06-21 op -alpha
1642 dbc68eed 2022-06-21 op +ALPHA
1643 dbc68eed 2022-06-21 op will it work?
1644 dbc68eed 2022-06-21 op EOF
1645 dbc68eed 2022-06-21 op
1646 dbc68eed 2022-06-21 op (cd $testroot/wt && got revert alpha > /dev/null && got patch patch) \
1647 dbc68eed 2022-06-21 op > $testroot/stdout
1648 dbc68eed 2022-06-21 op ret=$?
1649 dbc68eed 2022-06-21 op if [ $ret -ne 0 ]; then
1650 dbc68eed 2022-06-21 op test_done $testroot $ret
1651 dbc68eed 2022-06-21 op return 1
1652 dbc68eed 2022-06-21 op fi
1653 dbc68eed 2022-06-21 op
1654 dbc68eed 2022-06-21 op echo 'M alpha' > $testroot/stdout.expected
1655 dbc68eed 2022-06-21 op cmp -s $testroot/stdout.expected $testroot/stdout
1656 dbc68eed 2022-06-21 op ret=$?
1657 dbc68eed 2022-06-21 op if [ $ret -ne 0 ]; then
1658 dbc68eed 2022-06-21 op diff -u $testroot/stdout.expected $testroot/stdout
1659 db0dfdd7 2022-06-27 op test_done $testroot $ret
1660 db0dfdd7 2022-06-27 op return 1
1661 dbc68eed 2022-06-21 op fi
1662 db0dfdd7 2022-06-27 op
1663 db0dfdd7 2022-06-27 op # try again with a git-style diff
1664 db0dfdd7 2022-06-27 op
1665 db0dfdd7 2022-06-27 op cat <<EOF > $testroot/wt/patch
1666 db0dfdd7 2022-06-27 op diff --git a/alpha b/alpha
1667 db0dfdd7 2022-06-27 op index 0123456789ab..abcdef012345 100644
1668 db0dfdd7 2022-06-27 op --- a/alpha
1669 db0dfdd7 2022-06-27 op +++ b/alpha
1670 db0dfdd7 2022-06-27 op @@ -1 +1 @@
1671 db0dfdd7 2022-06-27 op -alpha
1672 db0dfdd7 2022-06-27 op +ALPHA
1673 db0dfdd7 2022-06-27 op EOF
1674 db0dfdd7 2022-06-27 op
1675 db0dfdd7 2022-06-27 op (cd $testroot/wt && got revert alpha > /dev/null && got patch patch) \
1676 db0dfdd7 2022-06-27 op > $testroot/stdout
1677 db0dfdd7 2022-06-27 op ret=$?
1678 db0dfdd7 2022-06-27 op if [ $ret -ne 0 ]; then
1679 db0dfdd7 2022-06-27 op test_done $testroot $ret
1680 db0dfdd7 2022-06-27 op return 1
1681 db0dfdd7 2022-06-27 op fi
1682 db0dfdd7 2022-06-27 op
1683 db0dfdd7 2022-06-27 op echo 'M alpha' > $testroot/stdout.expected
1684 db0dfdd7 2022-06-27 op cmp -s $testroot/stdout.expected $testroot/stdout
1685 db0dfdd7 2022-06-27 op ret=$?
1686 db0dfdd7 2022-06-27 op if [ $ret -ne 0 ]; then
1687 db0dfdd7 2022-06-27 op diff -u $testroot/stdout.expected $testroot/stdout
1688 db0dfdd7 2022-06-27 op fi
1689 55e9459f 2022-06-19 op test_done $testroot $ret
1690 55e9459f 2022-06-19 op }
1691 38d61ead 2022-07-23 op
1692 38d61ead 2022-07-23 op test_patch_merge_reverse() {
1693 38d61ead 2022-07-23 op local testroot=`test_init patch_merge_simple`
1694 38d61ead 2022-07-23 op
1695 38d61ead 2022-07-23 op got checkout $testroot/repo $testroot/wt > /dev/null
1696 38d61ead 2022-07-23 op ret=$?
1697 38d61ead 2022-07-23 op if [ $ret -ne 0 ]; then
1698 38d61ead 2022-07-23 op test_done $testroot $ret
1699 38d61ead 2022-07-23 op return 1
1700 38d61ead 2022-07-23 op fi
1701 55e9459f 2022-06-19 op
1702 38d61ead 2022-07-23 op jot 10 > $testroot/wt/numbers
1703 38d61ead 2022-07-23 op (cd $testroot/wt && got add numbers && got commit -m +numbers) \
1704 38d61ead 2022-07-23 op > /dev/null
1705 38d61ead 2022-07-23 op ret=$?
1706 38d61ead 2022-07-23 op if [ $ret -ne 0 ]; then
1707 38d61ead 2022-07-23 op test_done $testroot $ret
1708 38d61ead 2022-07-23 op return 1
1709 38d61ead 2022-07-23 op fi
1710 38d61ead 2022-07-23 op
1711 38d61ead 2022-07-23 op local commit_id=`git_show_head $testroot/repo`
1712 38d61ead 2022-07-23 op
1713 38d61ead 2022-07-23 op jot 10 | sed s/5/five/g > $testroot/wt/numbers
1714 38d61ead 2022-07-23 op (cd $testroot/wt && got diff > $testroot/wt/patch \
1715 38d61ead 2022-07-23 op && got commit -m 'edit numbers') > /dev/null
1716 38d61ead 2022-07-23 op ret=$?
1717 38d61ead 2022-07-23 op if [ $ret -ne 0 ]; then
1718 38d61ead 2022-07-23 op test_done $testroot $ret
1719 38d61ead 2022-07-23 op return 1
1720 38d61ead 2022-07-23 op fi
1721 38d61ead 2022-07-23 op
1722 38d61ead 2022-07-23 op jot 10 | sed -e s/5/five/g -e s/6/six/g > $testroot/wt/numbers
1723 38d61ead 2022-07-23 op (cd $testroot/wt && got commit -m 'edit numbers again') >/dev/null
1724 38d61ead 2022-07-23 op ret=$?
1725 38d61ead 2022-07-23 op if [ $ret -ne 0 ]; then
1726 38d61ead 2022-07-23 op test_done $testroot $ret
1727 38d61ead 2022-07-23 op return 1
1728 38d61ead 2022-07-23 op fi
1729 38d61ead 2022-07-23 op
1730 38d61ead 2022-07-23 op (cd $testroot/wt && got patch -R patch) >/dev/null 2>&1
1731 38d61ead 2022-07-23 op ret=$?
1732 38d61ead 2022-07-23 op if [ $ret -eq 0 ]; then
1733 38d61ead 2022-07-23 op echo "unexpectedly reverted the patch" >&2
1734 38d61ead 2022-07-23 op test_done $testroot 1
1735 38d61ead 2022-07-23 op return 1
1736 38d61ead 2022-07-23 op fi
1737 38d61ead 2022-07-23 op
1738 38d61ead 2022-07-23 op cat <<-EOF > $testroot/wt/numbers.expected
1739 38d61ead 2022-07-23 op 1
1740 38d61ead 2022-07-23 op 2
1741 38d61ead 2022-07-23 op 3
1742 38d61ead 2022-07-23 op 4
1743 38d61ead 2022-07-23 op <<<<<<< --- numbers
1744 38d61ead 2022-07-23 op 5
1745 38d61ead 2022-07-23 op 6
1746 38d61ead 2022-07-23 op ||||||| +++ numbers
1747 38d61ead 2022-07-23 op five
1748 38d61ead 2022-07-23 op =======
1749 38d61ead 2022-07-23 op five
1750 38d61ead 2022-07-23 op six
1751 38d61ead 2022-07-23 op >>>>>>> commit $commit_id
1752 38d61ead 2022-07-23 op 7
1753 38d61ead 2022-07-23 op 8
1754 38d61ead 2022-07-23 op 9
1755 38d61ead 2022-07-23 op 10
1756 38d61ead 2022-07-23 op EOF
1757 38d61ead 2022-07-23 op
1758 38d61ead 2022-07-23 op cmp -s $testroot/wt/numbers $testroot/wt/numbers.expected
1759 38d61ead 2022-07-23 op ret=$?
1760 38d61ead 2022-07-23 op if [ $ret -ne 0 ]; then
1761 38d61ead 2022-07-23 op diff -u $testroot/wt/numbers $testroot/wt/numbers.expected
1762 611e5fc2 2022-09-21 mark fi
1763 611e5fc2 2022-09-21 mark test_done $testroot $ret
1764 611e5fc2 2022-09-21 mark }
1765 611e5fc2 2022-09-21 mark
1766 611e5fc2 2022-09-21 mark test_patch_newfile_xbit_got_diff() {
1767 611e5fc2 2022-09-21 mark local testroot=`test_init patch_newfile_xbit`
1768 611e5fc2 2022-09-21 mark
1769 611e5fc2 2022-09-21 mark got checkout $testroot/repo $testroot/wt > /dev/null
1770 611e5fc2 2022-09-21 mark ret=$?
1771 611e5fc2 2022-09-21 mark if [ $ret -ne 0 ]; then
1772 611e5fc2 2022-09-21 mark test_done $testroot $ret
1773 611e5fc2 2022-09-21 mark return 1
1774 611e5fc2 2022-09-21 mark fi
1775 611e5fc2 2022-09-21 mark
1776 611e5fc2 2022-09-21 mark cat <<EOF > $testroot/wt/patch
1777 611e5fc2 2022-09-21 mark blob - /dev/null
1778 611e5fc2 2022-09-21 mark blob + abcdef0123456789abcdef012345678901234567 (mode 755)
1779 611e5fc2 2022-09-21 mark --- /dev/null
1780 611e5fc2 2022-09-21 mark +++ xfile
1781 611e5fc2 2022-09-21 mark @@ -0,0 +1,1 @@
1782 611e5fc2 2022-09-21 mark +xfile
1783 611e5fc2 2022-09-21 mark EOF
1784 611e5fc2 2022-09-21 mark
1785 611e5fc2 2022-09-21 mark (cd $testroot/wt && got patch patch) > /dev/null
1786 611e5fc2 2022-09-21 mark ret=$?
1787 611e5fc2 2022-09-21 mark if [ $ret -ne 0 ]; then
1788 611e5fc2 2022-09-21 mark test_done $testroot $ret
1789 611e5fc2 2022-09-21 mark return 1
1790 38d61ead 2022-07-23 op fi
1791 611e5fc2 2022-09-21 mark
1792 611e5fc2 2022-09-21 mark if [ ! -x $testroot/wt/xfile ]; then
1793 611e5fc2 2022-09-21 mark echo "failed to set xbit on newfile" >&2
1794 611e5fc2 2022-09-21 mark test_done $testroot 1
1795 611e5fc2 2022-09-21 mark return 1
1796 611e5fc2 2022-09-21 mark fi
1797 611e5fc2 2022-09-21 mark
1798 611e5fc2 2022-09-21 mark echo xfile > $testroot/wt/xfile.expected
1799 611e5fc2 2022-09-21 mark cmp -s $testroot/wt/xfile $testroot/wt/xfile.expected
1800 611e5fc2 2022-09-21 mark ret=$?
1801 611e5fc2 2022-09-21 mark if [ $ret -ne 0 ]; then
1802 611e5fc2 2022-09-21 mark echo "fail"
1803 611e5fc2 2022-09-21 mark diff -u $testroot/wt/xfile $testroot/wt/xfile.expected
1804 611e5fc2 2022-09-21 mark fi
1805 611e5fc2 2022-09-21 mark
1806 38d61ead 2022-07-23 op test_done $testroot $ret
1807 38d61ead 2022-07-23 op }
1808 38d61ead 2022-07-23 op
1809 611e5fc2 2022-09-21 mark test_patch_newfile_xbit_git_diff() {
1810 611e5fc2 2022-09-21 mark local testroot=`test_init patch_newfile_xbit`
1811 611e5fc2 2022-09-21 mark
1812 611e5fc2 2022-09-21 mark got checkout $testroot/repo $testroot/wt > /dev/null
1813 611e5fc2 2022-09-21 mark ret=$?
1814 611e5fc2 2022-09-21 mark if [ $ret -ne 0 ]; then
1815 611e5fc2 2022-09-21 mark test_done $testroot $ret
1816 611e5fc2 2022-09-21 mark return 1
1817 611e5fc2 2022-09-21 mark fi
1818 611e5fc2 2022-09-21 mark
1819 611e5fc2 2022-09-21 mark cat <<EOF > $testroot/wt/patch
1820 611e5fc2 2022-09-21 mark diff --git a/xfile b/xfile
1821 611e5fc2 2022-09-21 mark new file mode 100755
1822 611e5fc2 2022-09-21 mark index 00000000..abcdef01
1823 611e5fc2 2022-09-21 mark --- /dev/null
1824 611e5fc2 2022-09-21 mark +++ b/xfile
1825 611e5fc2 2022-09-21 mark @@ -0,0 +1,1 @@
1826 611e5fc2 2022-09-21 mark +xfile
1827 611e5fc2 2022-09-21 mark EOF
1828 611e5fc2 2022-09-21 mark
1829 611e5fc2 2022-09-21 mark (cd $testroot/wt && got patch patch) > /dev/null
1830 611e5fc2 2022-09-21 mark ret=$?
1831 611e5fc2 2022-09-21 mark if [ $ret -ne 0 ]; then
1832 611e5fc2 2022-09-21 mark test_done $testroot $ret
1833 611e5fc2 2022-09-21 mark return 1
1834 611e5fc2 2022-09-21 mark fi
1835 611e5fc2 2022-09-21 mark
1836 611e5fc2 2022-09-21 mark if [ ! -x $testroot/wt/xfile ]; then
1837 611e5fc2 2022-09-21 mark echo "failed to set xbit on newfile" >&2
1838 611e5fc2 2022-09-21 mark test_done $testroot 1
1839 611e5fc2 2022-09-21 mark return 1
1840 611e5fc2 2022-09-21 mark fi
1841 611e5fc2 2022-09-21 mark
1842 611e5fc2 2022-09-21 mark echo xfile > $testroot/wt/xfile.expected
1843 611e5fc2 2022-09-21 mark cmp -s $testroot/wt/xfile $testroot/wt/xfile.expected
1844 611e5fc2 2022-09-21 mark ret=$?
1845 611e5fc2 2022-09-21 mark if [ $ret -ne 0 ]; then
1846 611e5fc2 2022-09-21 mark echo "fail"
1847 611e5fc2 2022-09-21 mark diff -u $testroot/wt/xfile $testroot/wt/xfile.expected
1848 611e5fc2 2022-09-21 mark fi
1849 611e5fc2 2022-09-21 mark
1850 611e5fc2 2022-09-21 mark test_done $testroot $ret
1851 b2b3fce1 2022-10-29 op }
1852 b2b3fce1 2022-10-29 op
1853 b2b3fce1 2022-10-29 op test_patch_umask() {
1854 b2b3fce1 2022-10-29 op local testroot=`test_init patch_umask`
1855 b2b3fce1 2022-10-29 op
1856 b2b3fce1 2022-10-29 op got checkout "$testroot/repo" "$testroot/wt" >/dev/null
1857 b2b3fce1 2022-10-29 op
1858 b2b3fce1 2022-10-29 op cat <<EOF >$testroot/wt/patch
1859 b2b3fce1 2022-10-29 op --- alpha
1860 b2b3fce1 2022-10-29 op +++ alpha
1861 b2b3fce1 2022-10-29 op @@ -1 +1 @@
1862 b2b3fce1 2022-10-29 op -alpha
1863 b2b3fce1 2022-10-29 op +modified alpha
1864 b2b3fce1 2022-10-29 op EOF
1865 b2b3fce1 2022-10-29 op
1866 b2b3fce1 2022-10-29 op # using a subshell to avoid clobbering global umask
1867 b2b3fce1 2022-10-29 op (umask 077 && cd "$testroot/wt" && got patch <patch) >/dev/null
1868 b2b3fce1 2022-10-29 op ret=$?
1869 b2b3fce1 2022-10-29 op if [ $ret -ne 0 ]; then
1870 b2b3fce1 2022-10-29 op test_done "$testroot" $ret
1871 b2b3fce1 2022-10-29 op return 1
1872 b2b3fce1 2022-10-29 op fi
1873 b2b3fce1 2022-10-29 op
1874 b2b3fce1 2022-10-29 op if ! ls -l "$testroot/wt/alpha" | grep -q ^-rw-------; then
1875 b2b3fce1 2022-10-29 op echo "alpha is not 0600 after patch" >&2
1876 b2b3fce1 2022-10-29 op ls -l "$testroot/wt/alpha" >&2
1877 b2b3fce1 2022-10-29 op test_done "$testroot" 1
1878 b2b3fce1 2022-10-29 op return 1
1879 b2b3fce1 2022-10-29 op fi
1880 b2b3fce1 2022-10-29 op
1881 b2b3fce1 2022-10-29 op test_done "$testroot" 0
1882 611e5fc2 2022-09-21 mark }
1883 684a9a6c 2022-12-31 op
1884 684a9a6c 2022-12-31 op test_patch_remove_binary_file() {
1885 684a9a6c 2022-12-31 op local testroot=`test_init patch_remove_binary_file`
1886 684a9a6c 2022-12-31 op
1887 684a9a6c 2022-12-31 op if ! got checkout $testroot/repo $testroot/wt >/dev/null; then
1888 684a9a6c 2022-12-31 op test_done $testroot $ret
1889 684a9a6c 2022-12-31 op return 1
1890 684a9a6c 2022-12-31 op fi
1891 684a9a6c 2022-12-31 op
1892 684a9a6c 2022-12-31 op dd if=/dev/zero of=$testroot/wt/x bs=1 count=16 2>/dev/null >&2
1893 684a9a6c 2022-12-31 op (cd $testroot/wt && got add x && got commit -m +x) >/dev/null
1894 684a9a6c 2022-12-31 op
1895 684a9a6c 2022-12-31 op (cd $testroot/wt && \
1896 684a9a6c 2022-12-31 op got branch demo && \
1897 684a9a6c 2022-12-31 op got rm x && \
1898 684a9a6c 2022-12-31 op got ci -m -x &&
1899 684a9a6c 2022-12-31 op got up -b master) >/dev/null
1900 684a9a6c 2022-12-31 op
1901 684a9a6c 2022-12-31 op echo 'D x' > $testroot/stdout.expected
1902 611e5fc2 2022-09-21 mark
1903 684a9a6c 2022-12-31 op (cd $testroot/wt && got log -c demo -l 1 -p >patch)
1904 684a9a6c 2022-12-31 op
1905 684a9a6c 2022-12-31 op (cd $testroot/wt && got patch <patch) > $testroot/stdout
1906 684a9a6c 2022-12-31 op if [ $? -ne 0 ]; then
1907 684a9a6c 2022-12-31 op echo 'patch failed' >&2
1908 684a9a6c 2022-12-31 op test_done $testroot 1
1909 684a9a6c 2022-12-31 op return 1
1910 684a9a6c 2022-12-31 op fi
1911 684a9a6c 2022-12-31 op
1912 684a9a6c 2022-12-31 op if ! cmp -s $testroot/stdout.expected $testroot/stdout; then
1913 684a9a6c 2022-12-31 op diff -u $testroot/stdout.expected $testroot/stdout
1914 684a9a6c 2022-12-31 op test_done $testroot 1
1915 684a9a6c 2022-12-31 op return 1
1916 684a9a6c 2022-12-31 op fi
1917 684a9a6c 2022-12-31 op
1918 684a9a6c 2022-12-31 op # try again using a git produced diff
1919 684a9a6c 2022-12-31 op (cd $testroot/wt && got revert x) >/dev/null
1920 684a9a6c 2022-12-31 op
1921 684a9a6c 2022-12-31 op (cd $testroot/repo && git show demo) >$testroot/wt/patch
1922 684a9a6c 2022-12-31 op
1923 684a9a6c 2022-12-31 op (cd $testroot/wt && got patch <patch) > $testroot/stdout
1924 684a9a6c 2022-12-31 op if [ $? -ne 0 ]; then
1925 684a9a6c 2022-12-31 op echo 'patch failed' >&2
1926 684a9a6c 2022-12-31 op test_done $testroot 1
1927 684a9a6c 2022-12-31 op return 1
1928 684a9a6c 2022-12-31 op fi
1929 684a9a6c 2022-12-31 op
1930 684a9a6c 2022-12-31 op if ! cmp -s $testroot/stdout.expected $testroot/stdout; then
1931 684a9a6c 2022-12-31 op diff -u $testroot/stdout.expected $testroot/stdout
1932 684a9a6c 2022-12-31 op test_done $testroot 1
1933 684a9a6c 2022-12-31 op return 1
1934 684a9a6c 2022-12-31 op fi
1935 684a9a6c 2022-12-31 op
1936 684a9a6c 2022-12-31 op # try again using a diff(1) style patch
1937 684a9a6c 2022-12-31 op (cd $testroot/wt && got revert x) >/dev/null
1938 684a9a6c 2022-12-31 op
1939 684a9a6c 2022-12-31 op echo "Binary files x and /dev/null differ" >$testroot/wt/patch
1940 684a9a6c 2022-12-31 op (cd $testroot/wt && got patch <patch) >$testroot/stdout
1941 684a9a6c 2022-12-31 op if [ $? -ne 0 ]; then
1942 684a9a6c 2022-12-31 op echo 'patch failed' >&2
1943 684a9a6c 2022-12-31 op test_done $testroot 1
1944 684a9a6c 2022-12-31 op return 1
1945 684a9a6c 2022-12-31 op fi
1946 684a9a6c 2022-12-31 op
1947 684a9a6c 2022-12-31 op if ! cmp -s $testroot/stdout.expected $testroot/stdout; then
1948 684a9a6c 2022-12-31 op diff -u $testroot/stdout.expected $testroot/stdout
1949 684a9a6c 2022-12-31 op test_done $testroot 1
1950 684a9a6c 2022-12-31 op return 1
1951 684a9a6c 2022-12-31 op fi
1952 684a9a6c 2022-12-31 op
1953 684a9a6c 2022-12-31 op test_done $testroot 0
1954 684a9a6c 2022-12-31 op }
1955 684a9a6c 2022-12-31 op
1956 e9ce266e 2022-03-07 op test_parseargs "$@"
1957 57b1c3f2 2022-08-01 op run_test test_patch_basic
1958 e9ce266e 2022-03-07 op run_test test_patch_dont_apply
1959 e9ce266e 2022-03-07 op run_test test_patch_malformed
1960 e9ce266e 2022-03-07 op run_test test_patch_no_patch
1961 e9ce266e 2022-03-07 op run_test test_patch_equals_for_context
1962 6e96b326 2022-03-12 op run_test test_patch_rename
1963 dbda770b 2022-03-13 op run_test test_patch_illegal_status
1964 899fcfdf 2022-03-13 op run_test test_patch_nop
1965 2be5e1a2 2022-03-16 op run_test test_patch_preserve_perm
1966 95d68340 2022-03-16 op run_test test_patch_create_dirs
1967 60aa1fa0 2022-03-17 op run_test test_patch_with_offset
1968 7a30b5cb 2022-03-20 op run_test test_patch_prefer_new_path
1969 b3c57ab2 2022-03-22 op run_test test_patch_no_newline
1970 9d6cabd5 2022-04-07 op run_test test_patch_strip
1971 a92a2042 2022-07-02 op run_test test_patch_whitespace
1972 ed3bff83 2022-04-23 op run_test test_patch_relative_paths
1973 15e1bda6 2022-04-23 op run_test test_patch_with_path_prefix
1974 15e1bda6 2022-04-23 op run_test test_patch_relpath_with_path_prefix
1975 bad961bf 2022-04-23 op run_test test_patch_reverse
1976 55e9459f 2022-06-19 op run_test test_patch_merge_simple
1977 db0dfdd7 2022-06-27 op run_test test_patch_merge_gitdiff
1978 5f56d41e 2022-07-28 op run_test test_patch_merge_base_provided
1979 55e9459f 2022-06-19 op run_test test_patch_merge_conflict
1980 55e9459f 2022-06-19 op run_test test_patch_merge_unknown_blob
1981 38d61ead 2022-07-23 op run_test test_patch_merge_reverse
1982 611e5fc2 2022-09-21 mark run_test test_patch_newfile_xbit_got_diff
1983 611e5fc2 2022-09-21 mark run_test test_patch_newfile_xbit_git_diff
1984 b2b3fce1 2022-10-29 op run_test test_patch_umask
1985 684a9a6c 2022-12-31 op run_test test_patch_remove_binary_file