3 c84d8c75 2019-01-02 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
5 c84d8c75 2019-01-02 stsp # Permission to use, copy, modify, and distribute this software for any
6 c84d8c75 2019-01-02 stsp # purpose with or without fee is hereby granted, provided that the above
7 c84d8c75 2019-01-02 stsp # copyright notice and this permission notice appear in all copies.
9 c84d8c75 2019-01-02 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 c84d8c75 2019-01-02 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 c84d8c75 2019-01-02 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 c84d8c75 2019-01-02 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 c84d8c75 2019-01-02 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 c84d8c75 2019-01-02 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 c84d8c75 2019-01-02 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 c84d8c75 2019-01-02 stsp . ./common.sh
19 c84d8c75 2019-01-02 stsp function test_update_basic {
20 0fbd721f 2019-01-02 stsp local testroot=`test_init update_basic`
22 3c90ba67 2019-01-02 stsp got checkout $testroot/repo $testroot/wt > /dev/null
23 c84d8c75 2019-01-02 stsp if [ "$?" != "0" ]; then
24 c84d8c75 2019-01-02 stsp test_done "$testroot" "$?"
28 c84d8c75 2019-01-02 stsp echo "modified alpha" > $testroot/repo/alpha
29 c84d8c75 2019-01-02 stsp git_commit $testroot/repo -m "modified alpha"
31 c84d8c75 2019-01-02 stsp echo "U alpha" > $testroot/stdout.expected
32 9c4b8182 2019-01-02 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
33 9c4b8182 2019-01-02 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
34 9c4b8182 2019-01-02 stsp echo >> $testroot/stdout.expected
36 c84d8c75 2019-01-02 stsp (cd $testroot/wt && got update > $testroot/stdout)
38 c84d8c75 2019-01-02 stsp cmp $testroot/stdout.expected $testroot/stdout
39 c84d8c75 2019-01-02 stsp if [ "$?" != "0" ]; then
40 c84d8c75 2019-01-02 stsp diff -u $testroot/stdout.expected $testroot/stdout
41 c84d8c75 2019-01-02 stsp test_done "$testroot" "$?"
45 c84d8c75 2019-01-02 stsp echo "modified alpha" > $testroot/content.expected
46 52a3df9b 2019-01-06 stsp cat $testroot/wt/alpha > $testroot/content
48 c84d8c75 2019-01-02 stsp cmp $testroot/content.expected $testroot/content
50 693719bc 2019-01-03 stsp if [ "$ret" != "0" ]; then
51 c84d8c75 2019-01-02 stsp diff -u $testroot/content.expected $testroot/content
53 693719bc 2019-01-03 stsp test_done "$testroot" "$ret"
56 3b4d3732 2019-01-02 stsp function test_update_adds_file {
57 3b4d3732 2019-01-02 stsp local testroot=`test_init update_adds_file`
59 3b4d3732 2019-01-02 stsp got checkout $testroot/repo $testroot/wt > /dev/null
60 3b4d3732 2019-01-02 stsp if [ "$?" != "0" ]; then
61 3b4d3732 2019-01-02 stsp test_done "$testroot" "$?"
65 3b4d3732 2019-01-02 stsp echo "new" > $testroot/repo/gamma/new
66 3b4d3732 2019-01-02 stsp (cd $testroot/repo && git add .)
67 3b4d3732 2019-01-02 stsp git_commit $testroot/repo -m "adding a new file"
69 3b4d3732 2019-01-02 stsp echo "A gamma/new" > $testroot/stdout.expected
70 3b4d3732 2019-01-02 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
71 3b4d3732 2019-01-02 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
72 3b4d3732 2019-01-02 stsp echo >> $testroot/stdout.expected
74 3b4d3732 2019-01-02 stsp (cd $testroot/wt && got update > $testroot/stdout)
76 3b4d3732 2019-01-02 stsp cmp $testroot/stdout.expected $testroot/stdout
77 3b4d3732 2019-01-02 stsp if [ "$?" != "0" ]; then
78 3b4d3732 2019-01-02 stsp diff -u $testroot/stdout.expected $testroot/stdout
79 3b4d3732 2019-01-02 stsp test_done "$testroot" "$?"
83 3b4d3732 2019-01-02 stsp echo "new" >> $testroot/content.expected
84 52a3df9b 2019-01-06 stsp cat $testroot/wt/gamma/new > $testroot/content
86 3b4d3732 2019-01-02 stsp cmp $testroot/content.expected $testroot/content
88 693719bc 2019-01-03 stsp if [ "$ret" != "0" ]; then
89 3b4d3732 2019-01-02 stsp diff -u $testroot/content.expected $testroot/content
91 693719bc 2019-01-03 stsp test_done "$testroot" "$ret"
94 512f0d0e 2019-01-02 stsp function test_update_deletes_file {
95 512f0d0e 2019-01-02 stsp local testroot=`test_init update_deletes_file`
97 512f0d0e 2019-01-02 stsp got checkout $testroot/repo $testroot/wt > /dev/null
98 512f0d0e 2019-01-02 stsp if [ "$?" != "0" ]; then
99 512f0d0e 2019-01-02 stsp test_done "$testroot" "$?"
103 512f0d0e 2019-01-02 stsp (cd $testroot/repo && git_rm $testroot/repo beta)
104 512f0d0e 2019-01-02 stsp git_commit $testroot/repo -m "deleting a file"
106 512f0d0e 2019-01-02 stsp echo "D beta" > $testroot/stdout.expected
107 512f0d0e 2019-01-02 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
108 512f0d0e 2019-01-02 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
109 512f0d0e 2019-01-02 stsp echo >> $testroot/stdout.expected
111 512f0d0e 2019-01-02 stsp (cd $testroot/wt && got update > $testroot/stdout)
113 512f0d0e 2019-01-02 stsp cmp $testroot/stdout.expected $testroot/stdout
114 512f0d0e 2019-01-02 stsp if [ "$?" != "0" ]; then
115 512f0d0e 2019-01-02 stsp diff -u $testroot/stdout.expected $testroot/stdout
116 512f0d0e 2019-01-02 stsp test_done "$testroot" "$?"
120 512f0d0e 2019-01-02 stsp if [ -e $testroot/wt/beta ]; then
121 512f0d0e 2019-01-02 stsp echo "removed file beta still exists on disk" >&2
122 52a3df9b 2019-01-06 stsp test_done "$testroot" "1"
126 52a3df9b 2019-01-06 stsp test_done "$testroot" "0"
129 f5c49f82 2019-01-06 stsp function test_update_deletes_dir {
130 f5c49f82 2019-01-06 stsp local testroot=`test_init update_deletes_dir`
132 f5c49f82 2019-01-06 stsp got checkout $testroot/repo $testroot/wt > /dev/null
133 f5c49f82 2019-01-06 stsp if [ "$?" != "0" ]; then
134 f5c49f82 2019-01-06 stsp test_done "$testroot" "$?"
138 f5c49f82 2019-01-06 stsp (cd $testroot/repo && git_rm $testroot/repo -r epsilon)
139 f5c49f82 2019-01-06 stsp git_commit $testroot/repo -m "deleting a directory"
141 f5c49f82 2019-01-06 stsp echo "D epsilon/zeta" > $testroot/stdout.expected
142 f5c49f82 2019-01-06 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
143 f5c49f82 2019-01-06 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
144 f5c49f82 2019-01-06 stsp echo >> $testroot/stdout.expected
146 f5c49f82 2019-01-06 stsp (cd $testroot/wt && got update > $testroot/stdout)
148 f5c49f82 2019-01-06 stsp cmp $testroot/stdout.expected $testroot/stdout
149 f5c49f82 2019-01-06 stsp if [ "$?" != "0" ]; then
150 f5c49f82 2019-01-06 stsp diff -u $testroot/stdout.expected $testroot/stdout
151 f5c49f82 2019-01-06 stsp test_done "$testroot" "$?"
155 f5c49f82 2019-01-06 stsp if [ -e $testroot/wt/epsilon ]; then
156 f5c49f82 2019-01-06 stsp echo "removed dir epsilon still exists on disk" >&2
157 52a3df9b 2019-01-06 stsp test_done "$testroot" "1"
161 52a3df9b 2019-01-06 stsp test_done "$testroot" "0"
164 5cc266ba 2019-01-06 stsp function test_update_deletes_dir_with_path_prefix {
165 5cc266ba 2019-01-06 stsp local testroot=`test_init update_deletes_dir_with_path_prefix`
166 5cc266ba 2019-01-06 stsp local first_rev=`git_show_head $testroot/repo`
168 5cc266ba 2019-01-06 stsp mkdir $testroot/repo/epsilon/psi
169 5cc266ba 2019-01-06 stsp echo mu > $testroot/repo/epsilon/psi/mu
170 5cc266ba 2019-01-06 stsp (cd $testroot/repo && git add .)
171 5cc266ba 2019-01-06 stsp git_commit $testroot/repo -m "adding a sub-directory beneath epsilon"
173 5cc266ba 2019-01-06 stsp # check out the epsilon/ sub-tree
174 5cc266ba 2019-01-06 stsp got checkout -p epsilon $testroot/repo $testroot/wt > /dev/null
175 5cc266ba 2019-01-06 stsp if [ "$?" != "0" ]; then
176 5cc266ba 2019-01-06 stsp test_done "$testroot" "$?"
180 5cc266ba 2019-01-06 stsp # update back to first commit and expect psi/mu to be deleted
181 5cc266ba 2019-01-06 stsp echo "D psi/mu" > $testroot/stdout.expected
182 5cc266ba 2019-01-06 stsp echo "Updated to commit $first_rev" >> $testroot/stdout.expected
184 5cc266ba 2019-01-06 stsp (cd $testroot/wt && got update -c $first_rev > $testroot/stdout)
186 5cc266ba 2019-01-06 stsp cmp $testroot/stdout.expected $testroot/stdout
187 5cc266ba 2019-01-06 stsp if [ "$?" != "0" ]; then
188 5cc266ba 2019-01-06 stsp diff -u $testroot/stdout.expected $testroot/stdout
189 5cc266ba 2019-01-06 stsp test_done "$testroot" "$?"
193 5cc266ba 2019-01-06 stsp if [ -e $testroot/wt/psi ]; then
194 5cc266ba 2019-01-06 stsp echo "removed dir psi still exists on disk" >&2
195 5cc266ba 2019-01-06 stsp test_done "$testroot" "1"
199 52a3df9b 2019-01-06 stsp test_done "$testroot" "0"
202 90285c3b 2019-01-08 stsp function test_update_deletes_dir_recursively {
203 90285c3b 2019-01-08 stsp local testroot=`test_init update_deletes_dir_recursively`
204 90285c3b 2019-01-08 stsp local first_rev=`git_show_head $testroot/repo`
206 90285c3b 2019-01-08 stsp mkdir $testroot/repo/epsilon/psi
207 90285c3b 2019-01-08 stsp echo mu > $testroot/repo/epsilon/psi/mu
208 90285c3b 2019-01-08 stsp mkdir $testroot/repo/epsilon/psi/chi
209 90285c3b 2019-01-08 stsp echo tau > $testroot/repo/epsilon/psi/chi/tau
210 90285c3b 2019-01-08 stsp (cd $testroot/repo && git add .)
211 90285c3b 2019-01-08 stsp git_commit $testroot/repo -m "adding a sub-directory beneath epsilon"
213 90285c3b 2019-01-08 stsp # check out the epsilon/ sub-tree
214 90285c3b 2019-01-08 stsp got checkout -p epsilon $testroot/repo $testroot/wt > /dev/null
215 90285c3b 2019-01-08 stsp if [ "$?" != "0" ]; then
216 90285c3b 2019-01-08 stsp test_done "$testroot" "$?"
220 90285c3b 2019-01-08 stsp # update back to first commit and expect psi/mu to be deleted
221 90285c3b 2019-01-08 stsp echo "D psi/chi/tau" > $testroot/stdout.expected
222 90285c3b 2019-01-08 stsp echo "D psi/mu" >> $testroot/stdout.expected
223 90285c3b 2019-01-08 stsp echo "Updated to commit $first_rev" >> $testroot/stdout.expected
225 90285c3b 2019-01-08 stsp (cd $testroot/wt && got update -c $first_rev > $testroot/stdout)
227 90285c3b 2019-01-08 stsp cmp $testroot/stdout.expected $testroot/stdout
228 90285c3b 2019-01-08 stsp if [ "$?" != "0" ]; then
229 90285c3b 2019-01-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
230 90285c3b 2019-01-08 stsp test_done "$testroot" "$?"
234 90285c3b 2019-01-08 stsp if [ -e $testroot/wt/psi ]; then
235 90285c3b 2019-01-08 stsp echo "removed dir psi still exists on disk" >&2
236 90285c3b 2019-01-08 stsp test_done "$testroot" "1"
240 90285c3b 2019-01-08 stsp test_done "$testroot" "0"
243 4482e97b 2019-01-08 stsp function test_update_sibling_dirs_with_common_prefix {
244 4482e97b 2019-01-08 stsp local testroot=`test_init update_sibling_dirs_with_common_prefix`
246 81a30460 2019-01-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
247 81a30460 2019-01-08 stsp if [ "$?" != "0" ]; then
248 81a30460 2019-01-08 stsp test_done "$testroot" "$?"
252 81a30460 2019-01-08 stsp mkdir $testroot/repo/epsilon2
253 81a30460 2019-01-08 stsp echo mu > $testroot/repo/epsilon2/mu
254 81a30460 2019-01-08 stsp (cd $testroot/repo && git add epsilon2/mu)
255 81a30460 2019-01-08 stsp git_commit $testroot/repo -m "adding sibling of epsilon"
256 81a30460 2019-01-08 stsp echo change > $testroot/repo/epsilon/zeta
257 81a30460 2019-01-08 stsp git_commit $testroot/repo -m "changing epsilon/zeta"
259 81a30460 2019-01-08 stsp echo "U epsilon/zeta" > $testroot/stdout.expected
260 81a30460 2019-01-08 stsp echo "A epsilon2/mu" >> $testroot/stdout.expected
261 81a30460 2019-01-08 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
262 81a30460 2019-01-08 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
263 81a30460 2019-01-08 stsp echo >> $testroot/stdout.expected
265 81a30460 2019-01-08 stsp (cd $testroot/wt && got update > $testroot/stdout)
267 81a30460 2019-01-08 stsp cmp $testroot/stdout.expected $testroot/stdout
268 81a30460 2019-01-08 stsp if [ "$?" != "0" ]; then
269 81a30460 2019-01-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
270 81a30460 2019-01-08 stsp test_done "$testroot" "$?"
274 81a30460 2019-01-08 stsp echo "another change" > $testroot/repo/epsilon/zeta
275 81a30460 2019-01-08 stsp git_commit $testroot/repo -m "changing epsilon/zeta again"
277 81a30460 2019-01-08 stsp echo "U epsilon/zeta" > $testroot/stdout.expected
278 81a30460 2019-01-08 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
279 81a30460 2019-01-08 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
280 81a30460 2019-01-08 stsp echo >> $testroot/stdout.expected
282 81a30460 2019-01-08 stsp # Bug: This update used to do delete/add epsilon2/mu again:
283 81a30460 2019-01-08 stsp # U epsilon/zeta
284 81a30460 2019-01-08 stsp # D epsilon2/mu <--- not intended
285 81a30460 2019-01-08 stsp # A epsilon2/mu <--- not intended
286 50952927 2019-01-12 stsp (cd $testroot/wt && got update > $testroot/stdout)
288 50952927 2019-01-12 stsp cmp $testroot/stdout.expected $testroot/stdout
289 50952927 2019-01-12 stsp if [ "$?" != "0" ]; then
290 50952927 2019-01-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
291 50952927 2019-01-12 stsp test_done "$testroot" "$?"
295 50952927 2019-01-12 stsp cmp $testroot/stdout.expected $testroot/stdout
296 50952927 2019-01-12 stsp if [ "$?" != "0" ]; then
297 50952927 2019-01-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
298 50952927 2019-01-12 stsp test_done "$testroot" "$?"
302 50952927 2019-01-12 stsp test_done "$testroot" "0"
305 50952927 2019-01-12 stsp function test_update_dir_with_dot_sibling {
306 50952927 2019-01-12 stsp local testroot=`test_init update_dir_with_dot_sibling`
308 50952927 2019-01-12 stsp got checkout $testroot/repo $testroot/wt > /dev/null
309 50952927 2019-01-12 stsp if [ "$?" != "0" ]; then
310 50952927 2019-01-12 stsp test_done "$testroot" "$?"
314 50952927 2019-01-12 stsp echo text > $testroot/repo/epsilon.txt
315 50952927 2019-01-12 stsp (cd $testroot/repo && git add epsilon.txt)
316 50952927 2019-01-12 stsp git_commit $testroot/repo -m "adding sibling of epsilon"
317 50952927 2019-01-12 stsp echo change > $testroot/repo/epsilon/zeta
318 50952927 2019-01-12 stsp git_commit $testroot/repo -m "changing epsilon/zeta"
320 f5d3d7af 2019-02-05 stsp echo "U epsilon/zeta" > $testroot/stdout.expected
321 f5d3d7af 2019-02-05 stsp echo "A epsilon.txt" >> $testroot/stdout.expected
322 50952927 2019-01-12 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
323 50952927 2019-01-12 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
324 50952927 2019-01-12 stsp echo >> $testroot/stdout.expected
326 81a30460 2019-01-08 stsp (cd $testroot/wt && got update > $testroot/stdout)
328 81a30460 2019-01-08 stsp cmp $testroot/stdout.expected $testroot/stdout
329 81a30460 2019-01-08 stsp if [ "$?" != "0" ]; then
330 81a30460 2019-01-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
331 81a30460 2019-01-08 stsp test_done "$testroot" "$?"
335 50952927 2019-01-12 stsp echo "another change" > $testroot/repo/epsilon/zeta
336 50952927 2019-01-12 stsp git_commit $testroot/repo -m "changing epsilon/zeta again"
338 50952927 2019-01-12 stsp echo "U epsilon/zeta" > $testroot/stdout.expected
339 50952927 2019-01-12 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
340 50952927 2019-01-12 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
341 50952927 2019-01-12 stsp echo >> $testroot/stdout.expected
343 50952927 2019-01-12 stsp (cd $testroot/wt && got update > $testroot/stdout)
345 81a30460 2019-01-08 stsp cmp $testroot/stdout.expected $testroot/stdout
346 81a30460 2019-01-08 stsp if [ "$?" != "0" ]; then
347 81a30460 2019-01-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
348 81a30460 2019-01-08 stsp test_done "$testroot" "$?"
352 50952927 2019-01-12 stsp cmp $testroot/stdout.expected $testroot/stdout
353 50952927 2019-01-12 stsp if [ "$?" != "0" ]; then
354 50952927 2019-01-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
355 50952927 2019-01-12 stsp test_done "$testroot" "$?"
359 81a30460 2019-01-08 stsp test_done "$testroot" "0"
362 46cee7a3 2019-01-12 stsp function test_update_moves_files_upwards {
363 46cee7a3 2019-01-12 stsp local testroot=`test_init update_moves_files_upwards`
365 46cee7a3 2019-01-12 stsp mkdir $testroot/repo/epsilon/psi
366 46cee7a3 2019-01-12 stsp echo mu > $testroot/repo/epsilon/psi/mu
367 46cee7a3 2019-01-12 stsp mkdir $testroot/repo/epsilon/psi/chi
368 46cee7a3 2019-01-12 stsp echo tau > $testroot/repo/epsilon/psi/chi/tau
369 46cee7a3 2019-01-12 stsp (cd $testroot/repo && git add .)
370 46cee7a3 2019-01-12 stsp git_commit $testroot/repo -m "adding a sub-directory beneath epsilon"
372 46cee7a3 2019-01-12 stsp got checkout $testroot/repo $testroot/wt > /dev/null
373 46cee7a3 2019-01-12 stsp if [ "$?" != "0" ]; then
374 46cee7a3 2019-01-12 stsp test_done "$testroot" "$?"
378 46cee7a3 2019-01-12 stsp (cd $testroot/repo && git mv epsilon/psi/mu epsilon/mu)
379 46cee7a3 2019-01-12 stsp (cd $testroot/repo && git mv epsilon/psi/chi/tau epsilon/psi/tau)
380 46cee7a3 2019-01-12 stsp git_commit $testroot/repo -m "moving files upwards"
382 21908da4 2019-01-13 stsp echo "A epsilon/mu" > $testroot/stdout.expected
383 21908da4 2019-01-13 stsp echo "D epsilon/psi/chi/tau" >> $testroot/stdout.expected
384 46cee7a3 2019-01-12 stsp echo "D epsilon/psi/mu" >> $testroot/stdout.expected
385 bd4792ec 2019-01-13 stsp echo "A epsilon/psi/tau" >> $testroot/stdout.expected
386 46cee7a3 2019-01-12 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
387 46cee7a3 2019-01-12 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
388 46cee7a3 2019-01-12 stsp echo >> $testroot/stdout.expected
390 46cee7a3 2019-01-12 stsp (cd $testroot/wt && got update > $testroot/stdout)
392 46cee7a3 2019-01-12 stsp cmp $testroot/stdout.expected $testroot/stdout
393 46cee7a3 2019-01-12 stsp if [ "$?" != "0" ]; then
394 46cee7a3 2019-01-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
395 46cee7a3 2019-01-12 stsp test_done "$testroot" "$?"
399 46cee7a3 2019-01-12 stsp if [ -e $testroot/wt/epsilon/psi/chi ]; then
400 46cee7a3 2019-01-12 stsp echo "removed dir epsilon/psi/chi still exists on disk" >&2
401 46cee7a3 2019-01-12 stsp test_done "$testroot" "1"
405 46cee7a3 2019-01-12 stsp if [ -e $testroot/wt/epsilon/psi/mu ]; then
406 46cee7a3 2019-01-12 stsp echo "removed file epsilon/psi/mu still exists on disk" >&2
407 46cee7a3 2019-01-12 stsp test_done "$testroot" "1"
411 46cee7a3 2019-01-12 stsp test_done "$testroot" "0"
414 46cee7a3 2019-01-12 stsp function test_update_moves_files_to_new_dir {
415 46cee7a3 2019-01-12 stsp local testroot=`test_init update_moves_files_to_new_dir`
417 46cee7a3 2019-01-12 stsp mkdir $testroot/repo/epsilon/psi
418 46cee7a3 2019-01-12 stsp echo mu > $testroot/repo/epsilon/psi/mu
419 46cee7a3 2019-01-12 stsp mkdir $testroot/repo/epsilon/psi/chi
420 46cee7a3 2019-01-12 stsp echo tau > $testroot/repo/epsilon/psi/chi/tau
421 46cee7a3 2019-01-12 stsp (cd $testroot/repo && git add .)
422 46cee7a3 2019-01-12 stsp git_commit $testroot/repo -m "adding a sub-directory beneath epsilon"
424 46cee7a3 2019-01-12 stsp got checkout $testroot/repo $testroot/wt > /dev/null
425 46cee7a3 2019-01-12 stsp if [ "$?" != "0" ]; then
426 46cee7a3 2019-01-12 stsp test_done "$testroot" "$?"
430 46cee7a3 2019-01-12 stsp mkdir -p $testroot/repo/epsilon-new/psi
431 46cee7a3 2019-01-12 stsp (cd $testroot/repo && git mv epsilon/psi/mu epsilon-new/mu)
432 46cee7a3 2019-01-12 stsp (cd $testroot/repo && git mv epsilon/psi/chi/tau epsilon-new/psi/tau)
433 46cee7a3 2019-01-12 stsp git_commit $testroot/repo -m "moving files upwards"
435 f5d3d7af 2019-02-05 stsp echo "D epsilon/psi/chi/tau" > $testroot/stdout.expected
436 46cee7a3 2019-01-12 stsp echo "D epsilon/psi/mu" >> $testroot/stdout.expected
437 f5d3d7af 2019-02-05 stsp echo "A epsilon-new/mu" >> $testroot/stdout.expected
438 f5d3d7af 2019-02-05 stsp echo "A epsilon-new/psi/tau" >> $testroot/stdout.expected
439 46cee7a3 2019-01-12 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
440 46cee7a3 2019-01-12 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
441 46cee7a3 2019-01-12 stsp echo >> $testroot/stdout.expected
443 46cee7a3 2019-01-12 stsp (cd $testroot/wt && got update > $testroot/stdout)
445 46cee7a3 2019-01-12 stsp cmp $testroot/stdout.expected $testroot/stdout
446 46cee7a3 2019-01-12 stsp if [ "$?" != "0" ]; then
447 46cee7a3 2019-01-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
448 46cee7a3 2019-01-12 stsp test_done "$testroot" "$?"
452 46cee7a3 2019-01-12 stsp if [ -e $testroot/wt/epsilon/psi/chi ]; then
453 46cee7a3 2019-01-12 stsp echo "removed dir epsilon/psi/chi still exists on disk" >&2
454 46cee7a3 2019-01-12 stsp test_done "$testroot" "1"
458 46cee7a3 2019-01-12 stsp if [ -e $testroot/wt/epsilon/psi/mu ]; then
459 46cee7a3 2019-01-12 stsp echo "removed file epsilon/psi/mu still exists on disk" >&2
460 46cee7a3 2019-01-12 stsp test_done "$testroot" "1"
464 4a1ddfc2 2019-01-12 stsp test_done "$testroot" "0"
467 4a1ddfc2 2019-01-12 stsp function test_update_creates_missing_parent {
468 1aad446a 2019-01-13 stsp local testroot=`test_init update_creates_missing_parent 1`
470 4a1ddfc2 2019-01-12 stsp touch $testroot/repo/Makefile
471 4a1ddfc2 2019-01-12 stsp touch $testroot/repo/snake.6
472 4a1ddfc2 2019-01-12 stsp touch $testroot/repo/snake.c
473 4a1ddfc2 2019-01-12 stsp (cd $testroot/repo && git add .)
474 4a1ddfc2 2019-01-12 stsp git_commit $testroot/repo -m "adding initial snake tree"
476 4a1ddfc2 2019-01-12 stsp got checkout $testroot/repo $testroot/wt > /dev/null
477 4a1ddfc2 2019-01-12 stsp if [ "$?" != "0" ]; then
478 4a1ddfc2 2019-01-12 stsp test_done "$testroot" "$?"
482 4a1ddfc2 2019-01-12 stsp mkdir -p $testroot/repo/snake
483 4a1ddfc2 2019-01-12 stsp (cd $testroot/repo && git mv Makefile snake.6 snake.c snake)
484 4a1ddfc2 2019-01-12 stsp touch $testroot/repo/snake/move.c
485 4a1ddfc2 2019-01-12 stsp touch $testroot/repo/snake/pathnames.h
486 4a1ddfc2 2019-01-12 stsp touch $testroot/repo/snake/snake.h
487 4a1ddfc2 2019-01-12 stsp mkdir -p $testroot/repo/snscore
488 4a1ddfc2 2019-01-12 stsp touch $testroot/repo/snscore/Makefile
489 4a1ddfc2 2019-01-12 stsp touch $testroot/repo/snscore/snscore.c
490 4a1ddfc2 2019-01-12 stsp (cd $testroot/repo && git add .)
491 4a1ddfc2 2019-01-12 stsp git_commit $testroot/repo -m "restructuring snake tree"
493 4a1ddfc2 2019-01-12 stsp echo "D Makefile" > $testroot/stdout.expected
494 bd4792ec 2019-01-13 stsp echo "D snake.6" >> $testroot/stdout.expected
495 bd4792ec 2019-01-13 stsp echo "D snake.c" >> $testroot/stdout.expected
496 4a1ddfc2 2019-01-12 stsp echo "A snake/Makefile" >> $testroot/stdout.expected
497 4a1ddfc2 2019-01-12 stsp echo "A snake/move.c" >> $testroot/stdout.expected
498 4a1ddfc2 2019-01-12 stsp echo "A snake/pathnames.h" >> $testroot/stdout.expected
499 4a1ddfc2 2019-01-12 stsp echo "A snake/snake.6" >> $testroot/stdout.expected
500 4a1ddfc2 2019-01-12 stsp echo "A snake/snake.c" >> $testroot/stdout.expected
501 4a1ddfc2 2019-01-12 stsp echo "A snake/snake.h" >> $testroot/stdout.expected
502 bd4792ec 2019-01-13 stsp echo "A snscore/Makefile" >> $testroot/stdout.expected
503 bd4792ec 2019-01-13 stsp echo "A snscore/snscore.c" >> $testroot/stdout.expected
504 bd4792ec 2019-01-13 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
505 bd4792ec 2019-01-13 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
506 bd4792ec 2019-01-13 stsp echo >> $testroot/stdout.expected
508 bd4792ec 2019-01-13 stsp (cd $testroot/wt && got update > $testroot/stdout)
510 bd4792ec 2019-01-13 stsp cmp $testroot/stdout.expected $testroot/stdout
511 bd4792ec 2019-01-13 stsp if [ "$?" != "0" ]; then
512 bd4792ec 2019-01-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
513 bd4792ec 2019-01-13 stsp test_done "$testroot" "$?"
517 bd4792ec 2019-01-13 stsp test_done "$testroot" "0"
520 bd4792ec 2019-01-13 stsp function test_update_creates_missing_parent_with_subdir {
521 1aad446a 2019-01-13 stsp local testroot=`test_init update_creates_missing_parent_with_subdir 1`
523 bd4792ec 2019-01-13 stsp touch $testroot/repo/Makefile
524 bd4792ec 2019-01-13 stsp touch $testroot/repo/snake.6
525 bd4792ec 2019-01-13 stsp touch $testroot/repo/snake.c
526 bd4792ec 2019-01-13 stsp (cd $testroot/repo && git add .)
527 bd4792ec 2019-01-13 stsp git_commit $testroot/repo -m "adding initial snake tree"
529 bd4792ec 2019-01-13 stsp got checkout $testroot/repo $testroot/wt > /dev/null
530 bd4792ec 2019-01-13 stsp if [ "$?" != "0" ]; then
531 bd4792ec 2019-01-13 stsp test_done "$testroot" "$?"
535 bd4792ec 2019-01-13 stsp mkdir -p $testroot/repo/sss/snake
536 bd4792ec 2019-01-13 stsp (cd $testroot/repo && git mv Makefile snake.6 snake.c sss/snake)
537 bd4792ec 2019-01-13 stsp touch $testroot/repo/sss/snake/move.c
538 bd4792ec 2019-01-13 stsp touch $testroot/repo/sss/snake/pathnames.h
539 bd4792ec 2019-01-13 stsp touch $testroot/repo/sss/snake/snake.h
540 bd4792ec 2019-01-13 stsp mkdir -p $testroot/repo/snscore
541 bd4792ec 2019-01-13 stsp touch $testroot/repo/snscore/Makefile
542 bd4792ec 2019-01-13 stsp touch $testroot/repo/snscore/snscore.c
543 bd4792ec 2019-01-13 stsp (cd $testroot/repo && git add .)
544 bd4792ec 2019-01-13 stsp git_commit $testroot/repo -m "restructuring snake tree"
546 bd4792ec 2019-01-13 stsp echo "D Makefile" > $testroot/stdout.expected
547 4a1ddfc2 2019-01-12 stsp echo "D snake.6" >> $testroot/stdout.expected
548 4a1ddfc2 2019-01-12 stsp echo "D snake.c" >> $testroot/stdout.expected
549 4a1ddfc2 2019-01-12 stsp echo "A snscore/Makefile" >> $testroot/stdout.expected
550 4a1ddfc2 2019-01-12 stsp echo "A snscore/snscore.c" >> $testroot/stdout.expected
551 bd4792ec 2019-01-13 stsp echo "A sss/snake/Makefile" >> $testroot/stdout.expected
552 bd4792ec 2019-01-13 stsp echo "A sss/snake/move.c" >> $testroot/stdout.expected
553 bd4792ec 2019-01-13 stsp echo "A sss/snake/pathnames.h" >> $testroot/stdout.expected
554 bd4792ec 2019-01-13 stsp echo "A sss/snake/snake.6" >> $testroot/stdout.expected
555 bd4792ec 2019-01-13 stsp echo "A sss/snake/snake.c" >> $testroot/stdout.expected
556 bd4792ec 2019-01-13 stsp echo "A sss/snake/snake.h" >> $testroot/stdout.expected
557 4a1ddfc2 2019-01-12 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
558 4a1ddfc2 2019-01-12 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
559 4a1ddfc2 2019-01-12 stsp echo >> $testroot/stdout.expected
561 4a1ddfc2 2019-01-12 stsp (cd $testroot/wt && got update > $testroot/stdout)
563 4a1ddfc2 2019-01-12 stsp cmp $testroot/stdout.expected $testroot/stdout
564 4a1ddfc2 2019-01-12 stsp if [ "$?" != "0" ]; then
565 4a1ddfc2 2019-01-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
566 4a1ddfc2 2019-01-12 stsp test_done "$testroot" "$?"
570 46cee7a3 2019-01-12 stsp test_done "$testroot" "0"
573 21908da4 2019-01-13 stsp function test_update_file_in_subsubdir {
574 1aad446a 2019-01-13 stsp local testroot=`test_init update_fle_in_subsubdir 1`
576 21908da4 2019-01-13 stsp touch $testroot/repo/Makefile
577 21908da4 2019-01-13 stsp mkdir -p $testroot/repo/altq
578 21908da4 2019-01-13 stsp touch $testroot/repo/altq/if_altq.h
579 21908da4 2019-01-13 stsp mkdir -p $testroot/repo/arch/alpha
580 21908da4 2019-01-13 stsp touch $testroot/repo/arch/alpha/Makefile
581 21908da4 2019-01-13 stsp (cd $testroot/repo && git add .)
582 21908da4 2019-01-13 stsp git_commit $testroot/repo -m "adding initial tree"
584 21908da4 2019-01-13 stsp got checkout $testroot/repo $testroot/wt > /dev/null
585 21908da4 2019-01-13 stsp if [ "$?" != "0" ]; then
586 21908da4 2019-01-13 stsp test_done "$testroot" "$?"
590 21908da4 2019-01-13 stsp echo change > $testroot/repo/arch/alpha/Makefile
591 21908da4 2019-01-13 stsp (cd $testroot/repo && git add .)
592 21908da4 2019-01-13 stsp git_commit $testroot/repo -m "changed a file"
594 21908da4 2019-01-13 stsp echo "U arch/alpha/Makefile" > $testroot/stdout.expected
595 21908da4 2019-01-13 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
596 21908da4 2019-01-13 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
597 21908da4 2019-01-13 stsp echo >> $testroot/stdout.expected
599 21908da4 2019-01-13 stsp (cd $testroot/wt && got update > $testroot/stdout)
601 21908da4 2019-01-13 stsp cmp $testroot/stdout.expected $testroot/stdout
602 21908da4 2019-01-13 stsp if [ "$?" != "0" ]; then
603 21908da4 2019-01-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
604 21908da4 2019-01-13 stsp test_done "$testroot" "$?"
608 21908da4 2019-01-13 stsp test_done "$testroot" "0"
611 c84d8c75 2019-01-02 stsp run_test test_update_basic
612 3b4d3732 2019-01-02 stsp run_test test_update_adds_file
613 512f0d0e 2019-01-02 stsp run_test test_update_deletes_file
614 f5c49f82 2019-01-06 stsp run_test test_update_deletes_dir
615 5cc266ba 2019-01-06 stsp run_test test_update_deletes_dir_with_path_prefix
616 90285c3b 2019-01-08 stsp run_test test_update_deletes_dir_recursively
617 4482e97b 2019-01-08 stsp run_test test_update_sibling_dirs_with_common_prefix
618 50952927 2019-01-12 stsp run_test test_update_dir_with_dot_sibling
619 46cee7a3 2019-01-12 stsp run_test test_update_moves_files_upwards
620 bd4792ec 2019-01-13 stsp run_test test_update_moves_files_to_new_dir
621 4a1ddfc2 2019-01-12 stsp run_test test_update_creates_missing_parent
622 bd4792ec 2019-01-13 stsp run_test test_update_creates_missing_parent_with_subdir
623 21908da4 2019-01-13 stsp run_test test_update_file_in_subsubdir