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 f6cae3ed 2020-09-13 naddy 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 49c543a6 2022-03-31 naddy ret=$?
24 49c543a6 2022-03-31 naddy if [ $ret -ne 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 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $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 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
40 49c543a6 2022-03-31 naddy ret=$?
41 49c543a6 2022-03-31 naddy if [ $ret -ne 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 8d301dd9 2019-05-14 stsp cmp -s $testroot/content.expected $testroot/content
51 49c543a6 2022-03-31 naddy ret=$?
52 49c543a6 2022-03-31 naddy if [ $ret -ne 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 f6cae3ed 2020-09-13 naddy 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 49c543a6 2022-03-31 naddy ret=$?
63 49c543a6 2022-03-31 naddy if [ $ret -ne 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 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $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 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
80 49c543a6 2022-03-31 naddy ret=$?
81 49c543a6 2022-03-31 naddy if [ $ret -ne 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 8d301dd9 2019-05-14 stsp cmp -s $testroot/content.expected $testroot/content
91 49c543a6 2022-03-31 naddy ret=$?
92 49c543a6 2022-03-31 naddy if [ $ret -ne 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 f6cae3ed 2020-09-13 naddy test_update_deletes_file() {
99 512f0d0e 2019-01-02 stsp local testroot=`test_init update_deletes_file`
100 512f0d0e 2019-01-02 stsp
101 1c4cdd89 2021-06-20 stsp mkdir $testroot/wtparent
102 1c4cdd89 2021-06-20 stsp got checkout $testroot/repo $testroot/wtparent/wt > /dev/null
103 49c543a6 2022-03-31 naddy ret=$?
104 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
105 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
106 512f0d0e 2019-01-02 stsp return 1
107 512f0d0e 2019-01-02 stsp fi
108 512f0d0e 2019-01-02 stsp
109 512f0d0e 2019-01-02 stsp (cd $testroot/repo && git_rm $testroot/repo beta)
110 512f0d0e 2019-01-02 stsp git_commit $testroot/repo -m "deleting a file"
111 512f0d0e 2019-01-02 stsp
112 512f0d0e 2019-01-02 stsp echo "D beta" > $testroot/stdout.expected
113 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
114 512f0d0e 2019-01-02 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
115 512f0d0e 2019-01-02 stsp echo >> $testroot/stdout.expected
116 512f0d0e 2019-01-02 stsp
117 1c4cdd89 2021-06-20 stsp # verify that no error occurs if the work tree's parent
118 1c4cdd89 2021-06-20 stsp # directory is not writable
119 1c4cdd89 2021-06-20 stsp chmod u-w $testroot/wtparent
120 1c4cdd89 2021-06-20 stsp (cd $testroot/wtparent/wt && got update > $testroot/stdout)
121 1c4cdd89 2021-06-20 stsp chmod u+w $testroot/wtparent
122 512f0d0e 2019-01-02 stsp
123 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
124 49c543a6 2022-03-31 naddy ret=$?
125 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
126 512f0d0e 2019-01-02 stsp diff -u $testroot/stdout.expected $testroot/stdout
127 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
128 512f0d0e 2019-01-02 stsp return 1
129 512f0d0e 2019-01-02 stsp fi
130 512f0d0e 2019-01-02 stsp
131 1c4cdd89 2021-06-20 stsp if [ -e $testroot/wtparent/wt/beta ]; then
132 512f0d0e 2019-01-02 stsp echo "removed file beta still exists on disk" >&2
133 52a3df9b 2019-01-06 stsp test_done "$testroot" "1"
134 512f0d0e 2019-01-02 stsp return 1
135 512f0d0e 2019-01-02 stsp fi
136 512f0d0e 2019-01-02 stsp
137 52a3df9b 2019-01-06 stsp test_done "$testroot" "0"
138 512f0d0e 2019-01-02 stsp }
139 512f0d0e 2019-01-02 stsp
140 f6cae3ed 2020-09-13 naddy test_update_deletes_dir() {
141 f5c49f82 2019-01-06 stsp local testroot=`test_init update_deletes_dir`
142 f5c49f82 2019-01-06 stsp
143 f5c49f82 2019-01-06 stsp got checkout $testroot/repo $testroot/wt > /dev/null
144 49c543a6 2022-03-31 naddy ret=$?
145 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
146 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
147 f5c49f82 2019-01-06 stsp return 1
148 f5c49f82 2019-01-06 stsp fi
149 f5c49f82 2019-01-06 stsp
150 f5c49f82 2019-01-06 stsp (cd $testroot/repo && git_rm $testroot/repo -r epsilon)
151 f5c49f82 2019-01-06 stsp git_commit $testroot/repo -m "deleting a directory"
152 f5c49f82 2019-01-06 stsp
153 f5c49f82 2019-01-06 stsp echo "D epsilon/zeta" > $testroot/stdout.expected
154 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
155 f5c49f82 2019-01-06 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
156 f5c49f82 2019-01-06 stsp echo >> $testroot/stdout.expected
157 f5c49f82 2019-01-06 stsp
158 f5c49f82 2019-01-06 stsp (cd $testroot/wt && got update > $testroot/stdout)
159 f5c49f82 2019-01-06 stsp
160 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
161 49c543a6 2022-03-31 naddy ret=$?
162 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
163 f5c49f82 2019-01-06 stsp diff -u $testroot/stdout.expected $testroot/stdout
164 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
165 f5c49f82 2019-01-06 stsp return 1
166 f5c49f82 2019-01-06 stsp fi
167 f5c49f82 2019-01-06 stsp
168 f5c49f82 2019-01-06 stsp if [ -e $testroot/wt/epsilon ]; then
169 f5c49f82 2019-01-06 stsp echo "removed dir epsilon still exists on disk" >&2
170 52a3df9b 2019-01-06 stsp test_done "$testroot" "1"
171 f5c49f82 2019-01-06 stsp return 1
172 f5c49f82 2019-01-06 stsp fi
173 f5c49f82 2019-01-06 stsp
174 52a3df9b 2019-01-06 stsp test_done "$testroot" "0"
175 f5c49f82 2019-01-06 stsp }
176 f5c49f82 2019-01-06 stsp
177 f6cae3ed 2020-09-13 naddy test_update_deletes_dir_with_path_prefix() {
178 5cc266ba 2019-01-06 stsp local testroot=`test_init update_deletes_dir_with_path_prefix`
179 5cc266ba 2019-01-06 stsp local first_rev=`git_show_head $testroot/repo`
180 5cc266ba 2019-01-06 stsp
181 5cc266ba 2019-01-06 stsp mkdir $testroot/repo/epsilon/psi
182 5cc266ba 2019-01-06 stsp echo mu > $testroot/repo/epsilon/psi/mu
183 5cc266ba 2019-01-06 stsp (cd $testroot/repo && git add .)
184 5cc266ba 2019-01-06 stsp git_commit $testroot/repo -m "adding a sub-directory beneath epsilon"
185 5cc266ba 2019-01-06 stsp
186 5cc266ba 2019-01-06 stsp # check out the epsilon/ sub-tree
187 5cc266ba 2019-01-06 stsp got checkout -p epsilon $testroot/repo $testroot/wt > /dev/null
188 49c543a6 2022-03-31 naddy ret=$?
189 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
190 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
191 5cc266ba 2019-01-06 stsp return 1
192 5cc266ba 2019-01-06 stsp fi
193 5cc266ba 2019-01-06 stsp
194 5cc266ba 2019-01-06 stsp # update back to first commit and expect psi/mu to be deleted
195 5cc266ba 2019-01-06 stsp echo "D psi/mu" > $testroot/stdout.expected
196 4f3c844b 2021-09-14 stsp echo "Updated to refs/heads/master: $first_rev" \
197 4f3c844b 2021-09-14 stsp >> $testroot/stdout.expected
198 5cc266ba 2019-01-06 stsp
199 5cc266ba 2019-01-06 stsp (cd $testroot/wt && got update -c $first_rev > $testroot/stdout)
200 5cc266ba 2019-01-06 stsp
201 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
202 49c543a6 2022-03-31 naddy ret=$?
203 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
204 5cc266ba 2019-01-06 stsp diff -u $testroot/stdout.expected $testroot/stdout
205 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
206 5cc266ba 2019-01-06 stsp return 1
207 5cc266ba 2019-01-06 stsp fi
208 5cc266ba 2019-01-06 stsp
209 5cc266ba 2019-01-06 stsp if [ -e $testroot/wt/psi ]; then
210 5cc266ba 2019-01-06 stsp echo "removed dir psi still exists on disk" >&2
211 5cc266ba 2019-01-06 stsp test_done "$testroot" "1"
212 5cc266ba 2019-01-06 stsp return 1
213 5cc266ba 2019-01-06 stsp fi
214 5cc266ba 2019-01-06 stsp
215 52a3df9b 2019-01-06 stsp test_done "$testroot" "0"
216 5cc266ba 2019-01-06 stsp }
217 5cc266ba 2019-01-06 stsp
218 f6cae3ed 2020-09-13 naddy test_update_deletes_dir_recursively() {
219 90285c3b 2019-01-08 stsp local testroot=`test_init update_deletes_dir_recursively`
220 90285c3b 2019-01-08 stsp local first_rev=`git_show_head $testroot/repo`
221 90285c3b 2019-01-08 stsp
222 90285c3b 2019-01-08 stsp mkdir $testroot/repo/epsilon/psi
223 90285c3b 2019-01-08 stsp echo mu > $testroot/repo/epsilon/psi/mu
224 90285c3b 2019-01-08 stsp mkdir $testroot/repo/epsilon/psi/chi
225 90285c3b 2019-01-08 stsp echo tau > $testroot/repo/epsilon/psi/chi/tau
226 90285c3b 2019-01-08 stsp (cd $testroot/repo && git add .)
227 90285c3b 2019-01-08 stsp git_commit $testroot/repo -m "adding a sub-directory beneath epsilon"
228 90285c3b 2019-01-08 stsp
229 90285c3b 2019-01-08 stsp # check out the epsilon/ sub-tree
230 90285c3b 2019-01-08 stsp got checkout -p epsilon $testroot/repo $testroot/wt > /dev/null
231 49c543a6 2022-03-31 naddy ret=$?
232 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
233 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
234 90285c3b 2019-01-08 stsp return 1
235 90285c3b 2019-01-08 stsp fi
236 90285c3b 2019-01-08 stsp
237 90285c3b 2019-01-08 stsp # update back to first commit and expect psi/mu to be deleted
238 90285c3b 2019-01-08 stsp echo "D psi/chi/tau" > $testroot/stdout.expected
239 90285c3b 2019-01-08 stsp echo "D psi/mu" >> $testroot/stdout.expected
240 4f3c844b 2021-09-14 stsp echo "Updated to refs/heads/master: $first_rev" \
241 4f3c844b 2021-09-14 stsp >> $testroot/stdout.expected
242 90285c3b 2019-01-08 stsp
243 90285c3b 2019-01-08 stsp (cd $testroot/wt && got update -c $first_rev > $testroot/stdout)
244 90285c3b 2019-01-08 stsp
245 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
246 49c543a6 2022-03-31 naddy ret=$?
247 90285c3b 2019-01-08 stsp if [ "$?" != "0" ]; then
248 90285c3b 2019-01-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
249 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
250 90285c3b 2019-01-08 stsp return 1
251 90285c3b 2019-01-08 stsp fi
252 90285c3b 2019-01-08 stsp
253 90285c3b 2019-01-08 stsp if [ -e $testroot/wt/psi ]; then
254 90285c3b 2019-01-08 stsp echo "removed dir psi still exists on disk" >&2
255 90285c3b 2019-01-08 stsp test_done "$testroot" "1"
256 90285c3b 2019-01-08 stsp return 1
257 90285c3b 2019-01-08 stsp fi
258 90285c3b 2019-01-08 stsp
259 90285c3b 2019-01-08 stsp test_done "$testroot" "0"
260 90285c3b 2019-01-08 stsp }
261 90285c3b 2019-01-08 stsp
262 f6cae3ed 2020-09-13 naddy test_update_sibling_dirs_with_common_prefix() {
263 4482e97b 2019-01-08 stsp local testroot=`test_init update_sibling_dirs_with_common_prefix`
264 81a30460 2019-01-08 stsp
265 81a30460 2019-01-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
266 49c543a6 2022-03-31 naddy ret=$?
267 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
268 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
269 81a30460 2019-01-08 stsp return 1
270 81a30460 2019-01-08 stsp fi
271 81a30460 2019-01-08 stsp
272 81a30460 2019-01-08 stsp mkdir $testroot/repo/epsilon2
273 81a30460 2019-01-08 stsp echo mu > $testroot/repo/epsilon2/mu
274 81a30460 2019-01-08 stsp (cd $testroot/repo && git add epsilon2/mu)
275 81a30460 2019-01-08 stsp git_commit $testroot/repo -m "adding sibling of epsilon"
276 81a30460 2019-01-08 stsp echo change > $testroot/repo/epsilon/zeta
277 81a30460 2019-01-08 stsp git_commit $testroot/repo -m "changing epsilon/zeta"
278 81a30460 2019-01-08 stsp
279 81a30460 2019-01-08 stsp echo "U epsilon/zeta" > $testroot/stdout.expected
280 81a30460 2019-01-08 stsp echo "A epsilon2/mu" >> $testroot/stdout.expected
281 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
282 81a30460 2019-01-08 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
283 81a30460 2019-01-08 stsp echo >> $testroot/stdout.expected
284 81a30460 2019-01-08 stsp
285 81a30460 2019-01-08 stsp (cd $testroot/wt && got update > $testroot/stdout)
286 81a30460 2019-01-08 stsp
287 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
288 49c543a6 2022-03-31 naddy ret=$?
289 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
290 81a30460 2019-01-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
291 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
292 81a30460 2019-01-08 stsp return 1
293 81a30460 2019-01-08 stsp fi
294 81a30460 2019-01-08 stsp
295 81a30460 2019-01-08 stsp echo "another change" > $testroot/repo/epsilon/zeta
296 81a30460 2019-01-08 stsp git_commit $testroot/repo -m "changing epsilon/zeta again"
297 81a30460 2019-01-08 stsp
298 81a30460 2019-01-08 stsp echo "U epsilon/zeta" > $testroot/stdout.expected
299 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
300 81a30460 2019-01-08 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
301 81a30460 2019-01-08 stsp echo >> $testroot/stdout.expected
302 81a30460 2019-01-08 stsp
303 81a30460 2019-01-08 stsp # Bug: This update used to do delete/add epsilon2/mu again:
304 81a30460 2019-01-08 stsp # U epsilon/zeta
305 81a30460 2019-01-08 stsp # D epsilon2/mu <--- not intended
306 81a30460 2019-01-08 stsp # A epsilon2/mu <--- not intended
307 50952927 2019-01-12 stsp (cd $testroot/wt && got update > $testroot/stdout)
308 50952927 2019-01-12 stsp
309 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
310 49c543a6 2022-03-31 naddy ret=$?
311 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
312 50952927 2019-01-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
313 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
314 50952927 2019-01-12 stsp return 1
315 50952927 2019-01-12 stsp fi
316 50952927 2019-01-12 stsp
317 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
318 49c543a6 2022-03-31 naddy ret=$?
319 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
320 50952927 2019-01-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
321 50952927 2019-01-12 stsp fi
322 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
323 50952927 2019-01-12 stsp }
324 50952927 2019-01-12 stsp
325 f6cae3ed 2020-09-13 naddy test_update_dir_with_dot_sibling() {
326 50952927 2019-01-12 stsp local testroot=`test_init update_dir_with_dot_sibling`
327 50952927 2019-01-12 stsp
328 50952927 2019-01-12 stsp got checkout $testroot/repo $testroot/wt > /dev/null
329 49c543a6 2022-03-31 naddy ret=$?
330 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
331 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
332 50952927 2019-01-12 stsp return 1
333 50952927 2019-01-12 stsp fi
334 50952927 2019-01-12 stsp
335 50952927 2019-01-12 stsp echo text > $testroot/repo/epsilon.txt
336 50952927 2019-01-12 stsp (cd $testroot/repo && git add epsilon.txt)
337 50952927 2019-01-12 stsp git_commit $testroot/repo -m "adding sibling of epsilon"
338 50952927 2019-01-12 stsp echo change > $testroot/repo/epsilon/zeta
339 50952927 2019-01-12 stsp git_commit $testroot/repo -m "changing epsilon/zeta"
340 50952927 2019-01-12 stsp
341 f5d3d7af 2019-02-05 stsp echo "U epsilon/zeta" > $testroot/stdout.expected
342 f5d3d7af 2019-02-05 stsp echo "A epsilon.txt" >> $testroot/stdout.expected
343 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
344 50952927 2019-01-12 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
345 50952927 2019-01-12 stsp echo >> $testroot/stdout.expected
346 50952927 2019-01-12 stsp
347 81a30460 2019-01-08 stsp (cd $testroot/wt && got update > $testroot/stdout)
348 81a30460 2019-01-08 stsp
349 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
350 49c543a6 2022-03-31 naddy ret=$?
351 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
352 81a30460 2019-01-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
353 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
354 81a30460 2019-01-08 stsp return 1
355 81a30460 2019-01-08 stsp fi
356 81a30460 2019-01-08 stsp
357 50952927 2019-01-12 stsp echo "another change" > $testroot/repo/epsilon/zeta
358 50952927 2019-01-12 stsp git_commit $testroot/repo -m "changing epsilon/zeta again"
359 50952927 2019-01-12 stsp
360 50952927 2019-01-12 stsp echo "U epsilon/zeta" > $testroot/stdout.expected
361 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
362 50952927 2019-01-12 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
363 50952927 2019-01-12 stsp echo >> $testroot/stdout.expected
364 50952927 2019-01-12 stsp
365 50952927 2019-01-12 stsp (cd $testroot/wt && got update > $testroot/stdout)
366 50952927 2019-01-12 stsp
367 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
368 49c543a6 2022-03-31 naddy ret=$?
369 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
370 81a30460 2019-01-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
371 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
372 81a30460 2019-01-08 stsp return 1
373 81a30460 2019-01-08 stsp fi
374 81a30460 2019-01-08 stsp
375 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
376 49c543a6 2022-03-31 naddy ret=$?
377 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
378 50952927 2019-01-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
379 50952927 2019-01-12 stsp fi
380 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
381 81a30460 2019-01-08 stsp }
382 46cee7a3 2019-01-12 stsp
383 f6cae3ed 2020-09-13 naddy test_update_moves_files_upwards() {
384 46cee7a3 2019-01-12 stsp local testroot=`test_init update_moves_files_upwards`
385 46cee7a3 2019-01-12 stsp
386 46cee7a3 2019-01-12 stsp mkdir $testroot/repo/epsilon/psi
387 46cee7a3 2019-01-12 stsp echo mu > $testroot/repo/epsilon/psi/mu
388 46cee7a3 2019-01-12 stsp mkdir $testroot/repo/epsilon/psi/chi
389 46cee7a3 2019-01-12 stsp echo tau > $testroot/repo/epsilon/psi/chi/tau
390 46cee7a3 2019-01-12 stsp (cd $testroot/repo && git add .)
391 46cee7a3 2019-01-12 stsp git_commit $testroot/repo -m "adding a sub-directory beneath epsilon"
392 46cee7a3 2019-01-12 stsp
393 46cee7a3 2019-01-12 stsp got checkout $testroot/repo $testroot/wt > /dev/null
394 49c543a6 2022-03-31 naddy ret=$?
395 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
396 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
397 46cee7a3 2019-01-12 stsp return 1
398 46cee7a3 2019-01-12 stsp fi
399 81a30460 2019-01-08 stsp
400 46cee7a3 2019-01-12 stsp (cd $testroot/repo && git mv epsilon/psi/mu epsilon/mu)
401 46cee7a3 2019-01-12 stsp (cd $testroot/repo && git mv epsilon/psi/chi/tau epsilon/psi/tau)
402 46cee7a3 2019-01-12 stsp git_commit $testroot/repo -m "moving files upwards"
403 46cee7a3 2019-01-12 stsp
404 21908da4 2019-01-13 stsp echo "A epsilon/mu" > $testroot/stdout.expected
405 21908da4 2019-01-13 stsp echo "D epsilon/psi/chi/tau" >> $testroot/stdout.expected
406 46cee7a3 2019-01-12 stsp echo "D epsilon/psi/mu" >> $testroot/stdout.expected
407 bd4792ec 2019-01-13 stsp echo "A epsilon/psi/tau" >> $testroot/stdout.expected
408 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
409 46cee7a3 2019-01-12 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
410 46cee7a3 2019-01-12 stsp echo >> $testroot/stdout.expected
411 46cee7a3 2019-01-12 stsp
412 46cee7a3 2019-01-12 stsp (cd $testroot/wt && got update > $testroot/stdout)
413 46cee7a3 2019-01-12 stsp
414 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
415 49c543a6 2022-03-31 naddy ret=$?
416 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
417 46cee7a3 2019-01-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
418 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
419 46cee7a3 2019-01-12 stsp return 1
420 46cee7a3 2019-01-12 stsp fi
421 46cee7a3 2019-01-12 stsp
422 46cee7a3 2019-01-12 stsp if [ -e $testroot/wt/epsilon/psi/chi ]; then
423 46cee7a3 2019-01-12 stsp echo "removed dir epsilon/psi/chi still exists on disk" >&2
424 46cee7a3 2019-01-12 stsp test_done "$testroot" "1"
425 46cee7a3 2019-01-12 stsp return 1
426 46cee7a3 2019-01-12 stsp fi
427 46cee7a3 2019-01-12 stsp
428 46cee7a3 2019-01-12 stsp if [ -e $testroot/wt/epsilon/psi/mu ]; then
429 46cee7a3 2019-01-12 stsp echo "removed file epsilon/psi/mu still exists on disk" >&2
430 46cee7a3 2019-01-12 stsp test_done "$testroot" "1"
431 46cee7a3 2019-01-12 stsp return 1
432 46cee7a3 2019-01-12 stsp fi
433 46cee7a3 2019-01-12 stsp
434 46cee7a3 2019-01-12 stsp test_done "$testroot" "0"
435 46cee7a3 2019-01-12 stsp }
436 46cee7a3 2019-01-12 stsp
437 f6cae3ed 2020-09-13 naddy test_update_moves_files_to_new_dir() {
438 46cee7a3 2019-01-12 stsp local testroot=`test_init update_moves_files_to_new_dir`
439 46cee7a3 2019-01-12 stsp
440 46cee7a3 2019-01-12 stsp mkdir $testroot/repo/epsilon/psi
441 46cee7a3 2019-01-12 stsp echo mu > $testroot/repo/epsilon/psi/mu
442 46cee7a3 2019-01-12 stsp mkdir $testroot/repo/epsilon/psi/chi
443 46cee7a3 2019-01-12 stsp echo tau > $testroot/repo/epsilon/psi/chi/tau
444 46cee7a3 2019-01-12 stsp (cd $testroot/repo && git add .)
445 46cee7a3 2019-01-12 stsp git_commit $testroot/repo -m "adding a sub-directory beneath epsilon"
446 46cee7a3 2019-01-12 stsp
447 46cee7a3 2019-01-12 stsp got checkout $testroot/repo $testroot/wt > /dev/null
448 49c543a6 2022-03-31 naddy ret=$?
449 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
450 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
451 46cee7a3 2019-01-12 stsp return 1
452 46cee7a3 2019-01-12 stsp fi
453 46cee7a3 2019-01-12 stsp
454 46cee7a3 2019-01-12 stsp mkdir -p $testroot/repo/epsilon-new/psi
455 46cee7a3 2019-01-12 stsp (cd $testroot/repo && git mv epsilon/psi/mu epsilon-new/mu)
456 46cee7a3 2019-01-12 stsp (cd $testroot/repo && git mv epsilon/psi/chi/tau epsilon-new/psi/tau)
457 46cee7a3 2019-01-12 stsp git_commit $testroot/repo -m "moving files upwards"
458 46cee7a3 2019-01-12 stsp
459 f5d3d7af 2019-02-05 stsp echo "D epsilon/psi/chi/tau" > $testroot/stdout.expected
460 46cee7a3 2019-01-12 stsp echo "D epsilon/psi/mu" >> $testroot/stdout.expected
461 f5d3d7af 2019-02-05 stsp echo "A epsilon-new/mu" >> $testroot/stdout.expected
462 f5d3d7af 2019-02-05 stsp echo "A epsilon-new/psi/tau" >> $testroot/stdout.expected
463 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
464 46cee7a3 2019-01-12 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
465 46cee7a3 2019-01-12 stsp echo >> $testroot/stdout.expected
466 46cee7a3 2019-01-12 stsp
467 46cee7a3 2019-01-12 stsp (cd $testroot/wt && got update > $testroot/stdout)
468 46cee7a3 2019-01-12 stsp
469 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
470 49c543a6 2022-03-31 naddy ret=$?
471 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
472 46cee7a3 2019-01-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
473 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
474 46cee7a3 2019-01-12 stsp return 1
475 46cee7a3 2019-01-12 stsp fi
476 46cee7a3 2019-01-12 stsp
477 46cee7a3 2019-01-12 stsp if [ -e $testroot/wt/epsilon/psi/chi ]; then
478 46cee7a3 2019-01-12 stsp echo "removed dir epsilon/psi/chi still exists on disk" >&2
479 46cee7a3 2019-01-12 stsp test_done "$testroot" "1"
480 46cee7a3 2019-01-12 stsp return 1
481 46cee7a3 2019-01-12 stsp fi
482 46cee7a3 2019-01-12 stsp
483 46cee7a3 2019-01-12 stsp if [ -e $testroot/wt/epsilon/psi/mu ]; then
484 46cee7a3 2019-01-12 stsp echo "removed file epsilon/psi/mu still exists on disk" >&2
485 46cee7a3 2019-01-12 stsp test_done "$testroot" "1"
486 4a1ddfc2 2019-01-12 stsp return 1
487 4a1ddfc2 2019-01-12 stsp fi
488 4a1ddfc2 2019-01-12 stsp
489 4a1ddfc2 2019-01-12 stsp test_done "$testroot" "0"
490 4a1ddfc2 2019-01-12 stsp }
491 4a1ddfc2 2019-01-12 stsp
492 f6cae3ed 2020-09-13 naddy test_update_creates_missing_parent() {
493 1aad446a 2019-01-13 stsp local testroot=`test_init update_creates_missing_parent 1`
494 4a1ddfc2 2019-01-12 stsp
495 4a1ddfc2 2019-01-12 stsp touch $testroot/repo/Makefile
496 4a1ddfc2 2019-01-12 stsp touch $testroot/repo/snake.6
497 4a1ddfc2 2019-01-12 stsp touch $testroot/repo/snake.c
498 4a1ddfc2 2019-01-12 stsp (cd $testroot/repo && git add .)
499 4a1ddfc2 2019-01-12 stsp git_commit $testroot/repo -m "adding initial snake tree"
500 4a1ddfc2 2019-01-12 stsp
501 4a1ddfc2 2019-01-12 stsp got checkout $testroot/repo $testroot/wt > /dev/null
502 49c543a6 2022-03-31 naddy ret=$?
503 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
504 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
505 4a1ddfc2 2019-01-12 stsp return 1
506 4a1ddfc2 2019-01-12 stsp fi
507 4a1ddfc2 2019-01-12 stsp
508 4a1ddfc2 2019-01-12 stsp mkdir -p $testroot/repo/snake
509 4a1ddfc2 2019-01-12 stsp (cd $testroot/repo && git mv Makefile snake.6 snake.c snake)
510 4a1ddfc2 2019-01-12 stsp touch $testroot/repo/snake/move.c
511 4a1ddfc2 2019-01-12 stsp touch $testroot/repo/snake/pathnames.h
512 4a1ddfc2 2019-01-12 stsp touch $testroot/repo/snake/snake.h
513 4a1ddfc2 2019-01-12 stsp mkdir -p $testroot/repo/snscore
514 4a1ddfc2 2019-01-12 stsp touch $testroot/repo/snscore/Makefile
515 4a1ddfc2 2019-01-12 stsp touch $testroot/repo/snscore/snscore.c
516 4a1ddfc2 2019-01-12 stsp (cd $testroot/repo && git add .)
517 4a1ddfc2 2019-01-12 stsp git_commit $testroot/repo -m "restructuring snake tree"
518 4a1ddfc2 2019-01-12 stsp
519 4a1ddfc2 2019-01-12 stsp echo "D Makefile" > $testroot/stdout.expected
520 4a1ddfc2 2019-01-12 stsp echo "A snake/Makefile" >> $testroot/stdout.expected
521 4a1ddfc2 2019-01-12 stsp echo "A snake/move.c" >> $testroot/stdout.expected
522 4a1ddfc2 2019-01-12 stsp echo "A snake/pathnames.h" >> $testroot/stdout.expected
523 4a1ddfc2 2019-01-12 stsp echo "A snake/snake.6" >> $testroot/stdout.expected
524 4a1ddfc2 2019-01-12 stsp echo "A snake/snake.c" >> $testroot/stdout.expected
525 4a1ddfc2 2019-01-12 stsp echo "A snake/snake.h" >> $testroot/stdout.expected
526 18831e78 2019-02-10 stsp echo "D snake.6" >> $testroot/stdout.expected
527 18831e78 2019-02-10 stsp echo "D snake.c" >> $testroot/stdout.expected
528 bd4792ec 2019-01-13 stsp echo "A snscore/Makefile" >> $testroot/stdout.expected
529 bd4792ec 2019-01-13 stsp echo "A snscore/snscore.c" >> $testroot/stdout.expected
530 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
531 bd4792ec 2019-01-13 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
532 bd4792ec 2019-01-13 stsp echo >> $testroot/stdout.expected
533 bd4792ec 2019-01-13 stsp
534 bd4792ec 2019-01-13 stsp (cd $testroot/wt && got update > $testroot/stdout)
535 bd4792ec 2019-01-13 stsp
536 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
537 49c543a6 2022-03-31 naddy ret=$?
538 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
539 e60e7f5b 2019-02-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
540 bd4792ec 2019-01-13 stsp fi
541 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
542 bd4792ec 2019-01-13 stsp }
543 bd4792ec 2019-01-13 stsp
544 f6cae3ed 2020-09-13 naddy test_update_creates_missing_parent_with_subdir() {
545 1aad446a 2019-01-13 stsp local testroot=`test_init update_creates_missing_parent_with_subdir 1`
546 bd4792ec 2019-01-13 stsp
547 bd4792ec 2019-01-13 stsp touch $testroot/repo/Makefile
548 bd4792ec 2019-01-13 stsp touch $testroot/repo/snake.6
549 bd4792ec 2019-01-13 stsp touch $testroot/repo/snake.c
550 bd4792ec 2019-01-13 stsp (cd $testroot/repo && git add .)
551 bd4792ec 2019-01-13 stsp git_commit $testroot/repo -m "adding initial snake tree"
552 bd4792ec 2019-01-13 stsp
553 bd4792ec 2019-01-13 stsp got checkout $testroot/repo $testroot/wt > /dev/null
554 49c543a6 2022-03-31 naddy ret=$?
555 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
556 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
557 bd4792ec 2019-01-13 stsp return 1
558 bd4792ec 2019-01-13 stsp fi
559 bd4792ec 2019-01-13 stsp
560 bd4792ec 2019-01-13 stsp mkdir -p $testroot/repo/sss/snake
561 bd4792ec 2019-01-13 stsp (cd $testroot/repo && git mv Makefile snake.6 snake.c sss/snake)
562 bd4792ec 2019-01-13 stsp touch $testroot/repo/sss/snake/move.c
563 bd4792ec 2019-01-13 stsp touch $testroot/repo/sss/snake/pathnames.h
564 bd4792ec 2019-01-13 stsp touch $testroot/repo/sss/snake/snake.h
565 bd4792ec 2019-01-13 stsp mkdir -p $testroot/repo/snscore
566 bd4792ec 2019-01-13 stsp touch $testroot/repo/snscore/Makefile
567 bd4792ec 2019-01-13 stsp touch $testroot/repo/snscore/snscore.c
568 bd4792ec 2019-01-13 stsp (cd $testroot/repo && git add .)
569 bd4792ec 2019-01-13 stsp git_commit $testroot/repo -m "restructuring snake tree"
570 bd4792ec 2019-01-13 stsp
571 bd4792ec 2019-01-13 stsp echo "D Makefile" > $testroot/stdout.expected
572 4a1ddfc2 2019-01-12 stsp echo "D snake.6" >> $testroot/stdout.expected
573 4a1ddfc2 2019-01-12 stsp echo "D snake.c" >> $testroot/stdout.expected
574 4a1ddfc2 2019-01-12 stsp echo "A snscore/Makefile" >> $testroot/stdout.expected
575 4a1ddfc2 2019-01-12 stsp echo "A snscore/snscore.c" >> $testroot/stdout.expected
576 bd4792ec 2019-01-13 stsp echo "A sss/snake/Makefile" >> $testroot/stdout.expected
577 bd4792ec 2019-01-13 stsp echo "A sss/snake/move.c" >> $testroot/stdout.expected
578 bd4792ec 2019-01-13 stsp echo "A sss/snake/pathnames.h" >> $testroot/stdout.expected
579 bd4792ec 2019-01-13 stsp echo "A sss/snake/snake.6" >> $testroot/stdout.expected
580 bd4792ec 2019-01-13 stsp echo "A sss/snake/snake.c" >> $testroot/stdout.expected
581 bd4792ec 2019-01-13 stsp echo "A sss/snake/snake.h" >> $testroot/stdout.expected
582 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
583 4a1ddfc2 2019-01-12 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
584 4a1ddfc2 2019-01-12 stsp echo >> $testroot/stdout.expected
585 4a1ddfc2 2019-01-12 stsp
586 4a1ddfc2 2019-01-12 stsp (cd $testroot/wt && got update > $testroot/stdout)
587 4a1ddfc2 2019-01-12 stsp
588 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
589 49c543a6 2022-03-31 naddy ret=$?
590 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
591 4a1ddfc2 2019-01-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
592 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
593 46cee7a3 2019-01-12 stsp return 1
594 46cee7a3 2019-01-12 stsp fi
595 46cee7a3 2019-01-12 stsp
596 46cee7a3 2019-01-12 stsp test_done "$testroot" "0"
597 46cee7a3 2019-01-12 stsp }
598 21908da4 2019-01-13 stsp
599 f6cae3ed 2020-09-13 naddy test_update_file_in_subsubdir() {
600 1aad446a 2019-01-13 stsp local testroot=`test_init update_fle_in_subsubdir 1`
601 46cee7a3 2019-01-12 stsp
602 21908da4 2019-01-13 stsp touch $testroot/repo/Makefile
603 21908da4 2019-01-13 stsp mkdir -p $testroot/repo/altq
604 21908da4 2019-01-13 stsp touch $testroot/repo/altq/if_altq.h
605 21908da4 2019-01-13 stsp mkdir -p $testroot/repo/arch/alpha
606 21908da4 2019-01-13 stsp touch $testroot/repo/arch/alpha/Makefile
607 21908da4 2019-01-13 stsp (cd $testroot/repo && git add .)
608 21908da4 2019-01-13 stsp git_commit $testroot/repo -m "adding initial tree"
609 21908da4 2019-01-13 stsp
610 21908da4 2019-01-13 stsp got checkout $testroot/repo $testroot/wt > /dev/null
611 49c543a6 2022-03-31 naddy ret=$?
612 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
613 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
614 21908da4 2019-01-13 stsp return 1
615 21908da4 2019-01-13 stsp fi
616 21908da4 2019-01-13 stsp
617 21908da4 2019-01-13 stsp echo change > $testroot/repo/arch/alpha/Makefile
618 21908da4 2019-01-13 stsp (cd $testroot/repo && git add .)
619 21908da4 2019-01-13 stsp git_commit $testroot/repo -m "changed a file"
620 21908da4 2019-01-13 stsp
621 21908da4 2019-01-13 stsp echo "U arch/alpha/Makefile" > $testroot/stdout.expected
622 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
623 21908da4 2019-01-13 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
624 21908da4 2019-01-13 stsp echo >> $testroot/stdout.expected
625 21908da4 2019-01-13 stsp
626 21908da4 2019-01-13 stsp (cd $testroot/wt && got update > $testroot/stdout)
627 21908da4 2019-01-13 stsp
628 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
629 49c543a6 2022-03-31 naddy ret=$?
630 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
631 21908da4 2019-01-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
632 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
633 21908da4 2019-01-13 stsp return 1
634 21908da4 2019-01-13 stsp fi
635 21908da4 2019-01-13 stsp
636 21908da4 2019-01-13 stsp test_done "$testroot" "0"
637 21908da4 2019-01-13 stsp }
638 6353ad76 2019-02-08 stsp
639 f6cae3ed 2020-09-13 naddy test_update_merges_file_edits() {
640 6353ad76 2019-02-08 stsp local testroot=`test_init update_merges_file_edits`
641 6353ad76 2019-02-08 stsp
642 6353ad76 2019-02-08 stsp echo "1" > $testroot/repo/numbers
643 6353ad76 2019-02-08 stsp echo "2" >> $testroot/repo/numbers
644 6353ad76 2019-02-08 stsp echo "3" >> $testroot/repo/numbers
645 6353ad76 2019-02-08 stsp echo "4" >> $testroot/repo/numbers
646 6353ad76 2019-02-08 stsp echo "5" >> $testroot/repo/numbers
647 6353ad76 2019-02-08 stsp echo "6" >> $testroot/repo/numbers
648 6353ad76 2019-02-08 stsp echo "7" >> $testroot/repo/numbers
649 6353ad76 2019-02-08 stsp echo "8" >> $testroot/repo/numbers
650 6353ad76 2019-02-08 stsp (cd $testroot/repo && git add numbers)
651 6353ad76 2019-02-08 stsp git_commit $testroot/repo -m "added numbers file"
652 f69721c3 2019-10-21 stsp local base_commit=`git_show_head $testroot/repo`
653 21908da4 2019-01-13 stsp
654 6353ad76 2019-02-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
655 49c543a6 2022-03-31 naddy ret=$?
656 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
657 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
658 6353ad76 2019-02-08 stsp return 1
659 6353ad76 2019-02-08 stsp fi
660 6353ad76 2019-02-08 stsp
661 6353ad76 2019-02-08 stsp echo "modified alpha" > $testroot/repo/alpha
662 6353ad76 2019-02-08 stsp echo "modified beta" > $testroot/repo/beta
663 6353ad76 2019-02-08 stsp sed -i 's/2/22/' $testroot/repo/numbers
664 6353ad76 2019-02-08 stsp git_commit $testroot/repo -m "modified 3 files"
665 6353ad76 2019-02-08 stsp
666 6353ad76 2019-02-08 stsp echo "modified alpha, too" > $testroot/wt/alpha
667 6353ad76 2019-02-08 stsp touch $testroot/wt/beta
668 6353ad76 2019-02-08 stsp sed -i 's/7/77/' $testroot/wt/numbers
669 6353ad76 2019-02-08 stsp
670 6353ad76 2019-02-08 stsp echo "C alpha" > $testroot/stdout.expected
671 6353ad76 2019-02-08 stsp echo "U beta" >> $testroot/stdout.expected
672 6353ad76 2019-02-08 stsp echo "G numbers" >> $testroot/stdout.expected
673 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
674 6353ad76 2019-02-08 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
675 6353ad76 2019-02-08 stsp echo >> $testroot/stdout.expected
676 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
677 6353ad76 2019-02-08 stsp
678 6353ad76 2019-02-08 stsp (cd $testroot/wt && got update > $testroot/stdout)
679 6353ad76 2019-02-08 stsp
680 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
681 49c543a6 2022-03-31 naddy ret=$?
682 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
683 6353ad76 2019-02-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
684 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
685 6353ad76 2019-02-08 stsp return 1
686 6353ad76 2019-02-08 stsp fi
687 6353ad76 2019-02-08 stsp
688 f69721c3 2019-10-21 stsp echo -n "<<<<<<< merged change: commit " > $testroot/content.expected
689 6353ad76 2019-02-08 stsp git_show_head $testroot/repo >> $testroot/content.expected
690 6353ad76 2019-02-08 stsp echo >> $testroot/content.expected
691 6353ad76 2019-02-08 stsp echo "modified alpha" >> $testroot/content.expected
692 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $base_commit" \
693 f69721c3 2019-10-21 stsp >> $testroot/content.expected
694 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
695 6353ad76 2019-02-08 stsp echo "=======" >> $testroot/content.expected
696 6353ad76 2019-02-08 stsp echo "modified alpha, too" >> $testroot/content.expected
697 f69721c3 2019-10-21 stsp echo '>>>>>>>' >> $testroot/content.expected
698 6353ad76 2019-02-08 stsp echo "modified beta" >> $testroot/content.expected
699 6353ad76 2019-02-08 stsp echo "1" >> $testroot/content.expected
700 6353ad76 2019-02-08 stsp echo "22" >> $testroot/content.expected
701 6353ad76 2019-02-08 stsp echo "3" >> $testroot/content.expected
702 6353ad76 2019-02-08 stsp echo "4" >> $testroot/content.expected
703 6353ad76 2019-02-08 stsp echo "5" >> $testroot/content.expected
704 6353ad76 2019-02-08 stsp echo "6" >> $testroot/content.expected
705 6353ad76 2019-02-08 stsp echo "77" >> $testroot/content.expected
706 6353ad76 2019-02-08 stsp echo "8" >> $testroot/content.expected
707 6353ad76 2019-02-08 stsp
708 6353ad76 2019-02-08 stsp cat $testroot/wt/alpha > $testroot/content
709 6353ad76 2019-02-08 stsp cat $testroot/wt/beta >> $testroot/content
710 6353ad76 2019-02-08 stsp cat $testroot/wt/numbers >> $testroot/content
711 6353ad76 2019-02-08 stsp
712 8d301dd9 2019-05-14 stsp cmp -s $testroot/content.expected $testroot/content
713 49c543a6 2022-03-31 naddy ret=$?
714 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
715 6353ad76 2019-02-08 stsp diff -u $testroot/content.expected $testroot/content
716 68ed9ba5 2019-02-10 stsp fi
717 68ed9ba5 2019-02-10 stsp test_done "$testroot" "$ret"
718 68ed9ba5 2019-02-10 stsp }
719 68ed9ba5 2019-02-10 stsp
720 f6cae3ed 2020-09-13 naddy test_update_keeps_xbit() {
721 68ed9ba5 2019-02-10 stsp local testroot=`test_init update_keeps_xbit 1`
722 68ed9ba5 2019-02-10 stsp
723 68ed9ba5 2019-02-10 stsp touch $testroot/repo/xfile
724 68ed9ba5 2019-02-10 stsp chmod +x $testroot/repo/xfile
725 68ed9ba5 2019-02-10 stsp (cd $testroot/repo && git add .)
726 68ed9ba5 2019-02-10 stsp git_commit $testroot/repo -m "adding executable file"
727 68ed9ba5 2019-02-10 stsp
728 68ed9ba5 2019-02-10 stsp got checkout $testroot/repo $testroot/wt > $testroot/stdout
729 49c543a6 2022-03-31 naddy ret=$?
730 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
731 68ed9ba5 2019-02-10 stsp test_done "$testroot" "$ret"
732 68ed9ba5 2019-02-10 stsp return 1
733 68ed9ba5 2019-02-10 stsp fi
734 68ed9ba5 2019-02-10 stsp
735 68ed9ba5 2019-02-10 stsp echo foo > $testroot/repo/xfile
736 68ed9ba5 2019-02-10 stsp git_commit $testroot/repo -m "changed executable file"
737 68ed9ba5 2019-02-10 stsp
738 68ed9ba5 2019-02-10 stsp echo "U xfile" > $testroot/stdout.expected
739 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
740 68ed9ba5 2019-02-10 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
741 68ed9ba5 2019-02-10 stsp echo >> $testroot/stdout.expected
742 68ed9ba5 2019-02-10 stsp
743 68ed9ba5 2019-02-10 stsp (cd $testroot/wt && got update > $testroot/stdout)
744 49c543a6 2022-03-31 naddy ret=$?
745 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
746 68ed9ba5 2019-02-10 stsp test_done "$testroot" "$ret"
747 68ed9ba5 2019-02-10 stsp return 1
748 6353ad76 2019-02-08 stsp fi
749 68ed9ba5 2019-02-10 stsp
750 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
751 49c543a6 2022-03-31 naddy ret=$?
752 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
753 68ed9ba5 2019-02-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
754 68ed9ba5 2019-02-10 stsp test_done "$testroot" "$ret"
755 68ed9ba5 2019-02-10 stsp return 1
756 68ed9ba5 2019-02-10 stsp fi
757 68ed9ba5 2019-02-10 stsp
758 68ed9ba5 2019-02-10 stsp ls -l $testroot/wt/xfile | grep -q '^-rwx'
759 49c543a6 2022-03-31 naddy ret=$?
760 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
761 68ed9ba5 2019-02-10 stsp echo "file is not executable" >&2
762 68ed9ba5 2019-02-10 stsp ls -l $testroot/wt/xfile >&2
763 68ed9ba5 2019-02-10 stsp fi
764 6353ad76 2019-02-08 stsp test_done "$testroot" "$ret"
765 6353ad76 2019-02-08 stsp }
766 ba8a0d4d 2019-02-10 stsp
767 f6cae3ed 2020-09-13 naddy test_update_clears_xbit() {
768 ba8a0d4d 2019-02-10 stsp local testroot=`test_init update_clears_xbit 1`
769 ba8a0d4d 2019-02-10 stsp
770 ba8a0d4d 2019-02-10 stsp touch $testroot/repo/xfile
771 ba8a0d4d 2019-02-10 stsp chmod +x $testroot/repo/xfile
772 ba8a0d4d 2019-02-10 stsp (cd $testroot/repo && git add .)
773 ba8a0d4d 2019-02-10 stsp git_commit $testroot/repo -m "adding executable file"
774 6353ad76 2019-02-08 stsp
775 ba8a0d4d 2019-02-10 stsp got checkout $testroot/repo $testroot/wt > $testroot/stdout
776 49c543a6 2022-03-31 naddy ret=$?
777 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
778 ba8a0d4d 2019-02-10 stsp test_done "$testroot" "$ret"
779 ba8a0d4d 2019-02-10 stsp return 1
780 ba8a0d4d 2019-02-10 stsp fi
781 ba8a0d4d 2019-02-10 stsp
782 ba8a0d4d 2019-02-10 stsp ls -l $testroot/wt/xfile | grep -q '^-rwx'
783 49c543a6 2022-03-31 naddy ret=$?
784 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
785 ba8a0d4d 2019-02-10 stsp echo "file is not executable" >&2
786 ba8a0d4d 2019-02-10 stsp ls -l $testroot/wt/xfile >&2
787 ba8a0d4d 2019-02-10 stsp test_done "$testroot" "$ret"
788 ba8a0d4d 2019-02-10 stsp return 1
789 ba8a0d4d 2019-02-10 stsp fi
790 ba8a0d4d 2019-02-10 stsp
791 ba8a0d4d 2019-02-10 stsp # XXX git seems to require a file edit when flipping the x bit?
792 ba8a0d4d 2019-02-10 stsp echo foo > $testroot/repo/xfile
793 ba8a0d4d 2019-02-10 stsp chmod -x $testroot/repo/xfile
794 ba8a0d4d 2019-02-10 stsp git_commit $testroot/repo -m "not an executable file anymore"
795 ba8a0d4d 2019-02-10 stsp
796 ba8a0d4d 2019-02-10 stsp echo "U xfile" > $testroot/stdout.expected
797 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
798 ba8a0d4d 2019-02-10 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
799 ba8a0d4d 2019-02-10 stsp echo >> $testroot/stdout.expected
800 ba8a0d4d 2019-02-10 stsp
801 ba8a0d4d 2019-02-10 stsp (cd $testroot/wt && got update > $testroot/stdout)
802 49c543a6 2022-03-31 naddy ret=$?
803 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
804 ba8a0d4d 2019-02-10 stsp test_done "$testroot" "$ret"
805 ba8a0d4d 2019-02-10 stsp return 1
806 ba8a0d4d 2019-02-10 stsp fi
807 ba8a0d4d 2019-02-10 stsp
808 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
809 49c543a6 2022-03-31 naddy ret=$?
810 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
811 ba8a0d4d 2019-02-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
812 ba8a0d4d 2019-02-10 stsp test_done "$testroot" "$ret"
813 ba8a0d4d 2019-02-10 stsp return 1
814 ba8a0d4d 2019-02-10 stsp fi
815 ba8a0d4d 2019-02-10 stsp
816 ba8a0d4d 2019-02-10 stsp ls -l $testroot/wt/xfile | grep -q '^-rw-'
817 49c543a6 2022-03-31 naddy ret=$?
818 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
819 ba8a0d4d 2019-02-10 stsp echo "file is unexpectedly executable" >&2
820 ba8a0d4d 2019-02-10 stsp ls -l $testroot/wt/xfile >&2
821 ba8a0d4d 2019-02-10 stsp fi
822 ba8a0d4d 2019-02-10 stsp test_done "$testroot" "$ret"
823 ba8a0d4d 2019-02-10 stsp }
824 a378724f 2019-02-10 stsp
825 f6cae3ed 2020-09-13 naddy test_update_restores_missing_file() {
826 a378724f 2019-02-10 stsp local testroot=`test_init update_restores_missing_file`
827 a378724f 2019-02-10 stsp
828 a378724f 2019-02-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
829 49c543a6 2022-03-31 naddy ret=$?
830 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
831 a378724f 2019-02-10 stsp test_done "$testroot" "$ret"
832 a378724f 2019-02-10 stsp return 1
833 a378724f 2019-02-10 stsp fi
834 ba8a0d4d 2019-02-10 stsp
835 a378724f 2019-02-10 stsp rm $testroot/wt/alpha
836 a378724f 2019-02-10 stsp
837 a378724f 2019-02-10 stsp echo "! alpha" > $testroot/stdout.expected
838 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
839 1545c615 2019-02-10 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
840 1545c615 2019-02-10 stsp echo >> $testroot/stdout.expected
841 a378724f 2019-02-10 stsp (cd $testroot/wt && got update > $testroot/stdout)
842 a378724f 2019-02-10 stsp
843 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
844 49c543a6 2022-03-31 naddy ret=$?
845 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
846 a378724f 2019-02-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
847 a378724f 2019-02-10 stsp test_done "$testroot" "$ret"
848 a378724f 2019-02-10 stsp return 1
849 a378724f 2019-02-10 stsp fi
850 a378724f 2019-02-10 stsp
851 a378724f 2019-02-10 stsp echo "alpha" > $testroot/content.expected
852 a378724f 2019-02-10 stsp
853 a378724f 2019-02-10 stsp cat $testroot/wt/alpha > $testroot/content
854 1430b4e0 2019-03-27 stsp
855 8d301dd9 2019-05-14 stsp cmp -s $testroot/content.expected $testroot/content
856 49c543a6 2022-03-31 naddy ret=$?
857 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
858 1430b4e0 2019-03-27 stsp diff -u $testroot/content.expected $testroot/content
859 1430b4e0 2019-03-27 stsp fi
860 1430b4e0 2019-03-27 stsp test_done "$testroot" "$ret"
861 1430b4e0 2019-03-27 stsp }
862 1430b4e0 2019-03-27 stsp
863 f6cae3ed 2020-09-13 naddy test_update_conflict_wt_add_vs_repo_add() {
864 085d5bcf 2019-03-27 stsp local testroot=`test_init update_conflict_wt_add_vs_repo_add`
865 1430b4e0 2019-03-27 stsp
866 1430b4e0 2019-03-27 stsp got checkout $testroot/repo $testroot/wt > /dev/null
867 49c543a6 2022-03-31 naddy ret=$?
868 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
869 1430b4e0 2019-03-27 stsp test_done "$testroot" "$ret"
870 1430b4e0 2019-03-27 stsp return 1
871 1430b4e0 2019-03-27 stsp fi
872 1430b4e0 2019-03-27 stsp
873 1430b4e0 2019-03-27 stsp echo "new" > $testroot/repo/gamma/new
874 1430b4e0 2019-03-27 stsp (cd $testroot/repo && git add .)
875 1430b4e0 2019-03-27 stsp git_commit $testroot/repo -m "adding a new file"
876 1430b4e0 2019-03-27 stsp
877 1430b4e0 2019-03-27 stsp echo "also new" > $testroot/wt/gamma/new
878 1430b4e0 2019-03-27 stsp (cd $testroot/wt && got add gamma/new >/dev/null)
879 1430b4e0 2019-03-27 stsp
880 1430b4e0 2019-03-27 stsp (cd $testroot/wt && got update > $testroot/stdout)
881 a378724f 2019-02-10 stsp
882 1430b4e0 2019-03-27 stsp echo "C gamma/new" > $testroot/stdout.expected
883 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
884 1430b4e0 2019-03-27 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
885 1430b4e0 2019-03-27 stsp echo >> $testroot/stdout.expected
886 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
887 9627c110 2020-04-18 stsp
888 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
889 49c543a6 2022-03-31 naddy ret=$?
890 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
891 1430b4e0 2019-03-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
892 1430b4e0 2019-03-27 stsp test_done "$testroot" "$ret"
893 1430b4e0 2019-03-27 stsp return 1
894 1430b4e0 2019-03-27 stsp fi
895 1430b4e0 2019-03-27 stsp
896 f69721c3 2019-10-21 stsp echo -n "<<<<<<< merged change: commit " > $testroot/content.expected
897 1430b4e0 2019-03-27 stsp git_show_head $testroot/repo >> $testroot/content.expected
898 1430b4e0 2019-03-27 stsp echo >> $testroot/content.expected
899 1430b4e0 2019-03-27 stsp echo "new" >> $testroot/content.expected
900 1430b4e0 2019-03-27 stsp echo "=======" >> $testroot/content.expected
901 1430b4e0 2019-03-27 stsp echo "also new" >> $testroot/content.expected
902 f69721c3 2019-10-21 stsp echo '>>>>>>>' >> $testroot/content.expected
903 1430b4e0 2019-03-27 stsp
904 1430b4e0 2019-03-27 stsp cat $testroot/wt/gamma/new > $testroot/content
905 1430b4e0 2019-03-27 stsp
906 8d301dd9 2019-05-14 stsp cmp -s $testroot/content.expected $testroot/content
907 49c543a6 2022-03-31 naddy ret=$?
908 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
909 a378724f 2019-02-10 stsp diff -u $testroot/content.expected $testroot/content
910 3165301c 2019-03-27 stsp test_done "$testroot" "$ret"
911 3165301c 2019-03-27 stsp return 1
912 3165301c 2019-03-27 stsp fi
913 3165301c 2019-03-27 stsp
914 3165301c 2019-03-27 stsp # resolve the conflict
915 3165301c 2019-03-27 stsp echo "new and also new" > $testroot/wt/gamma/new
916 3165301c 2019-03-27 stsp echo 'M gamma/new' > $testroot/stdout.expected
917 3165301c 2019-03-27 stsp (cd $testroot/wt && got status > $testroot/stdout)
918 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
919 49c543a6 2022-03-31 naddy ret=$?
920 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
921 3165301c 2019-03-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
922 a378724f 2019-02-10 stsp fi
923 a378724f 2019-02-10 stsp test_done "$testroot" "$ret"
924 a378724f 2019-02-10 stsp }
925 708d8e67 2019-03-27 stsp
926 f6cae3ed 2020-09-13 naddy test_update_conflict_wt_edit_vs_repo_rm() {
927 085d5bcf 2019-03-27 stsp local testroot=`test_init update_conflict_wt_edit_vs_repo_rm`
928 708d8e67 2019-03-27 stsp
929 708d8e67 2019-03-27 stsp got checkout $testroot/repo $testroot/wt > /dev/null
930 49c543a6 2022-03-31 naddy ret=$?
931 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
932 708d8e67 2019-03-27 stsp test_done "$testroot" "$ret"
933 708d8e67 2019-03-27 stsp return 1
934 708d8e67 2019-03-27 stsp fi
935 708d8e67 2019-03-27 stsp
936 708d8e67 2019-03-27 stsp (cd $testroot/repo && git rm -q beta)
937 708d8e67 2019-03-27 stsp git_commit $testroot/repo -m "removing a file"
938 708d8e67 2019-03-27 stsp
939 708d8e67 2019-03-27 stsp echo "modified beta" > $testroot/wt/beta
940 a378724f 2019-02-10 stsp
941 708d8e67 2019-03-27 stsp (cd $testroot/wt && got update > $testroot/stdout)
942 708d8e67 2019-03-27 stsp
943 fc6346c4 2019-03-27 stsp echo "G beta" > $testroot/stdout.expected
944 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
945 708d8e67 2019-03-27 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
946 708d8e67 2019-03-27 stsp echo >> $testroot/stdout.expected
947 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
948 49c543a6 2022-03-31 naddy ret=$?
949 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
950 708d8e67 2019-03-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
951 708d8e67 2019-03-27 stsp test_done "$testroot" "$ret"
952 708d8e67 2019-03-27 stsp return 1
953 708d8e67 2019-03-27 stsp fi
954 708d8e67 2019-03-27 stsp
955 708d8e67 2019-03-27 stsp echo "modified beta" > $testroot/content.expected
956 708d8e67 2019-03-27 stsp
957 708d8e67 2019-03-27 stsp cat $testroot/wt/beta > $testroot/content
958 708d8e67 2019-03-27 stsp
959 8d301dd9 2019-05-14 stsp cmp -s $testroot/content.expected $testroot/content
960 49c543a6 2022-03-31 naddy ret=$?
961 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
962 708d8e67 2019-03-27 stsp diff -u $testroot/content.expected $testroot/content
963 708d8e67 2019-03-27 stsp test_done "$testroot" "$ret"
964 708d8e67 2019-03-27 stsp return 1
965 708d8e67 2019-03-27 stsp fi
966 708d8e67 2019-03-27 stsp
967 fc6346c4 2019-03-27 stsp # beta is now an added file... we don't flag tree conflicts yet
968 fc6346c4 2019-03-27 stsp echo 'A beta' > $testroot/stdout.expected
969 13d9040b 2019-03-27 stsp (cd $testroot/wt && got status > $testroot/stdout)
970 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
971 49c543a6 2022-03-31 naddy ret=$?
972 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
973 13d9040b 2019-03-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
974 13d9040b 2019-03-27 stsp fi
975 13d9040b 2019-03-27 stsp test_done "$testroot" "$ret"
976 13d9040b 2019-03-27 stsp }
977 13d9040b 2019-03-27 stsp
978 f6cae3ed 2020-09-13 naddy test_update_conflict_wt_rm_vs_repo_edit() {
979 13d9040b 2019-03-27 stsp local testroot=`test_init update_conflict_wt_rm_vs_repo_edit`
980 13d9040b 2019-03-27 stsp
981 13d9040b 2019-03-27 stsp got checkout $testroot/repo $testroot/wt > /dev/null
982 49c543a6 2022-03-31 naddy ret=$?
983 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
984 13d9040b 2019-03-27 stsp test_done "$testroot" "$ret"
985 13d9040b 2019-03-27 stsp return 1
986 13d9040b 2019-03-27 stsp fi
987 13d9040b 2019-03-27 stsp
988 13d9040b 2019-03-27 stsp echo "modified beta" > $testroot/repo/beta
989 13d9040b 2019-03-27 stsp git_commit $testroot/repo -m "modified a file"
990 13d9040b 2019-03-27 stsp
991 13d9040b 2019-03-27 stsp (cd $testroot/wt && got rm beta > /dev/null)
992 13d9040b 2019-03-27 stsp
993 13d9040b 2019-03-27 stsp (cd $testroot/wt && got update > $testroot/stdout)
994 13d9040b 2019-03-27 stsp
995 13d9040b 2019-03-27 stsp echo "G beta" > $testroot/stdout.expected
996 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
997 13d9040b 2019-03-27 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
998 13d9040b 2019-03-27 stsp echo >> $testroot/stdout.expected
999 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1000 49c543a6 2022-03-31 naddy ret=$?
1001 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1002 13d9040b 2019-03-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
1003 13d9040b 2019-03-27 stsp test_done "$testroot" "$ret"
1004 13d9040b 2019-03-27 stsp return 1
1005 13d9040b 2019-03-27 stsp fi
1006 13d9040b 2019-03-27 stsp
1007 13d9040b 2019-03-27 stsp # beta remains a deleted file... we don't flag tree conflicts yet
1008 13d9040b 2019-03-27 stsp echo 'D beta' > $testroot/stdout.expected
1009 708d8e67 2019-03-27 stsp (cd $testroot/wt && got status > $testroot/stdout)
1010 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1011 49c543a6 2022-03-31 naddy ret=$?
1012 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1013 708d8e67 2019-03-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
1014 13d9040b 2019-03-27 stsp test_done "$testroot" "$ret"
1015 13d9040b 2019-03-27 stsp return 1
1016 708d8e67 2019-03-27 stsp fi
1017 13d9040b 2019-03-27 stsp
1018 13d9040b 2019-03-27 stsp # 'got diff' should show post-update contents of beta being deleted
1019 13d9040b 2019-03-27 stsp local head_rev=`git_show_head $testroot/repo`
1020 13d9040b 2019-03-27 stsp echo "diff $head_rev $testroot/wt" > $testroot/stdout.expected
1021 13d9040b 2019-03-27 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1022 13d9040b 2019-03-27 stsp got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
1023 13d9040b 2019-03-27 stsp >> $testroot/stdout.expected
1024 13d9040b 2019-03-27 stsp echo 'file + /dev/null' >> $testroot/stdout.expected
1025 13d9040b 2019-03-27 stsp echo '--- beta' >> $testroot/stdout.expected
1026 1cb46f00 2020-11-21 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
1027 13d9040b 2019-03-27 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1028 13d9040b 2019-03-27 stsp echo '-modified beta' >> $testroot/stdout.expected
1029 13d9040b 2019-03-27 stsp
1030 13d9040b 2019-03-27 stsp (cd $testroot/wt && got diff > $testroot/stdout)
1031 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1032 49c543a6 2022-03-31 naddy ret=$?
1033 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1034 13d9040b 2019-03-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
1035 13d9040b 2019-03-27 stsp fi
1036 708d8e67 2019-03-27 stsp test_done "$testroot" "$ret"
1037 66b11bf5 2019-03-27 stsp }
1038 66b11bf5 2019-03-27 stsp
1039 f6cae3ed 2020-09-13 naddy test_update_conflict_wt_rm_vs_repo_rm() {
1040 66b11bf5 2019-03-27 stsp local testroot=`test_init update_conflict_wt_rm_vs_repo_rm`
1041 66b11bf5 2019-03-27 stsp
1042 66b11bf5 2019-03-27 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1043 49c543a6 2022-03-31 naddy ret=$?
1044 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1045 66b11bf5 2019-03-27 stsp test_done "$testroot" "$ret"
1046 66b11bf5 2019-03-27 stsp return 1
1047 66b11bf5 2019-03-27 stsp fi
1048 66b11bf5 2019-03-27 stsp
1049 66b11bf5 2019-03-27 stsp (cd $testroot/repo && git rm -q beta)
1050 66b11bf5 2019-03-27 stsp git_commit $testroot/repo -m "removing a file"
1051 66b11bf5 2019-03-27 stsp
1052 66b11bf5 2019-03-27 stsp (cd $testroot/wt && got rm beta > /dev/null)
1053 66b11bf5 2019-03-27 stsp
1054 66b11bf5 2019-03-27 stsp (cd $testroot/wt && got update > $testroot/stdout)
1055 66b11bf5 2019-03-27 stsp
1056 66b11bf5 2019-03-27 stsp echo "D beta" > $testroot/stdout.expected
1057 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1058 66b11bf5 2019-03-27 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1059 66b11bf5 2019-03-27 stsp echo >> $testroot/stdout.expected
1060 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1061 49c543a6 2022-03-31 naddy ret=$?
1062 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1063 66b11bf5 2019-03-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
1064 66b11bf5 2019-03-27 stsp test_done "$testroot" "$ret"
1065 66b11bf5 2019-03-27 stsp return 1
1066 66b11bf5 2019-03-27 stsp fi
1067 66b11bf5 2019-03-27 stsp
1068 66b11bf5 2019-03-27 stsp # beta is now gone... we don't flag tree conflicts yet
1069 2a06fe5f 2019-08-24 stsp echo "N beta" > $testroot/stdout.expected
1070 54817d72 2019-07-27 stsp echo -n > $testroot/stderr.expected
1071 54817d72 2019-07-27 stsp (cd $testroot/wt && got status beta > $testroot/stdout \
1072 54817d72 2019-07-27 stsp 2> $testroot/stderr)
1073 54817d72 2019-07-27 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1074 49c543a6 2022-03-31 naddy ret=$?
1075 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1076 54817d72 2019-07-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
1077 54817d72 2019-07-27 stsp test_done "$testroot" "$ret"
1078 54817d72 2019-07-27 stsp return 1
1079 54817d72 2019-07-27 stsp fi
1080 8d301dd9 2019-05-14 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1081 49c543a6 2022-03-31 naddy ret=$?
1082 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1083 66b11bf5 2019-03-27 stsp diff -u $testroot/stderr.expected $testroot/stderr
1084 66b11bf5 2019-03-27 stsp test_done "$testroot" "$ret"
1085 66b11bf5 2019-03-27 stsp return 1
1086 66b11bf5 2019-03-27 stsp fi
1087 66b11bf5 2019-03-27 stsp
1088 66b11bf5 2019-03-27 stsp if [ -e $testroot/wt/beta ]; then
1089 66b11bf5 2019-03-27 stsp echo "removed file beta still exists on disk" >&2
1090 66b11bf5 2019-03-27 stsp test_done "$testroot" "1"
1091 66b11bf5 2019-03-27 stsp return 1
1092 66b11bf5 2019-03-27 stsp fi
1093 66b11bf5 2019-03-27 stsp
1094 66b11bf5 2019-03-27 stsp test_done "$testroot" "0"
1095 708d8e67 2019-03-27 stsp }
1096 c4cdcb68 2019-04-03 stsp
1097 f6cae3ed 2020-09-13 naddy test_update_partial() {
1098 c4cdcb68 2019-04-03 stsp local testroot=`test_init update_partial`
1099 c4cdcb68 2019-04-03 stsp
1100 c4cdcb68 2019-04-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1101 49c543a6 2022-03-31 naddy ret=$?
1102 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1103 c4cdcb68 2019-04-03 stsp test_done "$testroot" "$ret"
1104 c4cdcb68 2019-04-03 stsp return 1
1105 c4cdcb68 2019-04-03 stsp fi
1106 708d8e67 2019-03-27 stsp
1107 c4cdcb68 2019-04-03 stsp echo "modified alpha" > $testroot/repo/alpha
1108 c4cdcb68 2019-04-03 stsp echo "modified beta" > $testroot/repo/beta
1109 c4cdcb68 2019-04-03 stsp echo "modified epsilon/zeta" > $testroot/repo/epsilon/zeta
1110 c4cdcb68 2019-04-03 stsp git_commit $testroot/repo -m "modified two files"
1111 c4cdcb68 2019-04-03 stsp
1112 f2ea84fa 2019-07-27 stsp echo "U alpha" > $testroot/stdout.expected
1113 f2ea84fa 2019-07-27 stsp echo "U beta" >> $testroot/stdout.expected
1114 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1115 f2ea84fa 2019-07-27 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1116 f2ea84fa 2019-07-27 stsp echo >> $testroot/stdout.expected
1117 c4cdcb68 2019-04-03 stsp
1118 f2ea84fa 2019-07-27 stsp (cd $testroot/wt && got update alpha beta > $testroot/stdout)
1119 c4cdcb68 2019-04-03 stsp
1120 f2ea84fa 2019-07-27 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1121 49c543a6 2022-03-31 naddy ret=$?
1122 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1123 f2ea84fa 2019-07-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
1124 f2ea84fa 2019-07-27 stsp test_done "$testroot" "$ret"
1125 f2ea84fa 2019-07-27 stsp return 1
1126 f2ea84fa 2019-07-27 stsp fi
1127 c4cdcb68 2019-04-03 stsp
1128 f2ea84fa 2019-07-27 stsp echo "modified alpha" > $testroot/content.expected
1129 f2ea84fa 2019-07-27 stsp echo "modified beta" >> $testroot/content.expected
1130 f2ea84fa 2019-07-27 stsp
1131 f2ea84fa 2019-07-27 stsp cat $testroot/wt/alpha $testroot/wt/beta > $testroot/content
1132 f2ea84fa 2019-07-27 stsp cmp -s $testroot/content.expected $testroot/content
1133 49c543a6 2022-03-31 naddy ret=$?
1134 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1135 f2ea84fa 2019-07-27 stsp diff -u $testroot/content.expected $testroot/content
1136 f2ea84fa 2019-07-27 stsp test_done "$testroot" "$ret"
1137 f2ea84fa 2019-07-27 stsp return 1
1138 f2ea84fa 2019-07-27 stsp fi
1139 e4d984c2 2019-05-22 stsp
1140 e4d984c2 2019-05-22 stsp echo "U epsilon/zeta" > $testroot/stdout.expected
1141 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1142 e4d984c2 2019-05-22 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1143 e4d984c2 2019-05-22 stsp echo >> $testroot/stdout.expected
1144 e4d984c2 2019-05-22 stsp
1145 e4d984c2 2019-05-22 stsp (cd $testroot/wt && got update epsilon > $testroot/stdout)
1146 e4d984c2 2019-05-22 stsp
1147 e4d984c2 2019-05-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1148 49c543a6 2022-03-31 naddy ret=$?
1149 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1150 e4d984c2 2019-05-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1151 e4d984c2 2019-05-22 stsp test_done "$testroot" "$ret"
1152 e4d984c2 2019-05-22 stsp return 1
1153 e4d984c2 2019-05-22 stsp fi
1154 e4d984c2 2019-05-22 stsp
1155 e4d984c2 2019-05-22 stsp echo "modified epsilon/zeta" > $testroot/content.expected
1156 e4d984c2 2019-05-22 stsp cat $testroot/wt/epsilon/zeta > $testroot/content
1157 e4d984c2 2019-05-22 stsp
1158 e4d984c2 2019-05-22 stsp cmp -s $testroot/content.expected $testroot/content
1159 49c543a6 2022-03-31 naddy ret=$?
1160 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1161 e4d984c2 2019-05-22 stsp diff -u $testroot/content.expected $testroot/content
1162 e4d984c2 2019-05-22 stsp test_done "$testroot" "$ret"
1163 e4d984c2 2019-05-22 stsp return 1
1164 e4d984c2 2019-05-22 stsp fi
1165 e4d984c2 2019-05-22 stsp
1166 c4cdcb68 2019-04-03 stsp test_done "$testroot" "$ret"
1167 c4cdcb68 2019-04-03 stsp }
1168 c4cdcb68 2019-04-03 stsp
1169 f6cae3ed 2020-09-13 naddy test_update_partial_add() {
1170 c4cdcb68 2019-04-03 stsp local testroot=`test_init update_partial_add`
1171 c4cdcb68 2019-04-03 stsp
1172 c4cdcb68 2019-04-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1173 49c543a6 2022-03-31 naddy ret=$?
1174 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1175 c4cdcb68 2019-04-03 stsp test_done "$testroot" "$ret"
1176 c4cdcb68 2019-04-03 stsp return 1
1177 c4cdcb68 2019-04-03 stsp fi
1178 c4cdcb68 2019-04-03 stsp
1179 c4cdcb68 2019-04-03 stsp echo "new" > $testroot/repo/new
1180 c4cdcb68 2019-04-03 stsp echo "epsilon/new2" > $testroot/repo/epsilon/new2
1181 c4cdcb68 2019-04-03 stsp (cd $testroot/repo && git add .)
1182 c4cdcb68 2019-04-03 stsp git_commit $testroot/repo -m "added two files"
1183 c4cdcb68 2019-04-03 stsp
1184 10a623df 2021-10-11 stsp echo "A epsilon/new2" > $testroot/stdout.expected
1185 10a623df 2021-10-11 stsp echo "A new" >> $testroot/stdout.expected
1186 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1187 f2ea84fa 2019-07-27 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1188 f2ea84fa 2019-07-27 stsp echo >> $testroot/stdout.expected
1189 c4cdcb68 2019-04-03 stsp
1190 f2ea84fa 2019-07-27 stsp (cd $testroot/wt && got update new epsilon/new2 > $testroot/stdout)
1191 c4cdcb68 2019-04-03 stsp
1192 f2ea84fa 2019-07-27 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1193 49c543a6 2022-03-31 naddy ret=$?
1194 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1195 f2ea84fa 2019-07-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
1196 f2ea84fa 2019-07-27 stsp test_done "$testroot" "$ret"
1197 f2ea84fa 2019-07-27 stsp return 1
1198 f2ea84fa 2019-07-27 stsp fi
1199 c4cdcb68 2019-04-03 stsp
1200 f2ea84fa 2019-07-27 stsp echo "new" > $testroot/content.expected
1201 f2ea84fa 2019-07-27 stsp echo "epsilon/new2" >> $testroot/content.expected
1202 c4cdcb68 2019-04-03 stsp
1203 f2ea84fa 2019-07-27 stsp cat $testroot/wt/new $testroot/wt/epsilon/new2 > $testroot/content
1204 f2ea84fa 2019-07-27 stsp
1205 f2ea84fa 2019-07-27 stsp cmp -s $testroot/content.expected $testroot/content
1206 49c543a6 2022-03-31 naddy ret=$?
1207 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1208 f2ea84fa 2019-07-27 stsp diff -u $testroot/content.expected $testroot/content
1209 f2ea84fa 2019-07-27 stsp fi
1210 c4cdcb68 2019-04-03 stsp test_done "$testroot" "$ret"
1211 c4cdcb68 2019-04-03 stsp }
1212 c4cdcb68 2019-04-03 stsp
1213 f6cae3ed 2020-09-13 naddy test_update_partial_rm() {
1214 c4cdcb68 2019-04-03 stsp local testroot=`test_init update_partial_rm`
1215 c4cdcb68 2019-04-03 stsp
1216 c4cdcb68 2019-04-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1217 49c543a6 2022-03-31 naddy ret=$?
1218 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1219 c4cdcb68 2019-04-03 stsp test_done "$testroot" "$ret"
1220 c4cdcb68 2019-04-03 stsp return 1
1221 c4cdcb68 2019-04-03 stsp fi
1222 c4cdcb68 2019-04-03 stsp
1223 f2ea84fa 2019-07-27 stsp (cd $testroot/repo && git rm -q alpha epsilon/zeta)
1224 c4cdcb68 2019-04-03 stsp git_commit $testroot/repo -m "removed two files"
1225 c4cdcb68 2019-04-03 stsp
1226 b66cd6f3 2020-07-31 stsp echo "got: /alpha: no such entry found in tree" \
1227 f2ea84fa 2019-07-27 stsp > $testroot/stderr.expected
1228 f2ea84fa 2019-07-27 stsp
1229 f2ea84fa 2019-07-27 stsp (cd $testroot/wt && got update alpha epsilon/zeta 2> $testroot/stderr)
1230 49c543a6 2022-03-31 naddy ret=$?
1231 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1232 f2ea84fa 2019-07-27 stsp echo "update succeeded unexpectedly" >&2
1233 f2ea84fa 2019-07-27 stsp test_done "$testroot" "1"
1234 f2ea84fa 2019-07-27 stsp return 1
1235 f2ea84fa 2019-07-27 stsp fi
1236 c4cdcb68 2019-04-03 stsp
1237 f2ea84fa 2019-07-27 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1238 49c543a6 2022-03-31 naddy ret=$?
1239 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1240 f2ea84fa 2019-07-27 stsp diff -u $testroot/stderr.expected $testroot/stderr
1241 f2ea84fa 2019-07-27 stsp test_done "$testroot" "$ret"
1242 f2ea84fa 2019-07-27 stsp return 1
1243 f2ea84fa 2019-07-27 stsp fi
1244 c4cdcb68 2019-04-03 stsp test_done "$testroot" "$ret"
1245 c4cdcb68 2019-04-03 stsp }
1246 c4cdcb68 2019-04-03 stsp
1247 f6cae3ed 2020-09-13 naddy test_update_partial_dir() {
1248 c4cdcb68 2019-04-03 stsp local testroot=`test_init update_partial_dir`
1249 c4cdcb68 2019-04-03 stsp
1250 c4cdcb68 2019-04-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1251 49c543a6 2022-03-31 naddy ret=$?
1252 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1253 c4cdcb68 2019-04-03 stsp test_done "$testroot" "$ret"
1254 c4cdcb68 2019-04-03 stsp return 1
1255 c4cdcb68 2019-04-03 stsp fi
1256 c4cdcb68 2019-04-03 stsp
1257 c4cdcb68 2019-04-03 stsp echo "modified alpha" > $testroot/repo/alpha
1258 c4cdcb68 2019-04-03 stsp echo "modified beta" > $testroot/repo/beta
1259 c4cdcb68 2019-04-03 stsp echo "modified epsilon/zeta" > $testroot/repo/epsilon/zeta
1260 c4cdcb68 2019-04-03 stsp git_commit $testroot/repo -m "modified two files"
1261 c4cdcb68 2019-04-03 stsp
1262 c4cdcb68 2019-04-03 stsp echo "U epsilon/zeta" > $testroot/stdout.expected
1263 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1264 c4cdcb68 2019-04-03 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1265 c4cdcb68 2019-04-03 stsp echo >> $testroot/stdout.expected
1266 c4cdcb68 2019-04-03 stsp
1267 c4cdcb68 2019-04-03 stsp (cd $testroot/wt && got update epsilon > $testroot/stdout)
1268 c4cdcb68 2019-04-03 stsp
1269 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1270 49c543a6 2022-03-31 naddy ret=$?
1271 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1272 c4cdcb68 2019-04-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1273 c4cdcb68 2019-04-03 stsp test_done "$testroot" "$ret"
1274 c4cdcb68 2019-04-03 stsp return 1
1275 c4cdcb68 2019-04-03 stsp fi
1276 c4cdcb68 2019-04-03 stsp
1277 c4cdcb68 2019-04-03 stsp echo "modified epsilon/zeta" > $testroot/content.expected
1278 c4cdcb68 2019-04-03 stsp cat $testroot/wt/epsilon/zeta > $testroot/content
1279 c4cdcb68 2019-04-03 stsp
1280 8d301dd9 2019-05-14 stsp cmp -s $testroot/content.expected $testroot/content
1281 49c543a6 2022-03-31 naddy ret=$?
1282 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1283 c4cdcb68 2019-04-03 stsp diff -u $testroot/content.expected $testroot/content
1284 c4cdcb68 2019-04-03 stsp test_done "$testroot" "$ret"
1285 c4cdcb68 2019-04-03 stsp return 1
1286 c4cdcb68 2019-04-03 stsp fi
1287 c4cdcb68 2019-04-03 stsp test_done "$testroot" "$ret"
1288 d5bea539 2019-05-13 stsp
1289 d5bea539 2019-05-13 stsp }
1290 d5bea539 2019-05-13 stsp
1291 f6cae3ed 2020-09-13 naddy test_update_moved_branch_ref() {
1292 d5bea539 2019-05-13 stsp local testroot=`test_init update_moved_branch_ref`
1293 d5bea539 2019-05-13 stsp
1294 d5bea539 2019-05-13 stsp git clone -q --mirror $testroot/repo $testroot/repo2
1295 d5bea539 2019-05-13 stsp
1296 d5bea539 2019-05-13 stsp echo "modified alpha with git" > $testroot/repo/alpha
1297 d5bea539 2019-05-13 stsp git_commit $testroot/repo -m "modified alpha with git"
1298 d5bea539 2019-05-13 stsp
1299 d5bea539 2019-05-13 stsp got checkout $testroot/repo2 $testroot/wt > /dev/null
1300 49c543a6 2022-03-31 naddy ret=$?
1301 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1302 d5bea539 2019-05-13 stsp test_done "$testroot" "$ret"
1303 d5bea539 2019-05-13 stsp return 1
1304 d5bea539 2019-05-13 stsp fi
1305 d5bea539 2019-05-13 stsp
1306 d5bea539 2019-05-13 stsp echo "modified alpha with got" > $testroot/wt/alpha
1307 d5bea539 2019-05-13 stsp (cd $testroot/wt && got commit -m "modified alpha with got" > /dev/null)
1308 d5bea539 2019-05-13 stsp
1309 d5bea539 2019-05-13 stsp # + xxxxxxx...yyyyyyy master -> master (forced update)
1310 d5bea539 2019-05-13 stsp (cd $testroot/repo2 && git fetch -q --all)
1311 c4cdcb68 2019-04-03 stsp
1312 d5bea539 2019-05-13 stsp echo -n > $testroot/stdout.expected
1313 a1fb16d8 2019-05-24 stsp echo -n "got: work tree's head reference now points to a different " \
1314 a367ff0f 2019-05-14 stsp > $testroot/stderr.expected
1315 a1fb16d8 2019-05-24 stsp echo "branch; new head reference and/or update -b required" \
1316 a1fb16d8 2019-05-24 stsp >> $testroot/stderr.expected
1317 d5bea539 2019-05-13 stsp
1318 d5bea539 2019-05-13 stsp (cd $testroot/wt && got update > $testroot/stdout 2> $testroot/stderr)
1319 d5bea539 2019-05-13 stsp
1320 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1321 49c543a6 2022-03-31 naddy ret=$?
1322 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1323 d5bea539 2019-05-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1324 d5bea539 2019-05-13 stsp test_done "$testroot" "$ret"
1325 d5bea539 2019-05-13 stsp return 1
1326 d5bea539 2019-05-13 stsp fi
1327 d5bea539 2019-05-13 stsp
1328 8d301dd9 2019-05-14 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1329 49c543a6 2022-03-31 naddy ret=$?
1330 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1331 d5bea539 2019-05-13 stsp diff -u $testroot/stderr.expected $testroot/stderr
1332 d5bea539 2019-05-13 stsp fi
1333 d5bea539 2019-05-13 stsp test_done "$testroot" "$ret"
1334 c4cdcb68 2019-04-03 stsp }
1335 024e9686 2019-05-14 stsp
1336 f6cae3ed 2020-09-13 naddy test_update_to_another_branch() {
1337 024e9686 2019-05-14 stsp local testroot=`test_init update_to_another_branch`
1338 f69721c3 2019-10-21 stsp local base_commit=`git_show_head $testroot/repo`
1339 024e9686 2019-05-14 stsp
1340 024e9686 2019-05-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1341 49c543a6 2022-03-31 naddy ret=$?
1342 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1343 024e9686 2019-05-14 stsp test_done "$testroot" "$ret"
1344 024e9686 2019-05-14 stsp return 1
1345 024e9686 2019-05-14 stsp fi
1346 024e9686 2019-05-14 stsp
1347 024e9686 2019-05-14 stsp echo 'refs/heads/master'> $testroot/head-ref.expected
1348 024e9686 2019-05-14 stsp cmp -s $testroot/head-ref.expected $testroot/wt/.got/head-ref
1349 49c543a6 2022-03-31 naddy ret=$?
1350 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1351 024e9686 2019-05-14 stsp diff -u $testroot/head-ref.expected $testroot/wt/.got/head-ref
1352 024e9686 2019-05-14 stsp test_done "$testroot" "$ret"
1353 024e9686 2019-05-14 stsp return 1
1354 024e9686 2019-05-14 stsp fi
1355 024e9686 2019-05-14 stsp
1356 024e9686 2019-05-14 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1357 024e9686 2019-05-14 stsp echo "modified alpha on new branch" > $testroot/repo/alpha
1358 024e9686 2019-05-14 stsp git_commit $testroot/repo -m "modified alpha on new branch"
1359 024e9686 2019-05-14 stsp
1360 024e9686 2019-05-14 stsp echo "modified alpha in work tree" > $testroot/wt/alpha
1361 024e9686 2019-05-14 stsp
1362 d969fa15 2019-05-22 stsp echo "Switching work tree from refs/heads/master to refs/heads/newbranch" > $testroot/stdout.expected
1363 d969fa15 2019-05-22 stsp echo "C alpha" >> $testroot/stdout.expected
1364 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/newbranch: " >> $testroot/stdout.expected
1365 024e9686 2019-05-14 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1366 024e9686 2019-05-14 stsp echo >> $testroot/stdout.expected
1367 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
1368 024e9686 2019-05-14 stsp
1369 024e9686 2019-05-14 stsp (cd $testroot/wt && got update -b newbranch > $testroot/stdout)
1370 024e9686 2019-05-14 stsp
1371 024e9686 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1372 49c543a6 2022-03-31 naddy ret=$?
1373 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1374 024e9686 2019-05-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1375 024e9686 2019-05-14 stsp test_done "$testroot" "$ret"
1376 024e9686 2019-05-14 stsp return 1
1377 024e9686 2019-05-14 stsp fi
1378 c4cdcb68 2019-04-03 stsp
1379 f69721c3 2019-10-21 stsp echo -n "<<<<<<< merged change: commit " > $testroot/content.expected
1380 024e9686 2019-05-14 stsp git_show_head $testroot/repo >> $testroot/content.expected
1381 024e9686 2019-05-14 stsp echo >> $testroot/content.expected
1382 024e9686 2019-05-14 stsp echo "modified alpha on new branch" >> $testroot/content.expected
1383 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $base_commit" \
1384 f69721c3 2019-10-21 stsp >> $testroot/content.expected
1385 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
1386 024e9686 2019-05-14 stsp echo "=======" >> $testroot/content.expected
1387 024e9686 2019-05-14 stsp echo "modified alpha in work tree" >> $testroot/content.expected
1388 f69721c3 2019-10-21 stsp echo '>>>>>>>' >> $testroot/content.expected
1389 d5bea539 2019-05-13 stsp
1390 024e9686 2019-05-14 stsp cat $testroot/wt/alpha > $testroot/content
1391 024e9686 2019-05-14 stsp
1392 024e9686 2019-05-14 stsp cmp -s $testroot/content.expected $testroot/content
1393 49c543a6 2022-03-31 naddy ret=$?
1394 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1395 024e9686 2019-05-14 stsp diff -u $testroot/content.expected $testroot/content
1396 024e9686 2019-05-14 stsp test_done "$testroot" "$ret"
1397 024e9686 2019-05-14 stsp return 1
1398 024e9686 2019-05-14 stsp fi
1399 024e9686 2019-05-14 stsp
1400 024e9686 2019-05-14 stsp echo 'refs/heads/newbranch'> $testroot/head-ref.expected
1401 024e9686 2019-05-14 stsp cmp -s $testroot/head-ref.expected $testroot/wt/.got/head-ref
1402 49c543a6 2022-03-31 naddy ret=$?
1403 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1404 024e9686 2019-05-14 stsp diff -u $testroot/head-ref.expected $testroot/wt/.got/head-ref
1405 a367ff0f 2019-05-14 stsp test_done "$testroot" "$ret"
1406 a367ff0f 2019-05-14 stsp return 1
1407 a367ff0f 2019-05-14 stsp fi
1408 a367ff0f 2019-05-14 stsp
1409 a367ff0f 2019-05-14 stsp test_done "$testroot" "$ret"
1410 a367ff0f 2019-05-14 stsp }
1411 a367ff0f 2019-05-14 stsp
1412 f6cae3ed 2020-09-13 naddy test_update_to_commit_on_wrong_branch() {
1413 a367ff0f 2019-05-14 stsp local testroot=`test_init update_to_commit_on_wrong_branch`
1414 a367ff0f 2019-05-14 stsp
1415 a367ff0f 2019-05-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1416 49c543a6 2022-03-31 naddy ret=$?
1417 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1418 a367ff0f 2019-05-14 stsp test_done "$testroot" "$ret"
1419 a367ff0f 2019-05-14 stsp return 1
1420 a367ff0f 2019-05-14 stsp fi
1421 a367ff0f 2019-05-14 stsp
1422 a367ff0f 2019-05-14 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1423 a367ff0f 2019-05-14 stsp echo "modified alpha on new branch" > $testroot/repo/alpha
1424 a367ff0f 2019-05-14 stsp git_commit $testroot/repo -m "modified alpha on new branch"
1425 a367ff0f 2019-05-14 stsp
1426 a367ff0f 2019-05-14 stsp echo -n "" > $testroot/stdout.expected
1427 a367ff0f 2019-05-14 stsp echo "got: target commit is on a different branch" \
1428 a367ff0f 2019-05-14 stsp > $testroot/stderr.expected
1429 a367ff0f 2019-05-14 stsp
1430 a367ff0f 2019-05-14 stsp local head_rev=`git_show_head $testroot/repo`
1431 a367ff0f 2019-05-14 stsp (cd $testroot/wt && got update -c $head_rev > $testroot/stdout \
1432 a367ff0f 2019-05-14 stsp 2> $testroot/stderr)
1433 a367ff0f 2019-05-14 stsp
1434 a367ff0f 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1435 49c543a6 2022-03-31 naddy ret=$?
1436 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1437 a367ff0f 2019-05-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1438 024e9686 2019-05-14 stsp test_done "$testroot" "$ret"
1439 024e9686 2019-05-14 stsp return 1
1440 024e9686 2019-05-14 stsp fi
1441 024e9686 2019-05-14 stsp
1442 a367ff0f 2019-05-14 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1443 49c543a6 2022-03-31 naddy ret=$?
1444 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1445 a367ff0f 2019-05-14 stsp diff -u $testroot/stderr.expected $testroot/stderr
1446 a367ff0f 2019-05-14 stsp test_done "$testroot" "$ret"
1447 a367ff0f 2019-05-14 stsp return 1
1448 a367ff0f 2019-05-14 stsp fi
1449 a367ff0f 2019-05-14 stsp
1450 024e9686 2019-05-14 stsp test_done "$testroot" "$ret"
1451 024e9686 2019-05-14 stsp }
1452 c932eeeb 2019-05-22 stsp
1453 f6cae3ed 2020-09-13 naddy test_update_bumps_base_commit_id() {
1454 a5e55564 2019-06-10 stsp local testroot=`test_init update_bumps_base_commit_id`
1455 c932eeeb 2019-05-22 stsp
1456 1a36436d 2019-06-10 stsp echo "psi" > $testroot/repo/epsilon/psi
1457 1a36436d 2019-06-10 stsp (cd $testroot/repo && git add .)
1458 1a36436d 2019-06-10 stsp git_commit $testroot/repo -m "adding another file"
1459 1a36436d 2019-06-10 stsp
1460 c932eeeb 2019-05-22 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1461 49c543a6 2022-03-31 naddy ret=$?
1462 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1463 c932eeeb 2019-05-22 stsp test_done "$testroot" "$ret"
1464 c932eeeb 2019-05-22 stsp return 1
1465 c932eeeb 2019-05-22 stsp fi
1466 024e9686 2019-05-14 stsp
1467 1a36436d 2019-06-10 stsp echo "modified psi" > $testroot/wt/epsilon/psi
1468 1a36436d 2019-06-10 stsp (cd $testroot/wt && got commit -m "changed psi" > $testroot/stdout)
1469 c932eeeb 2019-05-22 stsp
1470 c932eeeb 2019-05-22 stsp local head_rev=`git_show_head $testroot/repo`
1471 1a36436d 2019-06-10 stsp echo "M epsilon/psi" > $testroot/stdout.expected
1472 a7648d7a 2019-06-02 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1473 c932eeeb 2019-05-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1474 49c543a6 2022-03-31 naddy ret=$?
1475 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1476 c932eeeb 2019-05-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1477 c932eeeb 2019-05-22 stsp test_done "$testroot" "$ret"
1478 c932eeeb 2019-05-22 stsp return 1
1479 c932eeeb 2019-05-22 stsp fi
1480 9bead371 2019-07-28 stsp
1481 305993b9 2019-07-28 stsp echo "changed zeta with git" > $testroot/repo/epsilon/zeta
1482 9bead371 2019-07-28 stsp (cd $testroot/repo && git add .)
1483 9bead371 2019-07-28 stsp git_commit $testroot/repo -m "changing zeta with git"
1484 c932eeeb 2019-05-22 stsp
1485 1a36436d 2019-06-10 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
1486 1a36436d 2019-06-10 stsp (cd $testroot/wt && got commit -m "changed zeta" > $testroot/stdout \
1487 c932eeeb 2019-05-22 stsp 2> $testroot/stderr)
1488 c932eeeb 2019-05-22 stsp
1489 c932eeeb 2019-05-22 stsp echo -n "" > $testroot/stdout.expected
1490 c932eeeb 2019-05-22 stsp echo "got: work tree must be updated before these changes can be committed" > $testroot/stderr.expected
1491 c932eeeb 2019-05-22 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1492 49c543a6 2022-03-31 naddy ret=$?
1493 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1494 c932eeeb 2019-05-22 stsp diff -u $testroot/stderr.expected $testroot/stderr
1495 c932eeeb 2019-05-22 stsp test_done "$testroot" "$ret"
1496 c932eeeb 2019-05-22 stsp return 1
1497 c932eeeb 2019-05-22 stsp fi
1498 c932eeeb 2019-05-22 stsp
1499 c932eeeb 2019-05-22 stsp (cd $testroot/wt && got update > $testroot/stdout)
1500 c932eeeb 2019-05-22 stsp
1501 9bead371 2019-07-28 stsp echo "U epsilon/psi" > $testroot/stdout.expected
1502 9bead371 2019-07-28 stsp echo "C epsilon/zeta" >> $testroot/stdout.expected
1503 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1504 a484d721 2019-06-10 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1505 a484d721 2019-06-10 stsp echo >> $testroot/stdout.expected
1506 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
1507 9627c110 2020-04-18 stsp
1508 c932eeeb 2019-05-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1509 49c543a6 2022-03-31 naddy ret=$?
1510 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1511 c932eeeb 2019-05-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1512 c932eeeb 2019-05-22 stsp test_done "$testroot" "$ret"
1513 c932eeeb 2019-05-22 stsp return 1
1514 c932eeeb 2019-05-22 stsp fi
1515 c932eeeb 2019-05-22 stsp
1516 9bead371 2019-07-28 stsp # resolve conflict
1517 9bead371 2019-07-28 stsp echo "modified zeta with got and git" > $testroot/wt/epsilon/zeta
1518 9bead371 2019-07-28 stsp
1519 1a36436d 2019-06-10 stsp (cd $testroot/wt && got commit -m "changed zeta" > $testroot/stdout)
1520 c932eeeb 2019-05-22 stsp
1521 c932eeeb 2019-05-22 stsp local head_rev=`git_show_head $testroot/repo`
1522 1a36436d 2019-06-10 stsp echo "M epsilon/zeta" > $testroot/stdout.expected
1523 a7648d7a 2019-06-02 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1524 303e2782 2019-08-09 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1525 49c543a6 2022-03-31 naddy ret=$?
1526 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1527 303e2782 2019-08-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
1528 303e2782 2019-08-09 stsp test_done "$testroot" "$ret"
1529 303e2782 2019-08-09 stsp return 1
1530 303e2782 2019-08-09 stsp fi
1531 303e2782 2019-08-09 stsp
1532 303e2782 2019-08-09 stsp test_done "$testroot" "$ret"
1533 303e2782 2019-08-09 stsp }
1534 303e2782 2019-08-09 stsp
1535 f6cae3ed 2020-09-13 naddy test_update_tag() {
1536 303e2782 2019-08-09 stsp local testroot=`test_init update_tag`
1537 303e2782 2019-08-09 stsp local tag="1.0.0"
1538 303e2782 2019-08-09 stsp
1539 303e2782 2019-08-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1540 49c543a6 2022-03-31 naddy ret=$?
1541 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1542 303e2782 2019-08-09 stsp test_done "$testroot" "$ret"
1543 303e2782 2019-08-09 stsp return 1
1544 303e2782 2019-08-09 stsp fi
1545 303e2782 2019-08-09 stsp
1546 303e2782 2019-08-09 stsp echo "modified alpha" > $testroot/repo/alpha
1547 303e2782 2019-08-09 stsp git_commit $testroot/repo -m "modified alpha"
1548 303e2782 2019-08-09 stsp (cd $testroot/repo && git tag -m "test" -a $tag)
1549 303e2782 2019-08-09 stsp
1550 303e2782 2019-08-09 stsp echo "U alpha" > $testroot/stdout.expected
1551 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1552 303e2782 2019-08-09 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1553 303e2782 2019-08-09 stsp echo >> $testroot/stdout.expected
1554 303e2782 2019-08-09 stsp
1555 303e2782 2019-08-09 stsp (cd $testroot/wt && got update -c $tag > $testroot/stdout)
1556 303e2782 2019-08-09 stsp
1557 c932eeeb 2019-05-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1558 49c543a6 2022-03-31 naddy ret=$?
1559 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1560 c932eeeb 2019-05-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1561 c932eeeb 2019-05-22 stsp test_done "$testroot" "$ret"
1562 c932eeeb 2019-05-22 stsp return 1
1563 c932eeeb 2019-05-22 stsp fi
1564 c932eeeb 2019-05-22 stsp
1565 303e2782 2019-08-09 stsp echo "modified alpha" > $testroot/content.expected
1566 303e2782 2019-08-09 stsp cat $testroot/wt/alpha > $testroot/content
1567 303e2782 2019-08-09 stsp
1568 303e2782 2019-08-09 stsp cmp -s $testroot/content.expected $testroot/content
1569 49c543a6 2022-03-31 naddy ret=$?
1570 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1571 303e2782 2019-08-09 stsp diff -u $testroot/content.expected $testroot/content
1572 523b8417 2019-10-19 stsp fi
1573 523b8417 2019-10-19 stsp test_done "$testroot" "$ret"
1574 523b8417 2019-10-19 stsp }
1575 523b8417 2019-10-19 stsp
1576 f6cae3ed 2020-09-13 naddy test_update_toggles_xbit() {
1577 523b8417 2019-10-19 stsp local testroot=`test_init update_toggles_xbit 1`
1578 523b8417 2019-10-19 stsp
1579 523b8417 2019-10-19 stsp touch $testroot/repo/xfile
1580 523b8417 2019-10-19 stsp chmod +x $testroot/repo/xfile
1581 523b8417 2019-10-19 stsp (cd $testroot/repo && git add .)
1582 523b8417 2019-10-19 stsp git_commit $testroot/repo -m "adding executable file"
1583 523b8417 2019-10-19 stsp local commit_id1=`git_show_head $testroot/repo`
1584 523b8417 2019-10-19 stsp
1585 523b8417 2019-10-19 stsp got checkout $testroot/repo $testroot/wt > $testroot/stdout
1586 49c543a6 2022-03-31 naddy ret=$?
1587 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1588 523b8417 2019-10-19 stsp test_done "$testroot" "$ret"
1589 523b8417 2019-10-19 stsp return 1
1590 523b8417 2019-10-19 stsp fi
1591 523b8417 2019-10-19 stsp
1592 523b8417 2019-10-19 stsp ls -l $testroot/wt/xfile | grep -q '^-rwx'
1593 49c543a6 2022-03-31 naddy ret=$?
1594 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1595 523b8417 2019-10-19 stsp echo "file is not executable" >&2
1596 523b8417 2019-10-19 stsp ls -l $testroot/wt/xfile >&2
1597 523b8417 2019-10-19 stsp test_done "$testroot" "$ret"
1598 523b8417 2019-10-19 stsp return 1
1599 523b8417 2019-10-19 stsp fi
1600 523b8417 2019-10-19 stsp
1601 523b8417 2019-10-19 stsp chmod -x $testroot/wt/xfile
1602 523b8417 2019-10-19 stsp (cd $testroot/wt && got commit -m "clear x bit" >/dev/null)
1603 523b8417 2019-10-19 stsp local commit_id2=`git_show_head $testroot/repo`
1604 523b8417 2019-10-19 stsp
1605 523b8417 2019-10-19 stsp echo "U xfile" > $testroot/stdout.expected
1606 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1607 523b8417 2019-10-19 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1608 523b8417 2019-10-19 stsp echo >> $testroot/stdout.expected
1609 523b8417 2019-10-19 stsp
1610 523b8417 2019-10-19 stsp (cd $testroot/wt && got update -c $commit_id1 > $testroot/stdout)
1611 49c543a6 2022-03-31 naddy ret=$?
1612 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1613 523b8417 2019-10-19 stsp test_done "$testroot" "$ret"
1614 523b8417 2019-10-19 stsp return 1
1615 523b8417 2019-10-19 stsp fi
1616 523b8417 2019-10-19 stsp
1617 523b8417 2019-10-19 stsp echo "U xfile" > $testroot/stdout.expected
1618 4f3c844b 2021-09-14 stsp echo "Updated to refs/heads/master: $commit_id1" >> $testroot/stdout.expected
1619 523b8417 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1620 49c543a6 2022-03-31 naddy ret=$?
1621 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1622 523b8417 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
1623 523b8417 2019-10-19 stsp test_done "$testroot" "$ret"
1624 523b8417 2019-10-19 stsp return 1
1625 303e2782 2019-08-09 stsp fi
1626 523b8417 2019-10-19 stsp
1627 523b8417 2019-10-19 stsp
1628 523b8417 2019-10-19 stsp ls -l $testroot/wt/xfile | grep -q '^-rwx'
1629 49c543a6 2022-03-31 naddy ret=$?
1630 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1631 523b8417 2019-10-19 stsp echo "file is not executable" >&2
1632 523b8417 2019-10-19 stsp ls -l $testroot/wt/xfile >&2
1633 523b8417 2019-10-19 stsp test_done "$testroot" "$ret"
1634 523b8417 2019-10-19 stsp return 1
1635 523b8417 2019-10-19 stsp fi
1636 523b8417 2019-10-19 stsp
1637 523b8417 2019-10-19 stsp (cd $testroot/wt && got update > $testroot/stdout)
1638 49c543a6 2022-03-31 naddy ret=$?
1639 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1640 523b8417 2019-10-19 stsp test_done "$testroot" "$ret"
1641 523b8417 2019-10-19 stsp return 1
1642 523b8417 2019-10-19 stsp fi
1643 523b8417 2019-10-19 stsp
1644 523b8417 2019-10-19 stsp echo "U xfile" > $testroot/stdout.expected
1645 4f3c844b 2021-09-14 stsp echo "Updated to refs/heads/master: $commit_id2" \
1646 4f3c844b 2021-09-14 stsp >> $testroot/stdout.expected
1647 523b8417 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1648 49c543a6 2022-03-31 naddy ret=$?
1649 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1650 523b8417 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
1651 523b8417 2019-10-19 stsp test_done "$testroot" "$ret"
1652 523b8417 2019-10-19 stsp return 1
1653 523b8417 2019-10-19 stsp fi
1654 523b8417 2019-10-19 stsp
1655 523b8417 2019-10-19 stsp ls -l $testroot/wt/xfile | grep -q '^-rw-'
1656 49c543a6 2022-03-31 naddy ret=$?
1657 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1658 523b8417 2019-10-19 stsp echo "file is unexpectedly executable" >&2
1659 523b8417 2019-10-19 stsp ls -l $testroot/wt/xfile >&2
1660 5036ab18 2020-04-18 stsp fi
1661 5036ab18 2020-04-18 stsp test_done "$testroot" "$ret"
1662 5036ab18 2020-04-18 stsp }
1663 5036ab18 2020-04-18 stsp
1664 f6cae3ed 2020-09-13 naddy test_update_preserves_conflicted_file() {
1665 5036ab18 2020-04-18 stsp local testroot=`test_init update_preserves_conflicted_file`
1666 5036ab18 2020-04-18 stsp local commit_id0=`git_show_head $testroot/repo`
1667 5036ab18 2020-04-18 stsp
1668 5036ab18 2020-04-18 stsp echo "modified alpha" > $testroot/repo/alpha
1669 5036ab18 2020-04-18 stsp git_commit $testroot/repo -m "modified alpha"
1670 5036ab18 2020-04-18 stsp local commit_id1=`git_show_head $testroot/repo`
1671 5036ab18 2020-04-18 stsp
1672 5036ab18 2020-04-18 stsp got checkout -c $commit_id0 $testroot/repo $testroot/wt > /dev/null
1673 49c543a6 2022-03-31 naddy ret=$?
1674 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1675 5036ab18 2020-04-18 stsp test_done "$testroot" "$ret"
1676 5036ab18 2020-04-18 stsp return 1
1677 5036ab18 2020-04-18 stsp fi
1678 5036ab18 2020-04-18 stsp
1679 5036ab18 2020-04-18 stsp # fake a merge conflict
1680 5036ab18 2020-04-18 stsp echo '<<<<<<<' > $testroot/wt/alpha
1681 5036ab18 2020-04-18 stsp echo 'alpha' >> $testroot/wt/alpha
1682 5036ab18 2020-04-18 stsp echo '=======' >> $testroot/wt/alpha
1683 5036ab18 2020-04-18 stsp echo 'alpha, too' >> $testroot/wt/alpha
1684 5036ab18 2020-04-18 stsp echo '>>>>>>>' >> $testroot/wt/alpha
1685 5036ab18 2020-04-18 stsp cp $testroot/wt/alpha $testroot/content.expected
1686 5036ab18 2020-04-18 stsp
1687 5036ab18 2020-04-18 stsp echo "C alpha" > $testroot/stdout.expected
1688 5036ab18 2020-04-18 stsp (cd $testroot/wt && got status > $testroot/stdout)
1689 5036ab18 2020-04-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1690 49c543a6 2022-03-31 naddy ret=$?
1691 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1692 5036ab18 2020-04-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
1693 5036ab18 2020-04-18 stsp test_done "$testroot" "$ret"
1694 5036ab18 2020-04-18 stsp return 1
1695 523b8417 2019-10-19 stsp fi
1696 5036ab18 2020-04-18 stsp
1697 5036ab18 2020-04-18 stsp echo "# alpha" > $testroot/stdout.expected
1698 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1699 5036ab18 2020-04-18 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1700 5036ab18 2020-04-18 stsp echo >> $testroot/stdout.expected
1701 9627c110 2020-04-18 stsp echo "Files not updated because of existing merge conflicts: 1" \
1702 9627c110 2020-04-18 stsp >> $testroot/stdout.expected
1703 5036ab18 2020-04-18 stsp (cd $testroot/wt && got update > $testroot/stdout)
1704 5036ab18 2020-04-18 stsp
1705 5036ab18 2020-04-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1706 49c543a6 2022-03-31 naddy ret=$?
1707 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1708 5036ab18 2020-04-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
1709 5036ab18 2020-04-18 stsp test_done "$testroot" "$ret"
1710 5036ab18 2020-04-18 stsp return 1
1711 5036ab18 2020-04-18 stsp fi
1712 5036ab18 2020-04-18 stsp
1713 5036ab18 2020-04-18 stsp cmp -s $testroot/content.expected $testroot/wt/alpha
1714 49c543a6 2022-03-31 naddy ret=$?
1715 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1716 5036ab18 2020-04-18 stsp diff -u $testroot/content.expected $testroot/wt/alpha
1717 5036ab18 2020-04-18 stsp fi
1718 c932eeeb 2019-05-22 stsp test_done "$testroot" "$ret"
1719 c932eeeb 2019-05-22 stsp }
1720 e7303626 2020-05-14 stsp
1721 f6cae3ed 2020-09-13 naddy test_update_modified_submodules() {
1722 e7303626 2020-05-14 stsp local testroot=`test_init update_modified_submodules`
1723 e7303626 2020-05-14 stsp
1724 e7303626 2020-05-14 stsp make_single_file_repo $testroot/repo2 foo
1725 e7303626 2020-05-14 stsp
1726 e7303626 2020-05-14 stsp (cd $testroot/repo && git submodule -q add ../repo2)
1727 e7303626 2020-05-14 stsp (cd $testroot/repo && git commit -q -m 'adding submodule')
1728 c932eeeb 2019-05-22 stsp
1729 e7303626 2020-05-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1730 e7303626 2020-05-14 stsp
1731 e7303626 2020-05-14 stsp echo "modified foo" > $testroot/repo2/foo
1732 e7303626 2020-05-14 stsp (cd $testroot/repo2 && git commit -q -a -m 'modified a submodule')
1733 e7303626 2020-05-14 stsp
1734 e7303626 2020-05-14 stsp # Update the repo/repo2 submodule link
1735 e7303626 2020-05-14 stsp (cd $testroot/repo && git -C repo2 pull -q)
1736 e7303626 2020-05-14 stsp (cd $testroot/repo && git add repo2)
1737 e7303626 2020-05-14 stsp git_commit $testroot/repo -m "modified submodule link"
1738 e7303626 2020-05-14 stsp
1739 e7303626 2020-05-14 stsp # This update only records the new base commit. Otherwise it is a
1740 e7303626 2020-05-14 stsp # no-op change because Got's file index does not track submodules.
1741 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " > $testroot/stdout.expected
1742 e7303626 2020-05-14 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1743 e7303626 2020-05-14 stsp echo >> $testroot/stdout.expected
1744 e7303626 2020-05-14 stsp
1745 e7303626 2020-05-14 stsp (cd $testroot/wt && got update > $testroot/stdout)
1746 e7303626 2020-05-14 stsp
1747 e7303626 2020-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1748 49c543a6 2022-03-31 naddy ret=$?
1749 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1750 e7303626 2020-05-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1751 e7303626 2020-05-14 stsp fi
1752 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
1753 e7303626 2020-05-14 stsp }
1754 e7303626 2020-05-14 stsp
1755 f6cae3ed 2020-09-13 naddy test_update_adds_submodule() {
1756 e7303626 2020-05-14 stsp local testroot=`test_init update_adds_submodule`
1757 e7303626 2020-05-14 stsp
1758 e7303626 2020-05-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1759 e7303626 2020-05-14 stsp
1760 e7303626 2020-05-14 stsp make_single_file_repo $testroot/repo2 foo
1761 e7303626 2020-05-14 stsp
1762 e7303626 2020-05-14 stsp echo "modified foo" > $testroot/repo2/foo
1763 e7303626 2020-05-14 stsp (cd $testroot/repo2 && git commit -q -a -m 'modified a submodule')
1764 e7303626 2020-05-14 stsp
1765 e7303626 2020-05-14 stsp (cd $testroot/repo && git submodule -q add ../repo2)
1766 e7303626 2020-05-14 stsp (cd $testroot/repo && git commit -q -m 'adding submodule')
1767 e7303626 2020-05-14 stsp
1768 e7303626 2020-05-14 stsp echo "A .gitmodules" > $testroot/stdout.expected
1769 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1770 e7303626 2020-05-14 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1771 e7303626 2020-05-14 stsp echo >> $testroot/stdout.expected
1772 e7303626 2020-05-14 stsp
1773 e7303626 2020-05-14 stsp (cd $testroot/wt && got update > $testroot/stdout)
1774 e7303626 2020-05-14 stsp
1775 e7303626 2020-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1776 49c543a6 2022-03-31 naddy ret=$?
1777 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1778 e7303626 2020-05-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1779 e7303626 2020-05-14 stsp fi
1780 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
1781 e7303626 2020-05-14 stsp }
1782 e7303626 2020-05-14 stsp
1783 f6cae3ed 2020-09-13 naddy test_update_conflict_wt_file_vs_repo_submodule() {
1784 e7303626 2020-05-14 stsp local testroot=`test_init update_conflict_wt_file_vs_repo_submodule`
1785 e7303626 2020-05-14 stsp
1786 e7303626 2020-05-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1787 e7303626 2020-05-14 stsp
1788 e7303626 2020-05-14 stsp make_single_file_repo $testroot/repo2 foo
1789 e7303626 2020-05-14 stsp
1790 e7303626 2020-05-14 stsp # Add a file which will clash with the submodule
1791 e7303626 2020-05-14 stsp echo "This is a file called repo2" > $testroot/wt/repo2
1792 e7303626 2020-05-14 stsp (cd $testroot/wt && got add repo2 > /dev/null)
1793 e7303626 2020-05-14 stsp (cd $testroot/wt && got commit -m 'add file repo2' > /dev/null)
1794 49c543a6 2022-03-31 naddy ret=$?
1795 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1796 e7303626 2020-05-14 stsp echo "commit failed unexpectedly" >&2
1797 e7303626 2020-05-14 stsp test_done "$testroot" "1"
1798 e7303626 2020-05-14 stsp return 1
1799 e7303626 2020-05-14 stsp fi
1800 e7303626 2020-05-14 stsp
1801 e7303626 2020-05-14 stsp (cd $testroot/repo && git submodule -q add ../repo2)
1802 e7303626 2020-05-14 stsp (cd $testroot/repo && git commit -q -m 'adding submodule')
1803 e7303626 2020-05-14 stsp
1804 e7303626 2020-05-14 stsp # Modify the clashing file such that any modifications brought
1805 e7303626 2020-05-14 stsp # in by 'got update' would require a merge.
1806 e7303626 2020-05-14 stsp echo "This file was changed" > $testroot/wt/repo2
1807 e7303626 2020-05-14 stsp
1808 e7303626 2020-05-14 stsp # No conflict occurs because 'got update' ignores the submodule
1809 e7303626 2020-05-14 stsp # and leaves the clashing file as it was.
1810 e7303626 2020-05-14 stsp echo "A .gitmodules" > $testroot/stdout.expected
1811 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1812 e7303626 2020-05-14 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1813 e7303626 2020-05-14 stsp echo >> $testroot/stdout.expected
1814 e7303626 2020-05-14 stsp
1815 e7303626 2020-05-14 stsp (cd $testroot/wt && got update > $testroot/stdout)
1816 e7303626 2020-05-14 stsp
1817 e7303626 2020-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1818 49c543a6 2022-03-31 naddy ret=$?
1819 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1820 e7303626 2020-05-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1821 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
1822 e7303626 2020-05-14 stsp return 1
1823 e7303626 2020-05-14 stsp fi
1824 e7303626 2020-05-14 stsp
1825 e7303626 2020-05-14 stsp (cd $testroot/wt && got status > $testroot/stdout)
1826 e7303626 2020-05-14 stsp
1827 e7303626 2020-05-14 stsp echo "M repo2" > $testroot/stdout.expected
1828 e7303626 2020-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1829 49c543a6 2022-03-31 naddy ret=$?
1830 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1831 e7303626 2020-05-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1832 e7303626 2020-05-14 stsp fi
1833 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
1834 e7303626 2020-05-14 stsp }
1835 f35fa46a 2020-07-23 stsp
1836 f6cae3ed 2020-09-13 naddy test_update_adds_symlink() {
1837 f35fa46a 2020-07-23 stsp local testroot=`test_init update_adds_symlink`
1838 f35fa46a 2020-07-23 stsp
1839 f35fa46a 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1840 49c543a6 2022-03-31 naddy ret=$?
1841 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1842 f35fa46a 2020-07-23 stsp echo "checkout failed unexpectedly" >&2
1843 f35fa46a 2020-07-23 stsp test_done "$testroot" "$ret"
1844 f35fa46a 2020-07-23 stsp return 1
1845 f35fa46a 2020-07-23 stsp fi
1846 f35fa46a 2020-07-23 stsp
1847 f35fa46a 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
1848 f35fa46a 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
1849 f35fa46a 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
1850 f35fa46a 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
1851 f35fa46a 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
1852 f35fa46a 2020-07-23 stsp (cd $testroot/repo && git add .)
1853 f35fa46a 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
1854 f35fa46a 2020-07-23 stsp
1855 f35fa46a 2020-07-23 stsp echo "A alpha.link" > $testroot/stdout.expected
1856 f35fa46a 2020-07-23 stsp echo "A epsilon/beta.link" >> $testroot/stdout.expected
1857 f35fa46a 2020-07-23 stsp echo "A epsilon.link" >> $testroot/stdout.expected
1858 f35fa46a 2020-07-23 stsp echo "A nonexistent.link" >> $testroot/stdout.expected
1859 f35fa46a 2020-07-23 stsp echo "A passwd.link" >> $testroot/stdout.expected
1860 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1861 f35fa46a 2020-07-23 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1862 f35fa46a 2020-07-23 stsp echo >> $testroot/stdout.expected
1863 f35fa46a 2020-07-23 stsp
1864 f35fa46a 2020-07-23 stsp (cd $testroot/wt && got update > $testroot/stdout)
1865 f35fa46a 2020-07-23 stsp
1866 f35fa46a 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1867 49c543a6 2022-03-31 naddy ret=$?
1868 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1869 f35fa46a 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1870 f35fa46a 2020-07-23 stsp test_done "$testroot" "$ret"
1871 f35fa46a 2020-07-23 stsp return 1
1872 f35fa46a 2020-07-23 stsp fi
1873 f35fa46a 2020-07-23 stsp
1874 f35fa46a 2020-07-23 stsp if ! [ -h $testroot/wt/alpha.link ]; then
1875 f35fa46a 2020-07-23 stsp echo "alpha.link is not a symlink"
1876 f35fa46a 2020-07-23 stsp test_done "$testroot" "1"
1877 f35fa46a 2020-07-23 stsp return 1
1878 f35fa46a 2020-07-23 stsp fi
1879 f35fa46a 2020-07-23 stsp
1880 f35fa46a 2020-07-23 stsp readlink $testroot/wt/alpha.link > $testroot/stdout
1881 f35fa46a 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
1882 f35fa46a 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1883 49c543a6 2022-03-31 naddy ret=$?
1884 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1885 f35fa46a 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1886 f35fa46a 2020-07-23 stsp test_done "$testroot" "$ret"
1887 f35fa46a 2020-07-23 stsp return 1
1888 f35fa46a 2020-07-23 stsp fi
1889 f35fa46a 2020-07-23 stsp
1890 f35fa46a 2020-07-23 stsp if ! [ -h $testroot/wt/epsilon.link ]; then
1891 f35fa46a 2020-07-23 stsp echo "epsilon.link is not a symlink"
1892 f35fa46a 2020-07-23 stsp test_done "$testroot" "1"
1893 f35fa46a 2020-07-23 stsp return 1
1894 f35fa46a 2020-07-23 stsp fi
1895 e7303626 2020-05-14 stsp
1896 f35fa46a 2020-07-23 stsp readlink $testroot/wt/epsilon.link > $testroot/stdout
1897 f35fa46a 2020-07-23 stsp echo "epsilon" > $testroot/stdout.expected
1898 f35fa46a 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1899 49c543a6 2022-03-31 naddy ret=$?
1900 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1901 f35fa46a 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1902 f35fa46a 2020-07-23 stsp test_done "$testroot" "$ret"
1903 f35fa46a 2020-07-23 stsp return 1
1904 f35fa46a 2020-07-23 stsp fi
1905 e7303626 2020-05-14 stsp
1906 f35fa46a 2020-07-23 stsp if [ -h $testroot/wt/passwd.link ]; then
1907 f35fa46a 2020-07-23 stsp echo -n "passwd.link symlink points outside of work tree: " >&2
1908 f35fa46a 2020-07-23 stsp readlink $testroot/wt/passwd.link >&2
1909 f35fa46a 2020-07-23 stsp test_done "$testroot" "1"
1910 f35fa46a 2020-07-23 stsp return 1
1911 f35fa46a 2020-07-23 stsp fi
1912 f35fa46a 2020-07-23 stsp
1913 f35fa46a 2020-07-23 stsp echo -n "/etc/passwd" > $testroot/content.expected
1914 f35fa46a 2020-07-23 stsp cp $testroot/wt/passwd.link $testroot/content
1915 f35fa46a 2020-07-23 stsp
1916 f35fa46a 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
1917 49c543a6 2022-03-31 naddy ret=$?
1918 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1919 f35fa46a 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
1920 f35fa46a 2020-07-23 stsp test_done "$testroot" "$ret"
1921 f35fa46a 2020-07-23 stsp return 1
1922 f35fa46a 2020-07-23 stsp fi
1923 f35fa46a 2020-07-23 stsp
1924 f35fa46a 2020-07-23 stsp readlink $testroot/wt/epsilon/beta.link > $testroot/stdout
1925 f35fa46a 2020-07-23 stsp echo "../beta" > $testroot/stdout.expected
1926 f35fa46a 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1927 49c543a6 2022-03-31 naddy ret=$?
1928 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1929 f35fa46a 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1930 f35fa46a 2020-07-23 stsp test_done "$testroot" "$ret"
1931 f35fa46a 2020-07-23 stsp return 1
1932 f35fa46a 2020-07-23 stsp fi
1933 f35fa46a 2020-07-23 stsp
1934 f35fa46a 2020-07-23 stsp readlink $testroot/wt/nonexistent.link > $testroot/stdout
1935 f35fa46a 2020-07-23 stsp echo "nonexistent" > $testroot/stdout.expected
1936 f35fa46a 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1937 49c543a6 2022-03-31 naddy ret=$?
1938 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1939 f35fa46a 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1940 c6e8a826 2021-04-05 stsp test_done "$testroot" "$ret"
1941 c6e8a826 2021-04-05 stsp return 1
1942 f35fa46a 2020-07-23 stsp fi
1943 c6e8a826 2021-04-05 stsp
1944 c6e8a826 2021-04-05 stsp # Updating an up-to-date symlink should be a no-op.
1945 c6e8a826 2021-04-05 stsp echo 'Already up-to-date' > $testroot/stdout.expected
1946 c6e8a826 2021-04-05 stsp (cd $testroot/wt && got update > $testroot/stdout)
1947 c6e8a826 2021-04-05 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1948 49c543a6 2022-03-31 naddy ret=$?
1949 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1950 c6e8a826 2021-04-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
1951 c6e8a826 2021-04-05 stsp fi
1952 f35fa46a 2020-07-23 stsp test_done "$testroot" "$ret"
1953 993e2a1b 2020-07-23 stsp }
1954 993e2a1b 2020-07-23 stsp
1955 f6cae3ed 2020-09-13 naddy test_update_deletes_symlink() {
1956 993e2a1b 2020-07-23 stsp local testroot=`test_init update_deletes_symlink`
1957 993e2a1b 2020-07-23 stsp
1958 993e2a1b 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
1959 993e2a1b 2020-07-23 stsp (cd $testroot/repo && git add .)
1960 993e2a1b 2020-07-23 stsp git_commit $testroot/repo -m "add symlink"
1961 993e2a1b 2020-07-23 stsp
1962 993e2a1b 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1963 49c543a6 2022-03-31 naddy ret=$?
1964 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1965 993e2a1b 2020-07-23 stsp echo "checkout failed unexpectedly" >&2
1966 993e2a1b 2020-07-23 stsp test_done "$testroot" "$ret"
1967 993e2a1b 2020-07-23 stsp return 1
1968 993e2a1b 2020-07-23 stsp fi
1969 993e2a1b 2020-07-23 stsp
1970 993e2a1b 2020-07-23 stsp (cd $testroot/repo && git rm -q alpha.link)
1971 993e2a1b 2020-07-23 stsp git_commit $testroot/repo -m "delete symlink"
1972 993e2a1b 2020-07-23 stsp
1973 993e2a1b 2020-07-23 stsp echo "D alpha.link" > $testroot/stdout.expected
1974 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1975 993e2a1b 2020-07-23 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1976 993e2a1b 2020-07-23 stsp echo >> $testroot/stdout.expected
1977 993e2a1b 2020-07-23 stsp
1978 993e2a1b 2020-07-23 stsp (cd $testroot/wt && got update > $testroot/stdout)
1979 993e2a1b 2020-07-23 stsp
1980 993e2a1b 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1981 49c543a6 2022-03-31 naddy ret=$?
1982 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1983 993e2a1b 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1984 993e2a1b 2020-07-23 stsp test_done "$testroot" "$ret"
1985 993e2a1b 2020-07-23 stsp return 1
1986 993e2a1b 2020-07-23 stsp fi
1987 993e2a1b 2020-07-23 stsp
1988 993e2a1b 2020-07-23 stsp if [ -e $testroot/wt/alpha.link ]; then
1989 993e2a1b 2020-07-23 stsp echo "alpha.link still exists on disk"
1990 993e2a1b 2020-07-23 stsp test_done "$testroot" "1"
1991 993e2a1b 2020-07-23 stsp return 1
1992 993e2a1b 2020-07-23 stsp fi
1993 993e2a1b 2020-07-23 stsp
1994 993e2a1b 2020-07-23 stsp test_done "$testroot" "0"
1995 993e2a1b 2020-07-23 stsp }
1996 993e2a1b 2020-07-23 stsp
1997 f6cae3ed 2020-09-13 naddy test_update_symlink_conflicts() {
1998 993e2a1b 2020-07-23 stsp local testroot=`test_init update_symlink_conflicts`
1999 993e2a1b 2020-07-23 stsp
2000 993e2a1b 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
2001 993e2a1b 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
2002 993e2a1b 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
2003 993e2a1b 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
2004 993e2a1b 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
2005 993e2a1b 2020-07-23 stsp (cd $testroot/repo && ln -sf epsilon/zeta zeta.link)
2006 993e2a1b 2020-07-23 stsp (cd $testroot/repo && git add .)
2007 993e2a1b 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
2008 993e2a1b 2020-07-23 stsp local commit_id1=`git_show_head $testroot/repo`
2009 993e2a1b 2020-07-23 stsp
2010 993e2a1b 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2011 49c543a6 2022-03-31 naddy ret=$?
2012 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2013 993e2a1b 2020-07-23 stsp echo "checkout failed unexpectedly" >&2
2014 993e2a1b 2020-07-23 stsp test_done "$testroot" "$ret"
2015 993e2a1b 2020-07-23 stsp return 1
2016 993e2a1b 2020-07-23 stsp fi
2017 993e2a1b 2020-07-23 stsp
2018 993e2a1b 2020-07-23 stsp (cd $testroot/repo && ln -sf beta alpha.link)
2019 993e2a1b 2020-07-23 stsp (cd $testroot/repo && ln -sfh gamma epsilon.link)
2020 993e2a1b 2020-07-23 stsp (cd $testroot/repo && ln -sf ../gamma/delta epsilon/beta.link)
2021 993e2a1b 2020-07-23 stsp echo 'this is regular file foo' > $testroot/repo/dotgotfoo.link
2022 993e2a1b 2020-07-23 stsp (cd $testroot/repo && ln -sf .got/bar dotgotbar.link)
2023 993e2a1b 2020-07-23 stsp (cd $testroot/repo && git rm -q nonexistent.link)
2024 993e2a1b 2020-07-23 stsp (cd $testroot/repo && ln -sf gamma/delta zeta.link)
2025 993e2a1b 2020-07-23 stsp (cd $testroot/repo && ln -sf alpha new.link)
2026 993e2a1b 2020-07-23 stsp (cd $testroot/repo && git add .)
2027 993e2a1b 2020-07-23 stsp git_commit $testroot/repo -m "change symlinks"
2028 993e2a1b 2020-07-23 stsp local commit_id2=`git_show_head $testroot/repo`
2029 993e2a1b 2020-07-23 stsp
2030 993e2a1b 2020-07-23 stsp # modified symlink to file A vs modified symlink to file B
2031 993e2a1b 2020-07-23 stsp (cd $testroot/wt && ln -sf gamma/delta alpha.link)
2032 993e2a1b 2020-07-23 stsp # modified symlink to dir A vs modified symlink to file B
2033 993e2a1b 2020-07-23 stsp (cd $testroot/wt && ln -sfh beta epsilon.link)
2034 993e2a1b 2020-07-23 stsp # modeified symlink to file A vs modified symlink to dir B
2035 993e2a1b 2020-07-23 stsp (cd $testroot/wt && ln -sfh ../gamma epsilon/beta.link)
2036 993e2a1b 2020-07-23 stsp # added regular file A vs added bad symlink to file A
2037 993e2a1b 2020-07-23 stsp (cd $testroot/wt && ln -sf .got/bar dotgotfoo.link)
2038 3b9f0f87 2020-07-23 stsp (cd $testroot/wt && got add dotgotfoo.link > /dev/null)
2039 993e2a1b 2020-07-23 stsp # added bad symlink to file A vs added regular file A
2040 993e2a1b 2020-07-23 stsp echo 'this is regular file bar' > $testroot/wt/dotgotbar.link
2041 3b9f0f87 2020-07-23 stsp (cd $testroot/wt && got add dotgotbar.link > /dev/null)
2042 993e2a1b 2020-07-23 stsp # removed symlink to non-existent file A vs modified symlink
2043 993e2a1b 2020-07-23 stsp # to nonexistent file B
2044 993e2a1b 2020-07-23 stsp (cd $testroot/wt && ln -sf nonexistent2 nonexistent.link)
2045 993e2a1b 2020-07-23 stsp # modified symlink to file A vs removed symlink to file A
2046 993e2a1b 2020-07-23 stsp (cd $testroot/wt && got rm zeta.link > /dev/null)
2047 993e2a1b 2020-07-23 stsp # added symlink to file A vs added symlink to file B
2048 993e2a1b 2020-07-23 stsp (cd $testroot/wt && ln -sf beta new.link)
2049 993e2a1b 2020-07-23 stsp (cd $testroot/wt && got add new.link > /dev/null)
2050 993e2a1b 2020-07-23 stsp
2051 993e2a1b 2020-07-23 stsp (cd $testroot/wt && got update > $testroot/stdout)
2052 993e2a1b 2020-07-23 stsp
2053 993e2a1b 2020-07-23 stsp echo "C alpha.link" >> $testroot/stdout.expected
2054 3b9f0f87 2020-07-23 stsp echo "C dotgotbar.link" >> $testroot/stdout.expected
2055 3b9f0f87 2020-07-23 stsp echo "C dotgotfoo.link" >> $testroot/stdout.expected
2056 993e2a1b 2020-07-23 stsp echo "C epsilon/beta.link" >> $testroot/stdout.expected
2057 993e2a1b 2020-07-23 stsp echo "C epsilon.link" >> $testroot/stdout.expected
2058 993e2a1b 2020-07-23 stsp echo "C new.link" >> $testroot/stdout.expected
2059 993e2a1b 2020-07-23 stsp echo "C nonexistent.link" >> $testroot/stdout.expected
2060 993e2a1b 2020-07-23 stsp echo "G zeta.link" >> $testroot/stdout.expected
2061 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
2062 993e2a1b 2020-07-23 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
2063 993e2a1b 2020-07-23 stsp echo >> $testroot/stdout.expected
2064 3b9f0f87 2020-07-23 stsp echo "Files with new merge conflicts: 7" >> $testroot/stdout.expected
2065 993e2a1b 2020-07-23 stsp
2066 993e2a1b 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2067 49c543a6 2022-03-31 naddy ret=$?
2068 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2069 993e2a1b 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2070 993e2a1b 2020-07-23 stsp test_done "$testroot" "$ret"
2071 993e2a1b 2020-07-23 stsp return 1
2072 993e2a1b 2020-07-23 stsp fi
2073 993e2a1b 2020-07-23 stsp
2074 993e2a1b 2020-07-23 stsp if [ -h $testroot/wt/alpha.link ]; then
2075 993e2a1b 2020-07-23 stsp echo "alpha.link is a symlink"
2076 993e2a1b 2020-07-23 stsp test_done "$testroot" "1"
2077 993e2a1b 2020-07-23 stsp return 1
2078 993e2a1b 2020-07-23 stsp fi
2079 993e2a1b 2020-07-23 stsp
2080 993e2a1b 2020-07-23 stsp echo "<<<<<<< merged change: commit $commit_id2" \
2081 283102fc 2020-07-23 stsp > $testroot/content.expected
2082 993e2a1b 2020-07-23 stsp echo "beta" >> $testroot/content.expected
2083 993e2a1b 2020-07-23 stsp echo "3-way merge base: commit $commit_id1" \
2084 993e2a1b 2020-07-23 stsp >> $testroot/content.expected
2085 993e2a1b 2020-07-23 stsp echo "alpha" >> $testroot/content.expected
2086 993e2a1b 2020-07-23 stsp echo "=======" >> $testroot/content.expected
2087 993e2a1b 2020-07-23 stsp echo "gamma/delta" >> $testroot/content.expected
2088 993e2a1b 2020-07-23 stsp echo '>>>>>>>' >> $testroot/content.expected
2089 993e2a1b 2020-07-23 stsp echo -n "" >> $testroot/content.expected
2090 993e2a1b 2020-07-23 stsp
2091 993e2a1b 2020-07-23 stsp cp $testroot/wt/alpha.link $testroot/content
2092 993e2a1b 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2093 49c543a6 2022-03-31 naddy ret=$?
2094 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2095 993e2a1b 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2096 993e2a1b 2020-07-23 stsp test_done "$testroot" "$ret"
2097 993e2a1b 2020-07-23 stsp return 1
2098 993e2a1b 2020-07-23 stsp fi
2099 993e2a1b 2020-07-23 stsp
2100 993e2a1b 2020-07-23 stsp if [ -h $testroot/wt/epsilon.link ]; then
2101 993e2a1b 2020-07-23 stsp echo "epsilon.link is a symlink"
2102 993e2a1b 2020-07-23 stsp test_done "$testroot" "1"
2103 993e2a1b 2020-07-23 stsp return 1
2104 993e2a1b 2020-07-23 stsp fi
2105 993e2a1b 2020-07-23 stsp
2106 993e2a1b 2020-07-23 stsp echo "<<<<<<< merged change: commit $commit_id2" \
2107 283102fc 2020-07-23 stsp > $testroot/content.expected
2108 993e2a1b 2020-07-23 stsp echo "gamma" >> $testroot/content.expected
2109 993e2a1b 2020-07-23 stsp echo "3-way merge base: commit $commit_id1" \
2110 993e2a1b 2020-07-23 stsp >> $testroot/content.expected
2111 993e2a1b 2020-07-23 stsp echo "epsilon" >> $testroot/content.expected
2112 993e2a1b 2020-07-23 stsp echo "=======" >> $testroot/content.expected
2113 993e2a1b 2020-07-23 stsp echo "beta" >> $testroot/content.expected
2114 993e2a1b 2020-07-23 stsp echo '>>>>>>>' >> $testroot/content.expected
2115 993e2a1b 2020-07-23 stsp echo -n "" >> $testroot/content.expected
2116 993e2a1b 2020-07-23 stsp
2117 993e2a1b 2020-07-23 stsp cp $testroot/wt/epsilon.link $testroot/content
2118 993e2a1b 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2119 49c543a6 2022-03-31 naddy ret=$?
2120 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2121 993e2a1b 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2122 993e2a1b 2020-07-23 stsp test_done "$testroot" "$ret"
2123 993e2a1b 2020-07-23 stsp return 1
2124 993e2a1b 2020-07-23 stsp fi
2125 993e2a1b 2020-07-23 stsp
2126 993e2a1b 2020-07-23 stsp if [ -h $testroot/wt/passwd.link ]; then
2127 993e2a1b 2020-07-23 stsp echo -n "passwd.link symlink points outside of work tree: " >&2
2128 993e2a1b 2020-07-23 stsp readlink $testroot/wt/passwd.link >&2
2129 993e2a1b 2020-07-23 stsp test_done "$testroot" "1"
2130 993e2a1b 2020-07-23 stsp return 1
2131 993e2a1b 2020-07-23 stsp fi
2132 993e2a1b 2020-07-23 stsp
2133 993e2a1b 2020-07-23 stsp echo -n "/etc/passwd" > $testroot/content.expected
2134 993e2a1b 2020-07-23 stsp cp $testroot/wt/passwd.link $testroot/content
2135 993e2a1b 2020-07-23 stsp
2136 993e2a1b 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2137 49c543a6 2022-03-31 naddy ret=$?
2138 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2139 993e2a1b 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2140 993e2a1b 2020-07-23 stsp test_done "$testroot" "$ret"
2141 993e2a1b 2020-07-23 stsp return 1
2142 993e2a1b 2020-07-23 stsp fi
2143 993e2a1b 2020-07-23 stsp
2144 993e2a1b 2020-07-23 stsp if [ -h $testroot/wt/epsilon/beta.link ]; then
2145 993e2a1b 2020-07-23 stsp echo "epsilon/beta.link is a symlink"
2146 993e2a1b 2020-07-23 stsp test_done "$testroot" "1"
2147 993e2a1b 2020-07-23 stsp return 1
2148 993e2a1b 2020-07-23 stsp fi
2149 993e2a1b 2020-07-23 stsp
2150 993e2a1b 2020-07-23 stsp echo "<<<<<<< merged change: commit $commit_id2" \
2151 283102fc 2020-07-23 stsp > $testroot/content.expected
2152 993e2a1b 2020-07-23 stsp echo "../gamma/delta" >> $testroot/content.expected
2153 993e2a1b 2020-07-23 stsp echo "3-way merge base: commit $commit_id1" \
2154 993e2a1b 2020-07-23 stsp >> $testroot/content.expected
2155 993e2a1b 2020-07-23 stsp echo "../beta" >> $testroot/content.expected
2156 993e2a1b 2020-07-23 stsp echo "=======" >> $testroot/content.expected
2157 993e2a1b 2020-07-23 stsp echo "../gamma" >> $testroot/content.expected
2158 993e2a1b 2020-07-23 stsp echo '>>>>>>>' >> $testroot/content.expected
2159 993e2a1b 2020-07-23 stsp echo -n "" >> $testroot/content.expected
2160 993e2a1b 2020-07-23 stsp
2161 993e2a1b 2020-07-23 stsp cp $testroot/wt/epsilon/beta.link $testroot/content
2162 993e2a1b 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2163 49c543a6 2022-03-31 naddy ret=$?
2164 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2165 993e2a1b 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2166 993e2a1b 2020-07-23 stsp test_done "$testroot" "$ret"
2167 993e2a1b 2020-07-23 stsp return 1
2168 993e2a1b 2020-07-23 stsp fi
2169 993e2a1b 2020-07-23 stsp
2170 993e2a1b 2020-07-23 stsp if [ -h $testroot/wt/nonexistent.link ]; then
2171 993e2a1b 2020-07-23 stsp echo -n "nonexistent.link still exists on disk: " >&2
2172 993e2a1b 2020-07-23 stsp readlink $testroot/wt/nonexistent.link >&2
2173 993e2a1b 2020-07-23 stsp test_done "$testroot" "1"
2174 993e2a1b 2020-07-23 stsp return 1
2175 993e2a1b 2020-07-23 stsp fi
2176 993e2a1b 2020-07-23 stsp
2177 993e2a1b 2020-07-23 stsp echo "<<<<<<< merged change: commit $commit_id2" \
2178 283102fc 2020-07-23 stsp > $testroot/content.expected
2179 993e2a1b 2020-07-23 stsp echo "(symlink was deleted)" >> $testroot/content.expected
2180 993e2a1b 2020-07-23 stsp echo "=======" >> $testroot/content.expected
2181 993e2a1b 2020-07-23 stsp echo "nonexistent2" >> $testroot/content.expected
2182 993e2a1b 2020-07-23 stsp echo '>>>>>>>' >> $testroot/content.expected
2183 993e2a1b 2020-07-23 stsp echo -n "" >> $testroot/content.expected
2184 993e2a1b 2020-07-23 stsp
2185 993e2a1b 2020-07-23 stsp cp $testroot/wt/nonexistent.link $testroot/content
2186 993e2a1b 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2187 49c543a6 2022-03-31 naddy ret=$?
2188 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2189 993e2a1b 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2190 993e2a1b 2020-07-23 stsp test_done "$testroot" "$ret"
2191 993e2a1b 2020-07-23 stsp return 1
2192 993e2a1b 2020-07-23 stsp fi
2193 993e2a1b 2020-07-23 stsp
2194 993e2a1b 2020-07-23 stsp if [ -h $testroot/wt/dotgotfoo.link ]; then
2195 993e2a1b 2020-07-23 stsp echo "dotgotfoo.link is a symlink"
2196 993e2a1b 2020-07-23 stsp test_done "$testroot" "1"
2197 993e2a1b 2020-07-23 stsp return 1
2198 993e2a1b 2020-07-23 stsp fi
2199 993e2a1b 2020-07-23 stsp
2200 3b9f0f87 2020-07-23 stsp echo "<<<<<<< merged change: commit $commit_id2" \
2201 3b9f0f87 2020-07-23 stsp > $testroot/content.expected
2202 3b9f0f87 2020-07-23 stsp echo "this is regular file foo" >> $testroot/content.expected
2203 3b9f0f87 2020-07-23 stsp echo "=======" >> $testroot/content.expected
2204 3b9f0f87 2020-07-23 stsp echo -n ".got/bar" >> $testroot/content.expected
2205 3b9f0f87 2020-07-23 stsp echo '>>>>>>>' >> $testroot/content.expected
2206 3b9f0f87 2020-07-23 stsp echo -n "" >> $testroot/content.expected
2207 3b9f0f87 2020-07-23 stsp
2208 993e2a1b 2020-07-23 stsp cp $testroot/wt/dotgotfoo.link $testroot/content
2209 993e2a1b 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2210 49c543a6 2022-03-31 naddy ret=$?
2211 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2212 993e2a1b 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2213 993e2a1b 2020-07-23 stsp test_done "$testroot" "$ret"
2214 993e2a1b 2020-07-23 stsp return 1
2215 993e2a1b 2020-07-23 stsp fi
2216 993e2a1b 2020-07-23 stsp
2217 993e2a1b 2020-07-23 stsp if [ -h $testroot/wt/dotgotbar.link ]; then
2218 993e2a1b 2020-07-23 stsp echo "dotgotbar.link is a symlink"
2219 993e2a1b 2020-07-23 stsp test_done "$testroot" "1"
2220 993e2a1b 2020-07-23 stsp return 1
2221 993e2a1b 2020-07-23 stsp fi
2222 3b9f0f87 2020-07-23 stsp echo "<<<<<<< merged change: commit $commit_id2" \
2223 3b9f0f87 2020-07-23 stsp > $testroot/content.expected
2224 3b9f0f87 2020-07-23 stsp echo -n ".got/bar" >> $testroot/content.expected
2225 3b9f0f87 2020-07-23 stsp echo "=======" >> $testroot/content.expected
2226 3b9f0f87 2020-07-23 stsp echo "this is regular file bar" >> $testroot/content.expected
2227 3b9f0f87 2020-07-23 stsp echo '>>>>>>>' >> $testroot/content.expected
2228 3b9f0f87 2020-07-23 stsp echo -n "" >> $testroot/content.expected
2229 3b9f0f87 2020-07-23 stsp
2230 993e2a1b 2020-07-23 stsp cp $testroot/wt/dotgotbar.link $testroot/content
2231 993e2a1b 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2232 49c543a6 2022-03-31 naddy ret=$?
2233 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2234 993e2a1b 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2235 993e2a1b 2020-07-23 stsp test_done "$testroot" "$ret"
2236 993e2a1b 2020-07-23 stsp return 1
2237 993e2a1b 2020-07-23 stsp fi
2238 993e2a1b 2020-07-23 stsp
2239 993e2a1b 2020-07-23 stsp if [ -h $testroot/wt/new.link ]; then
2240 993e2a1b 2020-07-23 stsp echo "new.link is a symlink"
2241 993e2a1b 2020-07-23 stsp test_done "$testroot" "1"
2242 993e2a1b 2020-07-23 stsp return 1
2243 993e2a1b 2020-07-23 stsp fi
2244 993e2a1b 2020-07-23 stsp
2245 993e2a1b 2020-07-23 stsp echo "<<<<<<< merged change: commit $commit_id2" \
2246 283102fc 2020-07-23 stsp > $testroot/content.expected
2247 993e2a1b 2020-07-23 stsp echo "alpha" >> $testroot/content.expected
2248 993e2a1b 2020-07-23 stsp echo "=======" >> $testroot/content.expected
2249 993e2a1b 2020-07-23 stsp echo "beta" >> $testroot/content.expected
2250 993e2a1b 2020-07-23 stsp echo '>>>>>>>' >> $testroot/content.expected
2251 993e2a1b 2020-07-23 stsp echo -n "" >> $testroot/content.expected
2252 993e2a1b 2020-07-23 stsp
2253 993e2a1b 2020-07-23 stsp cp $testroot/wt/new.link $testroot/content
2254 993e2a1b 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2255 49c543a6 2022-03-31 naddy ret=$?
2256 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2257 993e2a1b 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2258 993e2a1b 2020-07-23 stsp test_done "$testroot" "$ret"
2259 993e2a1b 2020-07-23 stsp return 1
2260 993e2a1b 2020-07-23 stsp fi
2261 993e2a1b 2020-07-23 stsp
2262 993e2a1b 2020-07-23 stsp echo "A dotgotfoo.link" > $testroot/stdout.expected
2263 993e2a1b 2020-07-23 stsp echo "M new.link" >> $testroot/stdout.expected
2264 993e2a1b 2020-07-23 stsp echo "D nonexistent.link" >> $testroot/stdout.expected
2265 993e2a1b 2020-07-23 stsp (cd $testroot/wt && got status > $testroot/stdout)
2266 84246752 2022-06-03 op ret=$?
2267 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2268 993e2a1b 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2269 993e2a1b 2020-07-23 stsp test_done "$testroot" "$ret"
2270 993e2a1b 2020-07-23 stsp return 1
2271 993e2a1b 2020-07-23 stsp fi
2272 993e2a1b 2020-07-23 stsp
2273 993e2a1b 2020-07-23 stsp test_done "$testroot" "0"
2274 993e2a1b 2020-07-23 stsp
2275 f35fa46a 2020-07-23 stsp }
2276 194cb7cb 2021-01-19 stsp
2277 194cb7cb 2021-01-19 stsp test_update_single_file() {
2278 194cb7cb 2021-01-19 stsp local testroot=`test_init update_single_file 1`
2279 194cb7cb 2021-01-19 stsp
2280 194cb7cb 2021-01-19 stsp echo c1 > $testroot/repo/c
2281 194cb7cb 2021-01-19 stsp (cd $testroot/repo && git add .)
2282 79775c2f 2021-01-19 stsp git_commit $testroot/repo -m "adding file c"
2283 194cb7cb 2021-01-19 stsp local commit_id1=`git_show_head $testroot/repo`
2284 194cb7cb 2021-01-19 stsp
2285 194cb7cb 2021-01-19 stsp echo a > $testroot/repo/a
2286 194cb7cb 2021-01-19 stsp echo b > $testroot/repo/b
2287 194cb7cb 2021-01-19 stsp echo c2 > $testroot/repo/c
2288 194cb7cb 2021-01-19 stsp (cd $testroot/repo && git add .)
2289 79775c2f 2021-01-19 stsp git_commit $testroot/repo -m "add files a and b, change c"
2290 194cb7cb 2021-01-19 stsp local commit_id2=`git_show_head $testroot/repo`
2291 f35fa46a 2020-07-23 stsp
2292 d51387a0 2021-01-19 stsp (cd $testroot/repo && git rm -qf c)
2293 d51387a0 2021-01-19 stsp git_commit $testroot/repo -m "remove file c"
2294 d51387a0 2021-01-19 stsp local commit_id3=`git_show_head $testroot/repo`
2295 d51387a0 2021-01-19 stsp
2296 d51387a0 2021-01-19 stsp got checkout -c $commit_id2 $testroot/repo $testroot/wt > /dev/null
2297 49c543a6 2022-03-31 naddy ret=$?
2298 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2299 194cb7cb 2021-01-19 stsp test_done "$testroot" "$ret"
2300 194cb7cb 2021-01-19 stsp return 1
2301 194cb7cb 2021-01-19 stsp fi
2302 194cb7cb 2021-01-19 stsp
2303 194cb7cb 2021-01-19 stsp echo "U c" > $testroot/stdout.expected
2304 4f3c844b 2021-09-14 stsp echo "Updated to refs/heads/master: $commit_id1" \
2305 4f3c844b 2021-09-14 stsp >> $testroot/stdout.expected
2306 194cb7cb 2021-01-19 stsp
2307 194cb7cb 2021-01-19 stsp (cd $testroot/wt && got update -c $commit_id1 c \
2308 194cb7cb 2021-01-19 stsp > $testroot/stdout)
2309 194cb7cb 2021-01-19 stsp
2310 194cb7cb 2021-01-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2311 49c543a6 2022-03-31 naddy ret=$?
2312 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2313 194cb7cb 2021-01-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
2314 194cb7cb 2021-01-19 stsp test_done "$testroot" "$ret"
2315 194cb7cb 2021-01-19 stsp return 1
2316 194cb7cb 2021-01-19 stsp fi
2317 194cb7cb 2021-01-19 stsp
2318 194cb7cb 2021-01-19 stsp echo c1 > $testroot/content.expected
2319 194cb7cb 2021-01-19 stsp cat $testroot/wt/c > $testroot/content
2320 194cb7cb 2021-01-19 stsp
2321 194cb7cb 2021-01-19 stsp cmp -s $testroot/content.expected $testroot/content
2322 49c543a6 2022-03-31 naddy ret=$?
2323 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2324 194cb7cb 2021-01-19 stsp diff -u $testroot/content.expected $testroot/content
2325 194cb7cb 2021-01-19 stsp test_done "$testroot" "$ret"
2326 194cb7cb 2021-01-19 stsp return 1
2327 194cb7cb 2021-01-19 stsp fi
2328 194cb7cb 2021-01-19 stsp
2329 194cb7cb 2021-01-19 stsp echo "U c" > $testroot/stdout.expected
2330 4f3c844b 2021-09-14 stsp echo "Updated to refs/heads/master: $commit_id2" \
2331 4f3c844b 2021-09-14 stsp >> $testroot/stdout.expected
2332 194cb7cb 2021-01-19 stsp
2333 d51387a0 2021-01-19 stsp (cd $testroot/wt && got update -c $commit_id2 c > $testroot/stdout)
2334 194cb7cb 2021-01-19 stsp
2335 194cb7cb 2021-01-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2336 49c543a6 2022-03-31 naddy ret=$?
2337 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2338 194cb7cb 2021-01-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
2339 194cb7cb 2021-01-19 stsp test_done "$testroot" "$ret"
2340 194cb7cb 2021-01-19 stsp return 1
2341 194cb7cb 2021-01-19 stsp fi
2342 194cb7cb 2021-01-19 stsp
2343 194cb7cb 2021-01-19 stsp echo c2 > $testroot/content.expected
2344 194cb7cb 2021-01-19 stsp cat $testroot/wt/c > $testroot/content
2345 194cb7cb 2021-01-19 stsp
2346 194cb7cb 2021-01-19 stsp cmp -s $testroot/content.expected $testroot/content
2347 49c543a6 2022-03-31 naddy ret=$?
2348 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2349 194cb7cb 2021-01-19 stsp diff -u $testroot/content.expected $testroot/content
2350 d51387a0 2021-01-19 stsp test_done "$testroot" "$ret"
2351 d51387a0 2021-01-19 stsp return 1
2352 194cb7cb 2021-01-19 stsp fi
2353 d51387a0 2021-01-19 stsp
2354 d51387a0 2021-01-19 stsp echo "D c" > $testroot/stdout.expected
2355 4f3c844b 2021-09-14 stsp echo "Updated to refs/heads/master: $commit_id3" \
2356 4f3c844b 2021-09-14 stsp >> $testroot/stdout.expected
2357 d51387a0 2021-01-19 stsp
2358 d51387a0 2021-01-19 stsp (cd $testroot/wt && got update -c $commit_id3 c \
2359 d51387a0 2021-01-19 stsp > $testroot/stdout 2> $testroot/stderr)
2360 d51387a0 2021-01-19 stsp
2361 d51387a0 2021-01-19 stsp echo "got: /c: no such entry found in tree" > $testroot/stderr.expected
2362 d51387a0 2021-01-19 stsp cmp -s $testroot/stderr.expected $testroot/stderr
2363 49c543a6 2022-03-31 naddy ret=$?
2364 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2365 d51387a0 2021-01-19 stsp diff -u $testroot/stderr.expected $testroot/stderr
2366 d51387a0 2021-01-19 stsp test_done "$testroot" "$ret"
2367 d51387a0 2021-01-19 stsp return 1
2368 d51387a0 2021-01-19 stsp fi
2369 d51387a0 2021-01-19 stsp
2370 d51387a0 2021-01-19 stsp echo -n > $testroot/stdout.expected
2371 d51387a0 2021-01-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2372 49c543a6 2022-03-31 naddy ret=$?
2373 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2374 d51387a0 2021-01-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
2375 d51387a0 2021-01-19 stsp test_done "$testroot" "$ret"
2376 d51387a0 2021-01-19 stsp return 1
2377 d51387a0 2021-01-19 stsp fi
2378 d51387a0 2021-01-19 stsp
2379 d51387a0 2021-01-19 stsp echo "D c" > $testroot/stdout.expected
2380 4f3c844b 2021-09-14 stsp echo "Updated to refs/heads/master: $commit_id3" \
2381 4f3c844b 2021-09-14 stsp >> $testroot/stdout.expected
2382 d51387a0 2021-01-19 stsp
2383 d51387a0 2021-01-19 stsp (cd $testroot/wt && got update -c $commit_id3 > $testroot/stdout)
2384 d51387a0 2021-01-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2385 49c543a6 2022-03-31 naddy ret=$?
2386 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2387 d51387a0 2021-01-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
2388 d51387a0 2021-01-19 stsp test_done "$testroot" "$ret"
2389 d51387a0 2021-01-19 stsp return 1
2390 d51387a0 2021-01-19 stsp fi
2391 d51387a0 2021-01-19 stsp
2392 d51387a0 2021-01-19 stsp if [ -e $testroot/wt/c ]; then
2393 d51387a0 2021-01-19 stsp echo "removed file c still exists on disk" >&2
2394 d51387a0 2021-01-19 stsp test_done "$testroot" "1"
2395 d51387a0 2021-01-19 stsp return 1
2396 d51387a0 2021-01-19 stsp fi
2397 d51387a0 2021-01-19 stsp
2398 d51387a0 2021-01-19 stsp test_done "$testroot" "0"
2399 d51387a0 2021-01-19 stsp return 0
2400 a769b60b 2021-06-27 stsp }
2401 a769b60b 2021-06-27 stsp
2402 a769b60b 2021-06-27 stsp test_update_file_skipped_due_to_conflict() {
2403 a769b60b 2021-06-27 stsp local testroot=`test_init update_file_skipped_due_to_conflict`
2404 a769b60b 2021-06-27 stsp local commit_id0=`git_show_head $testroot/repo`
2405 a769b60b 2021-06-27 stsp blob_id0=`get_blob_id $testroot/repo "" beta`
2406 a769b60b 2021-06-27 stsp
2407 a769b60b 2021-06-27 stsp echo "changed beta" > $testroot/repo/beta
2408 a769b60b 2021-06-27 stsp git_commit $testroot/repo -m "changed beta"
2409 a769b60b 2021-06-27 stsp local commit_id1=`git_show_head $testroot/repo`
2410 a769b60b 2021-06-27 stsp blob_id1=`get_blob_id $testroot/repo "" beta`
2411 a769b60b 2021-06-27 stsp
2412 a769b60b 2021-06-27 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2413 49c543a6 2022-03-31 naddy ret=$?
2414 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2415 a769b60b 2021-06-27 stsp test_done "$testroot" "$ret"
2416 a769b60b 2021-06-27 stsp return 1
2417 a769b60b 2021-06-27 stsp fi
2418 a769b60b 2021-06-27 stsp
2419 a769b60b 2021-06-27 stsp blob_id=`(cd $testroot/wt && got info beta | grep 'blob:' | \
2420 a769b60b 2021-06-27 stsp cut -d ':' -f 2 | tr -d ' ')`
2421 a769b60b 2021-06-27 stsp if [ "$blob_id" != "$blob_id1" ]; then
2422 a769b60b 2021-06-27 stsp echo "file beta has the wrong base blob ID" >&2
2423 a769b60b 2021-06-27 stsp test_done "$testroot" "1"
2424 a769b60b 2021-06-27 stsp return 1
2425 a769b60b 2021-06-27 stsp fi
2426 a769b60b 2021-06-27 stsp
2427 a769b60b 2021-06-27 stsp commit_id=`(cd $testroot/wt && got info beta | \
2428 a769b60b 2021-06-27 stsp grep 'based on commit:' | cut -d ':' -f 2 | tr -d ' ')`
2429 a769b60b 2021-06-27 stsp if [ "$commit_id" != "$commit_id1" ]; then
2430 a769b60b 2021-06-27 stsp echo "file beta has the wrong base commit ID" >&2
2431 a769b60b 2021-06-27 stsp test_done "$testroot" "1"
2432 a769b60b 2021-06-27 stsp return 1
2433 a769b60b 2021-06-27 stsp fi
2434 a769b60b 2021-06-27 stsp
2435 a769b60b 2021-06-27 stsp echo "modified beta" > $testroot/wt/beta
2436 a769b60b 2021-06-27 stsp
2437 a769b60b 2021-06-27 stsp (cd $testroot/wt && got update -c $commit_id0 > $testroot/stdout)
2438 a769b60b 2021-06-27 stsp
2439 a769b60b 2021-06-27 stsp echo "C beta" > $testroot/stdout.expected
2440 4f3c844b 2021-09-14 stsp echo "Updated to refs/heads/master: $commit_id0" \
2441 4f3c844b 2021-09-14 stsp >> $testroot/stdout.expected
2442 a769b60b 2021-06-27 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
2443 a769b60b 2021-06-27 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2444 49c543a6 2022-03-31 naddy ret=$?
2445 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2446 a769b60b 2021-06-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
2447 a769b60b 2021-06-27 stsp test_done "$testroot" "$ret"
2448 a769b60b 2021-06-27 stsp return 1
2449 a769b60b 2021-06-27 stsp fi
2450 a769b60b 2021-06-27 stsp
2451 a769b60b 2021-06-27 stsp echo "<<<<<<< merged change: commit $commit_id0" \
2452 a769b60b 2021-06-27 stsp > $testroot/content.expected
2453 a769b60b 2021-06-27 stsp echo "beta" >> $testroot/content.expected
2454 a769b60b 2021-06-27 stsp echo "||||||| 3-way merge base: commit $commit_id1" \
2455 a769b60b 2021-06-27 stsp >> $testroot/content.expected
2456 a769b60b 2021-06-27 stsp echo "changed beta" >> $testroot/content.expected
2457 a769b60b 2021-06-27 stsp echo "=======" >> $testroot/content.expected
2458 a769b60b 2021-06-27 stsp echo "modified beta" >> $testroot/content.expected
2459 a769b60b 2021-06-27 stsp echo ">>>>>>>" >> $testroot/content.expected
2460 a769b60b 2021-06-27 stsp
2461 a769b60b 2021-06-27 stsp cat $testroot/wt/beta > $testroot/content
2462 a769b60b 2021-06-27 stsp
2463 a769b60b 2021-06-27 stsp cmp -s $testroot/content.expected $testroot/content
2464 49c543a6 2022-03-31 naddy ret=$?
2465 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2466 a769b60b 2021-06-27 stsp diff -u $testroot/content.expected $testroot/content
2467 a769b60b 2021-06-27 stsp test_done "$testroot" "$ret"
2468 a769b60b 2021-06-27 stsp return 1
2469 a769b60b 2021-06-27 stsp fi
2470 a769b60b 2021-06-27 stsp
2471 a769b60b 2021-06-27 stsp blob_id=`(cd $testroot/wt && got info beta | grep 'blob:' | \
2472 a769b60b 2021-06-27 stsp cut -d ':' -f 2 | tr -d ' ')`
2473 a769b60b 2021-06-27 stsp if [ "$blob_id" != "$blob_id0" ]; then
2474 a769b60b 2021-06-27 stsp echo "file beta has the wrong base blob ID" >&2
2475 a769b60b 2021-06-27 stsp test_done "$testroot" "1"
2476 a769b60b 2021-06-27 stsp return 1
2477 a769b60b 2021-06-27 stsp fi
2478 a769b60b 2021-06-27 stsp
2479 a769b60b 2021-06-27 stsp commit_id=`(cd $testroot/wt && got info beta | \
2480 a769b60b 2021-06-27 stsp grep 'based on commit:' | cut -d ':' -f 2 | tr -d ' ')`
2481 a769b60b 2021-06-27 stsp if [ "$commit_id" != "$commit_id0" ]; then
2482 a769b60b 2021-06-27 stsp echo "file beta has the wrong base commit ID" >&2
2483 a769b60b 2021-06-27 stsp test_done "$testroot" "1"
2484 a769b60b 2021-06-27 stsp return 1
2485 a769b60b 2021-06-27 stsp fi
2486 a769b60b 2021-06-27 stsp
2487 a769b60b 2021-06-27 stsp # update to the latest commit again; this skips beta
2488 a769b60b 2021-06-27 stsp (cd $testroot/wt && got update > $testroot/stdout)
2489 a769b60b 2021-06-27 stsp echo "# beta" > $testroot/stdout.expected
2490 4f3c844b 2021-09-14 stsp echo "Updated to refs/heads/master: $commit_id1" \
2491 4f3c844b 2021-09-14 stsp >> $testroot/stdout.expected
2492 a769b60b 2021-06-27 stsp echo "Files not updated because of existing merge conflicts: 1" \
2493 a769b60b 2021-06-27 stsp >> $testroot/stdout.expected
2494 a769b60b 2021-06-27 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2495 49c543a6 2022-03-31 naddy ret=$?
2496 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2497 a769b60b 2021-06-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
2498 a769b60b 2021-06-27 stsp test_done "$testroot" "$ret"
2499 a769b60b 2021-06-27 stsp return 1
2500 a769b60b 2021-06-27 stsp fi
2501 a769b60b 2021-06-27 stsp
2502 a769b60b 2021-06-27 stsp # blob ID of beta should not have changed
2503 a769b60b 2021-06-27 stsp blob_id=`(cd $testroot/wt && got info beta | grep 'blob:' | \
2504 a769b60b 2021-06-27 stsp cut -d ':' -f 2 | tr -d ' ')`
2505 a769b60b 2021-06-27 stsp if [ "$blob_id" != "$blob_id0" ]; then
2506 a769b60b 2021-06-27 stsp echo "file beta has the wrong base blob ID" >&2
2507 a769b60b 2021-06-27 stsp test_done "$testroot" "1"
2508 a769b60b 2021-06-27 stsp return 1
2509 a769b60b 2021-06-27 stsp fi
2510 a769b60b 2021-06-27 stsp
2511 a769b60b 2021-06-27 stsp # commit ID of beta should not have changed; There was a bug
2512 a769b60b 2021-06-27 stsp # here where the commit ID had been changed even though the
2513 a769b60b 2021-06-27 stsp # file was not updated.
2514 a769b60b 2021-06-27 stsp commit_id=`(cd $testroot/wt && got info beta | \
2515 a769b60b 2021-06-27 stsp grep 'based on commit:' | cut -d ':' -f 2 | tr -d ' ')`
2516 a769b60b 2021-06-27 stsp if [ "$commit_id" != "$commit_id0" ]; then
2517 a769b60b 2021-06-27 stsp echo "file beta has the wrong base commit ID: $commit_id" >&2
2518 a769b60b 2021-06-27 stsp test_done "$testroot" "1"
2519 a769b60b 2021-06-27 stsp return 1
2520 a769b60b 2021-06-27 stsp fi
2521 a769b60b 2021-06-27 stsp
2522 a769b60b 2021-06-27 stsp # beta is still conflicted and based on commit 0
2523 a769b60b 2021-06-27 stsp echo 'C beta' > $testroot/stdout.expected
2524 a769b60b 2021-06-27 stsp (cd $testroot/wt && got status > $testroot/stdout)
2525 a769b60b 2021-06-27 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2526 49c543a6 2022-03-31 naddy ret=$?
2527 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2528 a769b60b 2021-06-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
2529 a769b60b 2021-06-27 stsp test_done "$testroot" "$ret"
2530 a769b60b 2021-06-27 stsp return 1
2531 a769b60b 2021-06-27 stsp fi
2532 a769b60b 2021-06-27 stsp
2533 a769b60b 2021-06-27 stsp # resolve the conflict via revert
2534 a769b60b 2021-06-27 stsp (cd $testroot/wt && got revert beta >/dev/null)
2535 a769b60b 2021-06-27 stsp
2536 a769b60b 2021-06-27 stsp # beta now matches its base blob which is still from commit 0
2537 a769b60b 2021-06-27 stsp echo "beta" > $testroot/content.expected
2538 a769b60b 2021-06-27 stsp cat $testroot/wt/beta > $testroot/content
2539 a769b60b 2021-06-27 stsp cmp -s $testroot/content.expected $testroot/content
2540 49c543a6 2022-03-31 naddy ret=$?
2541 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2542 a769b60b 2021-06-27 stsp diff -u $testroot/content.expected $testroot/content
2543 a769b60b 2021-06-27 stsp test_done "$testroot" "$ret"
2544 a769b60b 2021-06-27 stsp return 1
2545 a769b60b 2021-06-27 stsp fi
2546 a769b60b 2021-06-27 stsp
2547 a769b60b 2021-06-27 stsp # updating to the latest commit should now update beta
2548 a769b60b 2021-06-27 stsp (cd $testroot/wt && got update > $testroot/stdout)
2549 a769b60b 2021-06-27 stsp echo "U beta" > $testroot/stdout.expected
2550 4f3c844b 2021-09-14 stsp echo "Updated to refs/heads/master: $commit_id1" \
2551 4f3c844b 2021-09-14 stsp >> $testroot/stdout.expected
2552 2c41dce7 2021-06-27 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2553 49c543a6 2022-03-31 naddy ret=$?
2554 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2555 2c41dce7 2021-06-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
2556 2c41dce7 2021-06-27 stsp test_done "$testroot" "$ret"
2557 2c41dce7 2021-06-27 stsp return 1
2558 2c41dce7 2021-06-27 stsp fi
2559 2c41dce7 2021-06-27 stsp
2560 2c41dce7 2021-06-27 stsp blob_id=`(cd $testroot/wt && got info beta | grep 'blob:' | \
2561 2c41dce7 2021-06-27 stsp cut -d ':' -f 2 | tr -d ' ')`
2562 2c41dce7 2021-06-27 stsp if [ "$blob_id" != "$blob_id1" ]; then
2563 2c41dce7 2021-06-27 stsp echo "file beta has the wrong base blob ID" >&2
2564 2c41dce7 2021-06-27 stsp test_done "$testroot" "1"
2565 2c41dce7 2021-06-27 stsp return 1
2566 2c41dce7 2021-06-27 stsp fi
2567 2c41dce7 2021-06-27 stsp
2568 2c41dce7 2021-06-27 stsp commit_id=`(cd $testroot/wt && got info beta | \
2569 2c41dce7 2021-06-27 stsp grep 'based on commit:' | cut -d ':' -f 2 | tr -d ' ')`
2570 2c41dce7 2021-06-27 stsp if [ "$commit_id" != "$commit_id1" ]; then
2571 2c41dce7 2021-06-27 stsp echo "file beta has the wrong base commit ID: $commit_id" >&2
2572 2c41dce7 2021-06-27 stsp test_done "$testroot" "1"
2573 2c41dce7 2021-06-27 stsp return 1
2574 2c41dce7 2021-06-27 stsp fi
2575 2c41dce7 2021-06-27 stsp
2576 2c41dce7 2021-06-27 stsp echo "changed beta" > $testroot/content.expected
2577 2c41dce7 2021-06-27 stsp cat $testroot/wt/beta > $testroot/content
2578 2c41dce7 2021-06-27 stsp cmp -s $testroot/content.expected $testroot/content
2579 49c543a6 2022-03-31 naddy ret=$?
2580 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2581 2c41dce7 2021-06-27 stsp diff -u $testroot/content.expected $testroot/content
2582 2c41dce7 2021-06-27 stsp fi
2583 2c41dce7 2021-06-27 stsp test_done "$testroot" "$ret"
2584 2c41dce7 2021-06-27 stsp }
2585 2c41dce7 2021-06-27 stsp
2586 2c41dce7 2021-06-27 stsp test_update_file_skipped_due_to_obstruction() {
2587 2c41dce7 2021-06-27 stsp local testroot=`test_init update_file_skipped_due_to_obstruction`
2588 2c41dce7 2021-06-27 stsp local commit_id0=`git_show_head $testroot/repo`
2589 2c41dce7 2021-06-27 stsp blob_id0=`get_blob_id $testroot/repo "" beta`
2590 2c41dce7 2021-06-27 stsp
2591 2c41dce7 2021-06-27 stsp echo "changed beta" > $testroot/repo/beta
2592 f6764181 2021-09-24 stsp echo "new file" > $testroot/repo/new
2593 f6764181 2021-09-24 stsp (cd $testroot/repo && git add new)
2594 2c41dce7 2021-06-27 stsp git_commit $testroot/repo -m "changed beta"
2595 2c41dce7 2021-06-27 stsp local commit_id1=`git_show_head $testroot/repo`
2596 2c41dce7 2021-06-27 stsp blob_id1=`get_blob_id $testroot/repo "" beta`
2597 2c41dce7 2021-06-27 stsp
2598 2c41dce7 2021-06-27 stsp got checkout -c $commit_id0 $testroot/repo $testroot/wt > /dev/null
2599 49c543a6 2022-03-31 naddy ret=$?
2600 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2601 2c41dce7 2021-06-27 stsp test_done "$testroot" "$ret"
2602 2c41dce7 2021-06-27 stsp return 1
2603 2c41dce7 2021-06-27 stsp fi
2604 2c41dce7 2021-06-27 stsp
2605 2c41dce7 2021-06-27 stsp blob_id=`(cd $testroot/wt && got info beta | grep 'blob:' | \
2606 2c41dce7 2021-06-27 stsp cut -d ':' -f 2 | tr -d ' ')`
2607 2c41dce7 2021-06-27 stsp if [ "$blob_id" != "$blob_id0" ]; then
2608 2c41dce7 2021-06-27 stsp echo "file beta has the wrong base blob ID" >&2
2609 2c41dce7 2021-06-27 stsp test_done "$testroot" "1"
2610 2c41dce7 2021-06-27 stsp return 1
2611 2c41dce7 2021-06-27 stsp fi
2612 2c41dce7 2021-06-27 stsp
2613 2c41dce7 2021-06-27 stsp commit_id=`(cd $testroot/wt && got info beta | \
2614 2c41dce7 2021-06-27 stsp grep 'based on commit:' | cut -d ':' -f 2 | tr -d ' ')`
2615 2c41dce7 2021-06-27 stsp if [ "$commit_id" != "$commit_id0" ]; then
2616 2c41dce7 2021-06-27 stsp echo "file beta has the wrong base commit ID" >&2
2617 2c41dce7 2021-06-27 stsp test_done "$testroot" "1"
2618 2c41dce7 2021-06-27 stsp return 1
2619 2c41dce7 2021-06-27 stsp fi
2620 2c41dce7 2021-06-27 stsp
2621 2c41dce7 2021-06-27 stsp rm $testroot/wt/beta
2622 2c41dce7 2021-06-27 stsp mkdir -p $testroot/wt/beta/psi
2623 f6764181 2021-09-24 stsp mkdir -p $testroot/wt/new
2624 2c41dce7 2021-06-27 stsp
2625 f6764181 2021-09-24 stsp # update to the latest commit; this skips beta and the new file
2626 2c41dce7 2021-06-27 stsp (cd $testroot/wt && got update > $testroot/stdout)
2627 49c543a6 2022-03-31 naddy ret=$?
2628 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2629 f6764181 2021-09-24 stsp echo "update failed unexpectedly" >&2
2630 f6764181 2021-09-24 stsp test_done "$testroot" "1"
2631 f6764181 2021-09-24 stsp return 1
2632 f6764181 2021-09-24 stsp fi
2633 2c41dce7 2021-06-27 stsp
2634 2c41dce7 2021-06-27 stsp echo "~ beta" > $testroot/stdout.expected
2635 f6764181 2021-09-24 stsp echo "~ new" >> $testroot/stdout.expected
2636 4f3c844b 2021-09-14 stsp echo "Updated to refs/heads/master: $commit_id1" \
2637 4f3c844b 2021-09-14 stsp >> $testroot/stdout.expected
2638 f6764181 2021-09-24 stsp echo "File paths obstructed by a non-regular file: 2" \
2639 4f3c844b 2021-09-14 stsp >> $testroot/stdout.expected
2640 a769b60b 2021-06-27 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2641 49c543a6 2022-03-31 naddy ret=$?
2642 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2643 a769b60b 2021-06-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
2644 a769b60b 2021-06-27 stsp test_done "$testroot" "$ret"
2645 a769b60b 2021-06-27 stsp return 1
2646 a769b60b 2021-06-27 stsp fi
2647 a769b60b 2021-06-27 stsp
2648 a769b60b 2021-06-27 stsp blob_id=`(cd $testroot/wt && got info beta | grep 'blob:' | \
2649 a769b60b 2021-06-27 stsp cut -d ':' -f 2 | tr -d ' ')`
2650 2c41dce7 2021-06-27 stsp if [ "$blob_id" != "$blob_id0" ]; then
2651 2c41dce7 2021-06-27 stsp echo "file beta has the wrong base blob ID" >&2
2652 2c41dce7 2021-06-27 stsp test_done "$testroot" "1"
2653 2c41dce7 2021-06-27 stsp return 1
2654 2c41dce7 2021-06-27 stsp fi
2655 2c41dce7 2021-06-27 stsp
2656 2c41dce7 2021-06-27 stsp commit_id=`(cd $testroot/wt && got info beta | \
2657 2c41dce7 2021-06-27 stsp grep 'based on commit:' | cut -d ':' -f 2 | tr -d ' ')`
2658 2c41dce7 2021-06-27 stsp if [ "$commit_id" != "$commit_id0" ]; then
2659 2c41dce7 2021-06-27 stsp echo "file beta has the wrong base commit ID" >&2
2660 2c41dce7 2021-06-27 stsp test_done "$testroot" "1"
2661 2c41dce7 2021-06-27 stsp return 1
2662 2c41dce7 2021-06-27 stsp fi
2663 2c41dce7 2021-06-27 stsp
2664 2c41dce7 2021-06-27 stsp # remove the directory which obstructs file beta
2665 2c41dce7 2021-06-27 stsp rm -r $testroot/wt/beta
2666 2c41dce7 2021-06-27 stsp
2667 2c41dce7 2021-06-27 stsp # updating to the latest commit should now update beta
2668 2c41dce7 2021-06-27 stsp (cd $testroot/wt && got update > $testroot/stdout)
2669 2c41dce7 2021-06-27 stsp echo "! beta" > $testroot/stdout.expected
2670 f6764181 2021-09-24 stsp echo "~ new" >> $testroot/stdout.expected
2671 4f3c844b 2021-09-14 stsp echo "Updated to refs/heads/master: $commit_id1" \
2672 4f3c844b 2021-09-14 stsp >> $testroot/stdout.expected
2673 f6764181 2021-09-24 stsp echo "File paths obstructed by a non-regular file: 1" \
2674 f6764181 2021-09-24 stsp >> $testroot/stdout.expected
2675 2c41dce7 2021-06-27 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2676 49c543a6 2022-03-31 naddy ret=$?
2677 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2678 2c41dce7 2021-06-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
2679 2c41dce7 2021-06-27 stsp test_done "$testroot" "$ret"
2680 2c41dce7 2021-06-27 stsp return 1
2681 2c41dce7 2021-06-27 stsp fi
2682 2c41dce7 2021-06-27 stsp
2683 2c41dce7 2021-06-27 stsp blob_id=`(cd $testroot/wt && got info beta | grep 'blob:' | \
2684 2c41dce7 2021-06-27 stsp cut -d ':' -f 2 | tr -d ' ')`
2685 a769b60b 2021-06-27 stsp if [ "$blob_id" != "$blob_id1" ]; then
2686 a769b60b 2021-06-27 stsp echo "file beta has the wrong base blob ID" >&2
2687 a769b60b 2021-06-27 stsp test_done "$testroot" "1"
2688 a769b60b 2021-06-27 stsp return 1
2689 a769b60b 2021-06-27 stsp fi
2690 a769b60b 2021-06-27 stsp
2691 a769b60b 2021-06-27 stsp commit_id=`(cd $testroot/wt && got info beta | \
2692 a769b60b 2021-06-27 stsp grep 'based on commit:' | cut -d ':' -f 2 | tr -d ' ')`
2693 a769b60b 2021-06-27 stsp if [ "$commit_id" != "$commit_id1" ]; then
2694 a769b60b 2021-06-27 stsp echo "file beta has the wrong base commit ID: $commit_id" >&2
2695 a769b60b 2021-06-27 stsp test_done "$testroot" "1"
2696 a769b60b 2021-06-27 stsp return 1
2697 a769b60b 2021-06-27 stsp fi
2698 a769b60b 2021-06-27 stsp
2699 a769b60b 2021-06-27 stsp echo "changed beta" > $testroot/content.expected
2700 a769b60b 2021-06-27 stsp cat $testroot/wt/beta > $testroot/content
2701 a769b60b 2021-06-27 stsp cmp -s $testroot/content.expected $testroot/content
2702 49c543a6 2022-03-31 naddy ret=$?
2703 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2704 a769b60b 2021-06-27 stsp diff -u $testroot/content.expected $testroot/content
2705 a769b60b 2021-06-27 stsp fi
2706 a769b60b 2021-06-27 stsp test_done "$testroot" "$ret"
2707 194cb7cb 2021-01-19 stsp }
2708 67c65ed7 2021-09-14 tracey
2709 67c65ed7 2021-09-14 tracey test_update_quiet() {
2710 67c65ed7 2021-09-14 tracey local testroot=`test_init update_quiet`
2711 67c65ed7 2021-09-14 tracey
2712 67c65ed7 2021-09-14 tracey got checkout $testroot/repo $testroot/wt > /dev/null
2713 49c543a6 2022-03-31 naddy ret=$?
2714 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2715 67c65ed7 2021-09-14 tracey test_done "$testroot" "$ret"
2716 67c65ed7 2021-09-14 tracey return 1
2717 67c65ed7 2021-09-14 tracey fi
2718 67c65ed7 2021-09-14 tracey
2719 67c65ed7 2021-09-14 tracey echo "modified alpha" > $testroot/repo/alpha
2720 67c65ed7 2021-09-14 tracey git_commit $testroot/repo -m "modified alpha"
2721 67c65ed7 2021-09-14 tracey
2722 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
2723 67c65ed7 2021-09-14 tracey git_show_head $testroot/repo >> $testroot/stdout.expected
2724 67c65ed7 2021-09-14 tracey echo >> $testroot/stdout.expected
2725 67c65ed7 2021-09-14 tracey
2726 67c65ed7 2021-09-14 tracey (cd $testroot/wt && got update -q > $testroot/stdout)
2727 67c65ed7 2021-09-14 tracey
2728 67c65ed7 2021-09-14 tracey cmp -s $testroot/stdout.expected $testroot/stdout
2729 49c543a6 2022-03-31 naddy ret=$?
2730 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2731 67c65ed7 2021-09-14 tracey diff -u $testroot/stdout.expected $testroot/stdout
2732 67c65ed7 2021-09-14 tracey test_done "$testroot" "$ret"
2733 67c65ed7 2021-09-14 tracey return 1
2734 67c65ed7 2021-09-14 tracey fi
2735 194cb7cb 2021-01-19 stsp
2736 67c65ed7 2021-09-14 tracey echo "modified alpha" > $testroot/content.expected
2737 67c65ed7 2021-09-14 tracey cat $testroot/wt/alpha > $testroot/content
2738 194cb7cb 2021-01-19 stsp
2739 67c65ed7 2021-09-14 tracey cmp -s $testroot/content.expected $testroot/content
2740 49c543a6 2022-03-31 naddy ret=$?
2741 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2742 67c65ed7 2021-09-14 tracey diff -u $testroot/content.expected $testroot/content
2743 67c65ed7 2021-09-14 tracey fi
2744 67c65ed7 2021-09-14 tracey test_done "$testroot" "$ret"
2745 0e039681 2021-11-15 stsp }
2746 0e039681 2021-11-15 stsp
2747 0e039681 2021-11-15 stsp test_update_binary_file() {
2748 0e039681 2021-11-15 stsp local testroot=`test_init update_binary_file`
2749 0e039681 2021-11-15 stsp local commit_id0=`git_show_head $testroot/repo`
2750 0e039681 2021-11-15 stsp
2751 0e039681 2021-11-15 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2752 49c543a6 2022-03-31 naddy ret=$?
2753 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2754 0e039681 2021-11-15 stsp test_done "$testroot" "$ret"
2755 0e039681 2021-11-15 stsp return 1
2756 0e039681 2021-11-15 stsp fi
2757 0e039681 2021-11-15 stsp
2758 0e039681 2021-11-15 stsp cp /bin/ls $testroot/wt/foo
2759 0e039681 2021-11-15 stsp chmod 755 $testroot/wt/foo
2760 0e039681 2021-11-15 stsp (cd $testroot/wt && got add foo >/dev/null)
2761 0e039681 2021-11-15 stsp (cd $testroot/wt && got commit -m 'add binary file' > /dev/null)
2762 0e039681 2021-11-15 stsp local commit_id1=`git_show_head $testroot/repo`
2763 0e039681 2021-11-15 stsp
2764 0e039681 2021-11-15 stsp cp /bin/cat $testroot/wt/foo
2765 0e039681 2021-11-15 stsp chmod 755 $testroot/wt/foo
2766 0e039681 2021-11-15 stsp (cd $testroot/wt && got commit -m 'change binary file' > /dev/null)
2767 0e039681 2021-11-15 stsp local commit_id2=`git_show_head $testroot/repo`
2768 0e039681 2021-11-15 stsp
2769 0e039681 2021-11-15 stsp cp /bin/cp $testroot/wt/foo
2770 0e039681 2021-11-15 stsp chmod 755 $testroot/wt/foo
2771 0e039681 2021-11-15 stsp (cd $testroot/wt && got commit -m 'change binary file' > /dev/null)
2772 0e039681 2021-11-15 stsp local commit_id3=`git_show_head $testroot/repo`
2773 0e039681 2021-11-15 stsp
2774 0e039681 2021-11-15 stsp (cd $testroot/wt && got rm foo >/dev/null)
2775 0e039681 2021-11-15 stsp (cd $testroot/wt && got commit -m 'remove binary file' > /dev/null)
2776 0e039681 2021-11-15 stsp local commit_id4=`git_show_head $testroot/repo`
2777 0e039681 2021-11-15 stsp
2778 0e039681 2021-11-15 stsp # backdate the work tree to make it usable for updating
2779 0e039681 2021-11-15 stsp (cd $testroot/wt && got up -c $commit_id0 > /dev/null)
2780 0e039681 2021-11-15 stsp
2781 0e039681 2021-11-15 stsp # update which adds a binary file
2782 0e039681 2021-11-15 stsp (cd $testroot/wt && got up -c $commit_id1 > $testroot/stdout)
2783 0e039681 2021-11-15 stsp
2784 0e039681 2021-11-15 stsp echo "A foo" > $testroot/stdout.expected
2785 0e039681 2021-11-15 stsp echo -n "Updated to refs/heads/master: $commit_id1" \
2786 0e039681 2021-11-15 stsp >> $testroot/stdout.expected
2787 0e039681 2021-11-15 stsp echo >> $testroot/stdout.expected
2788 0e039681 2021-11-15 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2789 49c543a6 2022-03-31 naddy ret=$?
2790 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2791 0e039681 2021-11-15 stsp diff -u $testroot/stdout.expected $testroot/stdout
2792 0e039681 2021-11-15 stsp test_done "$testroot" "$ret"
2793 0e039681 2021-11-15 stsp return 1
2794 0e039681 2021-11-15 stsp fi
2795 0e039681 2021-11-15 stsp
2796 0e039681 2021-11-15 stsp cp /bin/ls $testroot/content.expected
2797 0e039681 2021-11-15 stsp chmod 755 $testroot/content.expected
2798 0e039681 2021-11-15 stsp cat $testroot/wt/foo > $testroot/content
2799 0e039681 2021-11-15 stsp
2800 0e039681 2021-11-15 stsp cmp -s $testroot/content.expected $testroot/content
2801 49c543a6 2022-03-31 naddy ret=$?
2802 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2803 0e039681 2021-11-15 stsp diff -u $testroot/content.expected $testroot/content
2804 0e039681 2021-11-15 stsp test_done "$testroot" "$ret"
2805 0e039681 2021-11-15 stsp return 1
2806 0e039681 2021-11-15 stsp fi
2807 0e039681 2021-11-15 stsp
2808 0e039681 2021-11-15 stsp # update which adds a conflicting binary file
2809 0e039681 2021-11-15 stsp (cd $testroot/wt && got up -c $commit_id0 > /dev/null)
2810 0e039681 2021-11-15 stsp cp /bin/cat $testroot/wt/foo
2811 0e039681 2021-11-15 stsp chmod 755 $testroot/wt/foo
2812 0e039681 2021-11-15 stsp (cd $testroot/wt && got add foo > /dev/null)
2813 0e039681 2021-11-15 stsp (cd $testroot/wt && got up -c $commit_id1 > $testroot/stdout)
2814 0e039681 2021-11-15 stsp
2815 0e039681 2021-11-15 stsp echo "C foo" > $testroot/stdout.expected
2816 0e039681 2021-11-15 stsp echo "Updated to refs/heads/master: $commit_id1" \
2817 0e039681 2021-11-15 stsp >> $testroot/stdout.expected
2818 0e039681 2021-11-15 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
2819 0e039681 2021-11-15 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2820 49c543a6 2022-03-31 naddy ret=$?
2821 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2822 0e039681 2021-11-15 stsp diff -u $testroot/stdout.expected $testroot/stdout
2823 0e039681 2021-11-15 stsp test_done "$testroot" "$ret"
2824 0e039681 2021-11-15 stsp return 1
2825 0e039681 2021-11-15 stsp fi
2826 0e039681 2021-11-15 stsp
2827 0e039681 2021-11-15 stsp echo "Binary files differ and cannot be merged automatically:" \
2828 0e039681 2021-11-15 stsp > $testroot/content.expected
2829 0e039681 2021-11-15 stsp echo "<<<<<<< merged change: commit $commit_id1" \
2830 0e039681 2021-11-15 stsp >> $testroot/content.expected
2831 0e039681 2021-11-15 stsp echo -n "file " >> $testroot/content.expected
2832 0e039681 2021-11-15 stsp ls $testroot/wt/foo-1-* >> $testroot/content.expected
2833 0e039681 2021-11-15 stsp echo '=======' >> $testroot/content.expected
2834 0e039681 2021-11-15 stsp echo -n "file " >> $testroot/content.expected
2835 0e039681 2021-11-15 stsp ls $testroot/wt/foo-2-* >> $testroot/content.expected
2836 0e039681 2021-11-15 stsp echo ">>>>>>>" >> $testroot/content.expected
2837 0e039681 2021-11-15 stsp cat $testroot/wt/foo > $testroot/content
2838 0e039681 2021-11-15 stsp
2839 0e039681 2021-11-15 stsp cmp -s $testroot/content.expected $testroot/content
2840 49c543a6 2022-03-31 naddy ret=$?
2841 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2842 0e039681 2021-11-15 stsp diff -u $testroot/content.expected $testroot/content
2843 0e039681 2021-11-15 stsp test_done "$testroot" "$ret"
2844 0e039681 2021-11-15 stsp return 1
2845 0e039681 2021-11-15 stsp fi
2846 0e039681 2021-11-15 stsp
2847 0e039681 2021-11-15 stsp cp /bin/ls $testroot/content.expected
2848 0e039681 2021-11-15 stsp chmod 755 $testroot/content.expected
2849 0e039681 2021-11-15 stsp cat $testroot/wt/foo-1-* > $testroot/content
2850 0e039681 2021-11-15 stsp
2851 0e039681 2021-11-15 stsp cmp -s $testroot/content.expected $testroot/content
2852 49c543a6 2022-03-31 naddy ret=$?
2853 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2854 0e039681 2021-11-15 stsp diff -u $testroot/content.expected $testroot/content
2855 0e039681 2021-11-15 stsp test_done "$testroot" "$ret"
2856 0e039681 2021-11-15 stsp return 1
2857 0e039681 2021-11-15 stsp fi
2858 0e039681 2021-11-15 stsp
2859 0e039681 2021-11-15 stsp cp /bin/cat $testroot/content.expected
2860 0e039681 2021-11-15 stsp chmod 755 $testroot/content.expected
2861 0e039681 2021-11-15 stsp cat $testroot/wt/foo-2-* > $testroot/content
2862 0e039681 2021-11-15 stsp
2863 0e039681 2021-11-15 stsp cmp -s $testroot/content.expected $testroot/content
2864 49c543a6 2022-03-31 naddy ret=$?
2865 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2866 0e039681 2021-11-15 stsp diff -u $testroot/content.expected $testroot/content
2867 0e039681 2021-11-15 stsp test_done "$testroot" "$ret"
2868 0e039681 2021-11-15 stsp return 1
2869 0e039681 2021-11-15 stsp fi
2870 0e039681 2021-11-15 stsp
2871 0e039681 2021-11-15 stsp # tidy up
2872 0e039681 2021-11-15 stsp (cd $testroot/wt && got revert -R . >/dev/null)
2873 0e039681 2021-11-15 stsp rm $testroot/wt/foo-1-* $testroot/wt/foo-2-*
2874 0e039681 2021-11-15 stsp (cd $testroot/wt && got up -c $commit_id1 > /dev/null)
2875 0e039681 2021-11-15 stsp
2876 0e039681 2021-11-15 stsp # update which changes a binary file
2877 0e039681 2021-11-15 stsp (cd $testroot/wt && got up -c $commit_id2 > $testroot/stdout)
2878 0e039681 2021-11-15 stsp
2879 0e039681 2021-11-15 stsp echo "U foo" > $testroot/stdout.expected
2880 0e039681 2021-11-15 stsp echo -n "Updated to refs/heads/master: $commit_id2" \
2881 0e039681 2021-11-15 stsp >> $testroot/stdout.expected
2882 0e039681 2021-11-15 stsp echo >> $testroot/stdout.expected
2883 0e039681 2021-11-15 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2884 49c543a6 2022-03-31 naddy ret=$?
2885 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2886 0e039681 2021-11-15 stsp diff -u $testroot/stdout.expected $testroot/stdout
2887 0e039681 2021-11-15 stsp test_done "$testroot" "$ret"
2888 0e039681 2021-11-15 stsp return 1
2889 0e039681 2021-11-15 stsp fi
2890 0e039681 2021-11-15 stsp
2891 0e039681 2021-11-15 stsp cp /bin/cat $testroot/content.expected
2892 0e039681 2021-11-15 stsp chmod 755 $testroot/content.expected
2893 0e039681 2021-11-15 stsp cat $testroot/wt/foo > $testroot/content
2894 0e039681 2021-11-15 stsp
2895 0e039681 2021-11-15 stsp cmp -s $testroot/content.expected $testroot/content
2896 49c543a6 2022-03-31 naddy ret=$?
2897 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2898 0e039681 2021-11-15 stsp diff -u $testroot/content.expected $testroot/content
2899 0e039681 2021-11-15 stsp test_done "$testroot" "$ret"
2900 0e039681 2021-11-15 stsp return 1
2901 0e039681 2021-11-15 stsp fi
2902 0e039681 2021-11-15 stsp
2903 0e039681 2021-11-15 stsp # update which changes a locally modified binary file
2904 0e039681 2021-11-15 stsp cp /bin/ls $testroot/wt/foo
2905 0e039681 2021-11-15 stsp chmod 755 $testroot/wt/foo
2906 0e039681 2021-11-15 stsp (cd $testroot/wt && got up -c $commit_id3 > $testroot/stdout)
2907 0e039681 2021-11-15 stsp
2908 0e039681 2021-11-15 stsp echo "C foo" > $testroot/stdout.expected
2909 0e039681 2021-11-15 stsp echo -n "Updated to refs/heads/master: $commit_id3" \
2910 0e039681 2021-11-15 stsp >> $testroot/stdout.expected
2911 0e039681 2021-11-15 stsp echo >> $testroot/stdout.expected
2912 0e039681 2021-11-15 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
2913 0e039681 2021-11-15 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2914 49c543a6 2022-03-31 naddy ret=$?
2915 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2916 0e039681 2021-11-15 stsp diff -u $testroot/stdout.expected $testroot/stdout
2917 0e039681 2021-11-15 stsp test_done "$testroot" "$ret"
2918 0e039681 2021-11-15 stsp return 1
2919 0e039681 2021-11-15 stsp fi
2920 0e039681 2021-11-15 stsp
2921 0e039681 2021-11-15 stsp echo "Binary files differ and cannot be merged automatically:" \
2922 0e039681 2021-11-15 stsp > $testroot/content.expected
2923 0e039681 2021-11-15 stsp echo "<<<<<<< merged change: commit $commit_id3" \
2924 0e039681 2021-11-15 stsp >> $testroot/content.expected
2925 0e039681 2021-11-15 stsp echo -n "file " >> $testroot/content.expected
2926 0e039681 2021-11-15 stsp ls $testroot/wt/foo-1-* >> $testroot/content.expected
2927 0e039681 2021-11-15 stsp echo "||||||| 3-way merge base: commit $commit_id2" \
2928 0e039681 2021-11-15 stsp >> $testroot/content.expected
2929 0e039681 2021-11-15 stsp echo -n "file " >> $testroot/content.expected
2930 0e039681 2021-11-15 stsp ls $testroot/wt/foo-orig-* >> $testroot/content.expected
2931 0e039681 2021-11-15 stsp echo '=======' >> $testroot/content.expected
2932 0e039681 2021-11-15 stsp echo -n "file " >> $testroot/content.expected
2933 0e039681 2021-11-15 stsp ls $testroot/wt/foo-2-* >> $testroot/content.expected
2934 0e039681 2021-11-15 stsp echo ">>>>>>>" >> $testroot/content.expected
2935 0e039681 2021-11-15 stsp cat $testroot/wt/foo > $testroot/content
2936 0e039681 2021-11-15 stsp
2937 0e039681 2021-11-15 stsp cmp -s $testroot/content.expected $testroot/content
2938 49c543a6 2022-03-31 naddy ret=$?
2939 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2940 0e039681 2021-11-15 stsp diff -u $testroot/content.expected $testroot/content
2941 0e039681 2021-11-15 stsp test_done "$testroot" "$ret"
2942 0e039681 2021-11-15 stsp return 1
2943 0e039681 2021-11-15 stsp fi
2944 0e039681 2021-11-15 stsp
2945 0e039681 2021-11-15 stsp cp /bin/cp $testroot/content.expected
2946 0e039681 2021-11-15 stsp chmod 755 $testroot/content.expected
2947 0e039681 2021-11-15 stsp cp $testroot/wt/foo-1-* $testroot/content
2948 0e039681 2021-11-15 stsp cmp -s $testroot/content.expected $testroot/content
2949 49c543a6 2022-03-31 naddy ret=$?
2950 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2951 0e039681 2021-11-15 stsp diff -u $testroot/content.expected $testroot/content
2952 0e039681 2021-11-15 stsp test_done "$testroot" "$ret"
2953 0e039681 2021-11-15 stsp return 1
2954 0e039681 2021-11-15 stsp fi
2955 0e039681 2021-11-15 stsp
2956 0e039681 2021-11-15 stsp cp /bin/ls $testroot/content.expected
2957 0e039681 2021-11-15 stsp chmod 755 $testroot/content.expected
2958 0e039681 2021-11-15 stsp cp $testroot/wt/foo-2-* $testroot/content
2959 0e039681 2021-11-15 stsp cmp -s $testroot/content.expected $testroot/content
2960 49c543a6 2022-03-31 naddy ret=$?
2961 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2962 0e039681 2021-11-15 stsp diff -u $testroot/content.expected $testroot/content
2963 0e039681 2021-11-15 stsp test_done "$testroot" "$ret"
2964 0e039681 2021-11-15 stsp return 1
2965 0e039681 2021-11-15 stsp fi
2966 0e039681 2021-11-15 stsp
2967 0e039681 2021-11-15 stsp (cd $testroot/wt && got status > $testroot/stdout)
2968 0e039681 2021-11-15 stsp echo 'C foo' > $testroot/stdout.expected
2969 0e039681 2021-11-15 stsp echo -n '? ' >> $testroot/stdout.expected
2970 0e039681 2021-11-15 stsp (cd $testroot/wt && ls foo-1-* >> $testroot/stdout.expected)
2971 0e039681 2021-11-15 stsp echo -n '? ' >> $testroot/stdout.expected
2972 0e039681 2021-11-15 stsp (cd $testroot/wt && ls foo-2-* >> $testroot/stdout.expected)
2973 0e039681 2021-11-15 stsp echo -n '? ' >> $testroot/stdout.expected
2974 0e039681 2021-11-15 stsp (cd $testroot/wt && ls foo-orig-* >> $testroot/stdout.expected)
2975 0e039681 2021-11-15 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2976 49c543a6 2022-03-31 naddy ret=$?
2977 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2978 0e039681 2021-11-15 stsp diff -u $testroot/stdout.expected $testroot/stdout
2979 0e039681 2021-11-15 stsp test_done "$testroot" "$ret"
2980 0e039681 2021-11-15 stsp return 1
2981 0e039681 2021-11-15 stsp fi
2982 0e039681 2021-11-15 stsp
2983 0e039681 2021-11-15 stsp # tidy up
2984 0e039681 2021-11-15 stsp (cd $testroot/wt && got revert -R . > /dev/null)
2985 0e039681 2021-11-15 stsp rm $testroot/wt/foo-orig-* $testroot/wt/foo-1-* $testroot/wt/foo-2-*
2986 0e039681 2021-11-15 stsp
2987 0e039681 2021-11-15 stsp # update which deletes a binary file
2988 0e039681 2021-11-15 stsp (cd $testroot/wt && got up -c $commit_id4 > $testroot/stdout)
2989 0e039681 2021-11-15 stsp echo "D foo" > $testroot/stdout.expected
2990 0e039681 2021-11-15 stsp echo -n "Updated to refs/heads/master: $commit_id4" \
2991 0e039681 2021-11-15 stsp >> $testroot/stdout.expected
2992 0e039681 2021-11-15 stsp echo >> $testroot/stdout.expected
2993 0e039681 2021-11-15 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2994 49c543a6 2022-03-31 naddy ret=$?
2995 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
2996 0e039681 2021-11-15 stsp diff -u $testroot/stdout.expected $testroot/stdout
2997 0e039681 2021-11-15 stsp test_done "$testroot" "$ret"
2998 0e039681 2021-11-15 stsp fi
2999 0e039681 2021-11-15 stsp
3000 0e039681 2021-11-15 stsp if [ -e $testroot/wt/foo ]; then
3001 0e039681 2021-11-15 stsp echo "removed file foo still exists on disk" >&2
3002 0e039681 2021-11-15 stsp test_done "$testroot" "1"
3003 0e039681 2021-11-15 stsp return 1
3004 0e039681 2021-11-15 stsp fi
3005 0e039681 2021-11-15 stsp test_done "$testroot" "0"
3006 67c65ed7 2021-09-14 tracey }
3007 67c65ed7 2021-09-14 tracey
3008 7fb414ae 2020-08-08 stsp test_parseargs "$@"
3009 c84d8c75 2019-01-02 stsp run_test test_update_basic
3010 3b4d3732 2019-01-02 stsp run_test test_update_adds_file
3011 512f0d0e 2019-01-02 stsp run_test test_update_deletes_file
3012 f5c49f82 2019-01-06 stsp run_test test_update_deletes_dir
3013 5cc266ba 2019-01-06 stsp run_test test_update_deletes_dir_with_path_prefix
3014 90285c3b 2019-01-08 stsp run_test test_update_deletes_dir_recursively
3015 4482e97b 2019-01-08 stsp run_test test_update_sibling_dirs_with_common_prefix
3016 50952927 2019-01-12 stsp run_test test_update_dir_with_dot_sibling
3017 46cee7a3 2019-01-12 stsp run_test test_update_moves_files_upwards
3018 bd4792ec 2019-01-13 stsp run_test test_update_moves_files_to_new_dir
3019 4a1ddfc2 2019-01-12 stsp run_test test_update_creates_missing_parent
3020 bd4792ec 2019-01-13 stsp run_test test_update_creates_missing_parent_with_subdir
3021 21908da4 2019-01-13 stsp run_test test_update_file_in_subsubdir
3022 6353ad76 2019-02-08 stsp run_test test_update_merges_file_edits
3023 68ed9ba5 2019-02-10 stsp run_test test_update_keeps_xbit
3024 ba8a0d4d 2019-02-10 stsp run_test test_update_clears_xbit
3025 a378724f 2019-02-10 stsp run_test test_update_restores_missing_file
3026 085d5bcf 2019-03-27 stsp run_test test_update_conflict_wt_add_vs_repo_add
3027 085d5bcf 2019-03-27 stsp run_test test_update_conflict_wt_edit_vs_repo_rm
3028 13d9040b 2019-03-27 stsp run_test test_update_conflict_wt_rm_vs_repo_edit
3029 66b11bf5 2019-03-27 stsp run_test test_update_conflict_wt_rm_vs_repo_rm
3030 c4cdcb68 2019-04-03 stsp run_test test_update_partial
3031 c4cdcb68 2019-04-03 stsp run_test test_update_partial_add
3032 c4cdcb68 2019-04-03 stsp run_test test_update_partial_rm
3033 c4cdcb68 2019-04-03 stsp run_test test_update_partial_dir
3034 d5bea539 2019-05-13 stsp run_test test_update_moved_branch_ref
3035 024e9686 2019-05-14 stsp run_test test_update_to_another_branch
3036 a367ff0f 2019-05-14 stsp run_test test_update_to_commit_on_wrong_branch
3037 c932eeeb 2019-05-22 stsp run_test test_update_bumps_base_commit_id
3038 303e2782 2019-08-09 stsp run_test test_update_tag
3039 523b8417 2019-10-19 stsp run_test test_update_toggles_xbit
3040 5036ab18 2020-04-18 stsp run_test test_update_preserves_conflicted_file
3041 e7303626 2020-05-14 stsp run_test test_update_modified_submodules
3042 e7303626 2020-05-14 stsp run_test test_update_adds_submodule
3043 e7303626 2020-05-14 stsp run_test test_update_conflict_wt_file_vs_repo_submodule
3044 f35fa46a 2020-07-23 stsp run_test test_update_adds_symlink
3045 993e2a1b 2020-07-23 stsp run_test test_update_deletes_symlink
3046 993e2a1b 2020-07-23 stsp run_test test_update_symlink_conflicts
3047 194cb7cb 2021-01-19 stsp run_test test_update_single_file
3048 a769b60b 2021-06-27 stsp run_test test_update_file_skipped_due_to_conflict
3049 2c41dce7 2021-06-27 stsp run_test test_update_file_skipped_due_to_obstruction
3050 67c65ed7 2021-09-14 tracey run_test test_update_quiet
3051 0e039681 2021-11-15 stsp run_test test_update_binary_file