Blame


1 c84d8c75 2019-01-02 stsp #!/bin/sh
2 c84d8c75 2019-01-02 stsp #
3 c84d8c75 2019-01-02 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
4 c84d8c75 2019-01-02 stsp #
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.
8 c84d8c75 2019-01-02 stsp #
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.
16 c84d8c75 2019-01-02 stsp
17 c84d8c75 2019-01-02 stsp . ./common.sh
18 c84d8c75 2019-01-02 stsp
19 c84d8c75 2019-01-02 stsp function test_update_basic {
20 0fbd721f 2019-01-02 stsp local testroot=`test_init update_basic`
21 c84d8c75 2019-01-02 stsp
22 3c90ba67 2019-01-02 stsp got checkout $testroot/repo $testroot/wt > /dev/null
23 e60e7f5b 2019-02-10 stsp ret="$?"
24 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
25 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
26 c84d8c75 2019-01-02 stsp return 1
27 c84d8c75 2019-01-02 stsp fi
28 c84d8c75 2019-01-02 stsp
29 c84d8c75 2019-01-02 stsp echo "modified alpha" > $testroot/repo/alpha
30 c84d8c75 2019-01-02 stsp git_commit $testroot/repo -m "modified alpha"
31 c84d8c75 2019-01-02 stsp
32 c84d8c75 2019-01-02 stsp echo "U alpha" > $testroot/stdout.expected
33 9c4b8182 2019-01-02 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
34 9c4b8182 2019-01-02 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
35 9c4b8182 2019-01-02 stsp echo >> $testroot/stdout.expected
36 c84d8c75 2019-01-02 stsp
37 c84d8c75 2019-01-02 stsp (cd $testroot/wt && got update > $testroot/stdout)
38 c84d8c75 2019-01-02 stsp
39 c84d8c75 2019-01-02 stsp cmp $testroot/stdout.expected $testroot/stdout
40 e60e7f5b 2019-02-10 stsp ret="$?"
41 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
42 c84d8c75 2019-01-02 stsp diff -u $testroot/stdout.expected $testroot/stdout
43 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
44 c84d8c75 2019-01-02 stsp return 1
45 c84d8c75 2019-01-02 stsp fi
46 c84d8c75 2019-01-02 stsp
47 c84d8c75 2019-01-02 stsp echo "modified alpha" > $testroot/content.expected
48 52a3df9b 2019-01-06 stsp cat $testroot/wt/alpha > $testroot/content
49 c84d8c75 2019-01-02 stsp
50 c84d8c75 2019-01-02 stsp cmp $testroot/content.expected $testroot/content
51 693719bc 2019-01-03 stsp ret="$?"
52 693719bc 2019-01-03 stsp if [ "$ret" != "0" ]; then
53 c84d8c75 2019-01-02 stsp diff -u $testroot/content.expected $testroot/content
54 c84d8c75 2019-01-02 stsp fi
55 693719bc 2019-01-03 stsp test_done "$testroot" "$ret"
56 c84d8c75 2019-01-02 stsp }
57 c84d8c75 2019-01-02 stsp
58 3b4d3732 2019-01-02 stsp function test_update_adds_file {
59 3b4d3732 2019-01-02 stsp local testroot=`test_init update_adds_file`
60 3b4d3732 2019-01-02 stsp
61 3b4d3732 2019-01-02 stsp got checkout $testroot/repo $testroot/wt > /dev/null
62 e60e7f5b 2019-02-10 stsp ret="$?"
63 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
64 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
65 3b4d3732 2019-01-02 stsp return 1
66 3b4d3732 2019-01-02 stsp fi
67 3b4d3732 2019-01-02 stsp
68 3b4d3732 2019-01-02 stsp echo "new" > $testroot/repo/gamma/new
69 3b4d3732 2019-01-02 stsp (cd $testroot/repo && git add .)
70 3b4d3732 2019-01-02 stsp git_commit $testroot/repo -m "adding a new file"
71 3b4d3732 2019-01-02 stsp
72 3b4d3732 2019-01-02 stsp echo "A gamma/new" > $testroot/stdout.expected
73 3b4d3732 2019-01-02 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
74 3b4d3732 2019-01-02 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
75 3b4d3732 2019-01-02 stsp echo >> $testroot/stdout.expected
76 3b4d3732 2019-01-02 stsp
77 3b4d3732 2019-01-02 stsp (cd $testroot/wt && got update > $testroot/stdout)
78 3b4d3732 2019-01-02 stsp
79 3b4d3732 2019-01-02 stsp cmp $testroot/stdout.expected $testroot/stdout
80 e60e7f5b 2019-02-10 stsp ret="$?"
81 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
82 3b4d3732 2019-01-02 stsp diff -u $testroot/stdout.expected $testroot/stdout
83 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
84 3b4d3732 2019-01-02 stsp return 1
85 3b4d3732 2019-01-02 stsp fi
86 3b4d3732 2019-01-02 stsp
87 3b4d3732 2019-01-02 stsp echo "new" >> $testroot/content.expected
88 52a3df9b 2019-01-06 stsp cat $testroot/wt/gamma/new > $testroot/content
89 3b4d3732 2019-01-02 stsp
90 3b4d3732 2019-01-02 stsp cmp $testroot/content.expected $testroot/content
91 693719bc 2019-01-03 stsp ret="$?"
92 693719bc 2019-01-03 stsp if [ "$ret" != "0" ]; then
93 3b4d3732 2019-01-02 stsp diff -u $testroot/content.expected $testroot/content
94 3b4d3732 2019-01-02 stsp fi
95 693719bc 2019-01-03 stsp test_done "$testroot" "$ret"
96 3b4d3732 2019-01-02 stsp }
97 3b4d3732 2019-01-02 stsp
98 512f0d0e 2019-01-02 stsp function test_update_deletes_file {
99 512f0d0e 2019-01-02 stsp local testroot=`test_init update_deletes_file`
100 512f0d0e 2019-01-02 stsp
101 512f0d0e 2019-01-02 stsp got checkout $testroot/repo $testroot/wt > /dev/null
102 e60e7f5b 2019-02-10 stsp ret="$?"
103 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
104 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
105 512f0d0e 2019-01-02 stsp return 1
106 512f0d0e 2019-01-02 stsp fi
107 512f0d0e 2019-01-02 stsp
108 512f0d0e 2019-01-02 stsp (cd $testroot/repo && git_rm $testroot/repo beta)
109 512f0d0e 2019-01-02 stsp git_commit $testroot/repo -m "deleting a file"
110 512f0d0e 2019-01-02 stsp
111 512f0d0e 2019-01-02 stsp echo "D beta" > $testroot/stdout.expected
112 512f0d0e 2019-01-02 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
113 512f0d0e 2019-01-02 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
114 512f0d0e 2019-01-02 stsp echo >> $testroot/stdout.expected
115 512f0d0e 2019-01-02 stsp
116 512f0d0e 2019-01-02 stsp (cd $testroot/wt && got update > $testroot/stdout)
117 512f0d0e 2019-01-02 stsp
118 512f0d0e 2019-01-02 stsp cmp $testroot/stdout.expected $testroot/stdout
119 e60e7f5b 2019-02-10 stsp ret="$?"
120 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
121 512f0d0e 2019-01-02 stsp diff -u $testroot/stdout.expected $testroot/stdout
122 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
123 512f0d0e 2019-01-02 stsp return 1
124 512f0d0e 2019-01-02 stsp fi
125 512f0d0e 2019-01-02 stsp
126 512f0d0e 2019-01-02 stsp if [ -e $testroot/wt/beta ]; then
127 512f0d0e 2019-01-02 stsp echo "removed file beta still exists on disk" >&2
128 52a3df9b 2019-01-06 stsp test_done "$testroot" "1"
129 512f0d0e 2019-01-02 stsp return 1
130 512f0d0e 2019-01-02 stsp fi
131 512f0d0e 2019-01-02 stsp
132 52a3df9b 2019-01-06 stsp test_done "$testroot" "0"
133 512f0d0e 2019-01-02 stsp }
134 512f0d0e 2019-01-02 stsp
135 f5c49f82 2019-01-06 stsp function test_update_deletes_dir {
136 f5c49f82 2019-01-06 stsp local testroot=`test_init update_deletes_dir`
137 f5c49f82 2019-01-06 stsp
138 f5c49f82 2019-01-06 stsp got checkout $testroot/repo $testroot/wt > /dev/null
139 e60e7f5b 2019-02-10 stsp ret="$?"
140 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
141 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
142 f5c49f82 2019-01-06 stsp return 1
143 f5c49f82 2019-01-06 stsp fi
144 f5c49f82 2019-01-06 stsp
145 f5c49f82 2019-01-06 stsp (cd $testroot/repo && git_rm $testroot/repo -r epsilon)
146 f5c49f82 2019-01-06 stsp git_commit $testroot/repo -m "deleting a directory"
147 f5c49f82 2019-01-06 stsp
148 f5c49f82 2019-01-06 stsp echo "D epsilon/zeta" > $testroot/stdout.expected
149 f5c49f82 2019-01-06 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
150 f5c49f82 2019-01-06 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
151 f5c49f82 2019-01-06 stsp echo >> $testroot/stdout.expected
152 f5c49f82 2019-01-06 stsp
153 f5c49f82 2019-01-06 stsp (cd $testroot/wt && got update > $testroot/stdout)
154 f5c49f82 2019-01-06 stsp
155 f5c49f82 2019-01-06 stsp cmp $testroot/stdout.expected $testroot/stdout
156 e60e7f5b 2019-02-10 stsp ret="$?"
157 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
158 f5c49f82 2019-01-06 stsp diff -u $testroot/stdout.expected $testroot/stdout
159 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
160 f5c49f82 2019-01-06 stsp return 1
161 f5c49f82 2019-01-06 stsp fi
162 f5c49f82 2019-01-06 stsp
163 f5c49f82 2019-01-06 stsp if [ -e $testroot/wt/epsilon ]; then
164 f5c49f82 2019-01-06 stsp echo "removed dir epsilon still exists on disk" >&2
165 52a3df9b 2019-01-06 stsp test_done "$testroot" "1"
166 f5c49f82 2019-01-06 stsp return 1
167 f5c49f82 2019-01-06 stsp fi
168 f5c49f82 2019-01-06 stsp
169 52a3df9b 2019-01-06 stsp test_done "$testroot" "0"
170 f5c49f82 2019-01-06 stsp }
171 f5c49f82 2019-01-06 stsp
172 5cc266ba 2019-01-06 stsp function test_update_deletes_dir_with_path_prefix {
173 5cc266ba 2019-01-06 stsp local testroot=`test_init update_deletes_dir_with_path_prefix`
174 5cc266ba 2019-01-06 stsp local first_rev=`git_show_head $testroot/repo`
175 5cc266ba 2019-01-06 stsp
176 5cc266ba 2019-01-06 stsp mkdir $testroot/repo/epsilon/psi
177 5cc266ba 2019-01-06 stsp echo mu > $testroot/repo/epsilon/psi/mu
178 5cc266ba 2019-01-06 stsp (cd $testroot/repo && git add .)
179 5cc266ba 2019-01-06 stsp git_commit $testroot/repo -m "adding a sub-directory beneath epsilon"
180 5cc266ba 2019-01-06 stsp
181 5cc266ba 2019-01-06 stsp # check out the epsilon/ sub-tree
182 5cc266ba 2019-01-06 stsp got checkout -p epsilon $testroot/repo $testroot/wt > /dev/null
183 e60e7f5b 2019-02-10 stsp ret="$?"
184 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
185 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
186 5cc266ba 2019-01-06 stsp return 1
187 5cc266ba 2019-01-06 stsp fi
188 5cc266ba 2019-01-06 stsp
189 5cc266ba 2019-01-06 stsp # update back to first commit and expect psi/mu to be deleted
190 5cc266ba 2019-01-06 stsp echo "D psi/mu" > $testroot/stdout.expected
191 5cc266ba 2019-01-06 stsp echo "Updated to commit $first_rev" >> $testroot/stdout.expected
192 5cc266ba 2019-01-06 stsp
193 5cc266ba 2019-01-06 stsp (cd $testroot/wt && got update -c $first_rev > $testroot/stdout)
194 5cc266ba 2019-01-06 stsp
195 5cc266ba 2019-01-06 stsp cmp $testroot/stdout.expected $testroot/stdout
196 e60e7f5b 2019-02-10 stsp ret="$?"
197 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
198 5cc266ba 2019-01-06 stsp diff -u $testroot/stdout.expected $testroot/stdout
199 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
200 5cc266ba 2019-01-06 stsp return 1
201 5cc266ba 2019-01-06 stsp fi
202 5cc266ba 2019-01-06 stsp
203 5cc266ba 2019-01-06 stsp if [ -e $testroot/wt/psi ]; then
204 5cc266ba 2019-01-06 stsp echo "removed dir psi still exists on disk" >&2
205 5cc266ba 2019-01-06 stsp test_done "$testroot" "1"
206 5cc266ba 2019-01-06 stsp return 1
207 5cc266ba 2019-01-06 stsp fi
208 5cc266ba 2019-01-06 stsp
209 52a3df9b 2019-01-06 stsp test_done "$testroot" "0"
210 5cc266ba 2019-01-06 stsp }
211 5cc266ba 2019-01-06 stsp
212 90285c3b 2019-01-08 stsp function test_update_deletes_dir_recursively {
213 90285c3b 2019-01-08 stsp local testroot=`test_init update_deletes_dir_recursively`
214 90285c3b 2019-01-08 stsp local first_rev=`git_show_head $testroot/repo`
215 90285c3b 2019-01-08 stsp
216 90285c3b 2019-01-08 stsp mkdir $testroot/repo/epsilon/psi
217 90285c3b 2019-01-08 stsp echo mu > $testroot/repo/epsilon/psi/mu
218 90285c3b 2019-01-08 stsp mkdir $testroot/repo/epsilon/psi/chi
219 90285c3b 2019-01-08 stsp echo tau > $testroot/repo/epsilon/psi/chi/tau
220 90285c3b 2019-01-08 stsp (cd $testroot/repo && git add .)
221 90285c3b 2019-01-08 stsp git_commit $testroot/repo -m "adding a sub-directory beneath epsilon"
222 90285c3b 2019-01-08 stsp
223 90285c3b 2019-01-08 stsp # check out the epsilon/ sub-tree
224 90285c3b 2019-01-08 stsp got checkout -p epsilon $testroot/repo $testroot/wt > /dev/null
225 e60e7f5b 2019-02-10 stsp ret="$?"
226 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
227 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
228 90285c3b 2019-01-08 stsp return 1
229 90285c3b 2019-01-08 stsp fi
230 90285c3b 2019-01-08 stsp
231 90285c3b 2019-01-08 stsp # update back to first commit and expect psi/mu to be deleted
232 90285c3b 2019-01-08 stsp echo "D psi/chi/tau" > $testroot/stdout.expected
233 90285c3b 2019-01-08 stsp echo "D psi/mu" >> $testroot/stdout.expected
234 90285c3b 2019-01-08 stsp echo "Updated to commit $first_rev" >> $testroot/stdout.expected
235 90285c3b 2019-01-08 stsp
236 90285c3b 2019-01-08 stsp (cd $testroot/wt && got update -c $first_rev > $testroot/stdout)
237 90285c3b 2019-01-08 stsp
238 90285c3b 2019-01-08 stsp cmp $testroot/stdout.expected $testroot/stdout
239 e60e7f5b 2019-02-10 stsp ret="$?"
240 90285c3b 2019-01-08 stsp if [ "$?" != "0" ]; then
241 90285c3b 2019-01-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
242 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
243 90285c3b 2019-01-08 stsp return 1
244 90285c3b 2019-01-08 stsp fi
245 90285c3b 2019-01-08 stsp
246 90285c3b 2019-01-08 stsp if [ -e $testroot/wt/psi ]; then
247 90285c3b 2019-01-08 stsp echo "removed dir psi still exists on disk" >&2
248 90285c3b 2019-01-08 stsp test_done "$testroot" "1"
249 90285c3b 2019-01-08 stsp return 1
250 90285c3b 2019-01-08 stsp fi
251 90285c3b 2019-01-08 stsp
252 90285c3b 2019-01-08 stsp test_done "$testroot" "0"
253 90285c3b 2019-01-08 stsp }
254 90285c3b 2019-01-08 stsp
255 4482e97b 2019-01-08 stsp function test_update_sibling_dirs_with_common_prefix {
256 4482e97b 2019-01-08 stsp local testroot=`test_init update_sibling_dirs_with_common_prefix`
257 81a30460 2019-01-08 stsp
258 81a30460 2019-01-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
259 e60e7f5b 2019-02-10 stsp ret="$?"
260 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
261 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
262 81a30460 2019-01-08 stsp return 1
263 81a30460 2019-01-08 stsp fi
264 81a30460 2019-01-08 stsp
265 81a30460 2019-01-08 stsp mkdir $testroot/repo/epsilon2
266 81a30460 2019-01-08 stsp echo mu > $testroot/repo/epsilon2/mu
267 81a30460 2019-01-08 stsp (cd $testroot/repo && git add epsilon2/mu)
268 81a30460 2019-01-08 stsp git_commit $testroot/repo -m "adding sibling of epsilon"
269 81a30460 2019-01-08 stsp echo change > $testroot/repo/epsilon/zeta
270 81a30460 2019-01-08 stsp git_commit $testroot/repo -m "changing epsilon/zeta"
271 81a30460 2019-01-08 stsp
272 81a30460 2019-01-08 stsp echo "U epsilon/zeta" > $testroot/stdout.expected
273 81a30460 2019-01-08 stsp echo "A epsilon2/mu" >> $testroot/stdout.expected
274 81a30460 2019-01-08 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
275 81a30460 2019-01-08 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
276 81a30460 2019-01-08 stsp echo >> $testroot/stdout.expected
277 81a30460 2019-01-08 stsp
278 81a30460 2019-01-08 stsp (cd $testroot/wt && got update > $testroot/stdout)
279 81a30460 2019-01-08 stsp
280 81a30460 2019-01-08 stsp cmp $testroot/stdout.expected $testroot/stdout
281 e60e7f5b 2019-02-10 stsp ret="$?"
282 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
283 81a30460 2019-01-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
284 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
285 81a30460 2019-01-08 stsp return 1
286 81a30460 2019-01-08 stsp fi
287 81a30460 2019-01-08 stsp
288 81a30460 2019-01-08 stsp echo "another change" > $testroot/repo/epsilon/zeta
289 81a30460 2019-01-08 stsp git_commit $testroot/repo -m "changing epsilon/zeta again"
290 81a30460 2019-01-08 stsp
291 81a30460 2019-01-08 stsp echo "U epsilon/zeta" > $testroot/stdout.expected
292 81a30460 2019-01-08 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
293 81a30460 2019-01-08 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
294 81a30460 2019-01-08 stsp echo >> $testroot/stdout.expected
295 81a30460 2019-01-08 stsp
296 81a30460 2019-01-08 stsp # Bug: This update used to do delete/add epsilon2/mu again:
297 81a30460 2019-01-08 stsp # U epsilon/zeta
298 81a30460 2019-01-08 stsp # D epsilon2/mu <--- not intended
299 81a30460 2019-01-08 stsp # A epsilon2/mu <--- not intended
300 50952927 2019-01-12 stsp (cd $testroot/wt && got update > $testroot/stdout)
301 50952927 2019-01-12 stsp
302 50952927 2019-01-12 stsp cmp $testroot/stdout.expected $testroot/stdout
303 e60e7f5b 2019-02-10 stsp ret="$?"
304 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
305 50952927 2019-01-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
306 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
307 50952927 2019-01-12 stsp return 1
308 50952927 2019-01-12 stsp fi
309 50952927 2019-01-12 stsp
310 50952927 2019-01-12 stsp cmp $testroot/stdout.expected $testroot/stdout
311 e60e7f5b 2019-02-10 stsp ret="$?"
312 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
313 50952927 2019-01-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
314 50952927 2019-01-12 stsp fi
315 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
316 50952927 2019-01-12 stsp }
317 50952927 2019-01-12 stsp
318 50952927 2019-01-12 stsp function test_update_dir_with_dot_sibling {
319 50952927 2019-01-12 stsp local testroot=`test_init update_dir_with_dot_sibling`
320 50952927 2019-01-12 stsp
321 50952927 2019-01-12 stsp got checkout $testroot/repo $testroot/wt > /dev/null
322 e60e7f5b 2019-02-10 stsp ret="$ret"
323 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
324 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
325 50952927 2019-01-12 stsp return 1
326 50952927 2019-01-12 stsp fi
327 50952927 2019-01-12 stsp
328 50952927 2019-01-12 stsp echo text > $testroot/repo/epsilon.txt
329 50952927 2019-01-12 stsp (cd $testroot/repo && git add epsilon.txt)
330 50952927 2019-01-12 stsp git_commit $testroot/repo -m "adding sibling of epsilon"
331 50952927 2019-01-12 stsp echo change > $testroot/repo/epsilon/zeta
332 50952927 2019-01-12 stsp git_commit $testroot/repo -m "changing epsilon/zeta"
333 50952927 2019-01-12 stsp
334 f5d3d7af 2019-02-05 stsp echo "U epsilon/zeta" > $testroot/stdout.expected
335 f5d3d7af 2019-02-05 stsp echo "A epsilon.txt" >> $testroot/stdout.expected
336 50952927 2019-01-12 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
337 50952927 2019-01-12 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
338 50952927 2019-01-12 stsp echo >> $testroot/stdout.expected
339 50952927 2019-01-12 stsp
340 81a30460 2019-01-08 stsp (cd $testroot/wt && got update > $testroot/stdout)
341 81a30460 2019-01-08 stsp
342 81a30460 2019-01-08 stsp cmp $testroot/stdout.expected $testroot/stdout
343 e60e7f5b 2019-02-10 stsp ret="$?"
344 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
345 81a30460 2019-01-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
346 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
347 81a30460 2019-01-08 stsp return 1
348 81a30460 2019-01-08 stsp fi
349 81a30460 2019-01-08 stsp
350 50952927 2019-01-12 stsp echo "another change" > $testroot/repo/epsilon/zeta
351 50952927 2019-01-12 stsp git_commit $testroot/repo -m "changing epsilon/zeta again"
352 50952927 2019-01-12 stsp
353 50952927 2019-01-12 stsp echo "U epsilon/zeta" > $testroot/stdout.expected
354 50952927 2019-01-12 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
355 50952927 2019-01-12 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
356 50952927 2019-01-12 stsp echo >> $testroot/stdout.expected
357 50952927 2019-01-12 stsp
358 50952927 2019-01-12 stsp (cd $testroot/wt && got update > $testroot/stdout)
359 50952927 2019-01-12 stsp
360 81a30460 2019-01-08 stsp cmp $testroot/stdout.expected $testroot/stdout
361 e60e7f5b 2019-02-10 stsp ret="$?"
362 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
363 81a30460 2019-01-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
364 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
365 81a30460 2019-01-08 stsp return 1
366 81a30460 2019-01-08 stsp fi
367 81a30460 2019-01-08 stsp
368 50952927 2019-01-12 stsp cmp $testroot/stdout.expected $testroot/stdout
369 e60e7f5b 2019-02-10 stsp ret="$?"
370 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
371 50952927 2019-01-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
372 50952927 2019-01-12 stsp fi
373 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
374 81a30460 2019-01-08 stsp }
375 46cee7a3 2019-01-12 stsp
376 46cee7a3 2019-01-12 stsp function test_update_moves_files_upwards {
377 46cee7a3 2019-01-12 stsp local testroot=`test_init update_moves_files_upwards`
378 46cee7a3 2019-01-12 stsp
379 46cee7a3 2019-01-12 stsp mkdir $testroot/repo/epsilon/psi
380 46cee7a3 2019-01-12 stsp echo mu > $testroot/repo/epsilon/psi/mu
381 46cee7a3 2019-01-12 stsp mkdir $testroot/repo/epsilon/psi/chi
382 46cee7a3 2019-01-12 stsp echo tau > $testroot/repo/epsilon/psi/chi/tau
383 46cee7a3 2019-01-12 stsp (cd $testroot/repo && git add .)
384 46cee7a3 2019-01-12 stsp git_commit $testroot/repo -m "adding a sub-directory beneath epsilon"
385 46cee7a3 2019-01-12 stsp
386 46cee7a3 2019-01-12 stsp got checkout $testroot/repo $testroot/wt > /dev/null
387 e60e7f5b 2019-02-10 stsp ret="$?"
388 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
389 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
390 46cee7a3 2019-01-12 stsp return 1
391 46cee7a3 2019-01-12 stsp fi
392 81a30460 2019-01-08 stsp
393 46cee7a3 2019-01-12 stsp (cd $testroot/repo && git mv epsilon/psi/mu epsilon/mu)
394 46cee7a3 2019-01-12 stsp (cd $testroot/repo && git mv epsilon/psi/chi/tau epsilon/psi/tau)
395 46cee7a3 2019-01-12 stsp git_commit $testroot/repo -m "moving files upwards"
396 46cee7a3 2019-01-12 stsp
397 21908da4 2019-01-13 stsp echo "A epsilon/mu" > $testroot/stdout.expected
398 21908da4 2019-01-13 stsp echo "D epsilon/psi/chi/tau" >> $testroot/stdout.expected
399 46cee7a3 2019-01-12 stsp echo "D epsilon/psi/mu" >> $testroot/stdout.expected
400 bd4792ec 2019-01-13 stsp echo "A epsilon/psi/tau" >> $testroot/stdout.expected
401 46cee7a3 2019-01-12 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
402 46cee7a3 2019-01-12 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
403 46cee7a3 2019-01-12 stsp echo >> $testroot/stdout.expected
404 46cee7a3 2019-01-12 stsp
405 46cee7a3 2019-01-12 stsp (cd $testroot/wt && got update > $testroot/stdout)
406 46cee7a3 2019-01-12 stsp
407 46cee7a3 2019-01-12 stsp cmp $testroot/stdout.expected $testroot/stdout
408 e60e7f5b 2019-02-10 stsp ret="$?"
409 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
410 46cee7a3 2019-01-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
411 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
412 46cee7a3 2019-01-12 stsp return 1
413 46cee7a3 2019-01-12 stsp fi
414 46cee7a3 2019-01-12 stsp
415 46cee7a3 2019-01-12 stsp if [ -e $testroot/wt/epsilon/psi/chi ]; then
416 46cee7a3 2019-01-12 stsp echo "removed dir epsilon/psi/chi still exists on disk" >&2
417 46cee7a3 2019-01-12 stsp test_done "$testroot" "1"
418 46cee7a3 2019-01-12 stsp return 1
419 46cee7a3 2019-01-12 stsp fi
420 46cee7a3 2019-01-12 stsp
421 46cee7a3 2019-01-12 stsp if [ -e $testroot/wt/epsilon/psi/mu ]; then
422 46cee7a3 2019-01-12 stsp echo "removed file epsilon/psi/mu still exists on disk" >&2
423 46cee7a3 2019-01-12 stsp test_done "$testroot" "1"
424 46cee7a3 2019-01-12 stsp return 1
425 46cee7a3 2019-01-12 stsp fi
426 46cee7a3 2019-01-12 stsp
427 46cee7a3 2019-01-12 stsp test_done "$testroot" "0"
428 46cee7a3 2019-01-12 stsp }
429 46cee7a3 2019-01-12 stsp
430 46cee7a3 2019-01-12 stsp function test_update_moves_files_to_new_dir {
431 46cee7a3 2019-01-12 stsp local testroot=`test_init update_moves_files_to_new_dir`
432 46cee7a3 2019-01-12 stsp
433 46cee7a3 2019-01-12 stsp mkdir $testroot/repo/epsilon/psi
434 46cee7a3 2019-01-12 stsp echo mu > $testroot/repo/epsilon/psi/mu
435 46cee7a3 2019-01-12 stsp mkdir $testroot/repo/epsilon/psi/chi
436 46cee7a3 2019-01-12 stsp echo tau > $testroot/repo/epsilon/psi/chi/tau
437 46cee7a3 2019-01-12 stsp (cd $testroot/repo && git add .)
438 46cee7a3 2019-01-12 stsp git_commit $testroot/repo -m "adding a sub-directory beneath epsilon"
439 46cee7a3 2019-01-12 stsp
440 46cee7a3 2019-01-12 stsp got checkout $testroot/repo $testroot/wt > /dev/null
441 e60e7f5b 2019-02-10 stsp ret="$?"
442 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
443 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
444 46cee7a3 2019-01-12 stsp return 1
445 46cee7a3 2019-01-12 stsp fi
446 46cee7a3 2019-01-12 stsp
447 46cee7a3 2019-01-12 stsp mkdir -p $testroot/repo/epsilon-new/psi
448 46cee7a3 2019-01-12 stsp (cd $testroot/repo && git mv epsilon/psi/mu epsilon-new/mu)
449 46cee7a3 2019-01-12 stsp (cd $testroot/repo && git mv epsilon/psi/chi/tau epsilon-new/psi/tau)
450 46cee7a3 2019-01-12 stsp git_commit $testroot/repo -m "moving files upwards"
451 46cee7a3 2019-01-12 stsp
452 f5d3d7af 2019-02-05 stsp echo "D epsilon/psi/chi/tau" > $testroot/stdout.expected
453 46cee7a3 2019-01-12 stsp echo "D epsilon/psi/mu" >> $testroot/stdout.expected
454 f5d3d7af 2019-02-05 stsp echo "A epsilon-new/mu" >> $testroot/stdout.expected
455 f5d3d7af 2019-02-05 stsp echo "A epsilon-new/psi/tau" >> $testroot/stdout.expected
456 46cee7a3 2019-01-12 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
457 46cee7a3 2019-01-12 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
458 46cee7a3 2019-01-12 stsp echo >> $testroot/stdout.expected
459 46cee7a3 2019-01-12 stsp
460 46cee7a3 2019-01-12 stsp (cd $testroot/wt && got update > $testroot/stdout)
461 46cee7a3 2019-01-12 stsp
462 46cee7a3 2019-01-12 stsp cmp $testroot/stdout.expected $testroot/stdout
463 e60e7f5b 2019-02-10 stsp ret="$?"
464 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
465 46cee7a3 2019-01-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
466 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
467 46cee7a3 2019-01-12 stsp return 1
468 46cee7a3 2019-01-12 stsp fi
469 46cee7a3 2019-01-12 stsp
470 46cee7a3 2019-01-12 stsp if [ -e $testroot/wt/epsilon/psi/chi ]; then
471 46cee7a3 2019-01-12 stsp echo "removed dir epsilon/psi/chi still exists on disk" >&2
472 46cee7a3 2019-01-12 stsp test_done "$testroot" "1"
473 46cee7a3 2019-01-12 stsp return 1
474 46cee7a3 2019-01-12 stsp fi
475 46cee7a3 2019-01-12 stsp
476 46cee7a3 2019-01-12 stsp if [ -e $testroot/wt/epsilon/psi/mu ]; then
477 46cee7a3 2019-01-12 stsp echo "removed file epsilon/psi/mu still exists on disk" >&2
478 46cee7a3 2019-01-12 stsp test_done "$testroot" "1"
479 4a1ddfc2 2019-01-12 stsp return 1
480 4a1ddfc2 2019-01-12 stsp fi
481 4a1ddfc2 2019-01-12 stsp
482 4a1ddfc2 2019-01-12 stsp test_done "$testroot" "0"
483 4a1ddfc2 2019-01-12 stsp }
484 4a1ddfc2 2019-01-12 stsp
485 4a1ddfc2 2019-01-12 stsp function test_update_creates_missing_parent {
486 1aad446a 2019-01-13 stsp local testroot=`test_init update_creates_missing_parent 1`
487 4a1ddfc2 2019-01-12 stsp
488 4a1ddfc2 2019-01-12 stsp touch $testroot/repo/Makefile
489 4a1ddfc2 2019-01-12 stsp touch $testroot/repo/snake.6
490 4a1ddfc2 2019-01-12 stsp touch $testroot/repo/snake.c
491 4a1ddfc2 2019-01-12 stsp (cd $testroot/repo && git add .)
492 4a1ddfc2 2019-01-12 stsp git_commit $testroot/repo -m "adding initial snake tree"
493 4a1ddfc2 2019-01-12 stsp
494 4a1ddfc2 2019-01-12 stsp got checkout $testroot/repo $testroot/wt > /dev/null
495 e60e7f5b 2019-02-10 stsp ret="$?"
496 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
497 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
498 4a1ddfc2 2019-01-12 stsp return 1
499 4a1ddfc2 2019-01-12 stsp fi
500 4a1ddfc2 2019-01-12 stsp
501 4a1ddfc2 2019-01-12 stsp mkdir -p $testroot/repo/snake
502 4a1ddfc2 2019-01-12 stsp (cd $testroot/repo && git mv Makefile snake.6 snake.c snake)
503 4a1ddfc2 2019-01-12 stsp touch $testroot/repo/snake/move.c
504 4a1ddfc2 2019-01-12 stsp touch $testroot/repo/snake/pathnames.h
505 4a1ddfc2 2019-01-12 stsp touch $testroot/repo/snake/snake.h
506 4a1ddfc2 2019-01-12 stsp mkdir -p $testroot/repo/snscore
507 4a1ddfc2 2019-01-12 stsp touch $testroot/repo/snscore/Makefile
508 4a1ddfc2 2019-01-12 stsp touch $testroot/repo/snscore/snscore.c
509 4a1ddfc2 2019-01-12 stsp (cd $testroot/repo && git add .)
510 4a1ddfc2 2019-01-12 stsp git_commit $testroot/repo -m "restructuring snake tree"
511 4a1ddfc2 2019-01-12 stsp
512 4a1ddfc2 2019-01-12 stsp echo "D Makefile" > $testroot/stdout.expected
513 4a1ddfc2 2019-01-12 stsp echo "A snake/Makefile" >> $testroot/stdout.expected
514 4a1ddfc2 2019-01-12 stsp echo "A snake/move.c" >> $testroot/stdout.expected
515 4a1ddfc2 2019-01-12 stsp echo "A snake/pathnames.h" >> $testroot/stdout.expected
516 4a1ddfc2 2019-01-12 stsp echo "A snake/snake.6" >> $testroot/stdout.expected
517 4a1ddfc2 2019-01-12 stsp echo "A snake/snake.c" >> $testroot/stdout.expected
518 4a1ddfc2 2019-01-12 stsp echo "A snake/snake.h" >> $testroot/stdout.expected
519 18831e78 2019-02-10 stsp echo "D snake.6" >> $testroot/stdout.expected
520 18831e78 2019-02-10 stsp echo "D snake.c" >> $testroot/stdout.expected
521 bd4792ec 2019-01-13 stsp echo "A snscore/Makefile" >> $testroot/stdout.expected
522 bd4792ec 2019-01-13 stsp echo "A snscore/snscore.c" >> $testroot/stdout.expected
523 bd4792ec 2019-01-13 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
524 bd4792ec 2019-01-13 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
525 bd4792ec 2019-01-13 stsp echo >> $testroot/stdout.expected
526 bd4792ec 2019-01-13 stsp
527 bd4792ec 2019-01-13 stsp (cd $testroot/wt && got update > $testroot/stdout)
528 bd4792ec 2019-01-13 stsp
529 bd4792ec 2019-01-13 stsp cmp $testroot/stdout.expected $testroot/stdout
530 e60e7f5b 2019-02-10 stsp ret="$?"
531 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
532 e60e7f5b 2019-02-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
533 bd4792ec 2019-01-13 stsp fi
534 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
535 bd4792ec 2019-01-13 stsp }
536 bd4792ec 2019-01-13 stsp
537 bd4792ec 2019-01-13 stsp function test_update_creates_missing_parent_with_subdir {
538 1aad446a 2019-01-13 stsp local testroot=`test_init update_creates_missing_parent_with_subdir 1`
539 bd4792ec 2019-01-13 stsp
540 bd4792ec 2019-01-13 stsp touch $testroot/repo/Makefile
541 bd4792ec 2019-01-13 stsp touch $testroot/repo/snake.6
542 bd4792ec 2019-01-13 stsp touch $testroot/repo/snake.c
543 bd4792ec 2019-01-13 stsp (cd $testroot/repo && git add .)
544 bd4792ec 2019-01-13 stsp git_commit $testroot/repo -m "adding initial snake tree"
545 bd4792ec 2019-01-13 stsp
546 bd4792ec 2019-01-13 stsp got checkout $testroot/repo $testroot/wt > /dev/null
547 e60e7f5b 2019-02-10 stsp ret="$?"
548 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
549 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
550 bd4792ec 2019-01-13 stsp return 1
551 bd4792ec 2019-01-13 stsp fi
552 bd4792ec 2019-01-13 stsp
553 bd4792ec 2019-01-13 stsp mkdir -p $testroot/repo/sss/snake
554 bd4792ec 2019-01-13 stsp (cd $testroot/repo && git mv Makefile snake.6 snake.c sss/snake)
555 bd4792ec 2019-01-13 stsp touch $testroot/repo/sss/snake/move.c
556 bd4792ec 2019-01-13 stsp touch $testroot/repo/sss/snake/pathnames.h
557 bd4792ec 2019-01-13 stsp touch $testroot/repo/sss/snake/snake.h
558 bd4792ec 2019-01-13 stsp mkdir -p $testroot/repo/snscore
559 bd4792ec 2019-01-13 stsp touch $testroot/repo/snscore/Makefile
560 bd4792ec 2019-01-13 stsp touch $testroot/repo/snscore/snscore.c
561 bd4792ec 2019-01-13 stsp (cd $testroot/repo && git add .)
562 bd4792ec 2019-01-13 stsp git_commit $testroot/repo -m "restructuring snake tree"
563 bd4792ec 2019-01-13 stsp
564 bd4792ec 2019-01-13 stsp echo "D Makefile" > $testroot/stdout.expected
565 4a1ddfc2 2019-01-12 stsp echo "D snake.6" >> $testroot/stdout.expected
566 4a1ddfc2 2019-01-12 stsp echo "D snake.c" >> $testroot/stdout.expected
567 4a1ddfc2 2019-01-12 stsp echo "A snscore/Makefile" >> $testroot/stdout.expected
568 4a1ddfc2 2019-01-12 stsp echo "A snscore/snscore.c" >> $testroot/stdout.expected
569 bd4792ec 2019-01-13 stsp echo "A sss/snake/Makefile" >> $testroot/stdout.expected
570 bd4792ec 2019-01-13 stsp echo "A sss/snake/move.c" >> $testroot/stdout.expected
571 bd4792ec 2019-01-13 stsp echo "A sss/snake/pathnames.h" >> $testroot/stdout.expected
572 bd4792ec 2019-01-13 stsp echo "A sss/snake/snake.6" >> $testroot/stdout.expected
573 bd4792ec 2019-01-13 stsp echo "A sss/snake/snake.c" >> $testroot/stdout.expected
574 bd4792ec 2019-01-13 stsp echo "A sss/snake/snake.h" >> $testroot/stdout.expected
575 4a1ddfc2 2019-01-12 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
576 4a1ddfc2 2019-01-12 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
577 4a1ddfc2 2019-01-12 stsp echo >> $testroot/stdout.expected
578 4a1ddfc2 2019-01-12 stsp
579 4a1ddfc2 2019-01-12 stsp (cd $testroot/wt && got update > $testroot/stdout)
580 4a1ddfc2 2019-01-12 stsp
581 4a1ddfc2 2019-01-12 stsp cmp $testroot/stdout.expected $testroot/stdout
582 e60e7f5b 2019-02-10 stsp ret="$?"
583 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
584 4a1ddfc2 2019-01-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
585 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
586 46cee7a3 2019-01-12 stsp return 1
587 46cee7a3 2019-01-12 stsp fi
588 46cee7a3 2019-01-12 stsp
589 46cee7a3 2019-01-12 stsp test_done "$testroot" "0"
590 46cee7a3 2019-01-12 stsp }
591 21908da4 2019-01-13 stsp
592 21908da4 2019-01-13 stsp function test_update_file_in_subsubdir {
593 1aad446a 2019-01-13 stsp local testroot=`test_init update_fle_in_subsubdir 1`
594 46cee7a3 2019-01-12 stsp
595 21908da4 2019-01-13 stsp touch $testroot/repo/Makefile
596 21908da4 2019-01-13 stsp mkdir -p $testroot/repo/altq
597 21908da4 2019-01-13 stsp touch $testroot/repo/altq/if_altq.h
598 21908da4 2019-01-13 stsp mkdir -p $testroot/repo/arch/alpha
599 21908da4 2019-01-13 stsp touch $testroot/repo/arch/alpha/Makefile
600 21908da4 2019-01-13 stsp (cd $testroot/repo && git add .)
601 21908da4 2019-01-13 stsp git_commit $testroot/repo -m "adding initial tree"
602 21908da4 2019-01-13 stsp
603 21908da4 2019-01-13 stsp got checkout $testroot/repo $testroot/wt > /dev/null
604 e60e7f5b 2019-02-10 stsp ret="$?"
605 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
606 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
607 21908da4 2019-01-13 stsp return 1
608 21908da4 2019-01-13 stsp fi
609 21908da4 2019-01-13 stsp
610 21908da4 2019-01-13 stsp echo change > $testroot/repo/arch/alpha/Makefile
611 21908da4 2019-01-13 stsp (cd $testroot/repo && git add .)
612 21908da4 2019-01-13 stsp git_commit $testroot/repo -m "changed a file"
613 21908da4 2019-01-13 stsp
614 21908da4 2019-01-13 stsp echo "U arch/alpha/Makefile" > $testroot/stdout.expected
615 21908da4 2019-01-13 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
616 21908da4 2019-01-13 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
617 21908da4 2019-01-13 stsp echo >> $testroot/stdout.expected
618 21908da4 2019-01-13 stsp
619 21908da4 2019-01-13 stsp (cd $testroot/wt && got update > $testroot/stdout)
620 21908da4 2019-01-13 stsp
621 21908da4 2019-01-13 stsp cmp $testroot/stdout.expected $testroot/stdout
622 e60e7f5b 2019-02-10 stsp ret="$?"
623 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
624 21908da4 2019-01-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
625 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
626 21908da4 2019-01-13 stsp return 1
627 21908da4 2019-01-13 stsp fi
628 21908da4 2019-01-13 stsp
629 21908da4 2019-01-13 stsp test_done "$testroot" "0"
630 21908da4 2019-01-13 stsp }
631 6353ad76 2019-02-08 stsp
632 6353ad76 2019-02-08 stsp function test_update_merges_file_edits {
633 6353ad76 2019-02-08 stsp local testroot=`test_init update_merges_file_edits`
634 6353ad76 2019-02-08 stsp
635 6353ad76 2019-02-08 stsp echo "1" > $testroot/repo/numbers
636 6353ad76 2019-02-08 stsp echo "2" >> $testroot/repo/numbers
637 6353ad76 2019-02-08 stsp echo "3" >> $testroot/repo/numbers
638 6353ad76 2019-02-08 stsp echo "4" >> $testroot/repo/numbers
639 6353ad76 2019-02-08 stsp echo "5" >> $testroot/repo/numbers
640 6353ad76 2019-02-08 stsp echo "6" >> $testroot/repo/numbers
641 6353ad76 2019-02-08 stsp echo "7" >> $testroot/repo/numbers
642 6353ad76 2019-02-08 stsp echo "8" >> $testroot/repo/numbers
643 6353ad76 2019-02-08 stsp (cd $testroot/repo && git add numbers)
644 6353ad76 2019-02-08 stsp git_commit $testroot/repo -m "added numbers file"
645 21908da4 2019-01-13 stsp
646 6353ad76 2019-02-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
647 e60e7f5b 2019-02-10 stsp ret="$?"
648 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
649 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
650 6353ad76 2019-02-08 stsp return 1
651 6353ad76 2019-02-08 stsp fi
652 6353ad76 2019-02-08 stsp
653 6353ad76 2019-02-08 stsp echo "modified alpha" > $testroot/repo/alpha
654 6353ad76 2019-02-08 stsp echo "modified beta" > $testroot/repo/beta
655 6353ad76 2019-02-08 stsp sed -i 's/2/22/' $testroot/repo/numbers
656 6353ad76 2019-02-08 stsp git_commit $testroot/repo -m "modified 3 files"
657 6353ad76 2019-02-08 stsp
658 6353ad76 2019-02-08 stsp echo "modified alpha, too" > $testroot/wt/alpha
659 6353ad76 2019-02-08 stsp touch $testroot/wt/beta
660 6353ad76 2019-02-08 stsp sed -i 's/7/77/' $testroot/wt/numbers
661 6353ad76 2019-02-08 stsp
662 6353ad76 2019-02-08 stsp echo "C alpha" > $testroot/stdout.expected
663 6353ad76 2019-02-08 stsp echo "U beta" >> $testroot/stdout.expected
664 6353ad76 2019-02-08 stsp echo "G numbers" >> $testroot/stdout.expected
665 6353ad76 2019-02-08 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
666 6353ad76 2019-02-08 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
667 6353ad76 2019-02-08 stsp echo >> $testroot/stdout.expected
668 6353ad76 2019-02-08 stsp
669 6353ad76 2019-02-08 stsp (cd $testroot/wt && got update > $testroot/stdout)
670 6353ad76 2019-02-08 stsp
671 6353ad76 2019-02-08 stsp cmp $testroot/stdout.expected $testroot/stdout
672 e60e7f5b 2019-02-10 stsp ret="$?"
673 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
674 6353ad76 2019-02-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
675 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
676 6353ad76 2019-02-08 stsp return 1
677 6353ad76 2019-02-08 stsp fi
678 6353ad76 2019-02-08 stsp
679 6353ad76 2019-02-08 stsp echo -n "<<<<<<< commit " > $testroot/content.expected
680 6353ad76 2019-02-08 stsp git_show_head $testroot/repo >> $testroot/content.expected
681 6353ad76 2019-02-08 stsp echo >> $testroot/content.expected
682 6353ad76 2019-02-08 stsp echo "modified alpha" >> $testroot/content.expected
683 6353ad76 2019-02-08 stsp echo "=======" >> $testroot/content.expected
684 6353ad76 2019-02-08 stsp echo "modified alpha, too" >> $testroot/content.expected
685 6353ad76 2019-02-08 stsp echo '>>>>>>> alpha' >> $testroot/content.expected
686 6353ad76 2019-02-08 stsp echo "modified beta" >> $testroot/content.expected
687 6353ad76 2019-02-08 stsp echo "1" >> $testroot/content.expected
688 6353ad76 2019-02-08 stsp echo "22" >> $testroot/content.expected
689 6353ad76 2019-02-08 stsp echo "3" >> $testroot/content.expected
690 6353ad76 2019-02-08 stsp echo "4" >> $testroot/content.expected
691 6353ad76 2019-02-08 stsp echo "5" >> $testroot/content.expected
692 6353ad76 2019-02-08 stsp echo "6" >> $testroot/content.expected
693 6353ad76 2019-02-08 stsp echo "77" >> $testroot/content.expected
694 6353ad76 2019-02-08 stsp echo "8" >> $testroot/content.expected
695 6353ad76 2019-02-08 stsp
696 6353ad76 2019-02-08 stsp cat $testroot/wt/alpha > $testroot/content
697 6353ad76 2019-02-08 stsp cat $testroot/wt/beta >> $testroot/content
698 6353ad76 2019-02-08 stsp cat $testroot/wt/numbers >> $testroot/content
699 6353ad76 2019-02-08 stsp
700 6353ad76 2019-02-08 stsp cmp $testroot/content.expected $testroot/content
701 6353ad76 2019-02-08 stsp ret="$?"
702 6353ad76 2019-02-08 stsp if [ "$ret" != "0" ]; then
703 6353ad76 2019-02-08 stsp diff -u $testroot/content.expected $testroot/content
704 68ed9ba5 2019-02-10 stsp fi
705 68ed9ba5 2019-02-10 stsp test_done "$testroot" "$ret"
706 68ed9ba5 2019-02-10 stsp }
707 68ed9ba5 2019-02-10 stsp
708 68ed9ba5 2019-02-10 stsp function test_update_keeps_xbit {
709 68ed9ba5 2019-02-10 stsp local testroot=`test_init update_keeps_xbit 1`
710 68ed9ba5 2019-02-10 stsp
711 68ed9ba5 2019-02-10 stsp touch $testroot/repo/xfile
712 68ed9ba5 2019-02-10 stsp chmod +x $testroot/repo/xfile
713 68ed9ba5 2019-02-10 stsp (cd $testroot/repo && git add .)
714 68ed9ba5 2019-02-10 stsp git_commit $testroot/repo -m "adding executable file"
715 68ed9ba5 2019-02-10 stsp
716 68ed9ba5 2019-02-10 stsp got checkout $testroot/repo $testroot/wt > $testroot/stdout
717 68ed9ba5 2019-02-10 stsp ret="$?"
718 68ed9ba5 2019-02-10 stsp if [ "$ret" != "0" ]; then
719 68ed9ba5 2019-02-10 stsp test_done "$testroot" "$ret"
720 68ed9ba5 2019-02-10 stsp return 1
721 68ed9ba5 2019-02-10 stsp fi
722 68ed9ba5 2019-02-10 stsp
723 68ed9ba5 2019-02-10 stsp echo foo > $testroot/repo/xfile
724 68ed9ba5 2019-02-10 stsp git_commit $testroot/repo -m "changed executable file"
725 68ed9ba5 2019-02-10 stsp
726 68ed9ba5 2019-02-10 stsp echo "U xfile" > $testroot/stdout.expected
727 68ed9ba5 2019-02-10 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
728 68ed9ba5 2019-02-10 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
729 68ed9ba5 2019-02-10 stsp echo >> $testroot/stdout.expected
730 68ed9ba5 2019-02-10 stsp
731 68ed9ba5 2019-02-10 stsp (cd $testroot/wt && got update > $testroot/stdout)
732 68ed9ba5 2019-02-10 stsp ret="$?"
733 68ed9ba5 2019-02-10 stsp if [ "$ret" != "0" ]; then
734 68ed9ba5 2019-02-10 stsp test_done "$testroot" "$ret"
735 68ed9ba5 2019-02-10 stsp return 1
736 6353ad76 2019-02-08 stsp fi
737 68ed9ba5 2019-02-10 stsp
738 68ed9ba5 2019-02-10 stsp cmp $testroot/stdout.expected $testroot/stdout
739 68ed9ba5 2019-02-10 stsp ret="$?"
740 68ed9ba5 2019-02-10 stsp if [ "$ret" != "0" ]; then
741 68ed9ba5 2019-02-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
742 68ed9ba5 2019-02-10 stsp test_done "$testroot" "$ret"
743 68ed9ba5 2019-02-10 stsp return 1
744 68ed9ba5 2019-02-10 stsp fi
745 68ed9ba5 2019-02-10 stsp
746 68ed9ba5 2019-02-10 stsp ls -l $testroot/wt/xfile | grep -q '^-rwx'
747 68ed9ba5 2019-02-10 stsp ret="$?"
748 68ed9ba5 2019-02-10 stsp if [ "$ret" != "0" ]; then
749 68ed9ba5 2019-02-10 stsp echo "file is not executable" >&2
750 68ed9ba5 2019-02-10 stsp ls -l $testroot/wt/xfile >&2
751 68ed9ba5 2019-02-10 stsp fi
752 6353ad76 2019-02-08 stsp test_done "$testroot" "$ret"
753 6353ad76 2019-02-08 stsp }
754 ba8a0d4d 2019-02-10 stsp
755 ba8a0d4d 2019-02-10 stsp function test_update_clears_xbit {
756 ba8a0d4d 2019-02-10 stsp local testroot=`test_init update_clears_xbit 1`
757 ba8a0d4d 2019-02-10 stsp
758 ba8a0d4d 2019-02-10 stsp touch $testroot/repo/xfile
759 ba8a0d4d 2019-02-10 stsp chmod +x $testroot/repo/xfile
760 ba8a0d4d 2019-02-10 stsp (cd $testroot/repo && git add .)
761 ba8a0d4d 2019-02-10 stsp git_commit $testroot/repo -m "adding executable file"
762 6353ad76 2019-02-08 stsp
763 ba8a0d4d 2019-02-10 stsp got checkout $testroot/repo $testroot/wt > $testroot/stdout
764 ba8a0d4d 2019-02-10 stsp ret="$?"
765 ba8a0d4d 2019-02-10 stsp if [ "$ret" != "0" ]; then
766 ba8a0d4d 2019-02-10 stsp test_done "$testroot" "$ret"
767 ba8a0d4d 2019-02-10 stsp return 1
768 ba8a0d4d 2019-02-10 stsp fi
769 ba8a0d4d 2019-02-10 stsp
770 ba8a0d4d 2019-02-10 stsp ls -l $testroot/wt/xfile | grep -q '^-rwx'
771 ba8a0d4d 2019-02-10 stsp ret="$?"
772 ba8a0d4d 2019-02-10 stsp if [ "$ret" != "0" ]; then
773 ba8a0d4d 2019-02-10 stsp echo "file is not executable" >&2
774 ba8a0d4d 2019-02-10 stsp ls -l $testroot/wt/xfile >&2
775 ba8a0d4d 2019-02-10 stsp test_done "$testroot" "$ret"
776 ba8a0d4d 2019-02-10 stsp return 1
777 ba8a0d4d 2019-02-10 stsp fi
778 ba8a0d4d 2019-02-10 stsp
779 ba8a0d4d 2019-02-10 stsp # XXX git seems to require a file edit when flipping the x bit?
780 ba8a0d4d 2019-02-10 stsp echo foo > $testroot/repo/xfile
781 ba8a0d4d 2019-02-10 stsp chmod -x $testroot/repo/xfile
782 ba8a0d4d 2019-02-10 stsp git_commit $testroot/repo -m "not an executable file anymore"
783 ba8a0d4d 2019-02-10 stsp
784 ba8a0d4d 2019-02-10 stsp echo "U xfile" > $testroot/stdout.expected
785 ba8a0d4d 2019-02-10 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
786 ba8a0d4d 2019-02-10 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
787 ba8a0d4d 2019-02-10 stsp echo >> $testroot/stdout.expected
788 ba8a0d4d 2019-02-10 stsp
789 ba8a0d4d 2019-02-10 stsp (cd $testroot/wt && got update > $testroot/stdout)
790 ba8a0d4d 2019-02-10 stsp ret="$?"
791 ba8a0d4d 2019-02-10 stsp if [ "$ret" != "0" ]; then
792 ba8a0d4d 2019-02-10 stsp test_done "$testroot" "$ret"
793 ba8a0d4d 2019-02-10 stsp return 1
794 ba8a0d4d 2019-02-10 stsp fi
795 ba8a0d4d 2019-02-10 stsp
796 ba8a0d4d 2019-02-10 stsp cmp $testroot/stdout.expected $testroot/stdout
797 ba8a0d4d 2019-02-10 stsp ret="$?"
798 ba8a0d4d 2019-02-10 stsp if [ "$ret" != "0" ]; then
799 ba8a0d4d 2019-02-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
800 ba8a0d4d 2019-02-10 stsp test_done "$testroot" "$ret"
801 ba8a0d4d 2019-02-10 stsp return 1
802 ba8a0d4d 2019-02-10 stsp fi
803 ba8a0d4d 2019-02-10 stsp
804 ba8a0d4d 2019-02-10 stsp ls -l $testroot/wt/xfile | grep -q '^-rw-'
805 ba8a0d4d 2019-02-10 stsp ret="$?"
806 ba8a0d4d 2019-02-10 stsp if [ "$ret" != "0" ]; then
807 ba8a0d4d 2019-02-10 stsp echo "file is unexpectedly executable" >&2
808 ba8a0d4d 2019-02-10 stsp ls -l $testroot/wt/xfile >&2
809 ba8a0d4d 2019-02-10 stsp fi
810 ba8a0d4d 2019-02-10 stsp test_done "$testroot" "$ret"
811 ba8a0d4d 2019-02-10 stsp }
812 a378724f 2019-02-10 stsp
813 a378724f 2019-02-10 stsp function test_update_restores_missing_file {
814 a378724f 2019-02-10 stsp local testroot=`test_init update_restores_missing_file`
815 a378724f 2019-02-10 stsp
816 a378724f 2019-02-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
817 a378724f 2019-02-10 stsp ret="$?"
818 a378724f 2019-02-10 stsp if [ "$ret" != "0" ]; then
819 a378724f 2019-02-10 stsp test_done "$testroot" "$ret"
820 a378724f 2019-02-10 stsp return 1
821 a378724f 2019-02-10 stsp fi
822 ba8a0d4d 2019-02-10 stsp
823 a378724f 2019-02-10 stsp rm $testroot/wt/alpha
824 a378724f 2019-02-10 stsp
825 a378724f 2019-02-10 stsp echo "! alpha" > $testroot/stdout.expected
826 1545c615 2019-02-10 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
827 1545c615 2019-02-10 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
828 1545c615 2019-02-10 stsp echo >> $testroot/stdout.expected
829 a378724f 2019-02-10 stsp (cd $testroot/wt && got update > $testroot/stdout)
830 a378724f 2019-02-10 stsp
831 a378724f 2019-02-10 stsp cmp $testroot/stdout.expected $testroot/stdout
832 a378724f 2019-02-10 stsp ret="$?"
833 a378724f 2019-02-10 stsp if [ "$ret" != "0" ]; then
834 a378724f 2019-02-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
835 a378724f 2019-02-10 stsp test_done "$testroot" "$ret"
836 a378724f 2019-02-10 stsp return 1
837 a378724f 2019-02-10 stsp fi
838 a378724f 2019-02-10 stsp
839 a378724f 2019-02-10 stsp echo "alpha" > $testroot/content.expected
840 a378724f 2019-02-10 stsp
841 a378724f 2019-02-10 stsp cat $testroot/wt/alpha > $testroot/content
842 a378724f 2019-02-10 stsp
843 a378724f 2019-02-10 stsp cmp $testroot/content.expected $testroot/content
844 a378724f 2019-02-10 stsp ret="$?"
845 a378724f 2019-02-10 stsp if [ "$ret" != "0" ]; then
846 a378724f 2019-02-10 stsp diff -u $testroot/content.expected $testroot/content
847 a378724f 2019-02-10 stsp fi
848 a378724f 2019-02-10 stsp test_done "$testroot" "$ret"
849 a378724f 2019-02-10 stsp }
850 a378724f 2019-02-10 stsp
851 c84d8c75 2019-01-02 stsp run_test test_update_basic
852 3b4d3732 2019-01-02 stsp run_test test_update_adds_file
853 512f0d0e 2019-01-02 stsp run_test test_update_deletes_file
854 f5c49f82 2019-01-06 stsp run_test test_update_deletes_dir
855 5cc266ba 2019-01-06 stsp run_test test_update_deletes_dir_with_path_prefix
856 90285c3b 2019-01-08 stsp run_test test_update_deletes_dir_recursively
857 4482e97b 2019-01-08 stsp run_test test_update_sibling_dirs_with_common_prefix
858 50952927 2019-01-12 stsp run_test test_update_dir_with_dot_sibling
859 46cee7a3 2019-01-12 stsp run_test test_update_moves_files_upwards
860 bd4792ec 2019-01-13 stsp run_test test_update_moves_files_to_new_dir
861 4a1ddfc2 2019-01-12 stsp run_test test_update_creates_missing_parent
862 bd4792ec 2019-01-13 stsp run_test test_update_creates_missing_parent_with_subdir
863 21908da4 2019-01-13 stsp run_test test_update_file_in_subsubdir
864 6353ad76 2019-02-08 stsp run_test test_update_merges_file_edits
865 68ed9ba5 2019-02-10 stsp run_test test_update_keeps_xbit
866 ba8a0d4d 2019-02-10 stsp run_test test_update_clears_xbit
867 a378724f 2019-02-10 stsp run_test test_update_restores_missing_file