Blame


1 a129376b 2019-03-28 stsp #!/bin/sh
2 a129376b 2019-03-28 stsp #
3 a129376b 2019-03-28 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
4 a129376b 2019-03-28 stsp #
5 a129376b 2019-03-28 stsp # Permission to use, copy, modify, and distribute this software for any
6 a129376b 2019-03-28 stsp # purpose with or without fee is hereby granted, provided that the above
7 a129376b 2019-03-28 stsp # copyright notice and this permission notice appear in all copies.
8 a129376b 2019-03-28 stsp #
9 a129376b 2019-03-28 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 a129376b 2019-03-28 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 a129376b 2019-03-28 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 a129376b 2019-03-28 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 a129376b 2019-03-28 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 a129376b 2019-03-28 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 a129376b 2019-03-28 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 a129376b 2019-03-28 stsp
17 a129376b 2019-03-28 stsp . ./common.sh
18 a129376b 2019-03-28 stsp
19 f6cae3ed 2020-09-13 naddy test_revert_basic() {
20 a129376b 2019-03-28 stsp local testroot=`test_init revert_basic`
21 a129376b 2019-03-28 stsp
22 a129376b 2019-03-28 stsp got checkout $testroot/repo $testroot/wt > /dev/null
23 49c543a6 2022-03-31 naddy ret=$?
24 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
25 a129376b 2019-03-28 stsp test_done "$testroot" "$ret"
26 a129376b 2019-03-28 stsp return 1
27 a129376b 2019-03-28 stsp fi
28 a129376b 2019-03-28 stsp
29 5e54fb30 2019-05-31 stsp echo "modified epsilon/zeta" > $testroot/wt/epsilon/zeta
30 a129376b 2019-03-28 stsp
31 5e54fb30 2019-05-31 stsp echo 'R epsilon/zeta' > $testroot/stdout.expected
32 a129376b 2019-03-28 stsp
33 5e54fb30 2019-05-31 stsp (cd $testroot/wt && got revert epsilon/zeta > $testroot/stdout)
34 a129376b 2019-03-28 stsp
35 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
36 49c543a6 2022-03-31 naddy ret=$?
37 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
38 a129376b 2019-03-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
39 a129376b 2019-03-28 stsp test_done "$testroot" "$ret"
40 a129376b 2019-03-28 stsp return 1
41 a129376b 2019-03-28 stsp fi
42 a129376b 2019-03-28 stsp
43 5e54fb30 2019-05-31 stsp echo "zeta" > $testroot/content.expected
44 5e54fb30 2019-05-31 stsp cat $testroot/wt/epsilon/zeta > $testroot/content
45 a129376b 2019-03-28 stsp
46 8d301dd9 2019-05-14 stsp cmp -s $testroot/content.expected $testroot/content
47 49c543a6 2022-03-31 naddy ret=$?
48 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
49 a129376b 2019-03-28 stsp diff -u $testroot/content.expected $testroot/content
50 a129376b 2019-03-28 stsp fi
51 a129376b 2019-03-28 stsp test_done "$testroot" "$ret"
52 a129376b 2019-03-28 stsp
53 a129376b 2019-03-28 stsp }
54 a129376b 2019-03-28 stsp
55 f6cae3ed 2020-09-13 naddy test_revert_rm() {
56 a129376b 2019-03-28 stsp local testroot=`test_init revert_rm`
57 a129376b 2019-03-28 stsp
58 a129376b 2019-03-28 stsp got checkout $testroot/repo $testroot/wt > /dev/null
59 49c543a6 2022-03-31 naddy ret=$?
60 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
61 a129376b 2019-03-28 stsp test_done "$testroot" "$ret"
62 a129376b 2019-03-28 stsp return 1
63 a129376b 2019-03-28 stsp fi
64 a129376b 2019-03-28 stsp
65 a129376b 2019-03-28 stsp (cd $testroot/wt && got rm beta >/dev/null)
66 a129376b 2019-03-28 stsp
67 a129376b 2019-03-28 stsp echo 'R beta' > $testroot/stdout.expected
68 a129376b 2019-03-28 stsp
69 a129376b 2019-03-28 stsp (cd $testroot/wt && got revert beta > $testroot/stdout)
70 a129376b 2019-03-28 stsp
71 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
72 49c543a6 2022-03-31 naddy ret=$?
73 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
74 a129376b 2019-03-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
75 a129376b 2019-03-28 stsp test_done "$testroot" "$ret"
76 a129376b 2019-03-28 stsp return 1
77 a129376b 2019-03-28 stsp fi
78 a129376b 2019-03-28 stsp
79 a129376b 2019-03-28 stsp echo "beta" > $testroot/content.expected
80 a129376b 2019-03-28 stsp cat $testroot/wt/beta > $testroot/content
81 a129376b 2019-03-28 stsp
82 8d301dd9 2019-05-14 stsp cmp -s $testroot/content.expected $testroot/content
83 49c543a6 2022-03-31 naddy ret=$?
84 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
85 a129376b 2019-03-28 stsp diff -u $testroot/content.expected $testroot/content
86 a129376b 2019-03-28 stsp fi
87 a129376b 2019-03-28 stsp test_done "$testroot" "$ret"
88 a129376b 2019-03-28 stsp }
89 a129376b 2019-03-28 stsp
90 f6cae3ed 2020-09-13 naddy test_revert_add() {
91 a129376b 2019-03-28 stsp local testroot=`test_init revert_add`
92 a129376b 2019-03-28 stsp
93 a129376b 2019-03-28 stsp got checkout $testroot/repo $testroot/wt > /dev/null
94 49c543a6 2022-03-31 naddy ret=$?
95 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
96 a129376b 2019-03-28 stsp test_done "$testroot" "$ret"
97 a129376b 2019-03-28 stsp return 1
98 a129376b 2019-03-28 stsp fi
99 a129376b 2019-03-28 stsp
100 a129376b 2019-03-28 stsp echo "new file" > $testroot/wt/new
101 a129376b 2019-03-28 stsp (cd $testroot/wt && got add new >/dev/null)
102 a129376b 2019-03-28 stsp
103 a129376b 2019-03-28 stsp echo 'R new' > $testroot/stdout.expected
104 a129376b 2019-03-28 stsp
105 a129376b 2019-03-28 stsp (cd $testroot/wt && got revert new > $testroot/stdout)
106 a129376b 2019-03-28 stsp
107 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
108 49c543a6 2022-03-31 naddy ret=$?
109 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
110 a129376b 2019-03-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
111 a129376b 2019-03-28 stsp test_done "$testroot" "$ret"
112 a129376b 2019-03-28 stsp return 1
113 a129376b 2019-03-28 stsp fi
114 a129376b 2019-03-28 stsp
115 a129376b 2019-03-28 stsp echo "new file" > $testroot/content.expected
116 a129376b 2019-03-28 stsp cat $testroot/wt/new > $testroot/content
117 a129376b 2019-03-28 stsp
118 8d301dd9 2019-05-14 stsp cmp -s $testroot/content.expected $testroot/content
119 49c543a6 2022-03-31 naddy ret=$?
120 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
121 a129376b 2019-03-28 stsp diff -u $testroot/content.expected $testroot/content
122 a129376b 2019-03-28 stsp test_done "$testroot" "$ret"
123 a129376b 2019-03-28 stsp return 1
124 a129376b 2019-03-28 stsp fi
125 a129376b 2019-03-28 stsp
126 a129376b 2019-03-28 stsp echo '? new' > $testroot/stdout.expected
127 a129376b 2019-03-28 stsp
128 a129376b 2019-03-28 stsp (cd $testroot/wt && got status > $testroot/stdout)
129 a129376b 2019-03-28 stsp
130 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
131 49c543a6 2022-03-31 naddy ret=$?
132 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
133 a129376b 2019-03-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
134 a129376b 2019-03-28 stsp fi
135 a129376b 2019-03-28 stsp test_done "$testroot" "$ret"
136 a129376b 2019-03-28 stsp }
137 a129376b 2019-03-28 stsp
138 f6cae3ed 2020-09-13 naddy test_revert_multiple() {
139 e20a8b6f 2019-06-04 stsp local testroot=`test_init revert_multiple`
140 e20a8b6f 2019-06-04 stsp
141 e20a8b6f 2019-06-04 stsp got checkout $testroot/repo $testroot/wt > /dev/null
142 49c543a6 2022-03-31 naddy ret=$?
143 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
144 e20a8b6f 2019-06-04 stsp test_done "$testroot" "$ret"
145 e20a8b6f 2019-06-04 stsp return 1
146 e20a8b6f 2019-06-04 stsp fi
147 e20a8b6f 2019-06-04 stsp
148 e20a8b6f 2019-06-04 stsp echo "modified alpha" > $testroot/wt/alpha
149 e20a8b6f 2019-06-04 stsp echo "modified epsilon/zeta" > $testroot/wt/epsilon/zeta
150 e20a8b6f 2019-06-04 stsp
151 e20a8b6f 2019-06-04 stsp echo 'R alpha' > $testroot/stdout.expected
152 e20a8b6f 2019-06-04 stsp echo 'R epsilon/zeta' >> $testroot/stdout.expected
153 e20a8b6f 2019-06-04 stsp
154 e20a8b6f 2019-06-04 stsp (cd $testroot/wt && got revert alpha epsilon/zeta > $testroot/stdout)
155 e20a8b6f 2019-06-04 stsp
156 e20a8b6f 2019-06-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
157 49c543a6 2022-03-31 naddy ret=$?
158 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
159 e20a8b6f 2019-06-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
160 e20a8b6f 2019-06-04 stsp test_done "$testroot" "$ret"
161 e20a8b6f 2019-06-04 stsp return 1
162 e20a8b6f 2019-06-04 stsp fi
163 e20a8b6f 2019-06-04 stsp
164 e20a8b6f 2019-06-04 stsp echo "alpha" > $testroot/content.expected
165 e20a8b6f 2019-06-04 stsp cat $testroot/wt/alpha > $testroot/content
166 e20a8b6f 2019-06-04 stsp
167 e20a8b6f 2019-06-04 stsp cmp -s $testroot/content.expected $testroot/content
168 49c543a6 2022-03-31 naddy ret=$?
169 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
170 e20a8b6f 2019-06-04 stsp diff -u $testroot/content.expected $testroot/content
171 e20a8b6f 2019-06-04 stsp test_done "$testroot" "$ret"
172 e20a8b6f 2019-06-04 stsp return 1
173 e20a8b6f 2019-06-04 stsp fi
174 e20a8b6f 2019-06-04 stsp
175 e20a8b6f 2019-06-04 stsp echo "zeta" > $testroot/content.expected
176 e20a8b6f 2019-06-04 stsp cat $testroot/wt/epsilon/zeta > $testroot/content
177 e20a8b6f 2019-06-04 stsp
178 e20a8b6f 2019-06-04 stsp cmp -s $testroot/content.expected $testroot/content
179 49c543a6 2022-03-31 naddy ret=$?
180 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
181 e20a8b6f 2019-06-04 stsp diff -u $testroot/content.expected $testroot/content
182 e20a8b6f 2019-06-04 stsp fi
183 e20a8b6f 2019-06-04 stsp test_done "$testroot" "$ret"
184 e20a8b6f 2019-06-04 stsp }
185 e20a8b6f 2019-06-04 stsp
186 f6cae3ed 2020-09-13 naddy test_revert_file_in_new_subdir() {
187 a9fa2909 2019-07-27 stsp local testroot=`test_init revert_file_in_new_subdir`
188 a9fa2909 2019-07-27 stsp
189 a9fa2909 2019-07-27 stsp got checkout $testroot/repo $testroot/wt > /dev/null
190 49c543a6 2022-03-31 naddy ret=$?
191 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
192 a9fa2909 2019-07-27 stsp test_done "$testroot" "$ret"
193 a9fa2909 2019-07-27 stsp return 1
194 a9fa2909 2019-07-27 stsp fi
195 a9fa2909 2019-07-27 stsp
196 a9fa2909 2019-07-27 stsp
197 a9fa2909 2019-07-27 stsp mkdir -p $testroot/wt/newdir
198 a9fa2909 2019-07-27 stsp echo new > $testroot/wt/newdir/new
199 a9fa2909 2019-07-27 stsp (cd $testroot/wt && got add newdir/new > /dev/null)
200 a9fa2909 2019-07-27 stsp
201 a9fa2909 2019-07-27 stsp (cd $testroot/wt && got revert newdir/new > $testroot/stdout)
202 a9fa2909 2019-07-27 stsp
203 a9fa2909 2019-07-27 stsp echo "R newdir/new" > $testroot/stdout.expected
204 a9fa2909 2019-07-27 stsp cmp -s $testroot/stdout.expected $testroot/stdout
205 49c543a6 2022-03-31 naddy ret=$?
206 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
207 a9fa2909 2019-07-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
208 a9fa2909 2019-07-27 stsp test_done "$testroot" "$ret"
209 a9fa2909 2019-07-27 stsp return 1
210 a9fa2909 2019-07-27 stsp fi
211 a9fa2909 2019-07-27 stsp
212 a9fa2909 2019-07-27 stsp (cd $testroot/wt && got status > $testroot/stdout)
213 a9fa2909 2019-07-27 stsp
214 a9fa2909 2019-07-27 stsp echo "? newdir/new" > $testroot/stdout.expected
215 a9fa2909 2019-07-27 stsp cmp -s $testroot/stdout.expected $testroot/stdout
216 49c543a6 2022-03-31 naddy ret=$?
217 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
218 a9fa2909 2019-07-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
219 a9fa2909 2019-07-27 stsp fi
220 a9fa2909 2019-07-27 stsp test_done "$testroot" "$ret"
221 a9fa2909 2019-07-27 stsp
222 a9fa2909 2019-07-27 stsp }
223 a9fa2909 2019-07-27 stsp
224 f6cae3ed 2020-09-13 naddy test_revert_no_arguments() {
225 1f1abb7e 2019-08-08 stsp local testroot=`test_init revert_no_arguments`
226 1f1abb7e 2019-08-08 stsp
227 1f1abb7e 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
228 49c543a6 2022-03-31 naddy ret=$?
229 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
230 1f1abb7e 2019-08-08 stsp test_done "$testroot" "$ret"
231 1f1abb7e 2019-08-08 stsp return 1
232 1f1abb7e 2019-08-08 stsp fi
233 1f1abb7e 2019-08-08 stsp
234 1f1abb7e 2019-08-08 stsp echo "modified epsilon/zeta" > $testroot/wt/epsilon/zeta
235 1f1abb7e 2019-08-08 stsp
236 1f1abb7e 2019-08-08 stsp (cd $testroot/wt && got revert > $testroot/stdout 2> $testroot/stderr)
237 49c543a6 2022-03-31 naddy ret=$?
238 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
239 1f1abb7e 2019-08-08 stsp echo "revert command succeeded unexpectedly" >&2
240 1f1abb7e 2019-08-08 stsp test_done "$testroot" "1"
241 1f1abb7e 2019-08-08 stsp return 1
242 1f1abb7e 2019-08-08 stsp fi
243 1f1abb7e 2019-08-08 stsp
244 1f1abb7e 2019-08-08 stsp echo -n > $testroot/stdout.expected
245 1f1abb7e 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
246 49c543a6 2022-03-31 naddy ret=$?
247 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
248 1f1abb7e 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
249 1f1abb7e 2019-08-08 stsp test_done "$testroot" "$ret"
250 1f1abb7e 2019-08-08 stsp return 1
251 1f1abb7e 2019-08-08 stsp fi
252 1f1abb7e 2019-08-08 stsp
253 c912cbbf 2022-08-16 stsp echo "usage: got revert [-pR] [-F response-script] path ..." \
254 33aa809d 2019-08-08 stsp > $testroot/stderr.expected
255 0f6d7415 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
256 49c543a6 2022-03-31 naddy ret=$?
257 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
258 0f6d7415 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
259 0f6d7415 2019-08-08 stsp fi
260 0f6d7415 2019-08-08 stsp test_done "$testroot" "$ret"
261 0f6d7415 2019-08-08 stsp }
262 0f6d7415 2019-08-08 stsp
263 f6cae3ed 2020-09-13 naddy test_revert_directory() {
264 0f6d7415 2019-08-08 stsp local testroot=`test_init revert_directory`
265 0f6d7415 2019-08-08 stsp
266 0f6d7415 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
267 49c543a6 2022-03-31 naddy ret=$?
268 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
269 0f6d7415 2019-08-08 stsp test_done "$testroot" "$ret"
270 0f6d7415 2019-08-08 stsp return 1
271 0f6d7415 2019-08-08 stsp fi
272 0f6d7415 2019-08-08 stsp
273 0f6d7415 2019-08-08 stsp echo "modified epsilon/zeta" > $testroot/wt/epsilon/zeta
274 0f6d7415 2019-08-08 stsp
275 0f6d7415 2019-08-08 stsp (cd $testroot/wt && got revert . > $testroot/stdout 2> $testroot/stderr)
276 49c543a6 2022-03-31 naddy ret=$?
277 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
278 0f6d7415 2019-08-08 stsp echo "got revert command succeeded unexpectedly" >&2
279 0f6d7415 2019-08-08 stsp test_done "$testroot" "1"
280 0f6d7415 2019-08-08 stsp return 1
281 0f6d7415 2019-08-08 stsp fi
282 0f6d7415 2019-08-08 stsp echo "got: reverting directories requires -R option" \
283 0f6d7415 2019-08-08 stsp > $testroot/stderr.expected
284 1f1abb7e 2019-08-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
285 49c543a6 2022-03-31 naddy ret=$?
286 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
287 1f1abb7e 2019-08-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
288 0f6d7415 2019-08-08 stsp test_done "$testroot" "$ret"
289 0f6d7415 2019-08-08 stsp return 1
290 1f1abb7e 2019-08-08 stsp fi
291 0f6d7415 2019-08-08 stsp
292 0f6d7415 2019-08-08 stsp echo -n > $testroot/stdout.expected
293 0f6d7415 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
294 49c543a6 2022-03-31 naddy ret=$?
295 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
296 0f6d7415 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
297 0f6d7415 2019-08-08 stsp test_done "$testroot" "$ret"
298 0f6d7415 2019-08-08 stsp return 1
299 0f6d7415 2019-08-08 stsp fi
300 0f6d7415 2019-08-08 stsp
301 0f6d7415 2019-08-08 stsp (cd $testroot/wt && got revert -R . > $testroot/stdout)
302 0f6d7415 2019-08-08 stsp
303 0f6d7415 2019-08-08 stsp echo 'R epsilon/zeta' > $testroot/stdout.expected
304 0f6d7415 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
305 49c543a6 2022-03-31 naddy ret=$?
306 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
307 0f6d7415 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
308 0f6d7415 2019-08-08 stsp test_done "$testroot" "$ret"
309 0f6d7415 2019-08-08 stsp return 1
310 0f6d7415 2019-08-08 stsp fi
311 0f6d7415 2019-08-08 stsp
312 0f6d7415 2019-08-08 stsp echo "zeta" > $testroot/content.expected
313 0f6d7415 2019-08-08 stsp cat $testroot/wt/epsilon/zeta > $testroot/content
314 0f6d7415 2019-08-08 stsp
315 0f6d7415 2019-08-08 stsp cmp -s $testroot/content.expected $testroot/content
316 49c543a6 2022-03-31 naddy ret=$?
317 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
318 0f6d7415 2019-08-08 stsp diff -u $testroot/content.expected $testroot/content
319 33aa809d 2019-08-08 stsp fi
320 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
321 3d69ad8d 2019-08-17 semarie }
322 3d69ad8d 2019-08-17 semarie
323 f6cae3ed 2020-09-13 naddy test_revert_directory_unknown() {
324 3d69ad8d 2019-08-17 semarie local testroot=`test_init revert_directory_unknown`
325 3d69ad8d 2019-08-17 semarie
326 3d69ad8d 2019-08-17 semarie got checkout $testroot/repo $testroot/wt > /dev/null
327 49c543a6 2022-03-31 naddy ret=$?
328 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
329 3d69ad8d 2019-08-17 semarie test_done "$testroot" "$ret"
330 3d69ad8d 2019-08-17 semarie return 1
331 3d69ad8d 2019-08-17 semarie fi
332 3d69ad8d 2019-08-17 semarie
333 3d69ad8d 2019-08-17 semarie echo "modified alpha" > $testroot/wt/alpha
334 3d69ad8d 2019-08-17 semarie echo "new untracked file" > $testroot/wt/epsilon/new_file
335 6a5eff7c 2019-11-23 stsp echo "modified epsilon/zeta" > $testroot/wt/epsilon/zeta
336 3d69ad8d 2019-08-17 semarie
337 3d69ad8d 2019-08-17 semarie (cd $testroot/wt && got revert -R . > $testroot/stdout)
338 3d69ad8d 2019-08-17 semarie
339 3d69ad8d 2019-08-17 semarie echo 'R alpha' > $testroot/stdout.expected
340 3d69ad8d 2019-08-17 semarie echo 'R epsilon/zeta' >> $testroot/stdout.expected
341 3d69ad8d 2019-08-17 semarie cmp -s $testroot/stdout.expected $testroot/stdout
342 49c543a6 2022-03-31 naddy ret=$?
343 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
344 3d69ad8d 2019-08-17 semarie diff -u $testroot/stdout.expected $testroot/stdout
345 3d69ad8d 2019-08-17 semarie test_done "$testroot" "$ret"
346 3d69ad8d 2019-08-17 semarie return 1
347 3d69ad8d 2019-08-17 semarie fi
348 3d69ad8d 2019-08-17 semarie
349 3d69ad8d 2019-08-17 semarie echo "new untracked file" > $testroot/content.expected
350 3d69ad8d 2019-08-17 semarie cat $testroot/wt/epsilon/new_file > $testroot/content
351 31cf15ec 2023-04-12 stsp
352 31cf15ec 2023-04-12 stsp cmp -s $testroot/content.expected $testroot/content
353 31cf15ec 2023-04-12 stsp ret=$?
354 31cf15ec 2023-04-12 stsp if [ $ret -ne 0 ]; then
355 31cf15ec 2023-04-12 stsp diff -u $testroot/content.expected $testroot/content
356 31cf15ec 2023-04-12 stsp test_done "$testroot" "$ret"
357 31cf15ec 2023-04-12 stsp return 1
358 31cf15ec 2023-04-12 stsp fi
359 31cf15ec 2023-04-12 stsp
360 31cf15ec 2023-04-12 stsp echo "zeta" > $testroot/content.expected
361 31cf15ec 2023-04-12 stsp cat $testroot/wt/epsilon/zeta > $testroot/content
362 3d69ad8d 2019-08-17 semarie
363 3d69ad8d 2019-08-17 semarie cmp -s $testroot/content.expected $testroot/content
364 49c543a6 2022-03-31 naddy ret=$?
365 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
366 3d69ad8d 2019-08-17 semarie diff -u $testroot/content.expected $testroot/content
367 31cf15ec 2023-04-12 stsp fi
368 31cf15ec 2023-04-12 stsp
369 31cf15ec 2023-04-12 stsp test_done "$testroot" "$ret"
370 31cf15ec 2023-04-12 stsp }
371 31cf15ec 2023-04-12 stsp
372 31cf15ec 2023-04-12 stsp test_revert_missing_directory() {
373 31cf15ec 2023-04-12 stsp local testroot=`test_init revert_missing_directory`
374 31cf15ec 2023-04-12 stsp
375 31cf15ec 2023-04-12 stsp got checkout $testroot/repo $testroot/wt > /dev/null
376 31cf15ec 2023-04-12 stsp ret=$?
377 31cf15ec 2023-04-12 stsp if [ $ret -ne 0 ]; then
378 3d69ad8d 2019-08-17 semarie test_done "$testroot" "$ret"
379 3d69ad8d 2019-08-17 semarie return 1
380 3d69ad8d 2019-08-17 semarie fi
381 6a5eff7c 2019-11-23 stsp
382 31cf15ec 2023-04-12 stsp rm -r $testroot/wt/epsilon
383 31cf15ec 2023-04-12 stsp
384 31cf15ec 2023-04-12 stsp (cd $testroot/wt && got revert -R epsilon > $testroot/stdout)
385 31cf15ec 2023-04-12 stsp
386 31cf15ec 2023-04-12 stsp echo 'R epsilon/zeta' >> $testroot/stdout.expected
387 31cf15ec 2023-04-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
388 31cf15ec 2023-04-12 stsp ret=$?
389 31cf15ec 2023-04-12 stsp if [ $ret -ne 0 ]; then
390 31cf15ec 2023-04-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
391 31cf15ec 2023-04-12 stsp test_done "$testroot" "$ret"
392 31cf15ec 2023-04-12 stsp return 1
393 31cf15ec 2023-04-12 stsp fi
394 31cf15ec 2023-04-12 stsp
395 3d69ad8d 2019-08-17 semarie echo "zeta" > $testroot/content.expected
396 3d69ad8d 2019-08-17 semarie cat $testroot/wt/epsilon/zeta > $testroot/content
397 33aa809d 2019-08-08 stsp
398 3d69ad8d 2019-08-17 semarie cmp -s $testroot/content.expected $testroot/content
399 49c543a6 2022-03-31 naddy ret=$?
400 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
401 3d69ad8d 2019-08-17 semarie diff -u $testroot/content.expected $testroot/content
402 3d69ad8d 2019-08-17 semarie fi
403 3d69ad8d 2019-08-17 semarie
404 3d69ad8d 2019-08-17 semarie test_done "$testroot" "$ret"
405 33aa809d 2019-08-08 stsp }
406 33aa809d 2019-08-08 stsp
407 f6cae3ed 2020-09-13 naddy test_revert_patch() {
408 33aa809d 2019-08-08 stsp local testroot=`test_init revert_patch`
409 33aa809d 2019-08-08 stsp
410 33aa809d 2019-08-08 stsp jot 16 > $testroot/repo/numbers
411 33aa809d 2019-08-08 stsp (cd $testroot/repo && git add numbers)
412 33aa809d 2019-08-08 stsp git_commit $testroot/repo -m "added numbers file"
413 33aa809d 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
414 33aa809d 2019-08-08 stsp
415 33aa809d 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
416 49c543a6 2022-03-31 naddy ret=$?
417 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
418 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
419 33aa809d 2019-08-08 stsp return 1
420 33aa809d 2019-08-08 stsp fi
421 33aa809d 2019-08-08 stsp
422 885e96df 2023-03-06 naddy ed -s $testroot/wt/numbers <<-\EOF
423 885e96df 2023-03-06 naddy ,s/^2$/a/
424 885e96df 2023-03-06 naddy ,s/^7$/b/
425 885e96df 2023-03-06 naddy ,s/^16$/c/
426 885e96df 2023-03-06 naddy w
427 885e96df 2023-03-06 naddy EOF
428 33aa809d 2019-08-08 stsp
429 33aa809d 2019-08-08 stsp (cd $testroot/wt && got diff > $testroot/numbers.diff)
430 33aa809d 2019-08-08 stsp
431 33aa809d 2019-08-08 stsp # don't revert any hunks
432 33aa809d 2019-08-08 stsp printf "n\nn\nn\n" > $testroot/patchscript
433 33aa809d 2019-08-08 stsp (cd $testroot/wt && got revert -F $testroot/patchscript -p \
434 33aa809d 2019-08-08 stsp numbers > $testroot/stdout)
435 49c543a6 2022-03-31 naddy ret=$?
436 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
437 33aa809d 2019-08-08 stsp echo "got revert command failed unexpectedly" >&2
438 33aa809d 2019-08-08 stsp test_done "$testroot" "1"
439 33aa809d 2019-08-08 stsp return 1
440 33aa809d 2019-08-08 stsp fi
441 33aa809d 2019-08-08 stsp cat > $testroot/stdout.expected <<EOF
442 33aa809d 2019-08-08 stsp -----------------------------------------------
443 33aa809d 2019-08-08 stsp @@ -1,5 +1,5 @@
444 33aa809d 2019-08-08 stsp 1
445 33aa809d 2019-08-08 stsp -2
446 33aa809d 2019-08-08 stsp +a
447 33aa809d 2019-08-08 stsp 3
448 33aa809d 2019-08-08 stsp 4
449 33aa809d 2019-08-08 stsp 5
450 33aa809d 2019-08-08 stsp -----------------------------------------------
451 33aa809d 2019-08-08 stsp M numbers (change 1 of 3)
452 33aa809d 2019-08-08 stsp revert this change? [y/n/q] n
453 33aa809d 2019-08-08 stsp -----------------------------------------------
454 33aa809d 2019-08-08 stsp @@ -4,7 +4,7 @@
455 33aa809d 2019-08-08 stsp 4
456 33aa809d 2019-08-08 stsp 5
457 33aa809d 2019-08-08 stsp 6
458 33aa809d 2019-08-08 stsp -7
459 33aa809d 2019-08-08 stsp +b
460 33aa809d 2019-08-08 stsp 8
461 33aa809d 2019-08-08 stsp 9
462 33aa809d 2019-08-08 stsp 10
463 33aa809d 2019-08-08 stsp -----------------------------------------------
464 33aa809d 2019-08-08 stsp M numbers (change 2 of 3)
465 33aa809d 2019-08-08 stsp revert this change? [y/n/q] n
466 33aa809d 2019-08-08 stsp -----------------------------------------------
467 33aa809d 2019-08-08 stsp @@ -13,4 +13,4 @@
468 33aa809d 2019-08-08 stsp 13
469 33aa809d 2019-08-08 stsp 14
470 33aa809d 2019-08-08 stsp 15
471 33aa809d 2019-08-08 stsp -16
472 33aa809d 2019-08-08 stsp +c
473 33aa809d 2019-08-08 stsp -----------------------------------------------
474 33aa809d 2019-08-08 stsp M numbers (change 3 of 3)
475 33aa809d 2019-08-08 stsp revert this change? [y/n/q] n
476 33aa809d 2019-08-08 stsp EOF
477 33aa809d 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
478 49c543a6 2022-03-31 naddy ret=$?
479 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
480 33aa809d 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
481 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
482 33aa809d 2019-08-08 stsp return 1
483 33aa809d 2019-08-08 stsp fi
484 33aa809d 2019-08-08 stsp
485 33aa809d 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
486 33aa809d 2019-08-08 stsp echo "M numbers" > $testroot/stdout.expected
487 33aa809d 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
488 49c543a6 2022-03-31 naddy ret=$?
489 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
490 33aa809d 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
491 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
492 33aa809d 2019-08-08 stsp return 1
493 33aa809d 2019-08-08 stsp fi
494 33aa809d 2019-08-08 stsp
495 33aa809d 2019-08-08 stsp (cd $testroot/wt && got diff > $testroot/stdout)
496 33aa809d 2019-08-08 stsp cmp -s $testroot/numbers.diff $testroot/stdout
497 49c543a6 2022-03-31 naddy ret=$?
498 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
499 33aa809d 2019-08-08 stsp diff -u $testroot/numbers.diff $testroot/stdout
500 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
501 33aa809d 2019-08-08 stsp return 1
502 33aa809d 2019-08-08 stsp fi
503 33aa809d 2019-08-08 stsp
504 ce2b05c7 2019-08-10 stsp # revert first hunk
505 ce2b05c7 2019-08-10 stsp printf "y\nn\nn\n" > $testroot/patchscript
506 ce2b05c7 2019-08-10 stsp (cd $testroot/wt && got revert -F $testroot/patchscript -p \
507 ce2b05c7 2019-08-10 stsp numbers > $testroot/stdout)
508 49c543a6 2022-03-31 naddy ret=$?
509 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
510 ce2b05c7 2019-08-10 stsp echo "got revert command failed unexpectedly" >&2
511 ce2b05c7 2019-08-10 stsp test_done "$testroot" "1"
512 ce2b05c7 2019-08-10 stsp return 1
513 ce2b05c7 2019-08-10 stsp fi
514 ce2b05c7 2019-08-10 stsp cat > $testroot/stdout.expected <<EOF
515 ce2b05c7 2019-08-10 stsp -----------------------------------------------
516 ce2b05c7 2019-08-10 stsp @@ -1,5 +1,5 @@
517 ce2b05c7 2019-08-10 stsp 1
518 ce2b05c7 2019-08-10 stsp -2
519 ce2b05c7 2019-08-10 stsp +a
520 ce2b05c7 2019-08-10 stsp 3
521 ce2b05c7 2019-08-10 stsp 4
522 ce2b05c7 2019-08-10 stsp 5
523 ce2b05c7 2019-08-10 stsp -----------------------------------------------
524 ce2b05c7 2019-08-10 stsp M numbers (change 1 of 3)
525 ce2b05c7 2019-08-10 stsp revert this change? [y/n/q] y
526 ce2b05c7 2019-08-10 stsp -----------------------------------------------
527 ce2b05c7 2019-08-10 stsp @@ -4,7 +4,7 @@
528 ce2b05c7 2019-08-10 stsp 4
529 ce2b05c7 2019-08-10 stsp 5
530 ce2b05c7 2019-08-10 stsp 6
531 ce2b05c7 2019-08-10 stsp -7
532 ce2b05c7 2019-08-10 stsp +b
533 ce2b05c7 2019-08-10 stsp 8
534 ce2b05c7 2019-08-10 stsp 9
535 ce2b05c7 2019-08-10 stsp 10
536 ce2b05c7 2019-08-10 stsp -----------------------------------------------
537 ce2b05c7 2019-08-10 stsp M numbers (change 2 of 3)
538 ce2b05c7 2019-08-10 stsp revert this change? [y/n/q] n
539 ce2b05c7 2019-08-10 stsp -----------------------------------------------
540 ce2b05c7 2019-08-10 stsp @@ -13,4 +13,4 @@
541 ce2b05c7 2019-08-10 stsp 13
542 ce2b05c7 2019-08-10 stsp 14
543 ce2b05c7 2019-08-10 stsp 15
544 ce2b05c7 2019-08-10 stsp -16
545 ce2b05c7 2019-08-10 stsp +c
546 ce2b05c7 2019-08-10 stsp -----------------------------------------------
547 ce2b05c7 2019-08-10 stsp M numbers (change 3 of 3)
548 ce2b05c7 2019-08-10 stsp revert this change? [y/n/q] n
549 ce2b05c7 2019-08-10 stsp EOF
550 ce2b05c7 2019-08-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
551 49c543a6 2022-03-31 naddy ret=$?
552 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
553 ce2b05c7 2019-08-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
554 ce2b05c7 2019-08-10 stsp test_done "$testroot" "$ret"
555 ce2b05c7 2019-08-10 stsp return 1
556 ce2b05c7 2019-08-10 stsp fi
557 ce2b05c7 2019-08-10 stsp
558 ce2b05c7 2019-08-10 stsp (cd $testroot/wt && got status > $testroot/stdout)
559 ce2b05c7 2019-08-10 stsp echo "M numbers" > $testroot/stdout.expected
560 ce2b05c7 2019-08-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
561 49c543a6 2022-03-31 naddy ret=$?
562 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
563 ce2b05c7 2019-08-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
564 ce2b05c7 2019-08-10 stsp test_done "$testroot" "$ret"
565 ce2b05c7 2019-08-10 stsp return 1
566 ce2b05c7 2019-08-10 stsp fi
567 ce2b05c7 2019-08-10 stsp
568 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
569 8469d821 2022-06-25 stsp echo "commit - $commit_id" >> $testroot/stdout.expected
570 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
571 ce2b05c7 2019-08-10 stsp echo -n 'blob - ' >> $testroot/stdout.expected
572 ce2b05c7 2019-08-10 stsp got tree -r $testroot/repo -i -c $commit_id \
573 ce2b05c7 2019-08-10 stsp | grep 'numbers$' | cut -d' ' -f 1 \
574 ce2b05c7 2019-08-10 stsp >> $testroot/stdout.expected
575 ce2b05c7 2019-08-10 stsp echo 'file + numbers' >> $testroot/stdout.expected
576 ce2b05c7 2019-08-10 stsp cat >> $testroot/stdout.expected <<EOF
577 ce2b05c7 2019-08-10 stsp --- numbers
578 ce2b05c7 2019-08-10 stsp +++ numbers
579 ce2b05c7 2019-08-10 stsp @@ -4,7 +4,7 @@
580 ce2b05c7 2019-08-10 stsp 4
581 ce2b05c7 2019-08-10 stsp 5
582 ce2b05c7 2019-08-10 stsp 6
583 ce2b05c7 2019-08-10 stsp -7
584 ce2b05c7 2019-08-10 stsp +b
585 ce2b05c7 2019-08-10 stsp 8
586 ce2b05c7 2019-08-10 stsp 9
587 ce2b05c7 2019-08-10 stsp 10
588 ce2b05c7 2019-08-10 stsp @@ -13,4 +13,4 @@
589 ce2b05c7 2019-08-10 stsp 13
590 ce2b05c7 2019-08-10 stsp 14
591 ce2b05c7 2019-08-10 stsp 15
592 ce2b05c7 2019-08-10 stsp -16
593 ce2b05c7 2019-08-10 stsp +c
594 ce2b05c7 2019-08-10 stsp EOF
595 ce2b05c7 2019-08-10 stsp (cd $testroot/wt && got diff > $testroot/stdout)
596 ce2b05c7 2019-08-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
597 49c543a6 2022-03-31 naddy ret=$?
598 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
599 ce2b05c7 2019-08-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
600 ce2b05c7 2019-08-10 stsp test_done "$testroot" "$ret"
601 ce2b05c7 2019-08-10 stsp return 1
602 ce2b05c7 2019-08-10 stsp fi
603 ce2b05c7 2019-08-10 stsp
604 ce2b05c7 2019-08-10 stsp # put first hunk back
605 885e96df 2023-03-06 naddy ed -s $testroot/wt/numbers <<-\EOF
606 885e96df 2023-03-06 naddy ,s/^2$/a/
607 885e96df 2023-03-06 naddy w
608 885e96df 2023-03-06 naddy EOF
609 ce2b05c7 2019-08-10 stsp
610 33aa809d 2019-08-08 stsp # revert middle hunk
611 33aa809d 2019-08-08 stsp printf "n\ny\nn\n" > $testroot/patchscript
612 33aa809d 2019-08-08 stsp (cd $testroot/wt && got revert -F $testroot/patchscript -p \
613 33aa809d 2019-08-08 stsp numbers > $testroot/stdout)
614 33aa809d 2019-08-08 stsp
615 33aa809d 2019-08-08 stsp cat > $testroot/stdout.expected <<EOF
616 33aa809d 2019-08-08 stsp -----------------------------------------------
617 33aa809d 2019-08-08 stsp @@ -1,5 +1,5 @@
618 33aa809d 2019-08-08 stsp 1
619 33aa809d 2019-08-08 stsp -2
620 33aa809d 2019-08-08 stsp +a
621 33aa809d 2019-08-08 stsp 3
622 33aa809d 2019-08-08 stsp 4
623 33aa809d 2019-08-08 stsp 5
624 33aa809d 2019-08-08 stsp -----------------------------------------------
625 33aa809d 2019-08-08 stsp M numbers (change 1 of 3)
626 33aa809d 2019-08-08 stsp revert this change? [y/n/q] n
627 33aa809d 2019-08-08 stsp -----------------------------------------------
628 33aa809d 2019-08-08 stsp @@ -4,7 +4,7 @@
629 33aa809d 2019-08-08 stsp 4
630 33aa809d 2019-08-08 stsp 5
631 33aa809d 2019-08-08 stsp 6
632 33aa809d 2019-08-08 stsp -7
633 33aa809d 2019-08-08 stsp +b
634 33aa809d 2019-08-08 stsp 8
635 33aa809d 2019-08-08 stsp 9
636 33aa809d 2019-08-08 stsp 10
637 33aa809d 2019-08-08 stsp -----------------------------------------------
638 33aa809d 2019-08-08 stsp M numbers (change 2 of 3)
639 33aa809d 2019-08-08 stsp revert this change? [y/n/q] y
640 33aa809d 2019-08-08 stsp -----------------------------------------------
641 33aa809d 2019-08-08 stsp @@ -13,4 +13,4 @@
642 33aa809d 2019-08-08 stsp 13
643 33aa809d 2019-08-08 stsp 14
644 33aa809d 2019-08-08 stsp 15
645 33aa809d 2019-08-08 stsp -16
646 33aa809d 2019-08-08 stsp +c
647 33aa809d 2019-08-08 stsp -----------------------------------------------
648 33aa809d 2019-08-08 stsp M numbers (change 3 of 3)
649 33aa809d 2019-08-08 stsp revert this change? [y/n/q] n
650 33aa809d 2019-08-08 stsp EOF
651 33aa809d 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
652 49c543a6 2022-03-31 naddy ret=$?
653 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
654 33aa809d 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
655 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
656 33aa809d 2019-08-08 stsp return 1
657 33aa809d 2019-08-08 stsp fi
658 33aa809d 2019-08-08 stsp
659 33aa809d 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
660 33aa809d 2019-08-08 stsp echo "M numbers" > $testroot/stdout.expected
661 33aa809d 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
662 49c543a6 2022-03-31 naddy ret=$?
663 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
664 33aa809d 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
665 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
666 33aa809d 2019-08-08 stsp return 1
667 33aa809d 2019-08-08 stsp fi
668 33aa809d 2019-08-08 stsp
669 33aa809d 2019-08-08 stsp (cd $testroot/wt && got diff > $testroot/stdout)
670 33aa809d 2019-08-08 stsp
671 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
672 8469d821 2022-06-25 stsp echo "commit - $commit_id" >> $testroot/stdout.expected
673 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
674 33aa809d 2019-08-08 stsp echo -n 'blob - ' >> $testroot/stdout.expected
675 33aa809d 2019-08-08 stsp got tree -r $testroot/repo -i -c $commit_id \
676 33aa809d 2019-08-08 stsp | grep 'numbers$' | cut -d' ' -f 1 \
677 33aa809d 2019-08-08 stsp >> $testroot/stdout.expected
678 33aa809d 2019-08-08 stsp echo 'file + numbers' >> $testroot/stdout.expected
679 33aa809d 2019-08-08 stsp cat >> $testroot/stdout.expected <<EOF
680 33aa809d 2019-08-08 stsp --- numbers
681 33aa809d 2019-08-08 stsp +++ numbers
682 33aa809d 2019-08-08 stsp @@ -1,5 +1,5 @@
683 33aa809d 2019-08-08 stsp 1
684 33aa809d 2019-08-08 stsp -2
685 33aa809d 2019-08-08 stsp +a
686 33aa809d 2019-08-08 stsp 3
687 33aa809d 2019-08-08 stsp 4
688 33aa809d 2019-08-08 stsp 5
689 33aa809d 2019-08-08 stsp @@ -13,4 +13,4 @@
690 33aa809d 2019-08-08 stsp 13
691 33aa809d 2019-08-08 stsp 14
692 33aa809d 2019-08-08 stsp 15
693 33aa809d 2019-08-08 stsp -16
694 33aa809d 2019-08-08 stsp +c
695 33aa809d 2019-08-08 stsp EOF
696 33aa809d 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
697 49c543a6 2022-03-31 naddy ret=$?
698 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
699 33aa809d 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
700 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
701 33aa809d 2019-08-08 stsp return 1
702 0f6d7415 2019-08-08 stsp fi
703 33aa809d 2019-08-08 stsp
704 33aa809d 2019-08-08 stsp # revert last hunk
705 33aa809d 2019-08-08 stsp printf "n\ny\n" > $testroot/patchscript
706 33aa809d 2019-08-08 stsp (cd $testroot/wt && got revert -F $testroot/patchscript -p \
707 33aa809d 2019-08-08 stsp numbers > $testroot/stdout)
708 33aa809d 2019-08-08 stsp cat > $testroot/stdout.expected <<EOF
709 33aa809d 2019-08-08 stsp -----------------------------------------------
710 33aa809d 2019-08-08 stsp @@ -1,5 +1,5 @@
711 33aa809d 2019-08-08 stsp 1
712 33aa809d 2019-08-08 stsp -2
713 33aa809d 2019-08-08 stsp +a
714 33aa809d 2019-08-08 stsp 3
715 33aa809d 2019-08-08 stsp 4
716 33aa809d 2019-08-08 stsp 5
717 33aa809d 2019-08-08 stsp -----------------------------------------------
718 33aa809d 2019-08-08 stsp M numbers (change 1 of 2)
719 33aa809d 2019-08-08 stsp revert this change? [y/n/q] n
720 33aa809d 2019-08-08 stsp -----------------------------------------------
721 33aa809d 2019-08-08 stsp @@ -13,4 +13,4 @@
722 33aa809d 2019-08-08 stsp 13
723 33aa809d 2019-08-08 stsp 14
724 33aa809d 2019-08-08 stsp 15
725 33aa809d 2019-08-08 stsp -16
726 33aa809d 2019-08-08 stsp +c
727 33aa809d 2019-08-08 stsp -----------------------------------------------
728 33aa809d 2019-08-08 stsp M numbers (change 2 of 2)
729 33aa809d 2019-08-08 stsp revert this change? [y/n/q] y
730 33aa809d 2019-08-08 stsp EOF
731 33aa809d 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
732 49c543a6 2022-03-31 naddy ret=$?
733 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
734 33aa809d 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
735 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
736 33aa809d 2019-08-08 stsp return 1
737 33aa809d 2019-08-08 stsp fi
738 33aa809d 2019-08-08 stsp
739 33aa809d 2019-08-08 stsp (cd $testroot/wt && got diff > $testroot/stdout)
740 33aa809d 2019-08-08 stsp
741 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
742 8469d821 2022-06-25 stsp echo "commit - $commit_id" >> $testroot/stdout.expected
743 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
744 33aa809d 2019-08-08 stsp echo -n 'blob - ' >> $testroot/stdout.expected
745 33aa809d 2019-08-08 stsp got tree -r $testroot/repo -i -c $commit_id \
746 33aa809d 2019-08-08 stsp | grep 'numbers$' | cut -d' ' -f 1 \
747 33aa809d 2019-08-08 stsp >> $testroot/stdout.expected
748 33aa809d 2019-08-08 stsp echo 'file + numbers' >> $testroot/stdout.expected
749 33aa809d 2019-08-08 stsp cat >> $testroot/stdout.expected <<EOF
750 33aa809d 2019-08-08 stsp --- numbers
751 33aa809d 2019-08-08 stsp +++ numbers
752 33aa809d 2019-08-08 stsp @@ -1,5 +1,5 @@
753 33aa809d 2019-08-08 stsp 1
754 33aa809d 2019-08-08 stsp -2
755 33aa809d 2019-08-08 stsp +a
756 33aa809d 2019-08-08 stsp 3
757 33aa809d 2019-08-08 stsp 4
758 33aa809d 2019-08-08 stsp 5
759 33aa809d 2019-08-08 stsp EOF
760 33aa809d 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
761 49c543a6 2022-03-31 naddy ret=$?
762 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
763 33aa809d 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
764 33aa809d 2019-08-08 stsp fi
765 1f1abb7e 2019-08-08 stsp test_done "$testroot" "$ret"
766 33aa809d 2019-08-08 stsp }
767 0f6d7415 2019-08-08 stsp
768 f6cae3ed 2020-09-13 naddy test_revert_patch_added() {
769 33aa809d 2019-08-08 stsp local testroot=`test_init revert_patch_added`
770 33aa809d 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
771 33aa809d 2019-08-08 stsp
772 33aa809d 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
773 49c543a6 2022-03-31 naddy ret=$?
774 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
775 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
776 33aa809d 2019-08-08 stsp return 1
777 33aa809d 2019-08-08 stsp fi
778 33aa809d 2019-08-08 stsp
779 33aa809d 2019-08-08 stsp echo "new" > $testroot/wt/epsilon/new
780 33aa809d 2019-08-08 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
781 33aa809d 2019-08-08 stsp
782 33aa809d 2019-08-08 stsp printf "n\n" > $testroot/patchscript
783 33aa809d 2019-08-08 stsp (cd $testroot/wt && got revert -F $testroot/patchscript -p \
784 33aa809d 2019-08-08 stsp epsilon/new > $testroot/stdout)
785 33aa809d 2019-08-08 stsp
786 33aa809d 2019-08-08 stsp echo "A epsilon/new" > $testroot/stdout.expected
787 33aa809d 2019-08-08 stsp echo "revert this addition? [y/n] n" >> $testroot/stdout.expected
788 33aa809d 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
789 49c543a6 2022-03-31 naddy ret=$?
790 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
791 33aa809d 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
792 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
793 33aa809d 2019-08-08 stsp return 1
794 33aa809d 2019-08-08 stsp fi
795 33aa809d 2019-08-08 stsp
796 33aa809d 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
797 33aa809d 2019-08-08 stsp echo "A epsilon/new" > $testroot/stdout.expected
798 33aa809d 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
799 49c543a6 2022-03-31 naddy ret=$?
800 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
801 33aa809d 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
802 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
803 33aa809d 2019-08-08 stsp return 1
804 33aa809d 2019-08-08 stsp fi
805 33aa809d 2019-08-08 stsp
806 33aa809d 2019-08-08 stsp printf "y\n" > $testroot/patchscript
807 33aa809d 2019-08-08 stsp (cd $testroot/wt && got revert -F $testroot/patchscript -p \
808 33aa809d 2019-08-08 stsp epsilon/new > $testroot/stdout)
809 33aa809d 2019-08-08 stsp
810 33aa809d 2019-08-08 stsp echo "A epsilon/new" > $testroot/stdout.expected
811 33aa809d 2019-08-08 stsp echo "revert this addition? [y/n] y" >> $testroot/stdout.expected
812 33aa809d 2019-08-08 stsp echo "R epsilon/new" >> $testroot/stdout.expected
813 33aa809d 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
814 49c543a6 2022-03-31 naddy ret=$?
815 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
816 33aa809d 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
817 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
818 33aa809d 2019-08-08 stsp return 1
819 33aa809d 2019-08-08 stsp fi
820 33aa809d 2019-08-08 stsp
821 33aa809d 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
822 33aa809d 2019-08-08 stsp echo "? epsilon/new" > $testroot/stdout.expected
823 33aa809d 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
824 49c543a6 2022-03-31 naddy ret=$?
825 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
826 33aa809d 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
827 33aa809d 2019-08-08 stsp fi
828 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
829 1f1abb7e 2019-08-08 stsp }
830 1f1abb7e 2019-08-08 stsp
831 f6cae3ed 2020-09-13 naddy test_revert_patch_removed() {
832 33aa809d 2019-08-08 stsp local testroot=`test_init revert_patch_removed`
833 33aa809d 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
834 33aa809d 2019-08-08 stsp
835 33aa809d 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
836 49c543a6 2022-03-31 naddy ret=$?
837 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
838 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
839 33aa809d 2019-08-08 stsp return 1
840 33aa809d 2019-08-08 stsp fi
841 33aa809d 2019-08-08 stsp
842 33aa809d 2019-08-08 stsp (cd $testroot/wt && got rm beta > /dev/null)
843 33aa809d 2019-08-08 stsp
844 33aa809d 2019-08-08 stsp printf "n\n" > $testroot/patchscript
845 33aa809d 2019-08-08 stsp (cd $testroot/wt && got revert -F $testroot/patchscript -p \
846 33aa809d 2019-08-08 stsp beta > $testroot/stdout)
847 33aa809d 2019-08-08 stsp echo "D beta" > $testroot/stdout.expected
848 33aa809d 2019-08-08 stsp echo "revert this deletion? [y/n] n" >> $testroot/stdout.expected
849 33aa809d 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
850 49c543a6 2022-03-31 naddy ret=$?
851 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
852 33aa809d 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
853 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
854 33aa809d 2019-08-08 stsp return 1
855 33aa809d 2019-08-08 stsp fi
856 33aa809d 2019-08-08 stsp
857 33aa809d 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
858 33aa809d 2019-08-08 stsp echo "D beta" > $testroot/stdout.expected
859 33aa809d 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
860 49c543a6 2022-03-31 naddy ret=$?
861 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
862 33aa809d 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
863 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
864 33aa809d 2019-08-08 stsp return 1
865 33aa809d 2019-08-08 stsp fi
866 33aa809d 2019-08-08 stsp
867 33aa809d 2019-08-08 stsp printf "y\n" > $testroot/patchscript
868 33aa809d 2019-08-08 stsp (cd $testroot/wt && got revert -F $testroot/patchscript -p \
869 33aa809d 2019-08-08 stsp beta > $testroot/stdout)
870 33aa809d 2019-08-08 stsp
871 33aa809d 2019-08-08 stsp echo "D beta" > $testroot/stdout.expected
872 33aa809d 2019-08-08 stsp echo "revert this deletion? [y/n] y" >> $testroot/stdout.expected
873 33aa809d 2019-08-08 stsp echo "R beta" >> $testroot/stdout.expected
874 33aa809d 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
875 49c543a6 2022-03-31 naddy ret=$?
876 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
877 33aa809d 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
878 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
879 33aa809d 2019-08-08 stsp return 1
880 33aa809d 2019-08-08 stsp fi
881 33aa809d 2019-08-08 stsp
882 33aa809d 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
883 33aa809d 2019-08-08 stsp echo -n > $testroot/stdout.expected
884 33aa809d 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
885 49c543a6 2022-03-31 naddy ret=$?
886 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
887 33aa809d 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
888 33aa809d 2019-08-08 stsp fi
889 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
890 33aa809d 2019-08-08 stsp }
891 f1e81a05 2019-08-10 stsp
892 f6cae3ed 2020-09-13 naddy test_revert_patch_one_change() {
893 f1e81a05 2019-08-10 stsp local testroot=`test_init revert_patch_one_change`
894 f1e81a05 2019-08-10 stsp
895 f1e81a05 2019-08-10 stsp jot 16 > $testroot/repo/numbers
896 f1e81a05 2019-08-10 stsp (cd $testroot/repo && git add numbers)
897 f1e81a05 2019-08-10 stsp git_commit $testroot/repo -m "added numbers file"
898 f1e81a05 2019-08-10 stsp local commit_id=`git_show_head $testroot/repo`
899 f1e81a05 2019-08-10 stsp
900 f1e81a05 2019-08-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
901 49c543a6 2022-03-31 naddy ret=$?
902 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
903 f1e81a05 2019-08-10 stsp test_done "$testroot" "$ret"
904 f1e81a05 2019-08-10 stsp return 1
905 f1e81a05 2019-08-10 stsp fi
906 f1e81a05 2019-08-10 stsp
907 6c6b73bb 2019-08-10 stsp # Ensure file size is changed. Avoids race condition causing test
908 6c6b73bb 2019-08-10 stsp # failures where 'got revert' does not see changes to revert if
909 6c6b73bb 2019-08-10 stsp # timestamps and size in stat info remain unchanged.
910 885e96df 2023-03-06 naddy ed -s $testroot/wt/numbers <<-\EOF
911 885e96df 2023-03-06 naddy ,s/^2$/aa/
912 885e96df 2023-03-06 naddy w
913 885e96df 2023-03-06 naddy EOF
914 33aa809d 2019-08-08 stsp
915 f1e81a05 2019-08-10 stsp # revert change with -p
916 f1e81a05 2019-08-10 stsp printf "y\n" > $testroot/patchscript
917 f1e81a05 2019-08-10 stsp (cd $testroot/wt && got revert -F $testroot/patchscript -p \
918 f1e81a05 2019-08-10 stsp numbers > $testroot/stdout)
919 49c543a6 2022-03-31 naddy ret=$?
920 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
921 f1e81a05 2019-08-10 stsp echo "got revert command failed unexpectedly" >&2
922 f1e81a05 2019-08-10 stsp test_done "$testroot" "1"
923 f1e81a05 2019-08-10 stsp return 1
924 f1e81a05 2019-08-10 stsp fi
925 f1e81a05 2019-08-10 stsp cat > $testroot/stdout.expected <<EOF
926 f1e81a05 2019-08-10 stsp -----------------------------------------------
927 f1e81a05 2019-08-10 stsp @@ -1,5 +1,5 @@
928 f1e81a05 2019-08-10 stsp 1
929 f1e81a05 2019-08-10 stsp -2
930 6c6b73bb 2019-08-10 stsp +aa
931 f1e81a05 2019-08-10 stsp 3
932 f1e81a05 2019-08-10 stsp 4
933 f1e81a05 2019-08-10 stsp 5
934 f1e81a05 2019-08-10 stsp -----------------------------------------------
935 f1e81a05 2019-08-10 stsp M numbers (change 1 of 1)
936 f1e81a05 2019-08-10 stsp revert this change? [y/n/q] y
937 f1e81a05 2019-08-10 stsp EOF
938 49c543a6 2022-03-31 naddy ret=$?
939 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
940 6c6b73bb 2019-08-10 stsp echo "got revert command failed unexpectedly" >&2
941 6c6b73bb 2019-08-10 stsp test_done "$testroot" "1"
942 6c6b73bb 2019-08-10 stsp return 1
943 6c6b73bb 2019-08-10 stsp fi
944 6c6b73bb 2019-08-10 stsp
945 f1e81a05 2019-08-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
946 49c543a6 2022-03-31 naddy ret=$?
947 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
948 f1e81a05 2019-08-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
949 f1e81a05 2019-08-10 stsp test_done "$testroot" "$ret"
950 f1e81a05 2019-08-10 stsp return 1
951 f1e81a05 2019-08-10 stsp fi
952 f1e81a05 2019-08-10 stsp
953 f1e81a05 2019-08-10 stsp (cd $testroot/wt && got status > $testroot/stdout)
954 f1e81a05 2019-08-10 stsp echo -n > $testroot/stdout.expected
955 f1e81a05 2019-08-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
956 49c543a6 2022-03-31 naddy ret=$?
957 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
958 f1e81a05 2019-08-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
959 f1e81a05 2019-08-10 stsp test_done "$testroot" "$ret"
960 f1e81a05 2019-08-10 stsp return 1
961 f1e81a05 2019-08-10 stsp fi
962 f1e81a05 2019-08-10 stsp
963 f1e81a05 2019-08-10 stsp (cd $testroot/wt && got diff > $testroot/stdout)
964 f1e81a05 2019-08-10 stsp echo -n > $testroot/stdout.expected
965 f1e81a05 2019-08-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
966 49c543a6 2022-03-31 naddy ret=$?
967 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
968 f1e81a05 2019-08-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
969 f1e81a05 2019-08-10 stsp fi
970 f1e81a05 2019-08-10 stsp test_done "$testroot" "$ret"
971 f1e81a05 2019-08-10 stsp }
972 a46b9f33 2020-01-28 stsp
973 f6cae3ed 2020-09-13 naddy test_revert_added_subtree() {
974 a46b9f33 2020-01-28 stsp local testroot=`test_init revert_added_subtree`
975 f1e81a05 2019-08-10 stsp
976 a46b9f33 2020-01-28 stsp got checkout $testroot/repo $testroot/wt > /dev/null
977 49c543a6 2022-03-31 naddy ret=$?
978 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
979 a46b9f33 2020-01-28 stsp test_done "$testroot" "$ret"
980 a46b9f33 2020-01-28 stsp return 1
981 a46b9f33 2020-01-28 stsp fi
982 a46b9f33 2020-01-28 stsp
983 a46b9f33 2020-01-28 stsp mkdir -p $testroot/wt/epsilon/foo/bar/baz
984 a46b9f33 2020-01-28 stsp mkdir -p $testroot/wt/epsilon/foo/bar/bax
985 a46b9f33 2020-01-28 stsp echo "new file" > $testroot/wt/epsilon/foo/a.o
986 a46b9f33 2020-01-28 stsp echo "new file" > $testroot/wt/epsilon/foo/a.o
987 a46b9f33 2020-01-28 stsp echo "new file" > $testroot/wt/epsilon/foo/bar/b.o
988 a46b9f33 2020-01-28 stsp echo "new file" > $testroot/wt/epsilon/foo/bar/b.d
989 a46b9f33 2020-01-28 stsp echo "new file" > $testroot/wt/epsilon/foo/bar/baz/f.o
990 a46b9f33 2020-01-28 stsp echo "new file" > $testroot/wt/epsilon/foo/bar/baz/f.d
991 a46b9f33 2020-01-28 stsp echo "new file" > $testroot/wt/epsilon/foo/bar/baz/c.o
992 a46b9f33 2020-01-28 stsp echo "new file" > $testroot/wt/epsilon/foo/bar/baz/c.d
993 a46b9f33 2020-01-28 stsp echo "new file" > $testroot/wt/epsilon/foo/bar/bax/e.o
994 a46b9f33 2020-01-28 stsp echo "new file" > $testroot/wt/epsilon/foo/bar/bax/e.d
995 a46b9f33 2020-01-28 stsp echo "new file" > $testroot/wt/epsilon/foo/bar/bax/x.o
996 a46b9f33 2020-01-28 stsp echo "new file" > $testroot/wt/epsilon/foo/bar/bax/x.d
997 a46b9f33 2020-01-28 stsp (cd $testroot/wt && got add -R epsilon >/dev/null)
998 a46b9f33 2020-01-28 stsp
999 a46b9f33 2020-01-28 stsp echo "R epsilon/foo/a.o" > $testroot/stdout.expected
1000 a46b9f33 2020-01-28 stsp echo "R epsilon/foo/bar/b.d" >> $testroot/stdout.expected
1001 a46b9f33 2020-01-28 stsp echo "R epsilon/foo/bar/b.o" >> $testroot/stdout.expected
1002 a46b9f33 2020-01-28 stsp echo "R epsilon/foo/bar/bax/e.d" >> $testroot/stdout.expected
1003 a46b9f33 2020-01-28 stsp echo "R epsilon/foo/bar/bax/e.o" >> $testroot/stdout.expected
1004 a46b9f33 2020-01-28 stsp echo "R epsilon/foo/bar/bax/x.d" >> $testroot/stdout.expected
1005 a46b9f33 2020-01-28 stsp echo "R epsilon/foo/bar/bax/x.o" >> $testroot/stdout.expected
1006 a46b9f33 2020-01-28 stsp echo "R epsilon/foo/bar/baz/c.d" >> $testroot/stdout.expected
1007 a46b9f33 2020-01-28 stsp echo "R epsilon/foo/bar/baz/c.o" >> $testroot/stdout.expected
1008 a46b9f33 2020-01-28 stsp echo "R epsilon/foo/bar/baz/f.d" >> $testroot/stdout.expected
1009 a46b9f33 2020-01-28 stsp echo "R epsilon/foo/bar/baz/f.o" >> $testroot/stdout.expected
1010 a46b9f33 2020-01-28 stsp
1011 a46b9f33 2020-01-28 stsp (cd $testroot/wt && got revert -R . > $testroot/stdout)
1012 a46b9f33 2020-01-28 stsp
1013 a46b9f33 2020-01-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1014 49c543a6 2022-03-31 naddy ret=$?
1015 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1016 a46b9f33 2020-01-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
1017 a46b9f33 2020-01-28 stsp test_done "$testroot" "$ret"
1018 a46b9f33 2020-01-28 stsp return 1
1019 a46b9f33 2020-01-28 stsp fi
1020 a46b9f33 2020-01-28 stsp
1021 a46b9f33 2020-01-28 stsp echo "? epsilon/foo/a.o" > $testroot/stdout.expected
1022 a46b9f33 2020-01-28 stsp echo "? epsilon/foo/bar/b.d" >> $testroot/stdout.expected
1023 a46b9f33 2020-01-28 stsp echo "? epsilon/foo/bar/b.o" >> $testroot/stdout.expected
1024 a46b9f33 2020-01-28 stsp echo "? epsilon/foo/bar/bax/e.d" >> $testroot/stdout.expected
1025 a46b9f33 2020-01-28 stsp echo "? epsilon/foo/bar/bax/e.o" >> $testroot/stdout.expected
1026 a46b9f33 2020-01-28 stsp echo "? epsilon/foo/bar/bax/x.d" >> $testroot/stdout.expected
1027 a46b9f33 2020-01-28 stsp echo "? epsilon/foo/bar/bax/x.o" >> $testroot/stdout.expected
1028 a46b9f33 2020-01-28 stsp echo "? epsilon/foo/bar/baz/c.d" >> $testroot/stdout.expected
1029 a46b9f33 2020-01-28 stsp echo "? epsilon/foo/bar/baz/c.o" >> $testroot/stdout.expected
1030 a46b9f33 2020-01-28 stsp echo "? epsilon/foo/bar/baz/f.d" >> $testroot/stdout.expected
1031 a46b9f33 2020-01-28 stsp echo "? epsilon/foo/bar/baz/f.o" >> $testroot/stdout.expected
1032 15341bfd 2020-03-05 tracey
1033 15341bfd 2020-03-05 tracey (cd $testroot/wt && got status > $testroot/stdout)
1034 15341bfd 2020-03-05 tracey
1035 15341bfd 2020-03-05 tracey cmp -s $testroot/stdout.expected $testroot/stdout
1036 49c543a6 2022-03-31 naddy ret=$?
1037 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1038 15341bfd 2020-03-05 tracey diff -u $testroot/stdout.expected $testroot/stdout
1039 15341bfd 2020-03-05 tracey fi
1040 15341bfd 2020-03-05 tracey test_done "$testroot" "$ret"
1041 15341bfd 2020-03-05 tracey }
1042 15341bfd 2020-03-05 tracey
1043 f6cae3ed 2020-09-13 naddy test_revert_deleted_subtree() {
1044 15341bfd 2020-03-05 tracey local testroot=`test_init revert_deleted_subtree`
1045 15341bfd 2020-03-05 tracey
1046 15341bfd 2020-03-05 tracey got checkout $testroot/repo $testroot/wt > /dev/null
1047 49c543a6 2022-03-31 naddy ret=$?
1048 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1049 15341bfd 2020-03-05 tracey test_done "$testroot" "$ret"
1050 15341bfd 2020-03-05 tracey return 1
1051 15341bfd 2020-03-05 tracey fi
1052 15341bfd 2020-03-05 tracey
1053 15341bfd 2020-03-05 tracey mkdir -p $testroot/wt/epsilon/foo/bar/baz
1054 15341bfd 2020-03-05 tracey mkdir -p $testroot/wt/epsilon/foo/bar/bax
1055 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/a.o
1056 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/a.o
1057 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/b.o
1058 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/b.d
1059 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/baz/f.o
1060 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/baz/f.d
1061 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/baz/c.o
1062 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/baz/c.d
1063 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/bax/e.o
1064 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/bax/e.d
1065 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/bax/x.o
1066 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/bax/x.d
1067 15341bfd 2020-03-05 tracey (cd $testroot/wt && got add -R epsilon >/dev/null)
1068 15341bfd 2020-03-05 tracey (cd $testroot/wt && got commit -m "add subtree" >/dev/null)
1069 a46b9f33 2020-01-28 stsp
1070 15341bfd 2020-03-05 tracey # now delete and revert the entire subtree
1071 15341bfd 2020-03-05 tracey (cd $testroot/wt && got rm -R epsilon/foo >/dev/null)
1072 15341bfd 2020-03-05 tracey
1073 15341bfd 2020-03-05 tracey echo "R epsilon/foo/a.o" > $testroot/stdout.expected
1074 15341bfd 2020-03-05 tracey echo "R epsilon/foo/bar/b.d" >> $testroot/stdout.expected
1075 15341bfd 2020-03-05 tracey echo "R epsilon/foo/bar/b.o" >> $testroot/stdout.expected
1076 15341bfd 2020-03-05 tracey echo "R epsilon/foo/bar/bax/e.d" >> $testroot/stdout.expected
1077 15341bfd 2020-03-05 tracey echo "R epsilon/foo/bar/bax/e.o" >> $testroot/stdout.expected
1078 15341bfd 2020-03-05 tracey echo "R epsilon/foo/bar/bax/x.d" >> $testroot/stdout.expected
1079 15341bfd 2020-03-05 tracey echo "R epsilon/foo/bar/bax/x.o" >> $testroot/stdout.expected
1080 15341bfd 2020-03-05 tracey echo "R epsilon/foo/bar/baz/c.d" >> $testroot/stdout.expected
1081 15341bfd 2020-03-05 tracey echo "R epsilon/foo/bar/baz/c.o" >> $testroot/stdout.expected
1082 15341bfd 2020-03-05 tracey echo "R epsilon/foo/bar/baz/f.d" >> $testroot/stdout.expected
1083 15341bfd 2020-03-05 tracey echo "R epsilon/foo/bar/baz/f.o" >> $testroot/stdout.expected
1084 15341bfd 2020-03-05 tracey
1085 15341bfd 2020-03-05 tracey (cd $testroot/wt && got revert -R . > $testroot/stdout)
1086 15341bfd 2020-03-05 tracey
1087 15341bfd 2020-03-05 tracey cmp -s $testroot/stdout.expected $testroot/stdout
1088 49c543a6 2022-03-31 naddy ret=$?
1089 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1090 15341bfd 2020-03-05 tracey diff -u $testroot/stdout.expected $testroot/stdout
1091 15341bfd 2020-03-05 tracey test_done "$testroot" "$ret"
1092 15341bfd 2020-03-05 tracey return 1
1093 15341bfd 2020-03-05 tracey fi
1094 15341bfd 2020-03-05 tracey
1095 15341bfd 2020-03-05 tracey echo -n > $testroot/stdout.expected
1096 a46b9f33 2020-01-28 stsp (cd $testroot/wt && got status > $testroot/stdout)
1097 a46b9f33 2020-01-28 stsp
1098 a46b9f33 2020-01-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1099 49c543a6 2022-03-31 naddy ret=$?
1100 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1101 a46b9f33 2020-01-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
1102 a46b9f33 2020-01-28 stsp fi
1103 a46b9f33 2020-01-28 stsp test_done "$testroot" "$ret"
1104 a46b9f33 2020-01-28 stsp }
1105 4901ccfc 2020-07-23 stsp
1106 f6cae3ed 2020-09-13 naddy test_revert_symlink() {
1107 4901ccfc 2020-07-23 stsp local testroot=`test_init revert_symlink`
1108 4901ccfc 2020-07-23 stsp
1109 4901ccfc 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
1110 4901ccfc 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
1111 4901ccfc 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
1112 4901ccfc 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
1113 4901ccfc 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
1114 4901ccfc 2020-07-23 stsp (cd $testroot/repo && ln -sf epsilon/zeta zeta.link)
1115 4901ccfc 2020-07-23 stsp (cd $testroot/repo && git add .)
1116 4901ccfc 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
1117 4901ccfc 2020-07-23 stsp local commit_id1=`git_show_head $testroot/repo`
1118 4901ccfc 2020-07-23 stsp
1119 4901ccfc 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1120 4901ccfc 2020-07-23 stsp
1121 4901ccfc 2020-07-23 stsp # symlink to file A now points to file B
1122 4901ccfc 2020-07-23 stsp (cd $testroot/wt && ln -sf gamma/delta alpha.link)
1123 4901ccfc 2020-07-23 stsp # symlink to a directory A now points to file B
1124 f55db25a 2023-03-03 naddy (cd $testroot/wt && rm epsilon.link && ln -s beta epsilon.link)
1125 4901ccfc 2020-07-23 stsp # "bad" symlink now contains a different target path
1126 4901ccfc 2020-07-23 stsp echo "foo" > $testroot/wt/passwd.link
1127 4901ccfc 2020-07-23 stsp # relative symlink to directory A now points to relative directory B
1128 f55db25a 2023-03-03 naddy (cd $testroot/wt && rm epsilon/beta.link && ln -s ../gamma \
1129 f55db25a 2023-03-03 naddy epsilon/beta.link)
1130 4901ccfc 2020-07-23 stsp # an unversioned symlink
1131 4901ccfc 2020-07-23 stsp (cd $testroot/wt && ln -sf .got/foo dotgotfoo.link)
1132 4901ccfc 2020-07-23 stsp # symlink to file A now points to non-existent file B
1133 4901ccfc 2020-07-23 stsp (cd $testroot/wt && ln -sf nonexistent2 nonexistent.link)
1134 4901ccfc 2020-07-23 stsp # removed symlink
1135 4901ccfc 2020-07-23 stsp (cd $testroot/wt && got rm zeta.link > /dev/null)
1136 4901ccfc 2020-07-23 stsp # added symlink
1137 4901ccfc 2020-07-23 stsp (cd $testroot/wt && ln -sf beta new.link)
1138 4901ccfc 2020-07-23 stsp (cd $testroot/wt && got add new.link > /dev/null)
1139 a46b9f33 2020-01-28 stsp
1140 4901ccfc 2020-07-23 stsp (cd $testroot/wt && got revert alpha.link epsilon.link \
1141 4901ccfc 2020-07-23 stsp passwd.link epsilon/beta.link dotgotfoo.link \
1142 4901ccfc 2020-07-23 stsp nonexistent.link zeta.link new.link > $testroot/stdout)
1143 4901ccfc 2020-07-23 stsp
1144 4901ccfc 2020-07-23 stsp cat > $testroot/stdout.expected <<EOF
1145 4901ccfc 2020-07-23 stsp R alpha.link
1146 4901ccfc 2020-07-23 stsp R epsilon/beta.link
1147 10a623df 2021-10-11 stsp R epsilon.link
1148 10a623df 2021-10-11 stsp R new.link
1149 4901ccfc 2020-07-23 stsp R nonexistent.link
1150 10a623df 2021-10-11 stsp R passwd.link
1151 4901ccfc 2020-07-23 stsp R zeta.link
1152 4901ccfc 2020-07-23 stsp EOF
1153 4901ccfc 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1154 49c543a6 2022-03-31 naddy ret=$?
1155 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1156 4901ccfc 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1157 4901ccfc 2020-07-23 stsp test_done "$testroot" "$ret"
1158 4901ccfc 2020-07-23 stsp return 1
1159 4901ccfc 2020-07-23 stsp fi
1160 4901ccfc 2020-07-23 stsp
1161 4901ccfc 2020-07-23 stsp if ! [ -h $testroot/wt/alpha.link ]; then
1162 4901ccfc 2020-07-23 stsp echo "alpha.link is not a symlink"
1163 4901ccfc 2020-07-23 stsp test_done "$testroot" "1"
1164 4901ccfc 2020-07-23 stsp return 1
1165 4901ccfc 2020-07-23 stsp fi
1166 4901ccfc 2020-07-23 stsp
1167 4901ccfc 2020-07-23 stsp readlink $testroot/wt/alpha.link > $testroot/stdout
1168 4901ccfc 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
1169 4901ccfc 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1170 49c543a6 2022-03-31 naddy ret=$?
1171 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1172 4901ccfc 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1173 4901ccfc 2020-07-23 stsp test_done "$testroot" "$ret"
1174 4901ccfc 2020-07-23 stsp return 1
1175 4901ccfc 2020-07-23 stsp fi
1176 4901ccfc 2020-07-23 stsp
1177 4901ccfc 2020-07-23 stsp if ! [ -h $testroot/wt/epsilon.link ]; then
1178 4901ccfc 2020-07-23 stsp echo "epsilon.link is not a symlink"
1179 4901ccfc 2020-07-23 stsp test_done "$testroot" "1"
1180 4901ccfc 2020-07-23 stsp return 1
1181 4901ccfc 2020-07-23 stsp fi
1182 4901ccfc 2020-07-23 stsp
1183 4901ccfc 2020-07-23 stsp readlink $testroot/wt/epsilon.link > $testroot/stdout
1184 4901ccfc 2020-07-23 stsp echo "epsilon" > $testroot/stdout.expected
1185 4901ccfc 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1186 49c543a6 2022-03-31 naddy ret=$?
1187 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1188 4901ccfc 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1189 4901ccfc 2020-07-23 stsp test_done "$testroot" "$ret"
1190 4901ccfc 2020-07-23 stsp return 1
1191 4901ccfc 2020-07-23 stsp fi
1192 4901ccfc 2020-07-23 stsp
1193 4901ccfc 2020-07-23 stsp if [ -h $testroot/wt/passwd.link ]; then
1194 4901ccfc 2020-07-23 stsp echo "passwd.link should not be a symlink" >&2
1195 4901ccfc 2020-07-23 stsp test_done "$testroot" "1"
1196 4901ccfc 2020-07-23 stsp return 1
1197 4901ccfc 2020-07-23 stsp fi
1198 4901ccfc 2020-07-23 stsp
1199 4901ccfc 2020-07-23 stsp echo -n "/etc/passwd" > $testroot/content.expected
1200 4901ccfc 2020-07-23 stsp cp $testroot/wt/passwd.link $testroot/content
1201 4901ccfc 2020-07-23 stsp
1202 4901ccfc 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
1203 49c543a6 2022-03-31 naddy ret=$?
1204 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1205 4901ccfc 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
1206 4901ccfc 2020-07-23 stsp test_done "$testroot" "$ret"
1207 4901ccfc 2020-07-23 stsp return 1
1208 4901ccfc 2020-07-23 stsp fi
1209 4901ccfc 2020-07-23 stsp
1210 4901ccfc 2020-07-23 stsp readlink $testroot/wt/epsilon/beta.link > $testroot/stdout
1211 4901ccfc 2020-07-23 stsp echo "../beta" > $testroot/stdout.expected
1212 4901ccfc 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1213 49c543a6 2022-03-31 naddy ret=$?
1214 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1215 4901ccfc 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1216 4901ccfc 2020-07-23 stsp test_done "$testroot" "$ret"
1217 4901ccfc 2020-07-23 stsp return 1
1218 4901ccfc 2020-07-23 stsp fi
1219 4901ccfc 2020-07-23 stsp
1220 4901ccfc 2020-07-23 stsp readlink $testroot/wt/nonexistent.link > $testroot/stdout
1221 4901ccfc 2020-07-23 stsp echo "nonexistent" > $testroot/stdout.expected
1222 4901ccfc 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1223 49c543a6 2022-03-31 naddy ret=$?
1224 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1225 4901ccfc 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1226 4901ccfc 2020-07-23 stsp test_done "$testroot" "$ret"
1227 c2677d5d 2020-07-23 stsp return 1
1228 4901ccfc 2020-07-23 stsp fi
1229 4901ccfc 2020-07-23 stsp
1230 4901ccfc 2020-07-23 stsp if [ ! -h $testroot/wt/dotgotfoo.link ]; then
1231 4901ccfc 2020-07-23 stsp echo "dotgotfoo.link is not a symlink " >&2
1232 4901ccfc 2020-07-23 stsp test_done "$testroot" "1"
1233 4901ccfc 2020-07-23 stsp return 1
1234 4901ccfc 2020-07-23 stsp fi
1235 4901ccfc 2020-07-23 stsp readlink $testroot/wt/dotgotfoo.link > $testroot/stdout
1236 4901ccfc 2020-07-23 stsp echo ".got/foo" > $testroot/stdout.expected
1237 4901ccfc 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1238 49c543a6 2022-03-31 naddy ret=$?
1239 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1240 4901ccfc 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1241 4901ccfc 2020-07-23 stsp test_done "$testroot" "$ret"
1242 c2677d5d 2020-07-23 stsp return 1
1243 4901ccfc 2020-07-23 stsp fi
1244 4901ccfc 2020-07-23 stsp
1245 4901ccfc 2020-07-23 stsp if [ ! -h $testroot/wt/zeta.link ]; then
1246 4901ccfc 2020-07-23 stsp echo -n "zeta.link is not a symlink" >&2
1247 4901ccfc 2020-07-23 stsp test_done "$testroot" "1"
1248 4901ccfc 2020-07-23 stsp return 1
1249 4901ccfc 2020-07-23 stsp fi
1250 4901ccfc 2020-07-23 stsp
1251 4901ccfc 2020-07-23 stsp readlink $testroot/wt/zeta.link > $testroot/stdout
1252 4901ccfc 2020-07-23 stsp echo "epsilon/zeta" > $testroot/stdout.expected
1253 4901ccfc 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1254 49c543a6 2022-03-31 naddy ret=$?
1255 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1256 4901ccfc 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1257 4901ccfc 2020-07-23 stsp test_done "$testroot" "$ret"
1258 c2677d5d 2020-07-23 stsp return 1
1259 4901ccfc 2020-07-23 stsp fi
1260 4901ccfc 2020-07-23 stsp
1261 4901ccfc 2020-07-23 stsp if [ ! -h $testroot/wt/new.link ]; then
1262 4901ccfc 2020-07-23 stsp echo -n "new.link is not a symlink" >&2
1263 4901ccfc 2020-07-23 stsp test_done "$testroot" "1"
1264 4901ccfc 2020-07-23 stsp return 1
1265 4901ccfc 2020-07-23 stsp fi
1266 4901ccfc 2020-07-23 stsp
1267 4901ccfc 2020-07-23 stsp (cd $testroot/wt && got status > $testroot/stdout)
1268 4901ccfc 2020-07-23 stsp echo "? dotgotfoo.link" > $testroot/stdout.expected
1269 4901ccfc 2020-07-23 stsp echo "? new.link" >> $testroot/stdout.expected
1270 4901ccfc 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1271 49c543a6 2022-03-31 naddy ret=$?
1272 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1273 4901ccfc 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1274 4901ccfc 2020-07-23 stsp return 1
1275 4901ccfc 2020-07-23 stsp fi
1276 4901ccfc 2020-07-23 stsp test_done "$testroot" "$ret"
1277 4901ccfc 2020-07-23 stsp }
1278 4901ccfc 2020-07-23 stsp
1279 f6cae3ed 2020-09-13 naddy test_revert_patch_symlink() {
1280 369fd7e5 2020-07-23 stsp local testroot=`test_init revert_patch_symlink`
1281 369fd7e5 2020-07-23 stsp
1282 369fd7e5 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
1283 369fd7e5 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
1284 369fd7e5 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
1285 369fd7e5 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
1286 369fd7e5 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
1287 369fd7e5 2020-07-23 stsp (cd $testroot/repo && ln -sf epsilon/zeta zeta.link)
1288 369fd7e5 2020-07-23 stsp (cd $testroot/repo && ln -sf epsilon/zeta zeta2.link)
1289 369fd7e5 2020-07-23 stsp (cd $testroot/repo && git add .)
1290 369fd7e5 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
1291 369fd7e5 2020-07-23 stsp local commit_id1=`git_show_head $testroot/repo`
1292 369fd7e5 2020-07-23 stsp
1293 369fd7e5 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1294 369fd7e5 2020-07-23 stsp
1295 369fd7e5 2020-07-23 stsp # symlink to file A now points to file B
1296 369fd7e5 2020-07-23 stsp (cd $testroot/wt && ln -sf gamma/delta alpha.link)
1297 369fd7e5 2020-07-23 stsp # symlink to a directory A now points to file B
1298 f55db25a 2023-03-03 naddy (cd $testroot/wt && rm epsilon.link && ln -s beta epsilon.link)
1299 369fd7e5 2020-07-23 stsp # "bad" symlink now contains a different target path
1300 369fd7e5 2020-07-23 stsp echo "foo" > $testroot/wt/passwd.link
1301 369fd7e5 2020-07-23 stsp # relative symlink to directory A now points to relative directory B
1302 f55db25a 2023-03-03 naddy (cd $testroot/wt && rm epsilon/beta.link && ln -s ../gamma \
1303 f55db25a 2023-03-03 naddy epsilon/beta.link)
1304 369fd7e5 2020-07-23 stsp # an unversioned symlink
1305 369fd7e5 2020-07-23 stsp (cd $testroot/wt && ln -sf .got/foo dotgotfoo.link)
1306 369fd7e5 2020-07-23 stsp # symlink to file A now points to non-existent file B
1307 369fd7e5 2020-07-23 stsp (cd $testroot/wt && ln -sf nonexistent2 nonexistent.link)
1308 369fd7e5 2020-07-23 stsp # removed symlink
1309 369fd7e5 2020-07-23 stsp (cd $testroot/wt && got rm zeta.link > /dev/null)
1310 369fd7e5 2020-07-23 stsp (cd $testroot/wt && got rm zeta2.link > /dev/null)
1311 369fd7e5 2020-07-23 stsp # added symlink
1312 369fd7e5 2020-07-23 stsp (cd $testroot/wt && ln -sf beta new.link)
1313 369fd7e5 2020-07-23 stsp (cd $testroot/wt && got add new.link > /dev/null)
1314 369fd7e5 2020-07-23 stsp (cd $testroot/wt && ln -sf beta zeta3.link)
1315 369fd7e5 2020-07-23 stsp (cd $testroot/wt && got add zeta3.link > /dev/null)
1316 369fd7e5 2020-07-23 stsp
1317 369fd7e5 2020-07-23 stsp printf "y\nn\ny\nn\ny\ny\nn\ny\ny\n" > $testroot/patchscript
1318 369fd7e5 2020-07-23 stsp (cd $testroot/wt && got revert -F $testroot/patchscript -p -R . \
1319 369fd7e5 2020-07-23 stsp > $testroot/stdout)
1320 49c543a6 2022-03-31 naddy ret=$?
1321 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1322 369fd7e5 2020-07-23 stsp echo "got revert command failed unexpectedly" >&2
1323 369fd7e5 2020-07-23 stsp test_done "$testroot" "1"
1324 369fd7e5 2020-07-23 stsp return 1
1325 369fd7e5 2020-07-23 stsp fi
1326 369fd7e5 2020-07-23 stsp cat > $testroot/stdout.expected <<EOF
1327 369fd7e5 2020-07-23 stsp -----------------------------------------------
1328 369fd7e5 2020-07-23 stsp @@ -1 +1 @@
1329 369fd7e5 2020-07-23 stsp -alpha
1330 369fd7e5 2020-07-23 stsp \ No newline at end of file
1331 369fd7e5 2020-07-23 stsp +gamma/delta
1332 369fd7e5 2020-07-23 stsp \ No newline at end of file
1333 369fd7e5 2020-07-23 stsp -----------------------------------------------
1334 369fd7e5 2020-07-23 stsp M alpha.link (change 1 of 1)
1335 369fd7e5 2020-07-23 stsp revert this change? [y/n/q] y
1336 369fd7e5 2020-07-23 stsp R alpha.link
1337 369fd7e5 2020-07-23 stsp -----------------------------------------------
1338 369fd7e5 2020-07-23 stsp @@ -1 +1 @@
1339 369fd7e5 2020-07-23 stsp -../beta
1340 369fd7e5 2020-07-23 stsp \ No newline at end of file
1341 369fd7e5 2020-07-23 stsp +../gamma
1342 369fd7e5 2020-07-23 stsp \ No newline at end of file
1343 369fd7e5 2020-07-23 stsp -----------------------------------------------
1344 369fd7e5 2020-07-23 stsp M epsilon/beta.link (change 1 of 1)
1345 369fd7e5 2020-07-23 stsp revert this change? [y/n/q] n
1346 369fd7e5 2020-07-23 stsp -----------------------------------------------
1347 369fd7e5 2020-07-23 stsp @@ -1 +1 @@
1348 369fd7e5 2020-07-23 stsp -epsilon
1349 369fd7e5 2020-07-23 stsp \ No newline at end of file
1350 369fd7e5 2020-07-23 stsp +beta
1351 369fd7e5 2020-07-23 stsp \ No newline at end of file
1352 369fd7e5 2020-07-23 stsp -----------------------------------------------
1353 369fd7e5 2020-07-23 stsp M epsilon.link (change 1 of 1)
1354 369fd7e5 2020-07-23 stsp revert this change? [y/n/q] y
1355 369fd7e5 2020-07-23 stsp R epsilon.link
1356 369fd7e5 2020-07-23 stsp A new.link
1357 369fd7e5 2020-07-23 stsp revert this addition? [y/n] n
1358 369fd7e5 2020-07-23 stsp -----------------------------------------------
1359 369fd7e5 2020-07-23 stsp @@ -1 +1 @@
1360 369fd7e5 2020-07-23 stsp -nonexistent
1361 369fd7e5 2020-07-23 stsp \ No newline at end of file
1362 369fd7e5 2020-07-23 stsp +nonexistent2
1363 369fd7e5 2020-07-23 stsp \ No newline at end of file
1364 369fd7e5 2020-07-23 stsp -----------------------------------------------
1365 369fd7e5 2020-07-23 stsp M nonexistent.link (change 1 of 1)
1366 369fd7e5 2020-07-23 stsp revert this change? [y/n/q] y
1367 369fd7e5 2020-07-23 stsp R nonexistent.link
1368 369fd7e5 2020-07-23 stsp -----------------------------------------------
1369 369fd7e5 2020-07-23 stsp @@ -1 +1 @@
1370 369fd7e5 2020-07-23 stsp -/etc/passwd
1371 369fd7e5 2020-07-23 stsp \ No newline at end of file
1372 369fd7e5 2020-07-23 stsp +foo
1373 369fd7e5 2020-07-23 stsp -----------------------------------------------
1374 369fd7e5 2020-07-23 stsp M passwd.link (change 1 of 1)
1375 369fd7e5 2020-07-23 stsp revert this change? [y/n/q] y
1376 369fd7e5 2020-07-23 stsp R passwd.link
1377 369fd7e5 2020-07-23 stsp D zeta.link
1378 369fd7e5 2020-07-23 stsp revert this deletion? [y/n] n
1379 369fd7e5 2020-07-23 stsp D zeta2.link
1380 369fd7e5 2020-07-23 stsp revert this deletion? [y/n] y
1381 369fd7e5 2020-07-23 stsp R zeta2.link
1382 369fd7e5 2020-07-23 stsp A zeta3.link
1383 369fd7e5 2020-07-23 stsp revert this addition? [y/n] y
1384 369fd7e5 2020-07-23 stsp R zeta3.link
1385 369fd7e5 2020-07-23 stsp EOF
1386 369fd7e5 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1387 49c543a6 2022-03-31 naddy ret=$?
1388 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1389 369fd7e5 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1390 369fd7e5 2020-07-23 stsp test_done "$testroot" "$ret"
1391 369fd7e5 2020-07-23 stsp return 1
1392 369fd7e5 2020-07-23 stsp fi
1393 369fd7e5 2020-07-23 stsp
1394 369fd7e5 2020-07-23 stsp if ! [ -h $testroot/wt/alpha.link ]; then
1395 369fd7e5 2020-07-23 stsp echo "alpha.link is not a symlink"
1396 369fd7e5 2020-07-23 stsp test_done "$testroot" "1"
1397 369fd7e5 2020-07-23 stsp return 1
1398 369fd7e5 2020-07-23 stsp fi
1399 369fd7e5 2020-07-23 stsp
1400 369fd7e5 2020-07-23 stsp readlink $testroot/wt/alpha.link > $testroot/stdout
1401 369fd7e5 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
1402 369fd7e5 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1403 49c543a6 2022-03-31 naddy ret=$?
1404 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1405 369fd7e5 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1406 369fd7e5 2020-07-23 stsp test_done "$testroot" "$ret"
1407 369fd7e5 2020-07-23 stsp return 1
1408 369fd7e5 2020-07-23 stsp fi
1409 369fd7e5 2020-07-23 stsp
1410 369fd7e5 2020-07-23 stsp if ! [ -h $testroot/wt/epsilon.link ]; then
1411 369fd7e5 2020-07-23 stsp echo "epsilon.link is not a symlink"
1412 369fd7e5 2020-07-23 stsp test_done "$testroot" "1"
1413 369fd7e5 2020-07-23 stsp return 1
1414 369fd7e5 2020-07-23 stsp fi
1415 369fd7e5 2020-07-23 stsp
1416 369fd7e5 2020-07-23 stsp readlink $testroot/wt/epsilon.link > $testroot/stdout
1417 369fd7e5 2020-07-23 stsp echo "epsilon" > $testroot/stdout.expected
1418 369fd7e5 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1419 49c543a6 2022-03-31 naddy ret=$?
1420 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1421 369fd7e5 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1422 369fd7e5 2020-07-23 stsp test_done "$testroot" "$ret"
1423 369fd7e5 2020-07-23 stsp return 1
1424 369fd7e5 2020-07-23 stsp fi
1425 369fd7e5 2020-07-23 stsp
1426 369fd7e5 2020-07-23 stsp if [ -h $testroot/wt/passwd.link ]; then
1427 369fd7e5 2020-07-23 stsp echo "passwd.link should not be a symlink" >&2
1428 369fd7e5 2020-07-23 stsp test_done "$testroot" "1"
1429 369fd7e5 2020-07-23 stsp return 1
1430 369fd7e5 2020-07-23 stsp fi
1431 369fd7e5 2020-07-23 stsp
1432 369fd7e5 2020-07-23 stsp echo -n "/etc/passwd" > $testroot/content.expected
1433 369fd7e5 2020-07-23 stsp cp $testroot/wt/passwd.link $testroot/content
1434 369fd7e5 2020-07-23 stsp
1435 369fd7e5 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
1436 49c543a6 2022-03-31 naddy ret=$?
1437 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1438 369fd7e5 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
1439 369fd7e5 2020-07-23 stsp test_done "$testroot" "$ret"
1440 369fd7e5 2020-07-23 stsp return 1
1441 369fd7e5 2020-07-23 stsp fi
1442 369fd7e5 2020-07-23 stsp
1443 369fd7e5 2020-07-23 stsp readlink $testroot/wt/epsilon/beta.link > $testroot/stdout
1444 369fd7e5 2020-07-23 stsp echo "../gamma" > $testroot/stdout.expected
1445 369fd7e5 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1446 49c543a6 2022-03-31 naddy ret=$?
1447 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1448 369fd7e5 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1449 369fd7e5 2020-07-23 stsp test_done "$testroot" "$ret"
1450 369fd7e5 2020-07-23 stsp return 1
1451 369fd7e5 2020-07-23 stsp fi
1452 369fd7e5 2020-07-23 stsp
1453 369fd7e5 2020-07-23 stsp readlink $testroot/wt/nonexistent.link > $testroot/stdout
1454 369fd7e5 2020-07-23 stsp echo "nonexistent" > $testroot/stdout.expected
1455 369fd7e5 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1456 49c543a6 2022-03-31 naddy ret=$?
1457 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1458 369fd7e5 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1459 369fd7e5 2020-07-23 stsp test_done "$testroot" "$ret"
1460 c2677d5d 2020-07-23 stsp return 1
1461 369fd7e5 2020-07-23 stsp fi
1462 369fd7e5 2020-07-23 stsp
1463 369fd7e5 2020-07-23 stsp if [ ! -h $testroot/wt/dotgotfoo.link ]; then
1464 369fd7e5 2020-07-23 stsp echo "dotgotfoo.link is not a symlink " >&2
1465 369fd7e5 2020-07-23 stsp test_done "$testroot" "1"
1466 369fd7e5 2020-07-23 stsp return 1
1467 369fd7e5 2020-07-23 stsp fi
1468 369fd7e5 2020-07-23 stsp readlink $testroot/wt/dotgotfoo.link > $testroot/stdout
1469 369fd7e5 2020-07-23 stsp echo ".got/foo" > $testroot/stdout.expected
1470 369fd7e5 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1471 49c543a6 2022-03-31 naddy ret=$?
1472 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1473 369fd7e5 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1474 369fd7e5 2020-07-23 stsp test_done "$testroot" "$ret"
1475 c2677d5d 2020-07-23 stsp return 1
1476 369fd7e5 2020-07-23 stsp fi
1477 369fd7e5 2020-07-23 stsp
1478 369fd7e5 2020-07-23 stsp
1479 369fd7e5 2020-07-23 stsp if [ -e $testroot/wt/zeta.link ]; then
1480 369fd7e5 2020-07-23 stsp echo -n "zeta.link should not exist on disk" >&2
1481 369fd7e5 2020-07-23 stsp test_done "$testroot" "1"
1482 369fd7e5 2020-07-23 stsp return 1
1483 369fd7e5 2020-07-23 stsp fi
1484 369fd7e5 2020-07-23 stsp
1485 369fd7e5 2020-07-23 stsp if [ ! -h $testroot/wt/zeta2.link ]; then
1486 369fd7e5 2020-07-23 stsp echo -n "zeta2.link is not a symlink" >&2
1487 369fd7e5 2020-07-23 stsp test_done "$testroot" "1"
1488 369fd7e5 2020-07-23 stsp return 1
1489 369fd7e5 2020-07-23 stsp fi
1490 369fd7e5 2020-07-23 stsp
1491 369fd7e5 2020-07-23 stsp readlink $testroot/wt/zeta2.link > $testroot/stdout
1492 369fd7e5 2020-07-23 stsp echo "epsilon/zeta" > $testroot/stdout.expected
1493 369fd7e5 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1494 49c543a6 2022-03-31 naddy ret=$?
1495 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1496 369fd7e5 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1497 369fd7e5 2020-07-23 stsp test_done "$testroot" "$ret"
1498 c2677d5d 2020-07-23 stsp return 1
1499 369fd7e5 2020-07-23 stsp fi
1500 369fd7e5 2020-07-23 stsp
1501 369fd7e5 2020-07-23 stsp if [ ! -h $testroot/wt/zeta3.link ]; then
1502 369fd7e5 2020-07-23 stsp echo -n "zeta3.link is not a symlink" >&2
1503 369fd7e5 2020-07-23 stsp test_done "$testroot" "1"
1504 369fd7e5 2020-07-23 stsp return 1
1505 369fd7e5 2020-07-23 stsp fi
1506 369fd7e5 2020-07-23 stsp
1507 cf0e59fe 2020-07-23 stsp readlink $testroot/wt/zeta3.link > $testroot/stdout
1508 cf0e59fe 2020-07-23 stsp echo "beta" > $testroot/stdout.expected
1509 369fd7e5 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1510 49c543a6 2022-03-31 naddy ret=$?
1511 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1512 369fd7e5 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1513 369fd7e5 2020-07-23 stsp test_done "$testroot" "$ret"
1514 c2677d5d 2020-07-23 stsp return 1
1515 369fd7e5 2020-07-23 stsp fi
1516 369fd7e5 2020-07-23 stsp
1517 369fd7e5 2020-07-23 stsp if [ ! -h $testroot/wt/new.link ]; then
1518 369fd7e5 2020-07-23 stsp echo -n "new.link is not a symlink" >&2
1519 369fd7e5 2020-07-23 stsp test_done "$testroot" "1"
1520 369fd7e5 2020-07-23 stsp return 1
1521 369fd7e5 2020-07-23 stsp fi
1522 369fd7e5 2020-07-23 stsp
1523 369fd7e5 2020-07-23 stsp (cd $testroot/wt && got status > $testroot/stdout)
1524 369fd7e5 2020-07-23 stsp echo "? dotgotfoo.link" > $testroot/stdout.expected
1525 369fd7e5 2020-07-23 stsp echo "M epsilon/beta.link" >> $testroot/stdout.expected
1526 369fd7e5 2020-07-23 stsp echo "A new.link" >> $testroot/stdout.expected
1527 369fd7e5 2020-07-23 stsp echo "D zeta.link" >> $testroot/stdout.expected
1528 369fd7e5 2020-07-23 stsp echo "? zeta3.link" >> $testroot/stdout.expected
1529 369fd7e5 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1530 49c543a6 2022-03-31 naddy ret=$?
1531 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1532 369fd7e5 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1533 369fd7e5 2020-07-23 stsp return 1
1534 369fd7e5 2020-07-23 stsp fi
1535 369fd7e5 2020-07-23 stsp test_done "$testroot" "$ret"
1536 369fd7e5 2020-07-23 stsp }
1537 b2b3fce1 2022-10-29 op
1538 b2b3fce1 2022-10-29 op test_revert_umask() {
1539 b2b3fce1 2022-10-29 op local testroot=`test_init revert_umask`
1540 b2b3fce1 2022-10-29 op
1541 b2b3fce1 2022-10-29 op got checkout "$testroot/repo" "$testroot/wt" >/dev/null
1542 b2b3fce1 2022-10-29 op echo "edit alpha" > $testroot/wt/alpha
1543 369fd7e5 2020-07-23 stsp
1544 b2b3fce1 2022-10-29 op # using a subshell to avoid clobbering global umask
1545 b2b3fce1 2022-10-29 op (umask 077 && cd "$testroot/wt" && got revert alpha) \
1546 b2b3fce1 2022-10-29 op >/dev/null
1547 b2b3fce1 2022-10-29 op ret=$?
1548 b2b3fce1 2022-10-29 op if [ $ret -ne 0 ]; then
1549 b2b3fce1 2022-10-29 op test_done "$testroot" $ret
1550 b2b3fce1 2022-10-29 op return 1
1551 b2b3fce1 2022-10-29 op fi
1552 b2b3fce1 2022-10-29 op
1553 b2b3fce1 2022-10-29 op if ! ls -l "$testroot/wt/alpha" | grep -q ^-rw-------; then
1554 b2b3fce1 2022-10-29 op echo "alpha is not 0600 after revert" >&2
1555 b2b3fce1 2022-10-29 op ls -l "$testroot/wt/alpha" >&2
1556 b2b3fce1 2022-10-29 op test_done "$testroot" 1
1557 b2b3fce1 2022-10-29 op return 1
1558 b2b3fce1 2022-10-29 op fi
1559 b2b3fce1 2022-10-29 op test_done "$testroot" 0
1560 b2b3fce1 2022-10-29 op }
1561 b2b3fce1 2022-10-29 op
1562 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1563 a129376b 2019-03-28 stsp run_test test_revert_basic
1564 a129376b 2019-03-28 stsp run_test test_revert_rm
1565 a129376b 2019-03-28 stsp run_test test_revert_add
1566 e20a8b6f 2019-06-04 stsp run_test test_revert_multiple
1567 a9fa2909 2019-07-27 stsp run_test test_revert_file_in_new_subdir
1568 1f1abb7e 2019-08-08 stsp run_test test_revert_no_arguments
1569 0f6d7415 2019-08-08 stsp run_test test_revert_directory
1570 3d69ad8d 2019-08-17 semarie run_test test_revert_directory_unknown
1571 31cf15ec 2023-04-12 stsp run_test test_revert_missing_directory
1572 33aa809d 2019-08-08 stsp run_test test_revert_patch
1573 33aa809d 2019-08-08 stsp run_test test_revert_patch_added
1574 33aa809d 2019-08-08 stsp run_test test_revert_patch_removed
1575 f1e81a05 2019-08-10 stsp run_test test_revert_patch_one_change
1576 a46b9f33 2020-01-28 stsp run_test test_revert_added_subtree
1577 15341bfd 2020-03-05 tracey run_test test_revert_deleted_subtree
1578 4901ccfc 2020-07-23 stsp run_test test_revert_symlink
1579 369fd7e5 2020-07-23 stsp run_test test_revert_patch_symlink
1580 b2b3fce1 2022-10-29 op run_test test_revert_umask