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 3d69ad8d 2019-08-17 semarie
352 3d69ad8d 2019-08-17 semarie cmp -s $testroot/content.expected $testroot/content
353 49c543a6 2022-03-31 naddy ret=$?
354 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
355 3d69ad8d 2019-08-17 semarie diff -u $testroot/content.expected $testroot/content
356 3d69ad8d 2019-08-17 semarie test_done "$testroot" "$ret"
357 3d69ad8d 2019-08-17 semarie return 1
358 3d69ad8d 2019-08-17 semarie fi
359 6a5eff7c 2019-11-23 stsp
360 3d69ad8d 2019-08-17 semarie echo "zeta" > $testroot/content.expected
361 3d69ad8d 2019-08-17 semarie cat $testroot/wt/epsilon/zeta > $testroot/content
362 33aa809d 2019-08-08 stsp
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 3d69ad8d 2019-08-17 semarie fi
368 3d69ad8d 2019-08-17 semarie
369 3d69ad8d 2019-08-17 semarie test_done "$testroot" "$ret"
370 33aa809d 2019-08-08 stsp }
371 33aa809d 2019-08-08 stsp
372 f6cae3ed 2020-09-13 naddy test_revert_patch() {
373 33aa809d 2019-08-08 stsp local testroot=`test_init revert_patch`
374 33aa809d 2019-08-08 stsp
375 33aa809d 2019-08-08 stsp jot 16 > $testroot/repo/numbers
376 33aa809d 2019-08-08 stsp (cd $testroot/repo && git add numbers)
377 33aa809d 2019-08-08 stsp git_commit $testroot/repo -m "added numbers file"
378 33aa809d 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
379 33aa809d 2019-08-08 stsp
380 33aa809d 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
381 49c543a6 2022-03-31 naddy ret=$?
382 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
383 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
384 33aa809d 2019-08-08 stsp return 1
385 33aa809d 2019-08-08 stsp fi
386 33aa809d 2019-08-08 stsp
387 885e96df 2023-03-06 naddy ed -s $testroot/wt/numbers <<-\EOF
388 885e96df 2023-03-06 naddy ,s/^2$/a/
389 885e96df 2023-03-06 naddy ,s/^7$/b/
390 885e96df 2023-03-06 naddy ,s/^16$/c/
391 885e96df 2023-03-06 naddy w
392 885e96df 2023-03-06 naddy EOF
393 33aa809d 2019-08-08 stsp
394 33aa809d 2019-08-08 stsp (cd $testroot/wt && got diff > $testroot/numbers.diff)
395 33aa809d 2019-08-08 stsp
396 33aa809d 2019-08-08 stsp # don't revert any hunks
397 33aa809d 2019-08-08 stsp printf "n\nn\nn\n" > $testroot/patchscript
398 33aa809d 2019-08-08 stsp (cd $testroot/wt && got revert -F $testroot/patchscript -p \
399 33aa809d 2019-08-08 stsp numbers > $testroot/stdout)
400 49c543a6 2022-03-31 naddy ret=$?
401 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
402 33aa809d 2019-08-08 stsp echo "got revert command failed unexpectedly" >&2
403 33aa809d 2019-08-08 stsp test_done "$testroot" "1"
404 33aa809d 2019-08-08 stsp return 1
405 33aa809d 2019-08-08 stsp fi
406 33aa809d 2019-08-08 stsp cat > $testroot/stdout.expected <<EOF
407 33aa809d 2019-08-08 stsp -----------------------------------------------
408 33aa809d 2019-08-08 stsp @@ -1,5 +1,5 @@
409 33aa809d 2019-08-08 stsp 1
410 33aa809d 2019-08-08 stsp -2
411 33aa809d 2019-08-08 stsp +a
412 33aa809d 2019-08-08 stsp 3
413 33aa809d 2019-08-08 stsp 4
414 33aa809d 2019-08-08 stsp 5
415 33aa809d 2019-08-08 stsp -----------------------------------------------
416 33aa809d 2019-08-08 stsp M numbers (change 1 of 3)
417 33aa809d 2019-08-08 stsp revert this change? [y/n/q] n
418 33aa809d 2019-08-08 stsp -----------------------------------------------
419 33aa809d 2019-08-08 stsp @@ -4,7 +4,7 @@
420 33aa809d 2019-08-08 stsp 4
421 33aa809d 2019-08-08 stsp 5
422 33aa809d 2019-08-08 stsp 6
423 33aa809d 2019-08-08 stsp -7
424 33aa809d 2019-08-08 stsp +b
425 33aa809d 2019-08-08 stsp 8
426 33aa809d 2019-08-08 stsp 9
427 33aa809d 2019-08-08 stsp 10
428 33aa809d 2019-08-08 stsp -----------------------------------------------
429 33aa809d 2019-08-08 stsp M numbers (change 2 of 3)
430 33aa809d 2019-08-08 stsp revert this change? [y/n/q] n
431 33aa809d 2019-08-08 stsp -----------------------------------------------
432 33aa809d 2019-08-08 stsp @@ -13,4 +13,4 @@
433 33aa809d 2019-08-08 stsp 13
434 33aa809d 2019-08-08 stsp 14
435 33aa809d 2019-08-08 stsp 15
436 33aa809d 2019-08-08 stsp -16
437 33aa809d 2019-08-08 stsp +c
438 33aa809d 2019-08-08 stsp -----------------------------------------------
439 33aa809d 2019-08-08 stsp M numbers (change 3 of 3)
440 33aa809d 2019-08-08 stsp revert this change? [y/n/q] n
441 33aa809d 2019-08-08 stsp EOF
442 33aa809d 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
443 49c543a6 2022-03-31 naddy ret=$?
444 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
445 33aa809d 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
446 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
447 33aa809d 2019-08-08 stsp return 1
448 33aa809d 2019-08-08 stsp fi
449 33aa809d 2019-08-08 stsp
450 33aa809d 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
451 33aa809d 2019-08-08 stsp echo "M numbers" > $testroot/stdout.expected
452 33aa809d 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
453 49c543a6 2022-03-31 naddy ret=$?
454 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
455 33aa809d 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
456 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
457 33aa809d 2019-08-08 stsp return 1
458 33aa809d 2019-08-08 stsp fi
459 33aa809d 2019-08-08 stsp
460 33aa809d 2019-08-08 stsp (cd $testroot/wt && got diff > $testroot/stdout)
461 33aa809d 2019-08-08 stsp cmp -s $testroot/numbers.diff $testroot/stdout
462 49c543a6 2022-03-31 naddy ret=$?
463 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
464 33aa809d 2019-08-08 stsp diff -u $testroot/numbers.diff $testroot/stdout
465 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
466 33aa809d 2019-08-08 stsp return 1
467 33aa809d 2019-08-08 stsp fi
468 33aa809d 2019-08-08 stsp
469 ce2b05c7 2019-08-10 stsp # revert first hunk
470 ce2b05c7 2019-08-10 stsp printf "y\nn\nn\n" > $testroot/patchscript
471 ce2b05c7 2019-08-10 stsp (cd $testroot/wt && got revert -F $testroot/patchscript -p \
472 ce2b05c7 2019-08-10 stsp numbers > $testroot/stdout)
473 49c543a6 2022-03-31 naddy ret=$?
474 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
475 ce2b05c7 2019-08-10 stsp echo "got revert command failed unexpectedly" >&2
476 ce2b05c7 2019-08-10 stsp test_done "$testroot" "1"
477 ce2b05c7 2019-08-10 stsp return 1
478 ce2b05c7 2019-08-10 stsp fi
479 ce2b05c7 2019-08-10 stsp cat > $testroot/stdout.expected <<EOF
480 ce2b05c7 2019-08-10 stsp -----------------------------------------------
481 ce2b05c7 2019-08-10 stsp @@ -1,5 +1,5 @@
482 ce2b05c7 2019-08-10 stsp 1
483 ce2b05c7 2019-08-10 stsp -2
484 ce2b05c7 2019-08-10 stsp +a
485 ce2b05c7 2019-08-10 stsp 3
486 ce2b05c7 2019-08-10 stsp 4
487 ce2b05c7 2019-08-10 stsp 5
488 ce2b05c7 2019-08-10 stsp -----------------------------------------------
489 ce2b05c7 2019-08-10 stsp M numbers (change 1 of 3)
490 ce2b05c7 2019-08-10 stsp revert this change? [y/n/q] y
491 ce2b05c7 2019-08-10 stsp -----------------------------------------------
492 ce2b05c7 2019-08-10 stsp @@ -4,7 +4,7 @@
493 ce2b05c7 2019-08-10 stsp 4
494 ce2b05c7 2019-08-10 stsp 5
495 ce2b05c7 2019-08-10 stsp 6
496 ce2b05c7 2019-08-10 stsp -7
497 ce2b05c7 2019-08-10 stsp +b
498 ce2b05c7 2019-08-10 stsp 8
499 ce2b05c7 2019-08-10 stsp 9
500 ce2b05c7 2019-08-10 stsp 10
501 ce2b05c7 2019-08-10 stsp -----------------------------------------------
502 ce2b05c7 2019-08-10 stsp M numbers (change 2 of 3)
503 ce2b05c7 2019-08-10 stsp revert this change? [y/n/q] n
504 ce2b05c7 2019-08-10 stsp -----------------------------------------------
505 ce2b05c7 2019-08-10 stsp @@ -13,4 +13,4 @@
506 ce2b05c7 2019-08-10 stsp 13
507 ce2b05c7 2019-08-10 stsp 14
508 ce2b05c7 2019-08-10 stsp 15
509 ce2b05c7 2019-08-10 stsp -16
510 ce2b05c7 2019-08-10 stsp +c
511 ce2b05c7 2019-08-10 stsp -----------------------------------------------
512 ce2b05c7 2019-08-10 stsp M numbers (change 3 of 3)
513 ce2b05c7 2019-08-10 stsp revert this change? [y/n/q] n
514 ce2b05c7 2019-08-10 stsp EOF
515 ce2b05c7 2019-08-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
516 49c543a6 2022-03-31 naddy ret=$?
517 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
518 ce2b05c7 2019-08-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
519 ce2b05c7 2019-08-10 stsp test_done "$testroot" "$ret"
520 ce2b05c7 2019-08-10 stsp return 1
521 ce2b05c7 2019-08-10 stsp fi
522 ce2b05c7 2019-08-10 stsp
523 ce2b05c7 2019-08-10 stsp (cd $testroot/wt && got status > $testroot/stdout)
524 ce2b05c7 2019-08-10 stsp echo "M numbers" > $testroot/stdout.expected
525 ce2b05c7 2019-08-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
526 49c543a6 2022-03-31 naddy ret=$?
527 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
528 ce2b05c7 2019-08-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
529 ce2b05c7 2019-08-10 stsp test_done "$testroot" "$ret"
530 ce2b05c7 2019-08-10 stsp return 1
531 ce2b05c7 2019-08-10 stsp fi
532 ce2b05c7 2019-08-10 stsp
533 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
534 8469d821 2022-06-25 stsp echo "commit - $commit_id" >> $testroot/stdout.expected
535 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
536 ce2b05c7 2019-08-10 stsp echo -n 'blob - ' >> $testroot/stdout.expected
537 ce2b05c7 2019-08-10 stsp got tree -r $testroot/repo -i -c $commit_id \
538 ce2b05c7 2019-08-10 stsp | grep 'numbers$' | cut -d' ' -f 1 \
539 ce2b05c7 2019-08-10 stsp >> $testroot/stdout.expected
540 ce2b05c7 2019-08-10 stsp echo 'file + numbers' >> $testroot/stdout.expected
541 ce2b05c7 2019-08-10 stsp cat >> $testroot/stdout.expected <<EOF
542 ce2b05c7 2019-08-10 stsp --- numbers
543 ce2b05c7 2019-08-10 stsp +++ numbers
544 ce2b05c7 2019-08-10 stsp @@ -4,7 +4,7 @@
545 ce2b05c7 2019-08-10 stsp 4
546 ce2b05c7 2019-08-10 stsp 5
547 ce2b05c7 2019-08-10 stsp 6
548 ce2b05c7 2019-08-10 stsp -7
549 ce2b05c7 2019-08-10 stsp +b
550 ce2b05c7 2019-08-10 stsp 8
551 ce2b05c7 2019-08-10 stsp 9
552 ce2b05c7 2019-08-10 stsp 10
553 ce2b05c7 2019-08-10 stsp @@ -13,4 +13,4 @@
554 ce2b05c7 2019-08-10 stsp 13
555 ce2b05c7 2019-08-10 stsp 14
556 ce2b05c7 2019-08-10 stsp 15
557 ce2b05c7 2019-08-10 stsp -16
558 ce2b05c7 2019-08-10 stsp +c
559 ce2b05c7 2019-08-10 stsp EOF
560 ce2b05c7 2019-08-10 stsp (cd $testroot/wt && got diff > $testroot/stdout)
561 ce2b05c7 2019-08-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
562 49c543a6 2022-03-31 naddy ret=$?
563 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
564 ce2b05c7 2019-08-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
565 ce2b05c7 2019-08-10 stsp test_done "$testroot" "$ret"
566 ce2b05c7 2019-08-10 stsp return 1
567 ce2b05c7 2019-08-10 stsp fi
568 ce2b05c7 2019-08-10 stsp
569 ce2b05c7 2019-08-10 stsp # put first hunk back
570 885e96df 2023-03-06 naddy ed -s $testroot/wt/numbers <<-\EOF
571 885e96df 2023-03-06 naddy ,s/^2$/a/
572 885e96df 2023-03-06 naddy w
573 885e96df 2023-03-06 naddy EOF
574 ce2b05c7 2019-08-10 stsp
575 33aa809d 2019-08-08 stsp # revert middle hunk
576 33aa809d 2019-08-08 stsp printf "n\ny\nn\n" > $testroot/patchscript
577 33aa809d 2019-08-08 stsp (cd $testroot/wt && got revert -F $testroot/patchscript -p \
578 33aa809d 2019-08-08 stsp numbers > $testroot/stdout)
579 33aa809d 2019-08-08 stsp
580 33aa809d 2019-08-08 stsp cat > $testroot/stdout.expected <<EOF
581 33aa809d 2019-08-08 stsp -----------------------------------------------
582 33aa809d 2019-08-08 stsp @@ -1,5 +1,5 @@
583 33aa809d 2019-08-08 stsp 1
584 33aa809d 2019-08-08 stsp -2
585 33aa809d 2019-08-08 stsp +a
586 33aa809d 2019-08-08 stsp 3
587 33aa809d 2019-08-08 stsp 4
588 33aa809d 2019-08-08 stsp 5
589 33aa809d 2019-08-08 stsp -----------------------------------------------
590 33aa809d 2019-08-08 stsp M numbers (change 1 of 3)
591 33aa809d 2019-08-08 stsp revert this change? [y/n/q] n
592 33aa809d 2019-08-08 stsp -----------------------------------------------
593 33aa809d 2019-08-08 stsp @@ -4,7 +4,7 @@
594 33aa809d 2019-08-08 stsp 4
595 33aa809d 2019-08-08 stsp 5
596 33aa809d 2019-08-08 stsp 6
597 33aa809d 2019-08-08 stsp -7
598 33aa809d 2019-08-08 stsp +b
599 33aa809d 2019-08-08 stsp 8
600 33aa809d 2019-08-08 stsp 9
601 33aa809d 2019-08-08 stsp 10
602 33aa809d 2019-08-08 stsp -----------------------------------------------
603 33aa809d 2019-08-08 stsp M numbers (change 2 of 3)
604 33aa809d 2019-08-08 stsp revert this change? [y/n/q] y
605 33aa809d 2019-08-08 stsp -----------------------------------------------
606 33aa809d 2019-08-08 stsp @@ -13,4 +13,4 @@
607 33aa809d 2019-08-08 stsp 13
608 33aa809d 2019-08-08 stsp 14
609 33aa809d 2019-08-08 stsp 15
610 33aa809d 2019-08-08 stsp -16
611 33aa809d 2019-08-08 stsp +c
612 33aa809d 2019-08-08 stsp -----------------------------------------------
613 33aa809d 2019-08-08 stsp M numbers (change 3 of 3)
614 33aa809d 2019-08-08 stsp revert this change? [y/n/q] n
615 33aa809d 2019-08-08 stsp EOF
616 33aa809d 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
617 49c543a6 2022-03-31 naddy ret=$?
618 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
619 33aa809d 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
620 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
621 33aa809d 2019-08-08 stsp return 1
622 33aa809d 2019-08-08 stsp fi
623 33aa809d 2019-08-08 stsp
624 33aa809d 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
625 33aa809d 2019-08-08 stsp echo "M numbers" > $testroot/stdout.expected
626 33aa809d 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
627 49c543a6 2022-03-31 naddy ret=$?
628 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
629 33aa809d 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
630 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
631 33aa809d 2019-08-08 stsp return 1
632 33aa809d 2019-08-08 stsp fi
633 33aa809d 2019-08-08 stsp
634 33aa809d 2019-08-08 stsp (cd $testroot/wt && got diff > $testroot/stdout)
635 33aa809d 2019-08-08 stsp
636 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
637 8469d821 2022-06-25 stsp echo "commit - $commit_id" >> $testroot/stdout.expected
638 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
639 33aa809d 2019-08-08 stsp echo -n 'blob - ' >> $testroot/stdout.expected
640 33aa809d 2019-08-08 stsp got tree -r $testroot/repo -i -c $commit_id \
641 33aa809d 2019-08-08 stsp | grep 'numbers$' | cut -d' ' -f 1 \
642 33aa809d 2019-08-08 stsp >> $testroot/stdout.expected
643 33aa809d 2019-08-08 stsp echo 'file + numbers' >> $testroot/stdout.expected
644 33aa809d 2019-08-08 stsp cat >> $testroot/stdout.expected <<EOF
645 33aa809d 2019-08-08 stsp --- numbers
646 33aa809d 2019-08-08 stsp +++ numbers
647 33aa809d 2019-08-08 stsp @@ -1,5 +1,5 @@
648 33aa809d 2019-08-08 stsp 1
649 33aa809d 2019-08-08 stsp -2
650 33aa809d 2019-08-08 stsp +a
651 33aa809d 2019-08-08 stsp 3
652 33aa809d 2019-08-08 stsp 4
653 33aa809d 2019-08-08 stsp 5
654 33aa809d 2019-08-08 stsp @@ -13,4 +13,4 @@
655 33aa809d 2019-08-08 stsp 13
656 33aa809d 2019-08-08 stsp 14
657 33aa809d 2019-08-08 stsp 15
658 33aa809d 2019-08-08 stsp -16
659 33aa809d 2019-08-08 stsp +c
660 33aa809d 2019-08-08 stsp EOF
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 0f6d7415 2019-08-08 stsp fi
668 33aa809d 2019-08-08 stsp
669 33aa809d 2019-08-08 stsp # revert last hunk
670 33aa809d 2019-08-08 stsp printf "n\ny\n" > $testroot/patchscript
671 33aa809d 2019-08-08 stsp (cd $testroot/wt && got revert -F $testroot/patchscript -p \
672 33aa809d 2019-08-08 stsp numbers > $testroot/stdout)
673 33aa809d 2019-08-08 stsp cat > $testroot/stdout.expected <<EOF
674 33aa809d 2019-08-08 stsp -----------------------------------------------
675 33aa809d 2019-08-08 stsp @@ -1,5 +1,5 @@
676 33aa809d 2019-08-08 stsp 1
677 33aa809d 2019-08-08 stsp -2
678 33aa809d 2019-08-08 stsp +a
679 33aa809d 2019-08-08 stsp 3
680 33aa809d 2019-08-08 stsp 4
681 33aa809d 2019-08-08 stsp 5
682 33aa809d 2019-08-08 stsp -----------------------------------------------
683 33aa809d 2019-08-08 stsp M numbers (change 1 of 2)
684 33aa809d 2019-08-08 stsp revert this change? [y/n/q] n
685 33aa809d 2019-08-08 stsp -----------------------------------------------
686 33aa809d 2019-08-08 stsp @@ -13,4 +13,4 @@
687 33aa809d 2019-08-08 stsp 13
688 33aa809d 2019-08-08 stsp 14
689 33aa809d 2019-08-08 stsp 15
690 33aa809d 2019-08-08 stsp -16
691 33aa809d 2019-08-08 stsp +c
692 33aa809d 2019-08-08 stsp -----------------------------------------------
693 33aa809d 2019-08-08 stsp M numbers (change 2 of 2)
694 33aa809d 2019-08-08 stsp revert this change? [y/n/q] y
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 33aa809d 2019-08-08 stsp fi
703 33aa809d 2019-08-08 stsp
704 33aa809d 2019-08-08 stsp (cd $testroot/wt && got diff > $testroot/stdout)
705 33aa809d 2019-08-08 stsp
706 8469d821 2022-06-25 stsp echo "diff $testroot/wt" > $testroot/stdout.expected
707 8469d821 2022-06-25 stsp echo "commit - $commit_id" >> $testroot/stdout.expected
708 8469d821 2022-06-25 stsp echo "path + $testroot/wt" >> $testroot/stdout.expected
709 33aa809d 2019-08-08 stsp echo -n 'blob - ' >> $testroot/stdout.expected
710 33aa809d 2019-08-08 stsp got tree -r $testroot/repo -i -c $commit_id \
711 33aa809d 2019-08-08 stsp | grep 'numbers$' | cut -d' ' -f 1 \
712 33aa809d 2019-08-08 stsp >> $testroot/stdout.expected
713 33aa809d 2019-08-08 stsp echo 'file + numbers' >> $testroot/stdout.expected
714 33aa809d 2019-08-08 stsp cat >> $testroot/stdout.expected <<EOF
715 33aa809d 2019-08-08 stsp --- numbers
716 33aa809d 2019-08-08 stsp +++ numbers
717 33aa809d 2019-08-08 stsp @@ -1,5 +1,5 @@
718 33aa809d 2019-08-08 stsp 1
719 33aa809d 2019-08-08 stsp -2
720 33aa809d 2019-08-08 stsp +a
721 33aa809d 2019-08-08 stsp 3
722 33aa809d 2019-08-08 stsp 4
723 33aa809d 2019-08-08 stsp 5
724 33aa809d 2019-08-08 stsp EOF
725 33aa809d 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
726 49c543a6 2022-03-31 naddy ret=$?
727 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
728 33aa809d 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
729 33aa809d 2019-08-08 stsp fi
730 1f1abb7e 2019-08-08 stsp test_done "$testroot" "$ret"
731 33aa809d 2019-08-08 stsp }
732 0f6d7415 2019-08-08 stsp
733 f6cae3ed 2020-09-13 naddy test_revert_patch_added() {
734 33aa809d 2019-08-08 stsp local testroot=`test_init revert_patch_added`
735 33aa809d 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
736 33aa809d 2019-08-08 stsp
737 33aa809d 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
738 49c543a6 2022-03-31 naddy ret=$?
739 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
740 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
741 33aa809d 2019-08-08 stsp return 1
742 33aa809d 2019-08-08 stsp fi
743 33aa809d 2019-08-08 stsp
744 33aa809d 2019-08-08 stsp echo "new" > $testroot/wt/epsilon/new
745 33aa809d 2019-08-08 stsp (cd $testroot/wt && got add epsilon/new > /dev/null)
746 33aa809d 2019-08-08 stsp
747 33aa809d 2019-08-08 stsp printf "n\n" > $testroot/patchscript
748 33aa809d 2019-08-08 stsp (cd $testroot/wt && got revert -F $testroot/patchscript -p \
749 33aa809d 2019-08-08 stsp epsilon/new > $testroot/stdout)
750 33aa809d 2019-08-08 stsp
751 33aa809d 2019-08-08 stsp echo "A epsilon/new" > $testroot/stdout.expected
752 33aa809d 2019-08-08 stsp echo "revert this addition? [y/n] n" >> $testroot/stdout.expected
753 33aa809d 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
754 49c543a6 2022-03-31 naddy ret=$?
755 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
756 33aa809d 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
757 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
758 33aa809d 2019-08-08 stsp return 1
759 33aa809d 2019-08-08 stsp fi
760 33aa809d 2019-08-08 stsp
761 33aa809d 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
762 33aa809d 2019-08-08 stsp echo "A epsilon/new" > $testroot/stdout.expected
763 33aa809d 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
764 49c543a6 2022-03-31 naddy ret=$?
765 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
766 33aa809d 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
767 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
768 33aa809d 2019-08-08 stsp return 1
769 33aa809d 2019-08-08 stsp fi
770 33aa809d 2019-08-08 stsp
771 33aa809d 2019-08-08 stsp printf "y\n" > $testroot/patchscript
772 33aa809d 2019-08-08 stsp (cd $testroot/wt && got revert -F $testroot/patchscript -p \
773 33aa809d 2019-08-08 stsp epsilon/new > $testroot/stdout)
774 33aa809d 2019-08-08 stsp
775 33aa809d 2019-08-08 stsp echo "A epsilon/new" > $testroot/stdout.expected
776 33aa809d 2019-08-08 stsp echo "revert this addition? [y/n] y" >> $testroot/stdout.expected
777 33aa809d 2019-08-08 stsp echo "R epsilon/new" >> $testroot/stdout.expected
778 33aa809d 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
779 49c543a6 2022-03-31 naddy ret=$?
780 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
781 33aa809d 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
782 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
783 33aa809d 2019-08-08 stsp return 1
784 33aa809d 2019-08-08 stsp fi
785 33aa809d 2019-08-08 stsp
786 33aa809d 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
787 33aa809d 2019-08-08 stsp echo "? epsilon/new" > $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 fi
793 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
794 1f1abb7e 2019-08-08 stsp }
795 1f1abb7e 2019-08-08 stsp
796 f6cae3ed 2020-09-13 naddy test_revert_patch_removed() {
797 33aa809d 2019-08-08 stsp local testroot=`test_init revert_patch_removed`
798 33aa809d 2019-08-08 stsp local commit_id=`git_show_head $testroot/repo`
799 33aa809d 2019-08-08 stsp
800 33aa809d 2019-08-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
801 49c543a6 2022-03-31 naddy ret=$?
802 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
803 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
804 33aa809d 2019-08-08 stsp return 1
805 33aa809d 2019-08-08 stsp fi
806 33aa809d 2019-08-08 stsp
807 33aa809d 2019-08-08 stsp (cd $testroot/wt && got rm beta > /dev/null)
808 33aa809d 2019-08-08 stsp
809 33aa809d 2019-08-08 stsp printf "n\n" > $testroot/patchscript
810 33aa809d 2019-08-08 stsp (cd $testroot/wt && got revert -F $testroot/patchscript -p \
811 33aa809d 2019-08-08 stsp beta > $testroot/stdout)
812 33aa809d 2019-08-08 stsp echo "D beta" > $testroot/stdout.expected
813 33aa809d 2019-08-08 stsp echo "revert this deletion? [y/n] n" >> $testroot/stdout.expected
814 33aa809d 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
815 49c543a6 2022-03-31 naddy ret=$?
816 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
817 33aa809d 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
818 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
819 33aa809d 2019-08-08 stsp return 1
820 33aa809d 2019-08-08 stsp fi
821 33aa809d 2019-08-08 stsp
822 33aa809d 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
823 33aa809d 2019-08-08 stsp echo "D beta" > $testroot/stdout.expected
824 33aa809d 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
825 49c543a6 2022-03-31 naddy ret=$?
826 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
827 33aa809d 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
828 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
829 33aa809d 2019-08-08 stsp return 1
830 33aa809d 2019-08-08 stsp fi
831 33aa809d 2019-08-08 stsp
832 33aa809d 2019-08-08 stsp printf "y\n" > $testroot/patchscript
833 33aa809d 2019-08-08 stsp (cd $testroot/wt && got revert -F $testroot/patchscript -p \
834 33aa809d 2019-08-08 stsp beta > $testroot/stdout)
835 33aa809d 2019-08-08 stsp
836 33aa809d 2019-08-08 stsp echo "D beta" > $testroot/stdout.expected
837 33aa809d 2019-08-08 stsp echo "revert this deletion? [y/n] y" >> $testroot/stdout.expected
838 33aa809d 2019-08-08 stsp echo "R beta" >> $testroot/stdout.expected
839 33aa809d 2019-08-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
840 49c543a6 2022-03-31 naddy ret=$?
841 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
842 33aa809d 2019-08-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
843 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
844 33aa809d 2019-08-08 stsp return 1
845 33aa809d 2019-08-08 stsp fi
846 33aa809d 2019-08-08 stsp
847 33aa809d 2019-08-08 stsp (cd $testroot/wt && got status > $testroot/stdout)
848 33aa809d 2019-08-08 stsp echo -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 fi
854 33aa809d 2019-08-08 stsp test_done "$testroot" "$ret"
855 33aa809d 2019-08-08 stsp }
856 f1e81a05 2019-08-10 stsp
857 f6cae3ed 2020-09-13 naddy test_revert_patch_one_change() {
858 f1e81a05 2019-08-10 stsp local testroot=`test_init revert_patch_one_change`
859 f1e81a05 2019-08-10 stsp
860 f1e81a05 2019-08-10 stsp jot 16 > $testroot/repo/numbers
861 f1e81a05 2019-08-10 stsp (cd $testroot/repo && git add numbers)
862 f1e81a05 2019-08-10 stsp git_commit $testroot/repo -m "added numbers file"
863 f1e81a05 2019-08-10 stsp local commit_id=`git_show_head $testroot/repo`
864 f1e81a05 2019-08-10 stsp
865 f1e81a05 2019-08-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
866 49c543a6 2022-03-31 naddy ret=$?
867 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
868 f1e81a05 2019-08-10 stsp test_done "$testroot" "$ret"
869 f1e81a05 2019-08-10 stsp return 1
870 f1e81a05 2019-08-10 stsp fi
871 f1e81a05 2019-08-10 stsp
872 6c6b73bb 2019-08-10 stsp # Ensure file size is changed. Avoids race condition causing test
873 6c6b73bb 2019-08-10 stsp # failures where 'got revert' does not see changes to revert if
874 6c6b73bb 2019-08-10 stsp # timestamps and size in stat info remain unchanged.
875 885e96df 2023-03-06 naddy ed -s $testroot/wt/numbers <<-\EOF
876 885e96df 2023-03-06 naddy ,s/^2$/aa/
877 885e96df 2023-03-06 naddy w
878 885e96df 2023-03-06 naddy EOF
879 33aa809d 2019-08-08 stsp
880 f1e81a05 2019-08-10 stsp # revert change with -p
881 f1e81a05 2019-08-10 stsp printf "y\n" > $testroot/patchscript
882 f1e81a05 2019-08-10 stsp (cd $testroot/wt && got revert -F $testroot/patchscript -p \
883 f1e81a05 2019-08-10 stsp numbers > $testroot/stdout)
884 49c543a6 2022-03-31 naddy ret=$?
885 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
886 f1e81a05 2019-08-10 stsp echo "got revert command failed unexpectedly" >&2
887 f1e81a05 2019-08-10 stsp test_done "$testroot" "1"
888 f1e81a05 2019-08-10 stsp return 1
889 f1e81a05 2019-08-10 stsp fi
890 f1e81a05 2019-08-10 stsp cat > $testroot/stdout.expected <<EOF
891 f1e81a05 2019-08-10 stsp -----------------------------------------------
892 f1e81a05 2019-08-10 stsp @@ -1,5 +1,5 @@
893 f1e81a05 2019-08-10 stsp 1
894 f1e81a05 2019-08-10 stsp -2
895 6c6b73bb 2019-08-10 stsp +aa
896 f1e81a05 2019-08-10 stsp 3
897 f1e81a05 2019-08-10 stsp 4
898 f1e81a05 2019-08-10 stsp 5
899 f1e81a05 2019-08-10 stsp -----------------------------------------------
900 f1e81a05 2019-08-10 stsp M numbers (change 1 of 1)
901 f1e81a05 2019-08-10 stsp revert this change? [y/n/q] y
902 f1e81a05 2019-08-10 stsp EOF
903 49c543a6 2022-03-31 naddy ret=$?
904 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
905 6c6b73bb 2019-08-10 stsp echo "got revert command failed unexpectedly" >&2
906 6c6b73bb 2019-08-10 stsp test_done "$testroot" "1"
907 6c6b73bb 2019-08-10 stsp return 1
908 6c6b73bb 2019-08-10 stsp fi
909 6c6b73bb 2019-08-10 stsp
910 f1e81a05 2019-08-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
911 49c543a6 2022-03-31 naddy ret=$?
912 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
913 f1e81a05 2019-08-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
914 f1e81a05 2019-08-10 stsp test_done "$testroot" "$ret"
915 f1e81a05 2019-08-10 stsp return 1
916 f1e81a05 2019-08-10 stsp fi
917 f1e81a05 2019-08-10 stsp
918 f1e81a05 2019-08-10 stsp (cd $testroot/wt && got status > $testroot/stdout)
919 f1e81a05 2019-08-10 stsp echo -n > $testroot/stdout.expected
920 f1e81a05 2019-08-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
921 49c543a6 2022-03-31 naddy ret=$?
922 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
923 f1e81a05 2019-08-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
924 f1e81a05 2019-08-10 stsp test_done "$testroot" "$ret"
925 f1e81a05 2019-08-10 stsp return 1
926 f1e81a05 2019-08-10 stsp fi
927 f1e81a05 2019-08-10 stsp
928 f1e81a05 2019-08-10 stsp (cd $testroot/wt && got diff > $testroot/stdout)
929 f1e81a05 2019-08-10 stsp echo -n > $testroot/stdout.expected
930 f1e81a05 2019-08-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
931 49c543a6 2022-03-31 naddy ret=$?
932 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
933 f1e81a05 2019-08-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
934 f1e81a05 2019-08-10 stsp fi
935 f1e81a05 2019-08-10 stsp test_done "$testroot" "$ret"
936 f1e81a05 2019-08-10 stsp }
937 a46b9f33 2020-01-28 stsp
938 f6cae3ed 2020-09-13 naddy test_revert_added_subtree() {
939 a46b9f33 2020-01-28 stsp local testroot=`test_init revert_added_subtree`
940 f1e81a05 2019-08-10 stsp
941 a46b9f33 2020-01-28 stsp got checkout $testroot/repo $testroot/wt > /dev/null
942 49c543a6 2022-03-31 naddy ret=$?
943 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
944 a46b9f33 2020-01-28 stsp test_done "$testroot" "$ret"
945 a46b9f33 2020-01-28 stsp return 1
946 a46b9f33 2020-01-28 stsp fi
947 a46b9f33 2020-01-28 stsp
948 a46b9f33 2020-01-28 stsp mkdir -p $testroot/wt/epsilon/foo/bar/baz
949 a46b9f33 2020-01-28 stsp mkdir -p $testroot/wt/epsilon/foo/bar/bax
950 a46b9f33 2020-01-28 stsp echo "new file" > $testroot/wt/epsilon/foo/a.o
951 a46b9f33 2020-01-28 stsp echo "new file" > $testroot/wt/epsilon/foo/a.o
952 a46b9f33 2020-01-28 stsp echo "new file" > $testroot/wt/epsilon/foo/bar/b.o
953 a46b9f33 2020-01-28 stsp echo "new file" > $testroot/wt/epsilon/foo/bar/b.d
954 a46b9f33 2020-01-28 stsp echo "new file" > $testroot/wt/epsilon/foo/bar/baz/f.o
955 a46b9f33 2020-01-28 stsp echo "new file" > $testroot/wt/epsilon/foo/bar/baz/f.d
956 a46b9f33 2020-01-28 stsp echo "new file" > $testroot/wt/epsilon/foo/bar/baz/c.o
957 a46b9f33 2020-01-28 stsp echo "new file" > $testroot/wt/epsilon/foo/bar/baz/c.d
958 a46b9f33 2020-01-28 stsp echo "new file" > $testroot/wt/epsilon/foo/bar/bax/e.o
959 a46b9f33 2020-01-28 stsp echo "new file" > $testroot/wt/epsilon/foo/bar/bax/e.d
960 a46b9f33 2020-01-28 stsp echo "new file" > $testroot/wt/epsilon/foo/bar/bax/x.o
961 a46b9f33 2020-01-28 stsp echo "new file" > $testroot/wt/epsilon/foo/bar/bax/x.d
962 a46b9f33 2020-01-28 stsp (cd $testroot/wt && got add -R epsilon >/dev/null)
963 a46b9f33 2020-01-28 stsp
964 a46b9f33 2020-01-28 stsp echo "R epsilon/foo/a.o" > $testroot/stdout.expected
965 a46b9f33 2020-01-28 stsp echo "R epsilon/foo/bar/b.d" >> $testroot/stdout.expected
966 a46b9f33 2020-01-28 stsp echo "R epsilon/foo/bar/b.o" >> $testroot/stdout.expected
967 a46b9f33 2020-01-28 stsp echo "R epsilon/foo/bar/bax/e.d" >> $testroot/stdout.expected
968 a46b9f33 2020-01-28 stsp echo "R epsilon/foo/bar/bax/e.o" >> $testroot/stdout.expected
969 a46b9f33 2020-01-28 stsp echo "R epsilon/foo/bar/bax/x.d" >> $testroot/stdout.expected
970 a46b9f33 2020-01-28 stsp echo "R epsilon/foo/bar/bax/x.o" >> $testroot/stdout.expected
971 a46b9f33 2020-01-28 stsp echo "R epsilon/foo/bar/baz/c.d" >> $testroot/stdout.expected
972 a46b9f33 2020-01-28 stsp echo "R epsilon/foo/bar/baz/c.o" >> $testroot/stdout.expected
973 a46b9f33 2020-01-28 stsp echo "R epsilon/foo/bar/baz/f.d" >> $testroot/stdout.expected
974 a46b9f33 2020-01-28 stsp echo "R epsilon/foo/bar/baz/f.o" >> $testroot/stdout.expected
975 a46b9f33 2020-01-28 stsp
976 a46b9f33 2020-01-28 stsp (cd $testroot/wt && got revert -R . > $testroot/stdout)
977 a46b9f33 2020-01-28 stsp
978 a46b9f33 2020-01-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
979 49c543a6 2022-03-31 naddy ret=$?
980 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
981 a46b9f33 2020-01-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
982 a46b9f33 2020-01-28 stsp test_done "$testroot" "$ret"
983 a46b9f33 2020-01-28 stsp return 1
984 a46b9f33 2020-01-28 stsp fi
985 a46b9f33 2020-01-28 stsp
986 a46b9f33 2020-01-28 stsp echo "? epsilon/foo/a.o" > $testroot/stdout.expected
987 a46b9f33 2020-01-28 stsp echo "? epsilon/foo/bar/b.d" >> $testroot/stdout.expected
988 a46b9f33 2020-01-28 stsp echo "? epsilon/foo/bar/b.o" >> $testroot/stdout.expected
989 a46b9f33 2020-01-28 stsp echo "? epsilon/foo/bar/bax/e.d" >> $testroot/stdout.expected
990 a46b9f33 2020-01-28 stsp echo "? epsilon/foo/bar/bax/e.o" >> $testroot/stdout.expected
991 a46b9f33 2020-01-28 stsp echo "? epsilon/foo/bar/bax/x.d" >> $testroot/stdout.expected
992 a46b9f33 2020-01-28 stsp echo "? epsilon/foo/bar/bax/x.o" >> $testroot/stdout.expected
993 a46b9f33 2020-01-28 stsp echo "? epsilon/foo/bar/baz/c.d" >> $testroot/stdout.expected
994 a46b9f33 2020-01-28 stsp echo "? epsilon/foo/bar/baz/c.o" >> $testroot/stdout.expected
995 a46b9f33 2020-01-28 stsp echo "? epsilon/foo/bar/baz/f.d" >> $testroot/stdout.expected
996 a46b9f33 2020-01-28 stsp echo "? epsilon/foo/bar/baz/f.o" >> $testroot/stdout.expected
997 15341bfd 2020-03-05 tracey
998 15341bfd 2020-03-05 tracey (cd $testroot/wt && got status > $testroot/stdout)
999 15341bfd 2020-03-05 tracey
1000 15341bfd 2020-03-05 tracey cmp -s $testroot/stdout.expected $testroot/stdout
1001 49c543a6 2022-03-31 naddy ret=$?
1002 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1003 15341bfd 2020-03-05 tracey diff -u $testroot/stdout.expected $testroot/stdout
1004 15341bfd 2020-03-05 tracey fi
1005 15341bfd 2020-03-05 tracey test_done "$testroot" "$ret"
1006 15341bfd 2020-03-05 tracey }
1007 15341bfd 2020-03-05 tracey
1008 f6cae3ed 2020-09-13 naddy test_revert_deleted_subtree() {
1009 15341bfd 2020-03-05 tracey local testroot=`test_init revert_deleted_subtree`
1010 15341bfd 2020-03-05 tracey
1011 15341bfd 2020-03-05 tracey got checkout $testroot/repo $testroot/wt > /dev/null
1012 49c543a6 2022-03-31 naddy ret=$?
1013 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1014 15341bfd 2020-03-05 tracey test_done "$testroot" "$ret"
1015 15341bfd 2020-03-05 tracey return 1
1016 15341bfd 2020-03-05 tracey fi
1017 15341bfd 2020-03-05 tracey
1018 15341bfd 2020-03-05 tracey mkdir -p $testroot/wt/epsilon/foo/bar/baz
1019 15341bfd 2020-03-05 tracey mkdir -p $testroot/wt/epsilon/foo/bar/bax
1020 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/a.o
1021 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/a.o
1022 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/b.o
1023 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/b.d
1024 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/baz/f.o
1025 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/baz/f.d
1026 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/baz/c.o
1027 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/baz/c.d
1028 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/bax/e.o
1029 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/bax/e.d
1030 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/bax/x.o
1031 15341bfd 2020-03-05 tracey echo "new file" > $testroot/wt/epsilon/foo/bar/bax/x.d
1032 15341bfd 2020-03-05 tracey (cd $testroot/wt && got add -R epsilon >/dev/null)
1033 15341bfd 2020-03-05 tracey (cd $testroot/wt && got commit -m "add subtree" >/dev/null)
1034 a46b9f33 2020-01-28 stsp
1035 15341bfd 2020-03-05 tracey # now delete and revert the entire subtree
1036 15341bfd 2020-03-05 tracey (cd $testroot/wt && got rm -R epsilon/foo >/dev/null)
1037 15341bfd 2020-03-05 tracey
1038 15341bfd 2020-03-05 tracey echo "R epsilon/foo/a.o" > $testroot/stdout.expected
1039 15341bfd 2020-03-05 tracey echo "R epsilon/foo/bar/b.d" >> $testroot/stdout.expected
1040 15341bfd 2020-03-05 tracey echo "R epsilon/foo/bar/b.o" >> $testroot/stdout.expected
1041 15341bfd 2020-03-05 tracey echo "R epsilon/foo/bar/bax/e.d" >> $testroot/stdout.expected
1042 15341bfd 2020-03-05 tracey echo "R epsilon/foo/bar/bax/e.o" >> $testroot/stdout.expected
1043 15341bfd 2020-03-05 tracey echo "R epsilon/foo/bar/bax/x.d" >> $testroot/stdout.expected
1044 15341bfd 2020-03-05 tracey echo "R epsilon/foo/bar/bax/x.o" >> $testroot/stdout.expected
1045 15341bfd 2020-03-05 tracey echo "R epsilon/foo/bar/baz/c.d" >> $testroot/stdout.expected
1046 15341bfd 2020-03-05 tracey echo "R epsilon/foo/bar/baz/c.o" >> $testroot/stdout.expected
1047 15341bfd 2020-03-05 tracey echo "R epsilon/foo/bar/baz/f.d" >> $testroot/stdout.expected
1048 15341bfd 2020-03-05 tracey echo "R epsilon/foo/bar/baz/f.o" >> $testroot/stdout.expected
1049 15341bfd 2020-03-05 tracey
1050 15341bfd 2020-03-05 tracey (cd $testroot/wt && got revert -R . > $testroot/stdout)
1051 15341bfd 2020-03-05 tracey
1052 15341bfd 2020-03-05 tracey cmp -s $testroot/stdout.expected $testroot/stdout
1053 49c543a6 2022-03-31 naddy ret=$?
1054 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1055 15341bfd 2020-03-05 tracey diff -u $testroot/stdout.expected $testroot/stdout
1056 15341bfd 2020-03-05 tracey test_done "$testroot" "$ret"
1057 15341bfd 2020-03-05 tracey return 1
1058 15341bfd 2020-03-05 tracey fi
1059 15341bfd 2020-03-05 tracey
1060 15341bfd 2020-03-05 tracey echo -n > $testroot/stdout.expected
1061 a46b9f33 2020-01-28 stsp (cd $testroot/wt && got status > $testroot/stdout)
1062 a46b9f33 2020-01-28 stsp
1063 a46b9f33 2020-01-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1064 49c543a6 2022-03-31 naddy ret=$?
1065 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1066 a46b9f33 2020-01-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
1067 a46b9f33 2020-01-28 stsp fi
1068 a46b9f33 2020-01-28 stsp test_done "$testroot" "$ret"
1069 a46b9f33 2020-01-28 stsp }
1070 4901ccfc 2020-07-23 stsp
1071 f6cae3ed 2020-09-13 naddy test_revert_symlink() {
1072 4901ccfc 2020-07-23 stsp local testroot=`test_init revert_symlink`
1073 4901ccfc 2020-07-23 stsp
1074 4901ccfc 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
1075 4901ccfc 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
1076 4901ccfc 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
1077 4901ccfc 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
1078 4901ccfc 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
1079 4901ccfc 2020-07-23 stsp (cd $testroot/repo && ln -sf epsilon/zeta zeta.link)
1080 4901ccfc 2020-07-23 stsp (cd $testroot/repo && git add .)
1081 4901ccfc 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
1082 4901ccfc 2020-07-23 stsp local commit_id1=`git_show_head $testroot/repo`
1083 4901ccfc 2020-07-23 stsp
1084 4901ccfc 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1085 4901ccfc 2020-07-23 stsp
1086 4901ccfc 2020-07-23 stsp # symlink to file A now points to file B
1087 4901ccfc 2020-07-23 stsp (cd $testroot/wt && ln -sf gamma/delta alpha.link)
1088 4901ccfc 2020-07-23 stsp # symlink to a directory A now points to file B
1089 f55db25a 2023-03-03 naddy (cd $testroot/wt && rm epsilon.link && ln -s beta epsilon.link)
1090 4901ccfc 2020-07-23 stsp # "bad" symlink now contains a different target path
1091 4901ccfc 2020-07-23 stsp echo "foo" > $testroot/wt/passwd.link
1092 4901ccfc 2020-07-23 stsp # relative symlink to directory A now points to relative directory B
1093 f55db25a 2023-03-03 naddy (cd $testroot/wt && rm epsilon/beta.link && ln -s ../gamma \
1094 f55db25a 2023-03-03 naddy epsilon/beta.link)
1095 4901ccfc 2020-07-23 stsp # an unversioned symlink
1096 4901ccfc 2020-07-23 stsp (cd $testroot/wt && ln -sf .got/foo dotgotfoo.link)
1097 4901ccfc 2020-07-23 stsp # symlink to file A now points to non-existent file B
1098 4901ccfc 2020-07-23 stsp (cd $testroot/wt && ln -sf nonexistent2 nonexistent.link)
1099 4901ccfc 2020-07-23 stsp # removed symlink
1100 4901ccfc 2020-07-23 stsp (cd $testroot/wt && got rm zeta.link > /dev/null)
1101 4901ccfc 2020-07-23 stsp # added symlink
1102 4901ccfc 2020-07-23 stsp (cd $testroot/wt && ln -sf beta new.link)
1103 4901ccfc 2020-07-23 stsp (cd $testroot/wt && got add new.link > /dev/null)
1104 a46b9f33 2020-01-28 stsp
1105 4901ccfc 2020-07-23 stsp (cd $testroot/wt && got revert alpha.link epsilon.link \
1106 4901ccfc 2020-07-23 stsp passwd.link epsilon/beta.link dotgotfoo.link \
1107 4901ccfc 2020-07-23 stsp nonexistent.link zeta.link new.link > $testroot/stdout)
1108 4901ccfc 2020-07-23 stsp
1109 4901ccfc 2020-07-23 stsp cat > $testroot/stdout.expected <<EOF
1110 4901ccfc 2020-07-23 stsp R alpha.link
1111 4901ccfc 2020-07-23 stsp R epsilon/beta.link
1112 10a623df 2021-10-11 stsp R epsilon.link
1113 10a623df 2021-10-11 stsp R new.link
1114 4901ccfc 2020-07-23 stsp R nonexistent.link
1115 10a623df 2021-10-11 stsp R passwd.link
1116 4901ccfc 2020-07-23 stsp R zeta.link
1117 4901ccfc 2020-07-23 stsp EOF
1118 4901ccfc 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1119 49c543a6 2022-03-31 naddy ret=$?
1120 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1121 4901ccfc 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1122 4901ccfc 2020-07-23 stsp test_done "$testroot" "$ret"
1123 4901ccfc 2020-07-23 stsp return 1
1124 4901ccfc 2020-07-23 stsp fi
1125 4901ccfc 2020-07-23 stsp
1126 4901ccfc 2020-07-23 stsp if ! [ -h $testroot/wt/alpha.link ]; then
1127 4901ccfc 2020-07-23 stsp echo "alpha.link is not a symlink"
1128 4901ccfc 2020-07-23 stsp test_done "$testroot" "1"
1129 4901ccfc 2020-07-23 stsp return 1
1130 4901ccfc 2020-07-23 stsp fi
1131 4901ccfc 2020-07-23 stsp
1132 4901ccfc 2020-07-23 stsp readlink $testroot/wt/alpha.link > $testroot/stdout
1133 4901ccfc 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
1134 4901ccfc 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1135 49c543a6 2022-03-31 naddy ret=$?
1136 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1137 4901ccfc 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1138 4901ccfc 2020-07-23 stsp test_done "$testroot" "$ret"
1139 4901ccfc 2020-07-23 stsp return 1
1140 4901ccfc 2020-07-23 stsp fi
1141 4901ccfc 2020-07-23 stsp
1142 4901ccfc 2020-07-23 stsp if ! [ -h $testroot/wt/epsilon.link ]; then
1143 4901ccfc 2020-07-23 stsp echo "epsilon.link is not a symlink"
1144 4901ccfc 2020-07-23 stsp test_done "$testroot" "1"
1145 4901ccfc 2020-07-23 stsp return 1
1146 4901ccfc 2020-07-23 stsp fi
1147 4901ccfc 2020-07-23 stsp
1148 4901ccfc 2020-07-23 stsp readlink $testroot/wt/epsilon.link > $testroot/stdout
1149 4901ccfc 2020-07-23 stsp echo "epsilon" > $testroot/stdout.expected
1150 4901ccfc 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1151 49c543a6 2022-03-31 naddy ret=$?
1152 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1153 4901ccfc 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1154 4901ccfc 2020-07-23 stsp test_done "$testroot" "$ret"
1155 4901ccfc 2020-07-23 stsp return 1
1156 4901ccfc 2020-07-23 stsp fi
1157 4901ccfc 2020-07-23 stsp
1158 4901ccfc 2020-07-23 stsp if [ -h $testroot/wt/passwd.link ]; then
1159 4901ccfc 2020-07-23 stsp echo "passwd.link should not be a symlink" >&2
1160 4901ccfc 2020-07-23 stsp test_done "$testroot" "1"
1161 4901ccfc 2020-07-23 stsp return 1
1162 4901ccfc 2020-07-23 stsp fi
1163 4901ccfc 2020-07-23 stsp
1164 4901ccfc 2020-07-23 stsp echo -n "/etc/passwd" > $testroot/content.expected
1165 4901ccfc 2020-07-23 stsp cp $testroot/wt/passwd.link $testroot/content
1166 4901ccfc 2020-07-23 stsp
1167 4901ccfc 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
1168 49c543a6 2022-03-31 naddy ret=$?
1169 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1170 4901ccfc 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
1171 4901ccfc 2020-07-23 stsp test_done "$testroot" "$ret"
1172 4901ccfc 2020-07-23 stsp return 1
1173 4901ccfc 2020-07-23 stsp fi
1174 4901ccfc 2020-07-23 stsp
1175 4901ccfc 2020-07-23 stsp readlink $testroot/wt/epsilon/beta.link > $testroot/stdout
1176 4901ccfc 2020-07-23 stsp echo "../beta" > $testroot/stdout.expected
1177 4901ccfc 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1178 49c543a6 2022-03-31 naddy ret=$?
1179 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1180 4901ccfc 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1181 4901ccfc 2020-07-23 stsp test_done "$testroot" "$ret"
1182 4901ccfc 2020-07-23 stsp return 1
1183 4901ccfc 2020-07-23 stsp fi
1184 4901ccfc 2020-07-23 stsp
1185 4901ccfc 2020-07-23 stsp readlink $testroot/wt/nonexistent.link > $testroot/stdout
1186 4901ccfc 2020-07-23 stsp echo "nonexistent" > $testroot/stdout.expected
1187 4901ccfc 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1188 49c543a6 2022-03-31 naddy ret=$?
1189 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1190 4901ccfc 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1191 4901ccfc 2020-07-23 stsp test_done "$testroot" "$ret"
1192 c2677d5d 2020-07-23 stsp return 1
1193 4901ccfc 2020-07-23 stsp fi
1194 4901ccfc 2020-07-23 stsp
1195 4901ccfc 2020-07-23 stsp if [ ! -h $testroot/wt/dotgotfoo.link ]; then
1196 4901ccfc 2020-07-23 stsp echo "dotgotfoo.link is not a symlink " >&2
1197 4901ccfc 2020-07-23 stsp test_done "$testroot" "1"
1198 4901ccfc 2020-07-23 stsp return 1
1199 4901ccfc 2020-07-23 stsp fi
1200 4901ccfc 2020-07-23 stsp readlink $testroot/wt/dotgotfoo.link > $testroot/stdout
1201 4901ccfc 2020-07-23 stsp echo ".got/foo" > $testroot/stdout.expected
1202 4901ccfc 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
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/stdout.expected $testroot/stdout
1206 4901ccfc 2020-07-23 stsp test_done "$testroot" "$ret"
1207 c2677d5d 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 if [ ! -h $testroot/wt/zeta.link ]; then
1211 4901ccfc 2020-07-23 stsp echo -n "zeta.link is not a symlink" >&2
1212 4901ccfc 2020-07-23 stsp test_done "$testroot" "1"
1213 4901ccfc 2020-07-23 stsp return 1
1214 4901ccfc 2020-07-23 stsp fi
1215 4901ccfc 2020-07-23 stsp
1216 4901ccfc 2020-07-23 stsp readlink $testroot/wt/zeta.link > $testroot/stdout
1217 4901ccfc 2020-07-23 stsp echo "epsilon/zeta" > $testroot/stdout.expected
1218 4901ccfc 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1219 49c543a6 2022-03-31 naddy ret=$?
1220 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1221 4901ccfc 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1222 4901ccfc 2020-07-23 stsp test_done "$testroot" "$ret"
1223 c2677d5d 2020-07-23 stsp return 1
1224 4901ccfc 2020-07-23 stsp fi
1225 4901ccfc 2020-07-23 stsp
1226 4901ccfc 2020-07-23 stsp if [ ! -h $testroot/wt/new.link ]; then
1227 4901ccfc 2020-07-23 stsp echo -n "new.link is not a symlink" >&2
1228 4901ccfc 2020-07-23 stsp test_done "$testroot" "1"
1229 4901ccfc 2020-07-23 stsp return 1
1230 4901ccfc 2020-07-23 stsp fi
1231 4901ccfc 2020-07-23 stsp
1232 4901ccfc 2020-07-23 stsp (cd $testroot/wt && got status > $testroot/stdout)
1233 4901ccfc 2020-07-23 stsp echo "? dotgotfoo.link" > $testroot/stdout.expected
1234 4901ccfc 2020-07-23 stsp echo "? new.link" >> $testroot/stdout.expected
1235 4901ccfc 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1236 49c543a6 2022-03-31 naddy ret=$?
1237 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1238 4901ccfc 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1239 4901ccfc 2020-07-23 stsp return 1
1240 4901ccfc 2020-07-23 stsp fi
1241 4901ccfc 2020-07-23 stsp test_done "$testroot" "$ret"
1242 4901ccfc 2020-07-23 stsp }
1243 4901ccfc 2020-07-23 stsp
1244 f6cae3ed 2020-09-13 naddy test_revert_patch_symlink() {
1245 369fd7e5 2020-07-23 stsp local testroot=`test_init revert_patch_symlink`
1246 369fd7e5 2020-07-23 stsp
1247 369fd7e5 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
1248 369fd7e5 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
1249 369fd7e5 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
1250 369fd7e5 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
1251 369fd7e5 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
1252 369fd7e5 2020-07-23 stsp (cd $testroot/repo && ln -sf epsilon/zeta zeta.link)
1253 369fd7e5 2020-07-23 stsp (cd $testroot/repo && ln -sf epsilon/zeta zeta2.link)
1254 369fd7e5 2020-07-23 stsp (cd $testroot/repo && git add .)
1255 369fd7e5 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
1256 369fd7e5 2020-07-23 stsp local commit_id1=`git_show_head $testroot/repo`
1257 369fd7e5 2020-07-23 stsp
1258 369fd7e5 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1259 369fd7e5 2020-07-23 stsp
1260 369fd7e5 2020-07-23 stsp # symlink to file A now points to file B
1261 369fd7e5 2020-07-23 stsp (cd $testroot/wt && ln -sf gamma/delta alpha.link)
1262 369fd7e5 2020-07-23 stsp # symlink to a directory A now points to file B
1263 f55db25a 2023-03-03 naddy (cd $testroot/wt && rm epsilon.link && ln -s beta epsilon.link)
1264 369fd7e5 2020-07-23 stsp # "bad" symlink now contains a different target path
1265 369fd7e5 2020-07-23 stsp echo "foo" > $testroot/wt/passwd.link
1266 369fd7e5 2020-07-23 stsp # relative symlink to directory A now points to relative directory B
1267 f55db25a 2023-03-03 naddy (cd $testroot/wt && rm epsilon/beta.link && ln -s ../gamma \
1268 f55db25a 2023-03-03 naddy epsilon/beta.link)
1269 369fd7e5 2020-07-23 stsp # an unversioned symlink
1270 369fd7e5 2020-07-23 stsp (cd $testroot/wt && ln -sf .got/foo dotgotfoo.link)
1271 369fd7e5 2020-07-23 stsp # symlink to file A now points to non-existent file B
1272 369fd7e5 2020-07-23 stsp (cd $testroot/wt && ln -sf nonexistent2 nonexistent.link)
1273 369fd7e5 2020-07-23 stsp # removed symlink
1274 369fd7e5 2020-07-23 stsp (cd $testroot/wt && got rm zeta.link > /dev/null)
1275 369fd7e5 2020-07-23 stsp (cd $testroot/wt && got rm zeta2.link > /dev/null)
1276 369fd7e5 2020-07-23 stsp # added symlink
1277 369fd7e5 2020-07-23 stsp (cd $testroot/wt && ln -sf beta new.link)
1278 369fd7e5 2020-07-23 stsp (cd $testroot/wt && got add new.link > /dev/null)
1279 369fd7e5 2020-07-23 stsp (cd $testroot/wt && ln -sf beta zeta3.link)
1280 369fd7e5 2020-07-23 stsp (cd $testroot/wt && got add zeta3.link > /dev/null)
1281 369fd7e5 2020-07-23 stsp
1282 369fd7e5 2020-07-23 stsp printf "y\nn\ny\nn\ny\ny\nn\ny\ny\n" > $testroot/patchscript
1283 369fd7e5 2020-07-23 stsp (cd $testroot/wt && got revert -F $testroot/patchscript -p -R . \
1284 369fd7e5 2020-07-23 stsp > $testroot/stdout)
1285 49c543a6 2022-03-31 naddy ret=$?
1286 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1287 369fd7e5 2020-07-23 stsp echo "got revert command failed unexpectedly" >&2
1288 369fd7e5 2020-07-23 stsp test_done "$testroot" "1"
1289 369fd7e5 2020-07-23 stsp return 1
1290 369fd7e5 2020-07-23 stsp fi
1291 369fd7e5 2020-07-23 stsp cat > $testroot/stdout.expected <<EOF
1292 369fd7e5 2020-07-23 stsp -----------------------------------------------
1293 369fd7e5 2020-07-23 stsp @@ -1 +1 @@
1294 369fd7e5 2020-07-23 stsp -alpha
1295 369fd7e5 2020-07-23 stsp \ No newline at end of file
1296 369fd7e5 2020-07-23 stsp +gamma/delta
1297 369fd7e5 2020-07-23 stsp \ No newline at end of file
1298 369fd7e5 2020-07-23 stsp -----------------------------------------------
1299 369fd7e5 2020-07-23 stsp M alpha.link (change 1 of 1)
1300 369fd7e5 2020-07-23 stsp revert this change? [y/n/q] y
1301 369fd7e5 2020-07-23 stsp R alpha.link
1302 369fd7e5 2020-07-23 stsp -----------------------------------------------
1303 369fd7e5 2020-07-23 stsp @@ -1 +1 @@
1304 369fd7e5 2020-07-23 stsp -../beta
1305 369fd7e5 2020-07-23 stsp \ No newline at end of file
1306 369fd7e5 2020-07-23 stsp +../gamma
1307 369fd7e5 2020-07-23 stsp \ No newline at end of file
1308 369fd7e5 2020-07-23 stsp -----------------------------------------------
1309 369fd7e5 2020-07-23 stsp M epsilon/beta.link (change 1 of 1)
1310 369fd7e5 2020-07-23 stsp revert this change? [y/n/q] n
1311 369fd7e5 2020-07-23 stsp -----------------------------------------------
1312 369fd7e5 2020-07-23 stsp @@ -1 +1 @@
1313 369fd7e5 2020-07-23 stsp -epsilon
1314 369fd7e5 2020-07-23 stsp \ No newline at end of file
1315 369fd7e5 2020-07-23 stsp +beta
1316 369fd7e5 2020-07-23 stsp \ No newline at end of file
1317 369fd7e5 2020-07-23 stsp -----------------------------------------------
1318 369fd7e5 2020-07-23 stsp M epsilon.link (change 1 of 1)
1319 369fd7e5 2020-07-23 stsp revert this change? [y/n/q] y
1320 369fd7e5 2020-07-23 stsp R epsilon.link
1321 369fd7e5 2020-07-23 stsp A new.link
1322 369fd7e5 2020-07-23 stsp revert this addition? [y/n] n
1323 369fd7e5 2020-07-23 stsp -----------------------------------------------
1324 369fd7e5 2020-07-23 stsp @@ -1 +1 @@
1325 369fd7e5 2020-07-23 stsp -nonexistent
1326 369fd7e5 2020-07-23 stsp \ No newline at end of file
1327 369fd7e5 2020-07-23 stsp +nonexistent2
1328 369fd7e5 2020-07-23 stsp \ No newline at end of file
1329 369fd7e5 2020-07-23 stsp -----------------------------------------------
1330 369fd7e5 2020-07-23 stsp M nonexistent.link (change 1 of 1)
1331 369fd7e5 2020-07-23 stsp revert this change? [y/n/q] y
1332 369fd7e5 2020-07-23 stsp R nonexistent.link
1333 369fd7e5 2020-07-23 stsp -----------------------------------------------
1334 369fd7e5 2020-07-23 stsp @@ -1 +1 @@
1335 369fd7e5 2020-07-23 stsp -/etc/passwd
1336 369fd7e5 2020-07-23 stsp \ No newline at end of file
1337 369fd7e5 2020-07-23 stsp +foo
1338 369fd7e5 2020-07-23 stsp -----------------------------------------------
1339 369fd7e5 2020-07-23 stsp M passwd.link (change 1 of 1)
1340 369fd7e5 2020-07-23 stsp revert this change? [y/n/q] y
1341 369fd7e5 2020-07-23 stsp R passwd.link
1342 369fd7e5 2020-07-23 stsp D zeta.link
1343 369fd7e5 2020-07-23 stsp revert this deletion? [y/n] n
1344 369fd7e5 2020-07-23 stsp D zeta2.link
1345 369fd7e5 2020-07-23 stsp revert this deletion? [y/n] y
1346 369fd7e5 2020-07-23 stsp R zeta2.link
1347 369fd7e5 2020-07-23 stsp A zeta3.link
1348 369fd7e5 2020-07-23 stsp revert this addition? [y/n] y
1349 369fd7e5 2020-07-23 stsp R zeta3.link
1350 369fd7e5 2020-07-23 stsp EOF
1351 369fd7e5 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1352 49c543a6 2022-03-31 naddy ret=$?
1353 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1354 369fd7e5 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1355 369fd7e5 2020-07-23 stsp test_done "$testroot" "$ret"
1356 369fd7e5 2020-07-23 stsp return 1
1357 369fd7e5 2020-07-23 stsp fi
1358 369fd7e5 2020-07-23 stsp
1359 369fd7e5 2020-07-23 stsp if ! [ -h $testroot/wt/alpha.link ]; then
1360 369fd7e5 2020-07-23 stsp echo "alpha.link is not a symlink"
1361 369fd7e5 2020-07-23 stsp test_done "$testroot" "1"
1362 369fd7e5 2020-07-23 stsp return 1
1363 369fd7e5 2020-07-23 stsp fi
1364 369fd7e5 2020-07-23 stsp
1365 369fd7e5 2020-07-23 stsp readlink $testroot/wt/alpha.link > $testroot/stdout
1366 369fd7e5 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
1367 369fd7e5 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1368 49c543a6 2022-03-31 naddy ret=$?
1369 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1370 369fd7e5 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1371 369fd7e5 2020-07-23 stsp test_done "$testroot" "$ret"
1372 369fd7e5 2020-07-23 stsp return 1
1373 369fd7e5 2020-07-23 stsp fi
1374 369fd7e5 2020-07-23 stsp
1375 369fd7e5 2020-07-23 stsp if ! [ -h $testroot/wt/epsilon.link ]; then
1376 369fd7e5 2020-07-23 stsp echo "epsilon.link is not a symlink"
1377 369fd7e5 2020-07-23 stsp test_done "$testroot" "1"
1378 369fd7e5 2020-07-23 stsp return 1
1379 369fd7e5 2020-07-23 stsp fi
1380 369fd7e5 2020-07-23 stsp
1381 369fd7e5 2020-07-23 stsp readlink $testroot/wt/epsilon.link > $testroot/stdout
1382 369fd7e5 2020-07-23 stsp echo "epsilon" > $testroot/stdout.expected
1383 369fd7e5 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1384 49c543a6 2022-03-31 naddy ret=$?
1385 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1386 369fd7e5 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1387 369fd7e5 2020-07-23 stsp test_done "$testroot" "$ret"
1388 369fd7e5 2020-07-23 stsp return 1
1389 369fd7e5 2020-07-23 stsp fi
1390 369fd7e5 2020-07-23 stsp
1391 369fd7e5 2020-07-23 stsp if [ -h $testroot/wt/passwd.link ]; then
1392 369fd7e5 2020-07-23 stsp echo "passwd.link should not be a symlink" >&2
1393 369fd7e5 2020-07-23 stsp test_done "$testroot" "1"
1394 369fd7e5 2020-07-23 stsp return 1
1395 369fd7e5 2020-07-23 stsp fi
1396 369fd7e5 2020-07-23 stsp
1397 369fd7e5 2020-07-23 stsp echo -n "/etc/passwd" > $testroot/content.expected
1398 369fd7e5 2020-07-23 stsp cp $testroot/wt/passwd.link $testroot/content
1399 369fd7e5 2020-07-23 stsp
1400 369fd7e5 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
1401 49c543a6 2022-03-31 naddy ret=$?
1402 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1403 369fd7e5 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
1404 369fd7e5 2020-07-23 stsp test_done "$testroot" "$ret"
1405 369fd7e5 2020-07-23 stsp return 1
1406 369fd7e5 2020-07-23 stsp fi
1407 369fd7e5 2020-07-23 stsp
1408 369fd7e5 2020-07-23 stsp readlink $testroot/wt/epsilon/beta.link > $testroot/stdout
1409 369fd7e5 2020-07-23 stsp echo "../gamma" > $testroot/stdout.expected
1410 369fd7e5 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1411 49c543a6 2022-03-31 naddy ret=$?
1412 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1413 369fd7e5 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1414 369fd7e5 2020-07-23 stsp test_done "$testroot" "$ret"
1415 369fd7e5 2020-07-23 stsp return 1
1416 369fd7e5 2020-07-23 stsp fi
1417 369fd7e5 2020-07-23 stsp
1418 369fd7e5 2020-07-23 stsp readlink $testroot/wt/nonexistent.link > $testroot/stdout
1419 369fd7e5 2020-07-23 stsp echo "nonexistent" > $testroot/stdout.expected
1420 369fd7e5 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1421 49c543a6 2022-03-31 naddy ret=$?
1422 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1423 369fd7e5 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1424 369fd7e5 2020-07-23 stsp test_done "$testroot" "$ret"
1425 c2677d5d 2020-07-23 stsp return 1
1426 369fd7e5 2020-07-23 stsp fi
1427 369fd7e5 2020-07-23 stsp
1428 369fd7e5 2020-07-23 stsp if [ ! -h $testroot/wt/dotgotfoo.link ]; then
1429 369fd7e5 2020-07-23 stsp echo "dotgotfoo.link is not a symlink " >&2
1430 369fd7e5 2020-07-23 stsp test_done "$testroot" "1"
1431 369fd7e5 2020-07-23 stsp return 1
1432 369fd7e5 2020-07-23 stsp fi
1433 369fd7e5 2020-07-23 stsp readlink $testroot/wt/dotgotfoo.link > $testroot/stdout
1434 369fd7e5 2020-07-23 stsp echo ".got/foo" > $testroot/stdout.expected
1435 369fd7e5 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
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/stdout.expected $testroot/stdout
1439 369fd7e5 2020-07-23 stsp test_done "$testroot" "$ret"
1440 c2677d5d 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
1444 369fd7e5 2020-07-23 stsp if [ -e $testroot/wt/zeta.link ]; then
1445 369fd7e5 2020-07-23 stsp echo -n "zeta.link should not exist on disk" >&2
1446 369fd7e5 2020-07-23 stsp test_done "$testroot" "1"
1447 369fd7e5 2020-07-23 stsp return 1
1448 369fd7e5 2020-07-23 stsp fi
1449 369fd7e5 2020-07-23 stsp
1450 369fd7e5 2020-07-23 stsp if [ ! -h $testroot/wt/zeta2.link ]; then
1451 369fd7e5 2020-07-23 stsp echo -n "zeta2.link is not a symlink" >&2
1452 369fd7e5 2020-07-23 stsp test_done "$testroot" "1"
1453 369fd7e5 2020-07-23 stsp return 1
1454 369fd7e5 2020-07-23 stsp fi
1455 369fd7e5 2020-07-23 stsp
1456 369fd7e5 2020-07-23 stsp readlink $testroot/wt/zeta2.link > $testroot/stdout
1457 369fd7e5 2020-07-23 stsp echo "epsilon/zeta" > $testroot/stdout.expected
1458 369fd7e5 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1459 49c543a6 2022-03-31 naddy ret=$?
1460 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1461 369fd7e5 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1462 369fd7e5 2020-07-23 stsp test_done "$testroot" "$ret"
1463 c2677d5d 2020-07-23 stsp return 1
1464 369fd7e5 2020-07-23 stsp fi
1465 369fd7e5 2020-07-23 stsp
1466 369fd7e5 2020-07-23 stsp if [ ! -h $testroot/wt/zeta3.link ]; then
1467 369fd7e5 2020-07-23 stsp echo -n "zeta3.link is not a symlink" >&2
1468 369fd7e5 2020-07-23 stsp test_done "$testroot" "1"
1469 369fd7e5 2020-07-23 stsp return 1
1470 369fd7e5 2020-07-23 stsp fi
1471 369fd7e5 2020-07-23 stsp
1472 cf0e59fe 2020-07-23 stsp readlink $testroot/wt/zeta3.link > $testroot/stdout
1473 cf0e59fe 2020-07-23 stsp echo "beta" > $testroot/stdout.expected
1474 369fd7e5 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1475 49c543a6 2022-03-31 naddy ret=$?
1476 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1477 369fd7e5 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1478 369fd7e5 2020-07-23 stsp test_done "$testroot" "$ret"
1479 c2677d5d 2020-07-23 stsp return 1
1480 369fd7e5 2020-07-23 stsp fi
1481 369fd7e5 2020-07-23 stsp
1482 369fd7e5 2020-07-23 stsp if [ ! -h $testroot/wt/new.link ]; then
1483 369fd7e5 2020-07-23 stsp echo -n "new.link is not a symlink" >&2
1484 369fd7e5 2020-07-23 stsp test_done "$testroot" "1"
1485 369fd7e5 2020-07-23 stsp return 1
1486 369fd7e5 2020-07-23 stsp fi
1487 369fd7e5 2020-07-23 stsp
1488 369fd7e5 2020-07-23 stsp (cd $testroot/wt && got status > $testroot/stdout)
1489 369fd7e5 2020-07-23 stsp echo "? dotgotfoo.link" > $testroot/stdout.expected
1490 369fd7e5 2020-07-23 stsp echo "M epsilon/beta.link" >> $testroot/stdout.expected
1491 369fd7e5 2020-07-23 stsp echo "A new.link" >> $testroot/stdout.expected
1492 369fd7e5 2020-07-23 stsp echo "D zeta.link" >> $testroot/stdout.expected
1493 369fd7e5 2020-07-23 stsp echo "? zeta3.link" >> $testroot/stdout.expected
1494 369fd7e5 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1495 49c543a6 2022-03-31 naddy ret=$?
1496 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1497 369fd7e5 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1498 369fd7e5 2020-07-23 stsp return 1
1499 369fd7e5 2020-07-23 stsp fi
1500 369fd7e5 2020-07-23 stsp test_done "$testroot" "$ret"
1501 369fd7e5 2020-07-23 stsp }
1502 b2b3fce1 2022-10-29 op
1503 b2b3fce1 2022-10-29 op test_revert_umask() {
1504 b2b3fce1 2022-10-29 op local testroot=`test_init revert_umask`
1505 b2b3fce1 2022-10-29 op
1506 b2b3fce1 2022-10-29 op got checkout "$testroot/repo" "$testroot/wt" >/dev/null
1507 b2b3fce1 2022-10-29 op echo "edit alpha" > $testroot/wt/alpha
1508 369fd7e5 2020-07-23 stsp
1509 b2b3fce1 2022-10-29 op # using a subshell to avoid clobbering global umask
1510 b2b3fce1 2022-10-29 op (umask 077 && cd "$testroot/wt" && got revert alpha) \
1511 b2b3fce1 2022-10-29 op >/dev/null
1512 b2b3fce1 2022-10-29 op ret=$?
1513 b2b3fce1 2022-10-29 op if [ $ret -ne 0 ]; then
1514 b2b3fce1 2022-10-29 op test_done "$testroot" $ret
1515 b2b3fce1 2022-10-29 op return 1
1516 b2b3fce1 2022-10-29 op fi
1517 b2b3fce1 2022-10-29 op
1518 b2b3fce1 2022-10-29 op if ! ls -l "$testroot/wt/alpha" | grep -q ^-rw-------; then
1519 b2b3fce1 2022-10-29 op echo "alpha is not 0600 after revert" >&2
1520 b2b3fce1 2022-10-29 op ls -l "$testroot/wt/alpha" >&2
1521 b2b3fce1 2022-10-29 op test_done "$testroot" 1
1522 b2b3fce1 2022-10-29 op return 1
1523 b2b3fce1 2022-10-29 op fi
1524 b2b3fce1 2022-10-29 op test_done "$testroot" 0
1525 b2b3fce1 2022-10-29 op }
1526 b2b3fce1 2022-10-29 op
1527 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1528 a129376b 2019-03-28 stsp run_test test_revert_basic
1529 a129376b 2019-03-28 stsp run_test test_revert_rm
1530 a129376b 2019-03-28 stsp run_test test_revert_add
1531 e20a8b6f 2019-06-04 stsp run_test test_revert_multiple
1532 a9fa2909 2019-07-27 stsp run_test test_revert_file_in_new_subdir
1533 1f1abb7e 2019-08-08 stsp run_test test_revert_no_arguments
1534 0f6d7415 2019-08-08 stsp run_test test_revert_directory
1535 3d69ad8d 2019-08-17 semarie run_test test_revert_directory_unknown
1536 33aa809d 2019-08-08 stsp run_test test_revert_patch
1537 33aa809d 2019-08-08 stsp run_test test_revert_patch_added
1538 33aa809d 2019-08-08 stsp run_test test_revert_patch_removed
1539 f1e81a05 2019-08-10 stsp run_test test_revert_patch_one_change
1540 a46b9f33 2020-01-28 stsp run_test test_revert_added_subtree
1541 15341bfd 2020-03-05 tracey run_test test_revert_deleted_subtree
1542 4901ccfc 2020-07-23 stsp run_test test_revert_symlink
1543 369fd7e5 2020-07-23 stsp run_test test_revert_patch_symlink
1544 b2b3fce1 2022-10-29 op run_test test_revert_umask