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 fc414659 2022-04-16 thomas ret=$?
24 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
41 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
52 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
63 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
81 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
92 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
104 fc414659 2022-04-16 thomas 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 97631c52 2023-02-24 thomas 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 fc414659 2022-04-16 thomas ret=$?
125 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
145 fc414659 2022-04-16 thomas 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 97631c52 2023-02-24 thomas 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 fc414659 2022-04-16 thomas ret=$?
162 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
189 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
203 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
232 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
267 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
289 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
311 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
319 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
330 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
351 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
369 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
377 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
395 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
416 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
449 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
471 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
503 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
538 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
555 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
590 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
612 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas ret=$?
630 fc414659 2022-04-16 thomas 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 7b074ee1 2023-03-01 thomas
639 7b074ee1 2023-03-01 thomas test_update_changes_file_to_dir() {
640 7b074ee1 2023-03-01 thomas local testroot=`test_init update_changes_file_to_dir`
641 7b074ee1 2023-03-01 thomas
642 7b074ee1 2023-03-01 thomas got checkout $testroot/repo $testroot/wt > /dev/null
643 7b074ee1 2023-03-01 thomas ret=$?
644 7b074ee1 2023-03-01 thomas if [ $ret -ne 0 ]; then
645 7b074ee1 2023-03-01 thomas test_done "$testroot" "$ret"
646 7b074ee1 2023-03-01 thomas return 1
647 7b074ee1 2023-03-01 thomas fi
648 6353ad76 2019-02-08 stsp
649 7b074ee1 2023-03-01 thomas git_rm $testroot/repo alpha
650 7b074ee1 2023-03-01 thomas mkdir $testroot/repo/alpha
651 7b074ee1 2023-03-01 thomas echo eta > $testroot/repo/alpha/eta
652 7b074ee1 2023-03-01 thomas (cd $testroot/repo && git add alpha/eta)
653 7b074ee1 2023-03-01 thomas git_commit $testroot/repo -m "changed alpha into directory"
654 7b074ee1 2023-03-01 thomas
655 7b074ee1 2023-03-01 thomas (cd $testroot/wt && got update > $testroot/stdout 2> $testroot/stderr)
656 7b074ee1 2023-03-01 thomas ret=$?
657 7b074ee1 2023-03-01 thomas if [ $ret -ne 0 ]; then
658 9f323212 2023-03-10 thomas echo "update failed unexpectedly" >&2
659 9f323212 2023-03-10 thomas test_done "$testroot" "1"
660 9f323212 2023-03-10 thomas return 1
661 9f323212 2023-03-10 thomas fi
662 9f323212 2023-03-10 thomas
663 9f323212 2023-03-10 thomas echo "D alpha" > $testroot/stdout.expected
664 9f323212 2023-03-10 thomas echo "A alpha/eta" >> $testroot/stdout.expected
665 9f323212 2023-03-10 thomas echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
666 9f323212 2023-03-10 thomas git_show_head $testroot/repo >> $testroot/stdout.expected
667 9f323212 2023-03-10 thomas echo >> $testroot/stdout.expected
668 9f323212 2023-03-10 thomas
669 9f323212 2023-03-10 thomas cmp -s $testroot/stdout.expected $testroot/stdout
670 9f323212 2023-03-10 thomas ret=$?
671 9f323212 2023-03-10 thomas if [ $ret -ne 0 ]; then
672 9f323212 2023-03-10 thomas diff -u $testroot/stdout.expected $testroot/stdout
673 7b074ee1 2023-03-01 thomas fi
674 7b074ee1 2023-03-01 thomas test_done "$testroot" "$ret"
675 7b074ee1 2023-03-01 thomas }
676 8ed5d26b 2023-03-10 thomas
677 8ed5d26b 2023-03-10 thomas test_update_changes_dir_to_file() {
678 8ed5d26b 2023-03-10 thomas local testroot=`test_init update_changes_dir_to_file`
679 8ed5d26b 2023-03-10 thomas
680 8ed5d26b 2023-03-10 thomas got checkout $testroot/repo $testroot/wt > /dev/null
681 8ed5d26b 2023-03-10 thomas ret=$?
682 8ed5d26b 2023-03-10 thomas if [ $ret -ne 0 ]; then
683 8ed5d26b 2023-03-10 thomas test_done "$testroot" "$ret"
684 8ed5d26b 2023-03-10 thomas return 1
685 8ed5d26b 2023-03-10 thomas fi
686 8ed5d26b 2023-03-10 thomas
687 8ed5d26b 2023-03-10 thomas git_rmdir $testroot/repo epsilon
688 8ed5d26b 2023-03-10 thomas echo epsilon > $testroot/repo/epsilon
689 8ed5d26b 2023-03-10 thomas cp $testroot/repo/epsilon $testroot/content.expected
690 8ed5d26b 2023-03-10 thomas (cd $testroot/repo && git add epsilon)
691 8ed5d26b 2023-03-10 thomas git_commit $testroot/repo -m "changed epsilon into file"
692 8ed5d26b 2023-03-10 thomas
693 8ed5d26b 2023-03-10 thomas (cd $testroot/wt && got update > $testroot/stdout 2> $testroot/stderr)
694 8ed5d26b 2023-03-10 thomas ret=$?
695 8ed5d26b 2023-03-10 thomas if [ $ret -ne 0 ]; then
696 8ed5d26b 2023-03-10 thomas echo "update failed unexpectedly" >&2
697 8ed5d26b 2023-03-10 thomas test_done "$testroot" "1"
698 8ed5d26b 2023-03-10 thomas return 1
699 8ed5d26b 2023-03-10 thomas fi
700 7b074ee1 2023-03-01 thomas
701 8ed5d26b 2023-03-10 thomas # The current behaviour is not perfect, but we accept it for now.
702 8ed5d26b 2023-03-10 thomas echo "~ epsilon" > $testroot/stdout.expected
703 8ed5d26b 2023-03-10 thomas echo "D epsilon/zeta" >> $testroot/stdout.expected
704 8ed5d26b 2023-03-10 thomas echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
705 8ed5d26b 2023-03-10 thomas git_show_head $testroot/repo >> $testroot/stdout.expected
706 8ed5d26b 2023-03-10 thomas echo >> $testroot/stdout.expected
707 8ed5d26b 2023-03-10 thomas echo "File paths obstructed by a non-regular file: 1" \
708 8ed5d26b 2023-03-10 thomas >> $testroot/stdout.expected
709 8ed5d26b 2023-03-10 thomas
710 8ed5d26b 2023-03-10 thomas cmp -s $testroot/stdout.expected $testroot/stdout
711 8ed5d26b 2023-03-10 thomas ret=$?
712 8ed5d26b 2023-03-10 thomas if [ $ret -ne 0 ]; then
713 8ed5d26b 2023-03-10 thomas diff -u $testroot/stdout.expected $testroot/stdout
714 8ed5d26b 2023-03-10 thomas test_done "$testroot" "$ret"
715 8ed5d26b 2023-03-10 thomas return 1
716 8ed5d26b 2023-03-10 thomas fi
717 8ed5d26b 2023-03-10 thomas
718 8ed5d26b 2023-03-10 thomas # Updating again now restores the file which was obstructed by a
719 8ed5d26b 2023-03-10 thomas # directory in the previous update operation. Ideally, a single
720 8ed5d26b 2023-03-10 thomas # update operation would suffice.
721 8ed5d26b 2023-03-10 thomas (cd $testroot/wt && got update > $testroot/stdout 2> $testroot/stderr)
722 8ed5d26b 2023-03-10 thomas ret=$?
723 8ed5d26b 2023-03-10 thomas if [ $ret -ne 0 ]; then
724 8ed5d26b 2023-03-10 thomas echo "update failed unexpectedly" >&2
725 8ed5d26b 2023-03-10 thomas test_done "$testroot" "1"
726 8ed5d26b 2023-03-10 thomas return 1
727 8ed5d26b 2023-03-10 thomas fi
728 8ed5d26b 2023-03-10 thomas echo "A epsilon" > $testroot/stdout.expected
729 8ed5d26b 2023-03-10 thomas echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
730 8ed5d26b 2023-03-10 thomas git_show_head $testroot/repo >> $testroot/stdout.expected
731 8ed5d26b 2023-03-10 thomas echo >> $testroot/stdout.expected
732 8ed5d26b 2023-03-10 thomas
733 8ed5d26b 2023-03-10 thomas cmp -s $testroot/stdout.expected $testroot/stdout
734 8ed5d26b 2023-03-10 thomas ret=$?
735 8ed5d26b 2023-03-10 thomas if [ $ret -ne 0 ]; then
736 8ed5d26b 2023-03-10 thomas diff -u $testroot/stdout.expected $testroot/stdout
737 8ed5d26b 2023-03-10 thomas test_done "$testroot" "$ret"
738 8ed5d26b 2023-03-10 thomas return 1
739 8ed5d26b 2023-03-10 thomas fi
740 8ed5d26b 2023-03-10 thomas
741 8ed5d26b 2023-03-10 thomas cmp -s $testroot/content.expected $testroot/wt/epsilon
742 8ed5d26b 2023-03-10 thomas ret=$?
743 8ed5d26b 2023-03-10 thomas if [ $ret -ne 0 ]; then
744 8ed5d26b 2023-03-10 thomas diff -u $testroot/content.expected $testroot/wt/epsilon
745 8ed5d26b 2023-03-10 thomas fi
746 8ed5d26b 2023-03-10 thomas test_done "$testroot" "$ret"
747 8ed5d26b 2023-03-10 thomas }
748 8ed5d26b 2023-03-10 thomas
749 9f323212 2023-03-10 thomas test_update_changes_modified_file_to_dir() {
750 9f323212 2023-03-10 thomas local testroot=`test_init update_changes_modified_file_to_dir`
751 9f323212 2023-03-10 thomas
752 9f323212 2023-03-10 thomas got checkout $testroot/repo $testroot/wt > /dev/null
753 9f323212 2023-03-10 thomas ret=$?
754 9f323212 2023-03-10 thomas if [ $ret -ne 0 ]; then
755 9f323212 2023-03-10 thomas test_done "$testroot" "$ret"
756 9f323212 2023-03-10 thomas return 1
757 9f323212 2023-03-10 thomas fi
758 9f323212 2023-03-10 thomas
759 9f323212 2023-03-10 thomas git_rm $testroot/repo alpha
760 9f323212 2023-03-10 thomas mkdir $testroot/repo/alpha
761 9f323212 2023-03-10 thomas echo eta > $testroot/repo/alpha/eta
762 9f323212 2023-03-10 thomas (cd $testroot/repo && git add alpha/eta)
763 9f323212 2023-03-10 thomas git_commit $testroot/repo -m "changed alpha into directory"
764 9f323212 2023-03-10 thomas
765 9f323212 2023-03-10 thomas echo "modified alpha" >> $testroot/wt/alpha
766 9f323212 2023-03-10 thomas cp $testroot/wt/alpha $testroot/wt/content.expected
767 9f323212 2023-03-10 thomas (cd $testroot/wt && got update > $testroot/stdout 2> $testroot/stderr)
768 9f323212 2023-03-10 thomas ret=$?
769 9f323212 2023-03-10 thomas if [ $ret -eq 0 ]; then
770 9f323212 2023-03-10 thomas echo "update succeeded unexpectedly" >&2
771 9f323212 2023-03-10 thomas test_done "$testroot" "1"
772 9f323212 2023-03-10 thomas return 1
773 9f323212 2023-03-10 thomas fi
774 9f323212 2023-03-10 thomas
775 9f323212 2023-03-10 thomas echo "d alpha" > $testroot/stdout.expected
776 9f323212 2023-03-10 thomas cmp -s $testroot/stdout.expected $testroot/stdout
777 9f323212 2023-03-10 thomas ret=$?
778 9f323212 2023-03-10 thomas if [ $ret -ne 0 ]; then
779 9f323212 2023-03-10 thomas diff -u $testroot/stdout.expected $testroot/stdout
780 9f323212 2023-03-10 thomas test_done "$testroot" "$ret"
781 9f323212 2023-03-10 thomas return 1
782 9f323212 2023-03-10 thomas fi
783 9f323212 2023-03-10 thomas
784 9f323212 2023-03-10 thomas echo "got: alpha/eta: file is obstructed" > $testroot/stderr.expected
785 9f323212 2023-03-10 thomas cmp -s $testroot/stderr.expected $testroot/stderr
786 9f323212 2023-03-10 thomas ret=$?
787 9f323212 2023-03-10 thomas if [ $ret -ne 0 ]; then
788 9f323212 2023-03-10 thomas diff -u $testroot/stderr.expected $testroot/stderr
789 9f323212 2023-03-10 thomas fi
790 9f323212 2023-03-10 thomas test_done "$testroot" "$ret"
791 9f323212 2023-03-10 thomas }
792 9f323212 2023-03-10 thomas
793 f6cae3ed 2020-09-13 naddy test_update_merges_file_edits() {
794 6353ad76 2019-02-08 stsp local testroot=`test_init update_merges_file_edits`
795 6353ad76 2019-02-08 stsp
796 6353ad76 2019-02-08 stsp echo "1" > $testroot/repo/numbers
797 6353ad76 2019-02-08 stsp echo "2" >> $testroot/repo/numbers
798 6353ad76 2019-02-08 stsp echo "3" >> $testroot/repo/numbers
799 6353ad76 2019-02-08 stsp echo "4" >> $testroot/repo/numbers
800 6353ad76 2019-02-08 stsp echo "5" >> $testroot/repo/numbers
801 6353ad76 2019-02-08 stsp echo "6" >> $testroot/repo/numbers
802 6353ad76 2019-02-08 stsp echo "7" >> $testroot/repo/numbers
803 6353ad76 2019-02-08 stsp echo "8" >> $testroot/repo/numbers
804 6353ad76 2019-02-08 stsp (cd $testroot/repo && git add numbers)
805 6353ad76 2019-02-08 stsp git_commit $testroot/repo -m "added numbers file"
806 f69721c3 2019-10-21 stsp local base_commit=`git_show_head $testroot/repo`
807 21908da4 2019-01-13 stsp
808 6353ad76 2019-02-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
809 fc414659 2022-04-16 thomas ret=$?
810 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
811 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
812 6353ad76 2019-02-08 stsp return 1
813 6353ad76 2019-02-08 stsp fi
814 6353ad76 2019-02-08 stsp
815 6353ad76 2019-02-08 stsp echo "modified alpha" > $testroot/repo/alpha
816 6353ad76 2019-02-08 stsp echo "modified beta" > $testroot/repo/beta
817 ac3cdf31 2023-03-06 thomas ed -s $testroot/repo/numbers <<-\EOF
818 ac3cdf31 2023-03-06 thomas ,s/2/22/
819 ac3cdf31 2023-03-06 thomas w
820 ac3cdf31 2023-03-06 thomas EOF
821 6353ad76 2019-02-08 stsp git_commit $testroot/repo -m "modified 3 files"
822 6353ad76 2019-02-08 stsp
823 6353ad76 2019-02-08 stsp echo "modified alpha, too" > $testroot/wt/alpha
824 6353ad76 2019-02-08 stsp touch $testroot/wt/beta
825 ac3cdf31 2023-03-06 thomas ed -s $testroot/wt/numbers <<-\EOF
826 ac3cdf31 2023-03-06 thomas ,s/7/77/
827 ac3cdf31 2023-03-06 thomas w
828 ac3cdf31 2023-03-06 thomas EOF
829 6353ad76 2019-02-08 stsp
830 6353ad76 2019-02-08 stsp echo "C alpha" > $testroot/stdout.expected
831 6353ad76 2019-02-08 stsp echo "U beta" >> $testroot/stdout.expected
832 6353ad76 2019-02-08 stsp echo "G numbers" >> $testroot/stdout.expected
833 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
834 6353ad76 2019-02-08 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
835 6353ad76 2019-02-08 stsp echo >> $testroot/stdout.expected
836 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
837 6353ad76 2019-02-08 stsp
838 6353ad76 2019-02-08 stsp (cd $testroot/wt && got update > $testroot/stdout)
839 6353ad76 2019-02-08 stsp
840 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
841 fc414659 2022-04-16 thomas ret=$?
842 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
843 6353ad76 2019-02-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
844 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
845 6353ad76 2019-02-08 stsp return 1
846 6353ad76 2019-02-08 stsp fi
847 6353ad76 2019-02-08 stsp
848 f69721c3 2019-10-21 stsp echo -n "<<<<<<< merged change: commit " > $testroot/content.expected
849 6353ad76 2019-02-08 stsp git_show_head $testroot/repo >> $testroot/content.expected
850 6353ad76 2019-02-08 stsp echo >> $testroot/content.expected
851 6353ad76 2019-02-08 stsp echo "modified alpha" >> $testroot/content.expected
852 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $base_commit" \
853 f69721c3 2019-10-21 stsp >> $testroot/content.expected
854 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
855 6353ad76 2019-02-08 stsp echo "=======" >> $testroot/content.expected
856 6353ad76 2019-02-08 stsp echo "modified alpha, too" >> $testroot/content.expected
857 f69721c3 2019-10-21 stsp echo '>>>>>>>' >> $testroot/content.expected
858 6353ad76 2019-02-08 stsp echo "modified beta" >> $testroot/content.expected
859 6353ad76 2019-02-08 stsp echo "1" >> $testroot/content.expected
860 6353ad76 2019-02-08 stsp echo "22" >> $testroot/content.expected
861 6353ad76 2019-02-08 stsp echo "3" >> $testroot/content.expected
862 6353ad76 2019-02-08 stsp echo "4" >> $testroot/content.expected
863 6353ad76 2019-02-08 stsp echo "5" >> $testroot/content.expected
864 6353ad76 2019-02-08 stsp echo "6" >> $testroot/content.expected
865 6353ad76 2019-02-08 stsp echo "77" >> $testroot/content.expected
866 6353ad76 2019-02-08 stsp echo "8" >> $testroot/content.expected
867 6353ad76 2019-02-08 stsp
868 6353ad76 2019-02-08 stsp cat $testroot/wt/alpha > $testroot/content
869 6353ad76 2019-02-08 stsp cat $testroot/wt/beta >> $testroot/content
870 6353ad76 2019-02-08 stsp cat $testroot/wt/numbers >> $testroot/content
871 6353ad76 2019-02-08 stsp
872 8d301dd9 2019-05-14 stsp cmp -s $testroot/content.expected $testroot/content
873 fc414659 2022-04-16 thomas ret=$?
874 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
875 6353ad76 2019-02-08 stsp diff -u $testroot/content.expected $testroot/content
876 68ed9ba5 2019-02-10 stsp fi
877 68ed9ba5 2019-02-10 stsp test_done "$testroot" "$ret"
878 68ed9ba5 2019-02-10 stsp }
879 68ed9ba5 2019-02-10 stsp
880 f6cae3ed 2020-09-13 naddy test_update_keeps_xbit() {
881 68ed9ba5 2019-02-10 stsp local testroot=`test_init update_keeps_xbit 1`
882 68ed9ba5 2019-02-10 stsp
883 68ed9ba5 2019-02-10 stsp touch $testroot/repo/xfile
884 68ed9ba5 2019-02-10 stsp chmod +x $testroot/repo/xfile
885 68ed9ba5 2019-02-10 stsp (cd $testroot/repo && git add .)
886 68ed9ba5 2019-02-10 stsp git_commit $testroot/repo -m "adding executable file"
887 68ed9ba5 2019-02-10 stsp
888 68ed9ba5 2019-02-10 stsp got checkout $testroot/repo $testroot/wt > $testroot/stdout
889 fc414659 2022-04-16 thomas ret=$?
890 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
891 68ed9ba5 2019-02-10 stsp test_done "$testroot" "$ret"
892 68ed9ba5 2019-02-10 stsp return 1
893 68ed9ba5 2019-02-10 stsp fi
894 68ed9ba5 2019-02-10 stsp
895 68ed9ba5 2019-02-10 stsp echo foo > $testroot/repo/xfile
896 68ed9ba5 2019-02-10 stsp git_commit $testroot/repo -m "changed executable file"
897 68ed9ba5 2019-02-10 stsp
898 68ed9ba5 2019-02-10 stsp echo "U xfile" > $testroot/stdout.expected
899 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
900 68ed9ba5 2019-02-10 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
901 68ed9ba5 2019-02-10 stsp echo >> $testroot/stdout.expected
902 68ed9ba5 2019-02-10 stsp
903 68ed9ba5 2019-02-10 stsp (cd $testroot/wt && got update > $testroot/stdout)
904 fc414659 2022-04-16 thomas ret=$?
905 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
906 68ed9ba5 2019-02-10 stsp test_done "$testroot" "$ret"
907 68ed9ba5 2019-02-10 stsp return 1
908 6353ad76 2019-02-08 stsp fi
909 68ed9ba5 2019-02-10 stsp
910 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
911 fc414659 2022-04-16 thomas ret=$?
912 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
913 68ed9ba5 2019-02-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
914 68ed9ba5 2019-02-10 stsp test_done "$testroot" "$ret"
915 68ed9ba5 2019-02-10 stsp return 1
916 68ed9ba5 2019-02-10 stsp fi
917 68ed9ba5 2019-02-10 stsp
918 68ed9ba5 2019-02-10 stsp ls -l $testroot/wt/xfile | grep -q '^-rwx'
919 fc414659 2022-04-16 thomas ret=$?
920 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
921 68ed9ba5 2019-02-10 stsp echo "file is not executable" >&2
922 68ed9ba5 2019-02-10 stsp ls -l $testroot/wt/xfile >&2
923 68ed9ba5 2019-02-10 stsp fi
924 6353ad76 2019-02-08 stsp test_done "$testroot" "$ret"
925 6353ad76 2019-02-08 stsp }
926 ba8a0d4d 2019-02-10 stsp
927 f6cae3ed 2020-09-13 naddy test_update_clears_xbit() {
928 ba8a0d4d 2019-02-10 stsp local testroot=`test_init update_clears_xbit 1`
929 ba8a0d4d 2019-02-10 stsp
930 ba8a0d4d 2019-02-10 stsp touch $testroot/repo/xfile
931 ba8a0d4d 2019-02-10 stsp chmod +x $testroot/repo/xfile
932 ba8a0d4d 2019-02-10 stsp (cd $testroot/repo && git add .)
933 ba8a0d4d 2019-02-10 stsp git_commit $testroot/repo -m "adding executable file"
934 6353ad76 2019-02-08 stsp
935 ba8a0d4d 2019-02-10 stsp got checkout $testroot/repo $testroot/wt > $testroot/stdout
936 fc414659 2022-04-16 thomas ret=$?
937 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
938 ba8a0d4d 2019-02-10 stsp test_done "$testroot" "$ret"
939 ba8a0d4d 2019-02-10 stsp return 1
940 ba8a0d4d 2019-02-10 stsp fi
941 ba8a0d4d 2019-02-10 stsp
942 ba8a0d4d 2019-02-10 stsp ls -l $testroot/wt/xfile | grep -q '^-rwx'
943 fc414659 2022-04-16 thomas ret=$?
944 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
945 ba8a0d4d 2019-02-10 stsp echo "file is not executable" >&2
946 ba8a0d4d 2019-02-10 stsp ls -l $testroot/wt/xfile >&2
947 ba8a0d4d 2019-02-10 stsp test_done "$testroot" "$ret"
948 ba8a0d4d 2019-02-10 stsp return 1
949 ba8a0d4d 2019-02-10 stsp fi
950 ba8a0d4d 2019-02-10 stsp
951 ba8a0d4d 2019-02-10 stsp # XXX git seems to require a file edit when flipping the x bit?
952 ba8a0d4d 2019-02-10 stsp echo foo > $testroot/repo/xfile
953 ba8a0d4d 2019-02-10 stsp chmod -x $testroot/repo/xfile
954 ba8a0d4d 2019-02-10 stsp git_commit $testroot/repo -m "not an executable file anymore"
955 ba8a0d4d 2019-02-10 stsp
956 ba8a0d4d 2019-02-10 stsp echo "U xfile" > $testroot/stdout.expected
957 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
958 ba8a0d4d 2019-02-10 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
959 ba8a0d4d 2019-02-10 stsp echo >> $testroot/stdout.expected
960 ba8a0d4d 2019-02-10 stsp
961 ba8a0d4d 2019-02-10 stsp (cd $testroot/wt && got update > $testroot/stdout)
962 fc414659 2022-04-16 thomas ret=$?
963 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
964 ba8a0d4d 2019-02-10 stsp test_done "$testroot" "$ret"
965 ba8a0d4d 2019-02-10 stsp return 1
966 ba8a0d4d 2019-02-10 stsp fi
967 ba8a0d4d 2019-02-10 stsp
968 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
969 fc414659 2022-04-16 thomas ret=$?
970 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
971 ba8a0d4d 2019-02-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
972 ba8a0d4d 2019-02-10 stsp test_done "$testroot" "$ret"
973 ba8a0d4d 2019-02-10 stsp return 1
974 ba8a0d4d 2019-02-10 stsp fi
975 ba8a0d4d 2019-02-10 stsp
976 ba8a0d4d 2019-02-10 stsp ls -l $testroot/wt/xfile | grep -q '^-rw-'
977 fc414659 2022-04-16 thomas ret=$?
978 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
979 ba8a0d4d 2019-02-10 stsp echo "file is unexpectedly executable" >&2
980 ba8a0d4d 2019-02-10 stsp ls -l $testroot/wt/xfile >&2
981 ba8a0d4d 2019-02-10 stsp fi
982 ba8a0d4d 2019-02-10 stsp test_done "$testroot" "$ret"
983 ba8a0d4d 2019-02-10 stsp }
984 a378724f 2019-02-10 stsp
985 f6cae3ed 2020-09-13 naddy test_update_restores_missing_file() {
986 a378724f 2019-02-10 stsp local testroot=`test_init update_restores_missing_file`
987 a378724f 2019-02-10 stsp
988 a378724f 2019-02-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
989 fc414659 2022-04-16 thomas ret=$?
990 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
991 a378724f 2019-02-10 stsp test_done "$testroot" "$ret"
992 a378724f 2019-02-10 stsp return 1
993 a378724f 2019-02-10 stsp fi
994 ba8a0d4d 2019-02-10 stsp
995 a378724f 2019-02-10 stsp rm $testroot/wt/alpha
996 a378724f 2019-02-10 stsp
997 a378724f 2019-02-10 stsp echo "! alpha" > $testroot/stdout.expected
998 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
999 1545c615 2019-02-10 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1000 1545c615 2019-02-10 stsp echo >> $testroot/stdout.expected
1001 a378724f 2019-02-10 stsp (cd $testroot/wt && got update > $testroot/stdout)
1002 a378724f 2019-02-10 stsp
1003 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1004 fc414659 2022-04-16 thomas ret=$?
1005 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1006 a378724f 2019-02-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
1007 a378724f 2019-02-10 stsp test_done "$testroot" "$ret"
1008 a378724f 2019-02-10 stsp return 1
1009 a378724f 2019-02-10 stsp fi
1010 a378724f 2019-02-10 stsp
1011 a378724f 2019-02-10 stsp echo "alpha" > $testroot/content.expected
1012 a378724f 2019-02-10 stsp
1013 a378724f 2019-02-10 stsp cat $testroot/wt/alpha > $testroot/content
1014 1430b4e0 2019-03-27 stsp
1015 8d301dd9 2019-05-14 stsp cmp -s $testroot/content.expected $testroot/content
1016 fc414659 2022-04-16 thomas ret=$?
1017 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1018 1430b4e0 2019-03-27 stsp diff -u $testroot/content.expected $testroot/content
1019 1430b4e0 2019-03-27 stsp fi
1020 1430b4e0 2019-03-27 stsp test_done "$testroot" "$ret"
1021 1430b4e0 2019-03-27 stsp }
1022 1430b4e0 2019-03-27 stsp
1023 f6cae3ed 2020-09-13 naddy test_update_conflict_wt_add_vs_repo_add() {
1024 085d5bcf 2019-03-27 stsp local testroot=`test_init update_conflict_wt_add_vs_repo_add`
1025 1430b4e0 2019-03-27 stsp
1026 1430b4e0 2019-03-27 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1027 fc414659 2022-04-16 thomas ret=$?
1028 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1029 1430b4e0 2019-03-27 stsp test_done "$testroot" "$ret"
1030 1430b4e0 2019-03-27 stsp return 1
1031 1430b4e0 2019-03-27 stsp fi
1032 1430b4e0 2019-03-27 stsp
1033 1430b4e0 2019-03-27 stsp echo "new" > $testroot/repo/gamma/new
1034 1430b4e0 2019-03-27 stsp (cd $testroot/repo && git add .)
1035 1430b4e0 2019-03-27 stsp git_commit $testroot/repo -m "adding a new file"
1036 1430b4e0 2019-03-27 stsp
1037 1430b4e0 2019-03-27 stsp echo "also new" > $testroot/wt/gamma/new
1038 1430b4e0 2019-03-27 stsp (cd $testroot/wt && got add gamma/new >/dev/null)
1039 1430b4e0 2019-03-27 stsp
1040 1430b4e0 2019-03-27 stsp (cd $testroot/wt && got update > $testroot/stdout)
1041 a378724f 2019-02-10 stsp
1042 1430b4e0 2019-03-27 stsp echo "C gamma/new" > $testroot/stdout.expected
1043 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1044 1430b4e0 2019-03-27 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1045 1430b4e0 2019-03-27 stsp echo >> $testroot/stdout.expected
1046 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
1047 9627c110 2020-04-18 stsp
1048 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1049 fc414659 2022-04-16 thomas ret=$?
1050 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1051 1430b4e0 2019-03-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
1052 1430b4e0 2019-03-27 stsp test_done "$testroot" "$ret"
1053 1430b4e0 2019-03-27 stsp return 1
1054 1430b4e0 2019-03-27 stsp fi
1055 1430b4e0 2019-03-27 stsp
1056 f69721c3 2019-10-21 stsp echo -n "<<<<<<< merged change: commit " > $testroot/content.expected
1057 1430b4e0 2019-03-27 stsp git_show_head $testroot/repo >> $testroot/content.expected
1058 1430b4e0 2019-03-27 stsp echo >> $testroot/content.expected
1059 1430b4e0 2019-03-27 stsp echo "new" >> $testroot/content.expected
1060 1430b4e0 2019-03-27 stsp echo "=======" >> $testroot/content.expected
1061 1430b4e0 2019-03-27 stsp echo "also new" >> $testroot/content.expected
1062 f69721c3 2019-10-21 stsp echo '>>>>>>>' >> $testroot/content.expected
1063 1430b4e0 2019-03-27 stsp
1064 1430b4e0 2019-03-27 stsp cat $testroot/wt/gamma/new > $testroot/content
1065 1430b4e0 2019-03-27 stsp
1066 8d301dd9 2019-05-14 stsp cmp -s $testroot/content.expected $testroot/content
1067 fc414659 2022-04-16 thomas ret=$?
1068 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1069 a378724f 2019-02-10 stsp diff -u $testroot/content.expected $testroot/content
1070 3165301c 2019-03-27 stsp test_done "$testroot" "$ret"
1071 3165301c 2019-03-27 stsp return 1
1072 3165301c 2019-03-27 stsp fi
1073 3165301c 2019-03-27 stsp
1074 3165301c 2019-03-27 stsp # resolve the conflict
1075 3165301c 2019-03-27 stsp echo "new and also new" > $testroot/wt/gamma/new
1076 3165301c 2019-03-27 stsp echo 'M gamma/new' > $testroot/stdout.expected
1077 3165301c 2019-03-27 stsp (cd $testroot/wt && got status > $testroot/stdout)
1078 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1079 fc414659 2022-04-16 thomas ret=$?
1080 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1081 3165301c 2019-03-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
1082 a378724f 2019-02-10 stsp fi
1083 a378724f 2019-02-10 stsp test_done "$testroot" "$ret"
1084 a378724f 2019-02-10 stsp }
1085 708d8e67 2019-03-27 stsp
1086 f6cae3ed 2020-09-13 naddy test_update_conflict_wt_edit_vs_repo_rm() {
1087 085d5bcf 2019-03-27 stsp local testroot=`test_init update_conflict_wt_edit_vs_repo_rm`
1088 708d8e67 2019-03-27 stsp
1089 708d8e67 2019-03-27 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1090 fc414659 2022-04-16 thomas ret=$?
1091 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1092 708d8e67 2019-03-27 stsp test_done "$testroot" "$ret"
1093 708d8e67 2019-03-27 stsp return 1
1094 708d8e67 2019-03-27 stsp fi
1095 708d8e67 2019-03-27 stsp
1096 708d8e67 2019-03-27 stsp (cd $testroot/repo && git rm -q beta)
1097 708d8e67 2019-03-27 stsp git_commit $testroot/repo -m "removing a file"
1098 708d8e67 2019-03-27 stsp
1099 708d8e67 2019-03-27 stsp echo "modified beta" > $testroot/wt/beta
1100 a378724f 2019-02-10 stsp
1101 708d8e67 2019-03-27 stsp (cd $testroot/wt && got update > $testroot/stdout)
1102 708d8e67 2019-03-27 stsp
1103 fc6346c4 2019-03-27 stsp echo "G beta" > $testroot/stdout.expected
1104 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1105 708d8e67 2019-03-27 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1106 708d8e67 2019-03-27 stsp echo >> $testroot/stdout.expected
1107 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1108 fc414659 2022-04-16 thomas ret=$?
1109 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1110 708d8e67 2019-03-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
1111 708d8e67 2019-03-27 stsp test_done "$testroot" "$ret"
1112 708d8e67 2019-03-27 stsp return 1
1113 708d8e67 2019-03-27 stsp fi
1114 708d8e67 2019-03-27 stsp
1115 708d8e67 2019-03-27 stsp echo "modified beta" > $testroot/content.expected
1116 708d8e67 2019-03-27 stsp
1117 708d8e67 2019-03-27 stsp cat $testroot/wt/beta > $testroot/content
1118 708d8e67 2019-03-27 stsp
1119 8d301dd9 2019-05-14 stsp cmp -s $testroot/content.expected $testroot/content
1120 fc414659 2022-04-16 thomas ret=$?
1121 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1122 708d8e67 2019-03-27 stsp diff -u $testroot/content.expected $testroot/content
1123 708d8e67 2019-03-27 stsp test_done "$testroot" "$ret"
1124 708d8e67 2019-03-27 stsp return 1
1125 708d8e67 2019-03-27 stsp fi
1126 708d8e67 2019-03-27 stsp
1127 fc6346c4 2019-03-27 stsp # beta is now an added file... we don't flag tree conflicts yet
1128 fc6346c4 2019-03-27 stsp echo 'A beta' > $testroot/stdout.expected
1129 13d9040b 2019-03-27 stsp (cd $testroot/wt && got status > $testroot/stdout)
1130 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1131 fc414659 2022-04-16 thomas ret=$?
1132 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1133 13d9040b 2019-03-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
1134 13d9040b 2019-03-27 stsp fi
1135 13d9040b 2019-03-27 stsp test_done "$testroot" "$ret"
1136 13d9040b 2019-03-27 stsp }
1137 13d9040b 2019-03-27 stsp
1138 f6cae3ed 2020-09-13 naddy test_update_conflict_wt_rm_vs_repo_edit() {
1139 13d9040b 2019-03-27 stsp local testroot=`test_init update_conflict_wt_rm_vs_repo_edit`
1140 13d9040b 2019-03-27 stsp
1141 13d9040b 2019-03-27 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1142 fc414659 2022-04-16 thomas ret=$?
1143 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1144 13d9040b 2019-03-27 stsp test_done "$testroot" "$ret"
1145 13d9040b 2019-03-27 stsp return 1
1146 13d9040b 2019-03-27 stsp fi
1147 13d9040b 2019-03-27 stsp
1148 13d9040b 2019-03-27 stsp echo "modified beta" > $testroot/repo/beta
1149 13d9040b 2019-03-27 stsp git_commit $testroot/repo -m "modified a file"
1150 13d9040b 2019-03-27 stsp
1151 13d9040b 2019-03-27 stsp (cd $testroot/wt && got rm beta > /dev/null)
1152 13d9040b 2019-03-27 stsp
1153 13d9040b 2019-03-27 stsp (cd $testroot/wt && got update > $testroot/stdout)
1154 13d9040b 2019-03-27 stsp
1155 13d9040b 2019-03-27 stsp echo "G beta" > $testroot/stdout.expected
1156 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1157 13d9040b 2019-03-27 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1158 13d9040b 2019-03-27 stsp echo >> $testroot/stdout.expected
1159 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1160 fc414659 2022-04-16 thomas ret=$?
1161 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1162 13d9040b 2019-03-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
1163 13d9040b 2019-03-27 stsp test_done "$testroot" "$ret"
1164 13d9040b 2019-03-27 stsp return 1
1165 13d9040b 2019-03-27 stsp fi
1166 13d9040b 2019-03-27 stsp
1167 13d9040b 2019-03-27 stsp # beta remains a deleted file... we don't flag tree conflicts yet
1168 13d9040b 2019-03-27 stsp echo 'D beta' > $testroot/stdout.expected
1169 708d8e67 2019-03-27 stsp (cd $testroot/wt && got status > $testroot/stdout)
1170 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1171 fc414659 2022-04-16 thomas ret=$?
1172 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1173 708d8e67 2019-03-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
1174 13d9040b 2019-03-27 stsp test_done "$testroot" "$ret"
1175 13d9040b 2019-03-27 stsp return 1
1176 708d8e67 2019-03-27 stsp fi
1177 13d9040b 2019-03-27 stsp
1178 13d9040b 2019-03-27 stsp # 'got diff' should show post-update contents of beta being deleted
1179 13d9040b 2019-03-27 stsp local head_rev=`git_show_head $testroot/repo`
1180 9b4458b4 2022-06-26 thomas echo "diff $testroot/wt" > $testroot/stdout.expected
1181 9b4458b4 2022-06-26 thomas echo "commit - $head_rev" >> $testroot/stdout.expected
1182 9b4458b4 2022-06-26 thomas echo "path + $testroot/wt" >> $testroot/stdout.expected
1183 13d9040b 2019-03-27 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1184 13d9040b 2019-03-27 stsp got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
1185 13d9040b 2019-03-27 stsp >> $testroot/stdout.expected
1186 13d9040b 2019-03-27 stsp echo 'file + /dev/null' >> $testroot/stdout.expected
1187 13d9040b 2019-03-27 stsp echo '--- beta' >> $testroot/stdout.expected
1188 1cb46f00 2020-11-21 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
1189 13d9040b 2019-03-27 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1190 13d9040b 2019-03-27 stsp echo '-modified beta' >> $testroot/stdout.expected
1191 13d9040b 2019-03-27 stsp
1192 13d9040b 2019-03-27 stsp (cd $testroot/wt && got diff > $testroot/stdout)
1193 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1194 fc414659 2022-04-16 thomas ret=$?
1195 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1196 13d9040b 2019-03-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
1197 13d9040b 2019-03-27 stsp fi
1198 708d8e67 2019-03-27 stsp test_done "$testroot" "$ret"
1199 66b11bf5 2019-03-27 stsp }
1200 66b11bf5 2019-03-27 stsp
1201 f6cae3ed 2020-09-13 naddy test_update_conflict_wt_rm_vs_repo_rm() {
1202 66b11bf5 2019-03-27 stsp local testroot=`test_init update_conflict_wt_rm_vs_repo_rm`
1203 66b11bf5 2019-03-27 stsp
1204 66b11bf5 2019-03-27 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1205 fc414659 2022-04-16 thomas ret=$?
1206 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1207 66b11bf5 2019-03-27 stsp test_done "$testroot" "$ret"
1208 66b11bf5 2019-03-27 stsp return 1
1209 66b11bf5 2019-03-27 stsp fi
1210 66b11bf5 2019-03-27 stsp
1211 66b11bf5 2019-03-27 stsp (cd $testroot/repo && git rm -q beta)
1212 66b11bf5 2019-03-27 stsp git_commit $testroot/repo -m "removing a file"
1213 66b11bf5 2019-03-27 stsp
1214 66b11bf5 2019-03-27 stsp (cd $testroot/wt && got rm beta > /dev/null)
1215 66b11bf5 2019-03-27 stsp
1216 66b11bf5 2019-03-27 stsp (cd $testroot/wt && got update > $testroot/stdout)
1217 66b11bf5 2019-03-27 stsp
1218 66b11bf5 2019-03-27 stsp echo "D beta" > $testroot/stdout.expected
1219 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1220 66b11bf5 2019-03-27 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1221 66b11bf5 2019-03-27 stsp echo >> $testroot/stdout.expected
1222 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1223 fc414659 2022-04-16 thomas ret=$?
1224 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1225 66b11bf5 2019-03-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
1226 66b11bf5 2019-03-27 stsp test_done "$testroot" "$ret"
1227 66b11bf5 2019-03-27 stsp return 1
1228 66b11bf5 2019-03-27 stsp fi
1229 66b11bf5 2019-03-27 stsp
1230 66b11bf5 2019-03-27 stsp # beta is now gone... we don't flag tree conflicts yet
1231 2a06fe5f 2019-08-24 stsp echo "N beta" > $testroot/stdout.expected
1232 54817d72 2019-07-27 stsp echo -n > $testroot/stderr.expected
1233 54817d72 2019-07-27 stsp (cd $testroot/wt && got status beta > $testroot/stdout \
1234 54817d72 2019-07-27 stsp 2> $testroot/stderr)
1235 54817d72 2019-07-27 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1236 fc414659 2022-04-16 thomas ret=$?
1237 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1238 54817d72 2019-07-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
1239 54817d72 2019-07-27 stsp test_done "$testroot" "$ret"
1240 54817d72 2019-07-27 stsp return 1
1241 54817d72 2019-07-27 stsp fi
1242 8d301dd9 2019-05-14 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1243 fc414659 2022-04-16 thomas ret=$?
1244 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1245 66b11bf5 2019-03-27 stsp diff -u $testroot/stderr.expected $testroot/stderr
1246 66b11bf5 2019-03-27 stsp test_done "$testroot" "$ret"
1247 66b11bf5 2019-03-27 stsp return 1
1248 66b11bf5 2019-03-27 stsp fi
1249 66b11bf5 2019-03-27 stsp
1250 66b11bf5 2019-03-27 stsp if [ -e $testroot/wt/beta ]; then
1251 66b11bf5 2019-03-27 stsp echo "removed file beta still exists on disk" >&2
1252 66b11bf5 2019-03-27 stsp test_done "$testroot" "1"
1253 66b11bf5 2019-03-27 stsp return 1
1254 66b11bf5 2019-03-27 stsp fi
1255 66b11bf5 2019-03-27 stsp
1256 66b11bf5 2019-03-27 stsp test_done "$testroot" "0"
1257 708d8e67 2019-03-27 stsp }
1258 c4cdcb68 2019-04-03 stsp
1259 f6cae3ed 2020-09-13 naddy test_update_partial() {
1260 c4cdcb68 2019-04-03 stsp local testroot=`test_init update_partial`
1261 c4cdcb68 2019-04-03 stsp
1262 c4cdcb68 2019-04-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1263 fc414659 2022-04-16 thomas ret=$?
1264 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1265 c4cdcb68 2019-04-03 stsp test_done "$testroot" "$ret"
1266 c4cdcb68 2019-04-03 stsp return 1
1267 c4cdcb68 2019-04-03 stsp fi
1268 708d8e67 2019-03-27 stsp
1269 c4cdcb68 2019-04-03 stsp echo "modified alpha" > $testroot/repo/alpha
1270 c4cdcb68 2019-04-03 stsp echo "modified beta" > $testroot/repo/beta
1271 c4cdcb68 2019-04-03 stsp echo "modified epsilon/zeta" > $testroot/repo/epsilon/zeta
1272 c4cdcb68 2019-04-03 stsp git_commit $testroot/repo -m "modified two files"
1273 c4cdcb68 2019-04-03 stsp
1274 f2ea84fa 2019-07-27 stsp echo "U alpha" > $testroot/stdout.expected
1275 f2ea84fa 2019-07-27 stsp echo "U beta" >> $testroot/stdout.expected
1276 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1277 f2ea84fa 2019-07-27 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1278 f2ea84fa 2019-07-27 stsp echo >> $testroot/stdout.expected
1279 c4cdcb68 2019-04-03 stsp
1280 f2ea84fa 2019-07-27 stsp (cd $testroot/wt && got update alpha beta > $testroot/stdout)
1281 c4cdcb68 2019-04-03 stsp
1282 f2ea84fa 2019-07-27 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1283 fc414659 2022-04-16 thomas ret=$?
1284 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1285 f2ea84fa 2019-07-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
1286 f2ea84fa 2019-07-27 stsp test_done "$testroot" "$ret"
1287 f2ea84fa 2019-07-27 stsp return 1
1288 f2ea84fa 2019-07-27 stsp fi
1289 c4cdcb68 2019-04-03 stsp
1290 f2ea84fa 2019-07-27 stsp echo "modified alpha" > $testroot/content.expected
1291 f2ea84fa 2019-07-27 stsp echo "modified beta" >> $testroot/content.expected
1292 f2ea84fa 2019-07-27 stsp
1293 f2ea84fa 2019-07-27 stsp cat $testroot/wt/alpha $testroot/wt/beta > $testroot/content
1294 f2ea84fa 2019-07-27 stsp cmp -s $testroot/content.expected $testroot/content
1295 fc414659 2022-04-16 thomas ret=$?
1296 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1297 f2ea84fa 2019-07-27 stsp diff -u $testroot/content.expected $testroot/content
1298 f2ea84fa 2019-07-27 stsp test_done "$testroot" "$ret"
1299 f2ea84fa 2019-07-27 stsp return 1
1300 f2ea84fa 2019-07-27 stsp fi
1301 e4d984c2 2019-05-22 stsp
1302 e4d984c2 2019-05-22 stsp echo "U epsilon/zeta" > $testroot/stdout.expected
1303 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1304 e4d984c2 2019-05-22 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1305 e4d984c2 2019-05-22 stsp echo >> $testroot/stdout.expected
1306 e4d984c2 2019-05-22 stsp
1307 e4d984c2 2019-05-22 stsp (cd $testroot/wt && got update epsilon > $testroot/stdout)
1308 e4d984c2 2019-05-22 stsp
1309 e4d984c2 2019-05-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1310 fc414659 2022-04-16 thomas ret=$?
1311 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1312 e4d984c2 2019-05-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1313 e4d984c2 2019-05-22 stsp test_done "$testroot" "$ret"
1314 e4d984c2 2019-05-22 stsp return 1
1315 e4d984c2 2019-05-22 stsp fi
1316 e4d984c2 2019-05-22 stsp
1317 e4d984c2 2019-05-22 stsp echo "modified epsilon/zeta" > $testroot/content.expected
1318 e4d984c2 2019-05-22 stsp cat $testroot/wt/epsilon/zeta > $testroot/content
1319 e4d984c2 2019-05-22 stsp
1320 e4d984c2 2019-05-22 stsp cmp -s $testroot/content.expected $testroot/content
1321 fc414659 2022-04-16 thomas ret=$?
1322 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1323 e4d984c2 2019-05-22 stsp diff -u $testroot/content.expected $testroot/content
1324 e4d984c2 2019-05-22 stsp test_done "$testroot" "$ret"
1325 e4d984c2 2019-05-22 stsp return 1
1326 e4d984c2 2019-05-22 stsp fi
1327 e4d984c2 2019-05-22 stsp
1328 c4cdcb68 2019-04-03 stsp test_done "$testroot" "$ret"
1329 c4cdcb68 2019-04-03 stsp }
1330 c4cdcb68 2019-04-03 stsp
1331 f6cae3ed 2020-09-13 naddy test_update_partial_add() {
1332 c4cdcb68 2019-04-03 stsp local testroot=`test_init update_partial_add`
1333 c4cdcb68 2019-04-03 stsp
1334 c4cdcb68 2019-04-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1335 fc414659 2022-04-16 thomas ret=$?
1336 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1337 c4cdcb68 2019-04-03 stsp test_done "$testroot" "$ret"
1338 c4cdcb68 2019-04-03 stsp return 1
1339 c4cdcb68 2019-04-03 stsp fi
1340 c4cdcb68 2019-04-03 stsp
1341 c4cdcb68 2019-04-03 stsp echo "new" > $testroot/repo/new
1342 c4cdcb68 2019-04-03 stsp echo "epsilon/new2" > $testroot/repo/epsilon/new2
1343 c4cdcb68 2019-04-03 stsp (cd $testroot/repo && git add .)
1344 c4cdcb68 2019-04-03 stsp git_commit $testroot/repo -m "added two files"
1345 c4cdcb68 2019-04-03 stsp
1346 f1417e9f 2021-10-12 thomas echo "A epsilon/new2" > $testroot/stdout.expected
1347 f1417e9f 2021-10-12 thomas echo "A new" >> $testroot/stdout.expected
1348 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1349 f2ea84fa 2019-07-27 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1350 f2ea84fa 2019-07-27 stsp echo >> $testroot/stdout.expected
1351 c4cdcb68 2019-04-03 stsp
1352 f2ea84fa 2019-07-27 stsp (cd $testroot/wt && got update new epsilon/new2 > $testroot/stdout)
1353 c4cdcb68 2019-04-03 stsp
1354 f2ea84fa 2019-07-27 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1355 fc414659 2022-04-16 thomas ret=$?
1356 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1357 f2ea84fa 2019-07-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
1358 f2ea84fa 2019-07-27 stsp test_done "$testroot" "$ret"
1359 f2ea84fa 2019-07-27 stsp return 1
1360 f2ea84fa 2019-07-27 stsp fi
1361 c4cdcb68 2019-04-03 stsp
1362 f2ea84fa 2019-07-27 stsp echo "new" > $testroot/content.expected
1363 f2ea84fa 2019-07-27 stsp echo "epsilon/new2" >> $testroot/content.expected
1364 c4cdcb68 2019-04-03 stsp
1365 f2ea84fa 2019-07-27 stsp cat $testroot/wt/new $testroot/wt/epsilon/new2 > $testroot/content
1366 f2ea84fa 2019-07-27 stsp
1367 f2ea84fa 2019-07-27 stsp cmp -s $testroot/content.expected $testroot/content
1368 fc414659 2022-04-16 thomas ret=$?
1369 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1370 f2ea84fa 2019-07-27 stsp diff -u $testroot/content.expected $testroot/content
1371 f2ea84fa 2019-07-27 stsp fi
1372 c4cdcb68 2019-04-03 stsp test_done "$testroot" "$ret"
1373 c4cdcb68 2019-04-03 stsp }
1374 c4cdcb68 2019-04-03 stsp
1375 f6cae3ed 2020-09-13 naddy test_update_partial_rm() {
1376 c4cdcb68 2019-04-03 stsp local testroot=`test_init update_partial_rm`
1377 c4cdcb68 2019-04-03 stsp
1378 c4cdcb68 2019-04-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1379 fc414659 2022-04-16 thomas ret=$?
1380 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1381 c4cdcb68 2019-04-03 stsp test_done "$testroot" "$ret"
1382 c4cdcb68 2019-04-03 stsp return 1
1383 c4cdcb68 2019-04-03 stsp fi
1384 c4cdcb68 2019-04-03 stsp
1385 f2ea84fa 2019-07-27 stsp (cd $testroot/repo && git rm -q alpha epsilon/zeta)
1386 c4cdcb68 2019-04-03 stsp git_commit $testroot/repo -m "removed two files"
1387 c4cdcb68 2019-04-03 stsp
1388 b66cd6f3 2020-07-31 stsp echo "got: /alpha: no such entry found in tree" \
1389 f2ea84fa 2019-07-27 stsp > $testroot/stderr.expected
1390 f2ea84fa 2019-07-27 stsp
1391 f2ea84fa 2019-07-27 stsp (cd $testroot/wt && got update alpha epsilon/zeta 2> $testroot/stderr)
1392 fc414659 2022-04-16 thomas ret=$?
1393 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
1394 f2ea84fa 2019-07-27 stsp echo "update succeeded unexpectedly" >&2
1395 f2ea84fa 2019-07-27 stsp test_done "$testroot" "1"
1396 f2ea84fa 2019-07-27 stsp return 1
1397 f2ea84fa 2019-07-27 stsp fi
1398 c4cdcb68 2019-04-03 stsp
1399 f2ea84fa 2019-07-27 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1400 fc414659 2022-04-16 thomas ret=$?
1401 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1402 f2ea84fa 2019-07-27 stsp diff -u $testroot/stderr.expected $testroot/stderr
1403 f2ea84fa 2019-07-27 stsp test_done "$testroot" "$ret"
1404 f2ea84fa 2019-07-27 stsp return 1
1405 f2ea84fa 2019-07-27 stsp fi
1406 c4cdcb68 2019-04-03 stsp test_done "$testroot" "$ret"
1407 c4cdcb68 2019-04-03 stsp }
1408 c4cdcb68 2019-04-03 stsp
1409 f6cae3ed 2020-09-13 naddy test_update_partial_dir() {
1410 c4cdcb68 2019-04-03 stsp local testroot=`test_init update_partial_dir`
1411 c4cdcb68 2019-04-03 stsp
1412 c4cdcb68 2019-04-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1413 fc414659 2022-04-16 thomas ret=$?
1414 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1415 c4cdcb68 2019-04-03 stsp test_done "$testroot" "$ret"
1416 c4cdcb68 2019-04-03 stsp return 1
1417 c4cdcb68 2019-04-03 stsp fi
1418 c4cdcb68 2019-04-03 stsp
1419 c4cdcb68 2019-04-03 stsp echo "modified alpha" > $testroot/repo/alpha
1420 c4cdcb68 2019-04-03 stsp echo "modified beta" > $testroot/repo/beta
1421 c4cdcb68 2019-04-03 stsp echo "modified epsilon/zeta" > $testroot/repo/epsilon/zeta
1422 c4cdcb68 2019-04-03 stsp git_commit $testroot/repo -m "modified two files"
1423 c4cdcb68 2019-04-03 stsp
1424 c4cdcb68 2019-04-03 stsp echo "U epsilon/zeta" > $testroot/stdout.expected
1425 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1426 c4cdcb68 2019-04-03 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1427 c4cdcb68 2019-04-03 stsp echo >> $testroot/stdout.expected
1428 c4cdcb68 2019-04-03 stsp
1429 c4cdcb68 2019-04-03 stsp (cd $testroot/wt && got update epsilon > $testroot/stdout)
1430 c4cdcb68 2019-04-03 stsp
1431 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1432 fc414659 2022-04-16 thomas ret=$?
1433 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1434 c4cdcb68 2019-04-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1435 c4cdcb68 2019-04-03 stsp test_done "$testroot" "$ret"
1436 c4cdcb68 2019-04-03 stsp return 1
1437 c4cdcb68 2019-04-03 stsp fi
1438 c4cdcb68 2019-04-03 stsp
1439 c4cdcb68 2019-04-03 stsp echo "modified epsilon/zeta" > $testroot/content.expected
1440 c4cdcb68 2019-04-03 stsp cat $testroot/wt/epsilon/zeta > $testroot/content
1441 c4cdcb68 2019-04-03 stsp
1442 8d301dd9 2019-05-14 stsp cmp -s $testroot/content.expected $testroot/content
1443 fc414659 2022-04-16 thomas ret=$?
1444 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1445 c4cdcb68 2019-04-03 stsp diff -u $testroot/content.expected $testroot/content
1446 c4cdcb68 2019-04-03 stsp test_done "$testroot" "$ret"
1447 c4cdcb68 2019-04-03 stsp return 1
1448 c4cdcb68 2019-04-03 stsp fi
1449 c4cdcb68 2019-04-03 stsp test_done "$testroot" "$ret"
1450 d5bea539 2019-05-13 stsp
1451 d5bea539 2019-05-13 stsp }
1452 d5bea539 2019-05-13 stsp
1453 f6cae3ed 2020-09-13 naddy test_update_moved_branch_ref() {
1454 d5bea539 2019-05-13 stsp local testroot=`test_init update_moved_branch_ref`
1455 d5bea539 2019-05-13 stsp
1456 d5bea539 2019-05-13 stsp git clone -q --mirror $testroot/repo $testroot/repo2
1457 d5bea539 2019-05-13 stsp
1458 d5bea539 2019-05-13 stsp echo "modified alpha with git" > $testroot/repo/alpha
1459 d5bea539 2019-05-13 stsp git_commit $testroot/repo -m "modified alpha with git"
1460 d5bea539 2019-05-13 stsp
1461 d5bea539 2019-05-13 stsp got checkout $testroot/repo2 $testroot/wt > /dev/null
1462 fc414659 2022-04-16 thomas ret=$?
1463 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1464 d5bea539 2019-05-13 stsp test_done "$testroot" "$ret"
1465 d5bea539 2019-05-13 stsp return 1
1466 d5bea539 2019-05-13 stsp fi
1467 d5bea539 2019-05-13 stsp
1468 d5bea539 2019-05-13 stsp echo "modified alpha with got" > $testroot/wt/alpha
1469 d5bea539 2019-05-13 stsp (cd $testroot/wt && got commit -m "modified alpha with got" > /dev/null)
1470 d5bea539 2019-05-13 stsp
1471 d5bea539 2019-05-13 stsp # + xxxxxxx...yyyyyyy master -> master (forced update)
1472 d5bea539 2019-05-13 stsp (cd $testroot/repo2 && git fetch -q --all)
1473 c4cdcb68 2019-04-03 stsp
1474 d5bea539 2019-05-13 stsp echo -n > $testroot/stdout.expected
1475 a1fb16d8 2019-05-24 stsp echo -n "got: work tree's head reference now points to a different " \
1476 a367ff0f 2019-05-14 stsp > $testroot/stderr.expected
1477 a1fb16d8 2019-05-24 stsp echo "branch; new head reference and/or update -b required" \
1478 a1fb16d8 2019-05-24 stsp >> $testroot/stderr.expected
1479 d5bea539 2019-05-13 stsp
1480 d5bea539 2019-05-13 stsp (cd $testroot/wt && got update > $testroot/stdout 2> $testroot/stderr)
1481 d5bea539 2019-05-13 stsp
1482 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1483 fc414659 2022-04-16 thomas ret=$?
1484 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1485 d5bea539 2019-05-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1486 d5bea539 2019-05-13 stsp test_done "$testroot" "$ret"
1487 d5bea539 2019-05-13 stsp return 1
1488 d5bea539 2019-05-13 stsp fi
1489 d5bea539 2019-05-13 stsp
1490 8d301dd9 2019-05-14 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1491 fc414659 2022-04-16 thomas ret=$?
1492 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1493 d5bea539 2019-05-13 stsp diff -u $testroot/stderr.expected $testroot/stderr
1494 d5bea539 2019-05-13 stsp fi
1495 d5bea539 2019-05-13 stsp test_done "$testroot" "$ret"
1496 c4cdcb68 2019-04-03 stsp }
1497 024e9686 2019-05-14 stsp
1498 f6cae3ed 2020-09-13 naddy test_update_to_another_branch() {
1499 024e9686 2019-05-14 stsp local testroot=`test_init update_to_another_branch`
1500 f69721c3 2019-10-21 stsp local base_commit=`git_show_head $testroot/repo`
1501 024e9686 2019-05-14 stsp
1502 024e9686 2019-05-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1503 fc414659 2022-04-16 thomas ret=$?
1504 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1505 024e9686 2019-05-14 stsp test_done "$testroot" "$ret"
1506 024e9686 2019-05-14 stsp return 1
1507 024e9686 2019-05-14 stsp fi
1508 024e9686 2019-05-14 stsp
1509 024e9686 2019-05-14 stsp echo 'refs/heads/master'> $testroot/head-ref.expected
1510 024e9686 2019-05-14 stsp cmp -s $testroot/head-ref.expected $testroot/wt/.got/head-ref
1511 fc414659 2022-04-16 thomas ret=$?
1512 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1513 024e9686 2019-05-14 stsp diff -u $testroot/head-ref.expected $testroot/wt/.got/head-ref
1514 024e9686 2019-05-14 stsp test_done "$testroot" "$ret"
1515 024e9686 2019-05-14 stsp return 1
1516 024e9686 2019-05-14 stsp fi
1517 024e9686 2019-05-14 stsp
1518 024e9686 2019-05-14 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1519 024e9686 2019-05-14 stsp echo "modified alpha on new branch" > $testroot/repo/alpha
1520 024e9686 2019-05-14 stsp git_commit $testroot/repo -m "modified alpha on new branch"
1521 024e9686 2019-05-14 stsp
1522 024e9686 2019-05-14 stsp echo "modified alpha in work tree" > $testroot/wt/alpha
1523 024e9686 2019-05-14 stsp
1524 d969fa15 2019-05-22 stsp echo "Switching work tree from refs/heads/master to refs/heads/newbranch" > $testroot/stdout.expected
1525 d969fa15 2019-05-22 stsp echo "C alpha" >> $testroot/stdout.expected
1526 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/newbranch: " >> $testroot/stdout.expected
1527 024e9686 2019-05-14 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1528 024e9686 2019-05-14 stsp echo >> $testroot/stdout.expected
1529 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
1530 024e9686 2019-05-14 stsp
1531 024e9686 2019-05-14 stsp (cd $testroot/wt && got update -b newbranch > $testroot/stdout)
1532 024e9686 2019-05-14 stsp
1533 024e9686 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1534 fc414659 2022-04-16 thomas ret=$?
1535 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1536 024e9686 2019-05-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1537 024e9686 2019-05-14 stsp test_done "$testroot" "$ret"
1538 024e9686 2019-05-14 stsp return 1
1539 024e9686 2019-05-14 stsp fi
1540 c4cdcb68 2019-04-03 stsp
1541 f69721c3 2019-10-21 stsp echo -n "<<<<<<< merged change: commit " > $testroot/content.expected
1542 024e9686 2019-05-14 stsp git_show_head $testroot/repo >> $testroot/content.expected
1543 024e9686 2019-05-14 stsp echo >> $testroot/content.expected
1544 024e9686 2019-05-14 stsp echo "modified alpha on new branch" >> $testroot/content.expected
1545 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $base_commit" \
1546 f69721c3 2019-10-21 stsp >> $testroot/content.expected
1547 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
1548 024e9686 2019-05-14 stsp echo "=======" >> $testroot/content.expected
1549 024e9686 2019-05-14 stsp echo "modified alpha in work tree" >> $testroot/content.expected
1550 f69721c3 2019-10-21 stsp echo '>>>>>>>' >> $testroot/content.expected
1551 d5bea539 2019-05-13 stsp
1552 024e9686 2019-05-14 stsp cat $testroot/wt/alpha > $testroot/content
1553 024e9686 2019-05-14 stsp
1554 024e9686 2019-05-14 stsp cmp -s $testroot/content.expected $testroot/content
1555 fc414659 2022-04-16 thomas ret=$?
1556 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1557 024e9686 2019-05-14 stsp diff -u $testroot/content.expected $testroot/content
1558 024e9686 2019-05-14 stsp test_done "$testroot" "$ret"
1559 024e9686 2019-05-14 stsp return 1
1560 024e9686 2019-05-14 stsp fi
1561 024e9686 2019-05-14 stsp
1562 024e9686 2019-05-14 stsp echo 'refs/heads/newbranch'> $testroot/head-ref.expected
1563 024e9686 2019-05-14 stsp cmp -s $testroot/head-ref.expected $testroot/wt/.got/head-ref
1564 fc414659 2022-04-16 thomas ret=$?
1565 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1566 024e9686 2019-05-14 stsp diff -u $testroot/head-ref.expected $testroot/wt/.got/head-ref
1567 a367ff0f 2019-05-14 stsp test_done "$testroot" "$ret"
1568 a367ff0f 2019-05-14 stsp return 1
1569 a367ff0f 2019-05-14 stsp fi
1570 a367ff0f 2019-05-14 stsp
1571 a367ff0f 2019-05-14 stsp test_done "$testroot" "$ret"
1572 a367ff0f 2019-05-14 stsp }
1573 a367ff0f 2019-05-14 stsp
1574 f6cae3ed 2020-09-13 naddy test_update_to_commit_on_wrong_branch() {
1575 a367ff0f 2019-05-14 stsp local testroot=`test_init update_to_commit_on_wrong_branch`
1576 a367ff0f 2019-05-14 stsp
1577 a367ff0f 2019-05-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1578 fc414659 2022-04-16 thomas ret=$?
1579 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1580 a367ff0f 2019-05-14 stsp test_done "$testroot" "$ret"
1581 a367ff0f 2019-05-14 stsp return 1
1582 a367ff0f 2019-05-14 stsp fi
1583 a367ff0f 2019-05-14 stsp
1584 a367ff0f 2019-05-14 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1585 a367ff0f 2019-05-14 stsp echo "modified alpha on new branch" > $testroot/repo/alpha
1586 a367ff0f 2019-05-14 stsp git_commit $testroot/repo -m "modified alpha on new branch"
1587 a367ff0f 2019-05-14 stsp
1588 a367ff0f 2019-05-14 stsp echo -n "" > $testroot/stdout.expected
1589 a367ff0f 2019-05-14 stsp echo "got: target commit is on a different branch" \
1590 a367ff0f 2019-05-14 stsp > $testroot/stderr.expected
1591 a367ff0f 2019-05-14 stsp
1592 a367ff0f 2019-05-14 stsp local head_rev=`git_show_head $testroot/repo`
1593 a367ff0f 2019-05-14 stsp (cd $testroot/wt && got update -c $head_rev > $testroot/stdout \
1594 a367ff0f 2019-05-14 stsp 2> $testroot/stderr)
1595 a367ff0f 2019-05-14 stsp
1596 a367ff0f 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1597 fc414659 2022-04-16 thomas ret=$?
1598 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1599 a367ff0f 2019-05-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1600 024e9686 2019-05-14 stsp test_done "$testroot" "$ret"
1601 024e9686 2019-05-14 stsp return 1
1602 024e9686 2019-05-14 stsp fi
1603 024e9686 2019-05-14 stsp
1604 a367ff0f 2019-05-14 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1605 fc414659 2022-04-16 thomas ret=$?
1606 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1607 a367ff0f 2019-05-14 stsp diff -u $testroot/stderr.expected $testroot/stderr
1608 a367ff0f 2019-05-14 stsp test_done "$testroot" "$ret"
1609 a367ff0f 2019-05-14 stsp return 1
1610 a367ff0f 2019-05-14 stsp fi
1611 a367ff0f 2019-05-14 stsp
1612 024e9686 2019-05-14 stsp test_done "$testroot" "$ret"
1613 024e9686 2019-05-14 stsp }
1614 c932eeeb 2019-05-22 stsp
1615 f6cae3ed 2020-09-13 naddy test_update_bumps_base_commit_id() {
1616 a5e55564 2019-06-10 stsp local testroot=`test_init update_bumps_base_commit_id`
1617 c932eeeb 2019-05-22 stsp
1618 1a36436d 2019-06-10 stsp echo "psi" > $testroot/repo/epsilon/psi
1619 1a36436d 2019-06-10 stsp (cd $testroot/repo && git add .)
1620 1a36436d 2019-06-10 stsp git_commit $testroot/repo -m "adding another file"
1621 1a36436d 2019-06-10 stsp
1622 c932eeeb 2019-05-22 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1623 fc414659 2022-04-16 thomas ret=$?
1624 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1625 c932eeeb 2019-05-22 stsp test_done "$testroot" "$ret"
1626 c932eeeb 2019-05-22 stsp return 1
1627 c932eeeb 2019-05-22 stsp fi
1628 024e9686 2019-05-14 stsp
1629 1a36436d 2019-06-10 stsp echo "modified psi" > $testroot/wt/epsilon/psi
1630 1a36436d 2019-06-10 stsp (cd $testroot/wt && got commit -m "changed psi" > $testroot/stdout)
1631 c932eeeb 2019-05-22 stsp
1632 c932eeeb 2019-05-22 stsp local head_rev=`git_show_head $testroot/repo`
1633 1a36436d 2019-06-10 stsp echo "M epsilon/psi" > $testroot/stdout.expected
1634 a7648d7a 2019-06-02 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1635 c932eeeb 2019-05-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1636 fc414659 2022-04-16 thomas ret=$?
1637 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1638 c932eeeb 2019-05-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1639 c932eeeb 2019-05-22 stsp test_done "$testroot" "$ret"
1640 c932eeeb 2019-05-22 stsp return 1
1641 c932eeeb 2019-05-22 stsp fi
1642 9bead371 2019-07-28 stsp
1643 305993b9 2019-07-28 stsp echo "changed zeta with git" > $testroot/repo/epsilon/zeta
1644 9bead371 2019-07-28 stsp (cd $testroot/repo && git add .)
1645 9bead371 2019-07-28 stsp git_commit $testroot/repo -m "changing zeta with git"
1646 c932eeeb 2019-05-22 stsp
1647 1a36436d 2019-06-10 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
1648 1a36436d 2019-06-10 stsp (cd $testroot/wt && got commit -m "changed zeta" > $testroot/stdout \
1649 c932eeeb 2019-05-22 stsp 2> $testroot/stderr)
1650 c932eeeb 2019-05-22 stsp
1651 c932eeeb 2019-05-22 stsp echo -n "" > $testroot/stdout.expected
1652 c932eeeb 2019-05-22 stsp echo "got: work tree must be updated before these changes can be committed" > $testroot/stderr.expected
1653 c932eeeb 2019-05-22 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1654 fc414659 2022-04-16 thomas ret=$?
1655 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1656 c932eeeb 2019-05-22 stsp diff -u $testroot/stderr.expected $testroot/stderr
1657 c932eeeb 2019-05-22 stsp test_done "$testroot" "$ret"
1658 c932eeeb 2019-05-22 stsp return 1
1659 c932eeeb 2019-05-22 stsp fi
1660 c932eeeb 2019-05-22 stsp
1661 c932eeeb 2019-05-22 stsp (cd $testroot/wt && got update > $testroot/stdout)
1662 c932eeeb 2019-05-22 stsp
1663 9bead371 2019-07-28 stsp echo "U epsilon/psi" > $testroot/stdout.expected
1664 9bead371 2019-07-28 stsp echo "C epsilon/zeta" >> $testroot/stdout.expected
1665 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1666 a484d721 2019-06-10 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1667 a484d721 2019-06-10 stsp echo >> $testroot/stdout.expected
1668 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
1669 9627c110 2020-04-18 stsp
1670 c932eeeb 2019-05-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1671 fc414659 2022-04-16 thomas ret=$?
1672 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1673 c932eeeb 2019-05-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1674 c932eeeb 2019-05-22 stsp test_done "$testroot" "$ret"
1675 c932eeeb 2019-05-22 stsp return 1
1676 c932eeeb 2019-05-22 stsp fi
1677 c932eeeb 2019-05-22 stsp
1678 9bead371 2019-07-28 stsp # resolve conflict
1679 9bead371 2019-07-28 stsp echo "modified zeta with got and git" > $testroot/wt/epsilon/zeta
1680 9bead371 2019-07-28 stsp
1681 1a36436d 2019-06-10 stsp (cd $testroot/wt && got commit -m "changed zeta" > $testroot/stdout)
1682 c932eeeb 2019-05-22 stsp
1683 c932eeeb 2019-05-22 stsp local head_rev=`git_show_head $testroot/repo`
1684 1a36436d 2019-06-10 stsp echo "M epsilon/zeta" > $testroot/stdout.expected
1685 a7648d7a 2019-06-02 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1686 303e2782 2019-08-09 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1687 fc414659 2022-04-16 thomas ret=$?
1688 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1689 303e2782 2019-08-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
1690 303e2782 2019-08-09 stsp test_done "$testroot" "$ret"
1691 303e2782 2019-08-09 stsp return 1
1692 303e2782 2019-08-09 stsp fi
1693 303e2782 2019-08-09 stsp
1694 303e2782 2019-08-09 stsp test_done "$testroot" "$ret"
1695 303e2782 2019-08-09 stsp }
1696 303e2782 2019-08-09 stsp
1697 f6cae3ed 2020-09-13 naddy test_update_tag() {
1698 303e2782 2019-08-09 stsp local testroot=`test_init update_tag`
1699 303e2782 2019-08-09 stsp local tag="1.0.0"
1700 303e2782 2019-08-09 stsp
1701 303e2782 2019-08-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1702 fc414659 2022-04-16 thomas ret=$?
1703 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1704 303e2782 2019-08-09 stsp test_done "$testroot" "$ret"
1705 303e2782 2019-08-09 stsp return 1
1706 303e2782 2019-08-09 stsp fi
1707 303e2782 2019-08-09 stsp
1708 303e2782 2019-08-09 stsp echo "modified alpha" > $testroot/repo/alpha
1709 303e2782 2019-08-09 stsp git_commit $testroot/repo -m "modified alpha"
1710 303e2782 2019-08-09 stsp (cd $testroot/repo && git tag -m "test" -a $tag)
1711 303e2782 2019-08-09 stsp
1712 303e2782 2019-08-09 stsp echo "U alpha" > $testroot/stdout.expected
1713 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1714 303e2782 2019-08-09 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1715 303e2782 2019-08-09 stsp echo >> $testroot/stdout.expected
1716 303e2782 2019-08-09 stsp
1717 303e2782 2019-08-09 stsp (cd $testroot/wt && got update -c $tag > $testroot/stdout)
1718 303e2782 2019-08-09 stsp
1719 c932eeeb 2019-05-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1720 fc414659 2022-04-16 thomas ret=$?
1721 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1722 c932eeeb 2019-05-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1723 c932eeeb 2019-05-22 stsp test_done "$testroot" "$ret"
1724 c932eeeb 2019-05-22 stsp return 1
1725 c932eeeb 2019-05-22 stsp fi
1726 c932eeeb 2019-05-22 stsp
1727 303e2782 2019-08-09 stsp echo "modified alpha" > $testroot/content.expected
1728 303e2782 2019-08-09 stsp cat $testroot/wt/alpha > $testroot/content
1729 303e2782 2019-08-09 stsp
1730 303e2782 2019-08-09 stsp cmp -s $testroot/content.expected $testroot/content
1731 fc414659 2022-04-16 thomas ret=$?
1732 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1733 303e2782 2019-08-09 stsp diff -u $testroot/content.expected $testroot/content
1734 523b8417 2019-10-19 stsp fi
1735 523b8417 2019-10-19 stsp test_done "$testroot" "$ret"
1736 523b8417 2019-10-19 stsp }
1737 523b8417 2019-10-19 stsp
1738 f6cae3ed 2020-09-13 naddy test_update_toggles_xbit() {
1739 523b8417 2019-10-19 stsp local testroot=`test_init update_toggles_xbit 1`
1740 523b8417 2019-10-19 stsp
1741 523b8417 2019-10-19 stsp touch $testroot/repo/xfile
1742 523b8417 2019-10-19 stsp chmod +x $testroot/repo/xfile
1743 523b8417 2019-10-19 stsp (cd $testroot/repo && git add .)
1744 523b8417 2019-10-19 stsp git_commit $testroot/repo -m "adding executable file"
1745 523b8417 2019-10-19 stsp local commit_id1=`git_show_head $testroot/repo`
1746 523b8417 2019-10-19 stsp
1747 523b8417 2019-10-19 stsp got checkout $testroot/repo $testroot/wt > $testroot/stdout
1748 fc414659 2022-04-16 thomas ret=$?
1749 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1750 523b8417 2019-10-19 stsp test_done "$testroot" "$ret"
1751 523b8417 2019-10-19 stsp return 1
1752 523b8417 2019-10-19 stsp fi
1753 523b8417 2019-10-19 stsp
1754 523b8417 2019-10-19 stsp ls -l $testroot/wt/xfile | grep -q '^-rwx'
1755 fc414659 2022-04-16 thomas ret=$?
1756 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1757 523b8417 2019-10-19 stsp echo "file is not executable" >&2
1758 523b8417 2019-10-19 stsp ls -l $testroot/wt/xfile >&2
1759 523b8417 2019-10-19 stsp test_done "$testroot" "$ret"
1760 523b8417 2019-10-19 stsp return 1
1761 523b8417 2019-10-19 stsp fi
1762 523b8417 2019-10-19 stsp
1763 523b8417 2019-10-19 stsp chmod -x $testroot/wt/xfile
1764 523b8417 2019-10-19 stsp (cd $testroot/wt && got commit -m "clear x bit" >/dev/null)
1765 523b8417 2019-10-19 stsp local commit_id2=`git_show_head $testroot/repo`
1766 523b8417 2019-10-19 stsp
1767 523b8417 2019-10-19 stsp echo "U xfile" > $testroot/stdout.expected
1768 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1769 523b8417 2019-10-19 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1770 523b8417 2019-10-19 stsp echo >> $testroot/stdout.expected
1771 523b8417 2019-10-19 stsp
1772 523b8417 2019-10-19 stsp (cd $testroot/wt && got update -c $commit_id1 > $testroot/stdout)
1773 fc414659 2022-04-16 thomas ret=$?
1774 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1775 523b8417 2019-10-19 stsp test_done "$testroot" "$ret"
1776 523b8417 2019-10-19 stsp return 1
1777 523b8417 2019-10-19 stsp fi
1778 523b8417 2019-10-19 stsp
1779 523b8417 2019-10-19 stsp echo "U xfile" > $testroot/stdout.expected
1780 4f3c844b 2021-09-14 stsp echo "Updated to refs/heads/master: $commit_id1" >> $testroot/stdout.expected
1781 523b8417 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1782 fc414659 2022-04-16 thomas ret=$?
1783 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1784 523b8417 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
1785 523b8417 2019-10-19 stsp test_done "$testroot" "$ret"
1786 523b8417 2019-10-19 stsp return 1
1787 303e2782 2019-08-09 stsp fi
1788 523b8417 2019-10-19 stsp
1789 523b8417 2019-10-19 stsp
1790 523b8417 2019-10-19 stsp ls -l $testroot/wt/xfile | grep -q '^-rwx'
1791 fc414659 2022-04-16 thomas ret=$?
1792 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1793 523b8417 2019-10-19 stsp echo "file is not executable" >&2
1794 523b8417 2019-10-19 stsp ls -l $testroot/wt/xfile >&2
1795 523b8417 2019-10-19 stsp test_done "$testroot" "$ret"
1796 523b8417 2019-10-19 stsp return 1
1797 523b8417 2019-10-19 stsp fi
1798 523b8417 2019-10-19 stsp
1799 523b8417 2019-10-19 stsp (cd $testroot/wt && got update > $testroot/stdout)
1800 fc414659 2022-04-16 thomas ret=$?
1801 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1802 523b8417 2019-10-19 stsp test_done "$testroot" "$ret"
1803 523b8417 2019-10-19 stsp return 1
1804 523b8417 2019-10-19 stsp fi
1805 523b8417 2019-10-19 stsp
1806 523b8417 2019-10-19 stsp echo "U xfile" > $testroot/stdout.expected
1807 4f3c844b 2021-09-14 stsp echo "Updated to refs/heads/master: $commit_id2" \
1808 4f3c844b 2021-09-14 stsp >> $testroot/stdout.expected
1809 523b8417 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1810 fc414659 2022-04-16 thomas ret=$?
1811 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1812 523b8417 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
1813 523b8417 2019-10-19 stsp test_done "$testroot" "$ret"
1814 523b8417 2019-10-19 stsp return 1
1815 523b8417 2019-10-19 stsp fi
1816 523b8417 2019-10-19 stsp
1817 523b8417 2019-10-19 stsp ls -l $testroot/wt/xfile | grep -q '^-rw-'
1818 fc414659 2022-04-16 thomas ret=$?
1819 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1820 523b8417 2019-10-19 stsp echo "file is unexpectedly executable" >&2
1821 523b8417 2019-10-19 stsp ls -l $testroot/wt/xfile >&2
1822 5036ab18 2020-04-18 stsp fi
1823 5036ab18 2020-04-18 stsp test_done "$testroot" "$ret"
1824 5036ab18 2020-04-18 stsp }
1825 5036ab18 2020-04-18 stsp
1826 f6cae3ed 2020-09-13 naddy test_update_preserves_conflicted_file() {
1827 5036ab18 2020-04-18 stsp local testroot=`test_init update_preserves_conflicted_file`
1828 5036ab18 2020-04-18 stsp local commit_id0=`git_show_head $testroot/repo`
1829 5036ab18 2020-04-18 stsp
1830 5036ab18 2020-04-18 stsp echo "modified alpha" > $testroot/repo/alpha
1831 5036ab18 2020-04-18 stsp git_commit $testroot/repo -m "modified alpha"
1832 5036ab18 2020-04-18 stsp local commit_id1=`git_show_head $testroot/repo`
1833 5036ab18 2020-04-18 stsp
1834 5036ab18 2020-04-18 stsp got checkout -c $commit_id0 $testroot/repo $testroot/wt > /dev/null
1835 fc414659 2022-04-16 thomas ret=$?
1836 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1837 5036ab18 2020-04-18 stsp test_done "$testroot" "$ret"
1838 5036ab18 2020-04-18 stsp return 1
1839 5036ab18 2020-04-18 stsp fi
1840 5036ab18 2020-04-18 stsp
1841 5036ab18 2020-04-18 stsp # fake a merge conflict
1842 5036ab18 2020-04-18 stsp echo '<<<<<<<' > $testroot/wt/alpha
1843 5036ab18 2020-04-18 stsp echo 'alpha' >> $testroot/wt/alpha
1844 5036ab18 2020-04-18 stsp echo '=======' >> $testroot/wt/alpha
1845 5036ab18 2020-04-18 stsp echo 'alpha, too' >> $testroot/wt/alpha
1846 5036ab18 2020-04-18 stsp echo '>>>>>>>' >> $testroot/wt/alpha
1847 5036ab18 2020-04-18 stsp cp $testroot/wt/alpha $testroot/content.expected
1848 5036ab18 2020-04-18 stsp
1849 5036ab18 2020-04-18 stsp echo "C alpha" > $testroot/stdout.expected
1850 5036ab18 2020-04-18 stsp (cd $testroot/wt && got status > $testroot/stdout)
1851 5036ab18 2020-04-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1852 fc414659 2022-04-16 thomas ret=$?
1853 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1854 5036ab18 2020-04-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
1855 5036ab18 2020-04-18 stsp test_done "$testroot" "$ret"
1856 5036ab18 2020-04-18 stsp return 1
1857 523b8417 2019-10-19 stsp fi
1858 5036ab18 2020-04-18 stsp
1859 5036ab18 2020-04-18 stsp echo "# alpha" > $testroot/stdout.expected
1860 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1861 5036ab18 2020-04-18 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1862 5036ab18 2020-04-18 stsp echo >> $testroot/stdout.expected
1863 9627c110 2020-04-18 stsp echo "Files not updated because of existing merge conflicts: 1" \
1864 9627c110 2020-04-18 stsp >> $testroot/stdout.expected
1865 5036ab18 2020-04-18 stsp (cd $testroot/wt && got update > $testroot/stdout)
1866 5036ab18 2020-04-18 stsp
1867 5036ab18 2020-04-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1868 fc414659 2022-04-16 thomas ret=$?
1869 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1870 5036ab18 2020-04-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
1871 5036ab18 2020-04-18 stsp test_done "$testroot" "$ret"
1872 5036ab18 2020-04-18 stsp return 1
1873 5036ab18 2020-04-18 stsp fi
1874 5036ab18 2020-04-18 stsp
1875 5036ab18 2020-04-18 stsp cmp -s $testroot/content.expected $testroot/wt/alpha
1876 fc414659 2022-04-16 thomas ret=$?
1877 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1878 5036ab18 2020-04-18 stsp diff -u $testroot/content.expected $testroot/wt/alpha
1879 5036ab18 2020-04-18 stsp fi
1880 c932eeeb 2019-05-22 stsp test_done "$testroot" "$ret"
1881 c932eeeb 2019-05-22 stsp }
1882 e7303626 2020-05-14 stsp
1883 f6cae3ed 2020-09-13 naddy test_update_modified_submodules() {
1884 e7303626 2020-05-14 stsp local testroot=`test_init update_modified_submodules`
1885 e7303626 2020-05-14 stsp
1886 e7303626 2020-05-14 stsp make_single_file_repo $testroot/repo2 foo
1887 e7303626 2020-05-14 stsp
1888 bf3ab206 2022-10-24 thomas (cd $testroot/repo && git -c protocol.file.allow=always \
1889 bf3ab206 2022-10-24 thomas submodule -q add ../repo2)
1890 e7303626 2020-05-14 stsp (cd $testroot/repo && git commit -q -m 'adding submodule')
1891 c932eeeb 2019-05-22 stsp
1892 e7303626 2020-05-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1893 e7303626 2020-05-14 stsp
1894 e7303626 2020-05-14 stsp echo "modified foo" > $testroot/repo2/foo
1895 e7303626 2020-05-14 stsp (cd $testroot/repo2 && git commit -q -a -m 'modified a submodule')
1896 e7303626 2020-05-14 stsp
1897 e7303626 2020-05-14 stsp # Update the repo/repo2 submodule link
1898 e7303626 2020-05-14 stsp (cd $testroot/repo && git -C repo2 pull -q)
1899 e7303626 2020-05-14 stsp (cd $testroot/repo && git add repo2)
1900 e7303626 2020-05-14 stsp git_commit $testroot/repo -m "modified submodule link"
1901 e7303626 2020-05-14 stsp
1902 e7303626 2020-05-14 stsp # This update only records the new base commit. Otherwise it is a
1903 e7303626 2020-05-14 stsp # no-op change because Got's file index does not track submodules.
1904 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " > $testroot/stdout.expected
1905 e7303626 2020-05-14 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1906 e7303626 2020-05-14 stsp echo >> $testroot/stdout.expected
1907 e7303626 2020-05-14 stsp
1908 e7303626 2020-05-14 stsp (cd $testroot/wt && got update > $testroot/stdout)
1909 e7303626 2020-05-14 stsp
1910 e7303626 2020-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1911 fc414659 2022-04-16 thomas ret=$?
1912 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1913 e7303626 2020-05-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1914 e7303626 2020-05-14 stsp fi
1915 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
1916 e7303626 2020-05-14 stsp }
1917 e7303626 2020-05-14 stsp
1918 f6cae3ed 2020-09-13 naddy test_update_adds_submodule() {
1919 e7303626 2020-05-14 stsp local testroot=`test_init update_adds_submodule`
1920 e7303626 2020-05-14 stsp
1921 e7303626 2020-05-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1922 e7303626 2020-05-14 stsp
1923 e7303626 2020-05-14 stsp make_single_file_repo $testroot/repo2 foo
1924 e7303626 2020-05-14 stsp
1925 e7303626 2020-05-14 stsp echo "modified foo" > $testroot/repo2/foo
1926 e7303626 2020-05-14 stsp (cd $testroot/repo2 && git commit -q -a -m 'modified a submodule')
1927 e7303626 2020-05-14 stsp
1928 bf3ab206 2022-10-24 thomas (cd $testroot/repo && git -c protocol.file.allow=always \
1929 bf3ab206 2022-10-24 thomas submodule -q add ../repo2)
1930 e7303626 2020-05-14 stsp (cd $testroot/repo && git commit -q -m 'adding submodule')
1931 e7303626 2020-05-14 stsp
1932 e7303626 2020-05-14 stsp echo "A .gitmodules" > $testroot/stdout.expected
1933 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1934 e7303626 2020-05-14 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1935 e7303626 2020-05-14 stsp echo >> $testroot/stdout.expected
1936 e7303626 2020-05-14 stsp
1937 e7303626 2020-05-14 stsp (cd $testroot/wt && got update > $testroot/stdout)
1938 e7303626 2020-05-14 stsp
1939 e7303626 2020-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1940 fc414659 2022-04-16 thomas ret=$?
1941 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1942 e7303626 2020-05-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1943 e7303626 2020-05-14 stsp fi
1944 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
1945 e7303626 2020-05-14 stsp }
1946 e7303626 2020-05-14 stsp
1947 f6cae3ed 2020-09-13 naddy test_update_conflict_wt_file_vs_repo_submodule() {
1948 e7303626 2020-05-14 stsp local testroot=`test_init update_conflict_wt_file_vs_repo_submodule`
1949 e7303626 2020-05-14 stsp
1950 e7303626 2020-05-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1951 e7303626 2020-05-14 stsp
1952 e7303626 2020-05-14 stsp make_single_file_repo $testroot/repo2 foo
1953 e7303626 2020-05-14 stsp
1954 e7303626 2020-05-14 stsp # Add a file which will clash with the submodule
1955 e7303626 2020-05-14 stsp echo "This is a file called repo2" > $testroot/wt/repo2
1956 e7303626 2020-05-14 stsp (cd $testroot/wt && got add repo2 > /dev/null)
1957 e7303626 2020-05-14 stsp (cd $testroot/wt && got commit -m 'add file repo2' > /dev/null)
1958 fc414659 2022-04-16 thomas ret=$?
1959 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1960 e7303626 2020-05-14 stsp echo "commit failed unexpectedly" >&2
1961 e7303626 2020-05-14 stsp test_done "$testroot" "1"
1962 e7303626 2020-05-14 stsp return 1
1963 e7303626 2020-05-14 stsp fi
1964 e7303626 2020-05-14 stsp
1965 bf3ab206 2022-10-24 thomas (cd $testroot/repo && git -c protocol.file.allow=always \
1966 bf3ab206 2022-10-24 thomas submodule -q add ../repo2)
1967 e7303626 2020-05-14 stsp (cd $testroot/repo && git commit -q -m 'adding submodule')
1968 e7303626 2020-05-14 stsp
1969 e7303626 2020-05-14 stsp # Modify the clashing file such that any modifications brought
1970 e7303626 2020-05-14 stsp # in by 'got update' would require a merge.
1971 e7303626 2020-05-14 stsp echo "This file was changed" > $testroot/wt/repo2
1972 e7303626 2020-05-14 stsp
1973 e7303626 2020-05-14 stsp # No conflict occurs because 'got update' ignores the submodule
1974 e7303626 2020-05-14 stsp # and leaves the clashing file as it was.
1975 e7303626 2020-05-14 stsp echo "A .gitmodules" > $testroot/stdout.expected
1976 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
1977 e7303626 2020-05-14 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1978 e7303626 2020-05-14 stsp echo >> $testroot/stdout.expected
1979 e7303626 2020-05-14 stsp
1980 e7303626 2020-05-14 stsp (cd $testroot/wt && got update > $testroot/stdout)
1981 e7303626 2020-05-14 stsp
1982 e7303626 2020-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1983 fc414659 2022-04-16 thomas ret=$?
1984 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1985 e7303626 2020-05-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1986 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
1987 e7303626 2020-05-14 stsp return 1
1988 e7303626 2020-05-14 stsp fi
1989 e7303626 2020-05-14 stsp
1990 e7303626 2020-05-14 stsp (cd $testroot/wt && got status > $testroot/stdout)
1991 e7303626 2020-05-14 stsp
1992 e7303626 2020-05-14 stsp echo "M repo2" > $testroot/stdout.expected
1993 e7303626 2020-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1994 fc414659 2022-04-16 thomas ret=$?
1995 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1996 e7303626 2020-05-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1997 e7303626 2020-05-14 stsp fi
1998 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
1999 e7303626 2020-05-14 stsp }
2000 f35fa46a 2020-07-23 stsp
2001 f6cae3ed 2020-09-13 naddy test_update_adds_symlink() {
2002 f35fa46a 2020-07-23 stsp local testroot=`test_init update_adds_symlink`
2003 f35fa46a 2020-07-23 stsp
2004 f35fa46a 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2005 fc414659 2022-04-16 thomas ret=$?
2006 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2007 f35fa46a 2020-07-23 stsp echo "checkout failed unexpectedly" >&2
2008 f35fa46a 2020-07-23 stsp test_done "$testroot" "$ret"
2009 f35fa46a 2020-07-23 stsp return 1
2010 f35fa46a 2020-07-23 stsp fi
2011 f35fa46a 2020-07-23 stsp
2012 f35fa46a 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
2013 f35fa46a 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
2014 f35fa46a 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
2015 f35fa46a 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
2016 f35fa46a 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
2017 f35fa46a 2020-07-23 stsp (cd $testroot/repo && git add .)
2018 f35fa46a 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
2019 f35fa46a 2020-07-23 stsp
2020 f35fa46a 2020-07-23 stsp echo "A alpha.link" > $testroot/stdout.expected
2021 f35fa46a 2020-07-23 stsp echo "A epsilon/beta.link" >> $testroot/stdout.expected
2022 f35fa46a 2020-07-23 stsp echo "A epsilon.link" >> $testroot/stdout.expected
2023 f35fa46a 2020-07-23 stsp echo "A nonexistent.link" >> $testroot/stdout.expected
2024 f35fa46a 2020-07-23 stsp echo "A passwd.link" >> $testroot/stdout.expected
2025 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
2026 f35fa46a 2020-07-23 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
2027 f35fa46a 2020-07-23 stsp echo >> $testroot/stdout.expected
2028 f35fa46a 2020-07-23 stsp
2029 f35fa46a 2020-07-23 stsp (cd $testroot/wt && got update > $testroot/stdout)
2030 f35fa46a 2020-07-23 stsp
2031 f35fa46a 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2032 fc414659 2022-04-16 thomas ret=$?
2033 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2034 f35fa46a 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2035 f35fa46a 2020-07-23 stsp test_done "$testroot" "$ret"
2036 f35fa46a 2020-07-23 stsp return 1
2037 f35fa46a 2020-07-23 stsp fi
2038 f35fa46a 2020-07-23 stsp
2039 f35fa46a 2020-07-23 stsp if ! [ -h $testroot/wt/alpha.link ]; then
2040 f35fa46a 2020-07-23 stsp echo "alpha.link is not a symlink"
2041 f35fa46a 2020-07-23 stsp test_done "$testroot" "1"
2042 f35fa46a 2020-07-23 stsp return 1
2043 f35fa46a 2020-07-23 stsp fi
2044 f35fa46a 2020-07-23 stsp
2045 f35fa46a 2020-07-23 stsp readlink $testroot/wt/alpha.link > $testroot/stdout
2046 f35fa46a 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
2047 f35fa46a 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2048 fc414659 2022-04-16 thomas ret=$?
2049 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2050 f35fa46a 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2051 f35fa46a 2020-07-23 stsp test_done "$testroot" "$ret"
2052 f35fa46a 2020-07-23 stsp return 1
2053 f35fa46a 2020-07-23 stsp fi
2054 f35fa46a 2020-07-23 stsp
2055 f35fa46a 2020-07-23 stsp if ! [ -h $testroot/wt/epsilon.link ]; then
2056 f35fa46a 2020-07-23 stsp echo "epsilon.link is not a symlink"
2057 f35fa46a 2020-07-23 stsp test_done "$testroot" "1"
2058 f35fa46a 2020-07-23 stsp return 1
2059 f35fa46a 2020-07-23 stsp fi
2060 e7303626 2020-05-14 stsp
2061 f35fa46a 2020-07-23 stsp readlink $testroot/wt/epsilon.link > $testroot/stdout
2062 f35fa46a 2020-07-23 stsp echo "epsilon" > $testroot/stdout.expected
2063 f35fa46a 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2064 fc414659 2022-04-16 thomas ret=$?
2065 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2066 f35fa46a 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2067 f35fa46a 2020-07-23 stsp test_done "$testroot" "$ret"
2068 f35fa46a 2020-07-23 stsp return 1
2069 f35fa46a 2020-07-23 stsp fi
2070 e7303626 2020-05-14 stsp
2071 f35fa46a 2020-07-23 stsp if [ -h $testroot/wt/passwd.link ]; then
2072 f35fa46a 2020-07-23 stsp echo -n "passwd.link symlink points outside of work tree: " >&2
2073 f35fa46a 2020-07-23 stsp readlink $testroot/wt/passwd.link >&2
2074 f35fa46a 2020-07-23 stsp test_done "$testroot" "1"
2075 f35fa46a 2020-07-23 stsp return 1
2076 f35fa46a 2020-07-23 stsp fi
2077 f35fa46a 2020-07-23 stsp
2078 f35fa46a 2020-07-23 stsp echo -n "/etc/passwd" > $testroot/content.expected
2079 f35fa46a 2020-07-23 stsp cp $testroot/wt/passwd.link $testroot/content
2080 f35fa46a 2020-07-23 stsp
2081 f35fa46a 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2082 fc414659 2022-04-16 thomas ret=$?
2083 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2084 f35fa46a 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2085 f35fa46a 2020-07-23 stsp test_done "$testroot" "$ret"
2086 f35fa46a 2020-07-23 stsp return 1
2087 f35fa46a 2020-07-23 stsp fi
2088 f35fa46a 2020-07-23 stsp
2089 f35fa46a 2020-07-23 stsp readlink $testroot/wt/epsilon/beta.link > $testroot/stdout
2090 f35fa46a 2020-07-23 stsp echo "../beta" > $testroot/stdout.expected
2091 f35fa46a 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2092 fc414659 2022-04-16 thomas ret=$?
2093 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2094 f35fa46a 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2095 f35fa46a 2020-07-23 stsp test_done "$testroot" "$ret"
2096 f35fa46a 2020-07-23 stsp return 1
2097 f35fa46a 2020-07-23 stsp fi
2098 f35fa46a 2020-07-23 stsp
2099 f35fa46a 2020-07-23 stsp readlink $testroot/wt/nonexistent.link > $testroot/stdout
2100 f35fa46a 2020-07-23 stsp echo "nonexistent" > $testroot/stdout.expected
2101 f35fa46a 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2102 fc414659 2022-04-16 thomas ret=$?
2103 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2104 f35fa46a 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2105 c6e8a826 2021-04-05 stsp test_done "$testroot" "$ret"
2106 c6e8a826 2021-04-05 stsp return 1
2107 f35fa46a 2020-07-23 stsp fi
2108 c6e8a826 2021-04-05 stsp
2109 c6e8a826 2021-04-05 stsp # Updating an up-to-date symlink should be a no-op.
2110 c6e8a826 2021-04-05 stsp echo 'Already up-to-date' > $testroot/stdout.expected
2111 c6e8a826 2021-04-05 stsp (cd $testroot/wt && got update > $testroot/stdout)
2112 c6e8a826 2021-04-05 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2113 fc414659 2022-04-16 thomas ret=$?
2114 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2115 c6e8a826 2021-04-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
2116 c6e8a826 2021-04-05 stsp fi
2117 f35fa46a 2020-07-23 stsp test_done "$testroot" "$ret"
2118 993e2a1b 2020-07-23 stsp }
2119 993e2a1b 2020-07-23 stsp
2120 f6cae3ed 2020-09-13 naddy test_update_deletes_symlink() {
2121 993e2a1b 2020-07-23 stsp local testroot=`test_init update_deletes_symlink`
2122 993e2a1b 2020-07-23 stsp
2123 993e2a1b 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
2124 993e2a1b 2020-07-23 stsp (cd $testroot/repo && git add .)
2125 993e2a1b 2020-07-23 stsp git_commit $testroot/repo -m "add symlink"
2126 993e2a1b 2020-07-23 stsp
2127 993e2a1b 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2128 fc414659 2022-04-16 thomas ret=$?
2129 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2130 993e2a1b 2020-07-23 stsp echo "checkout failed unexpectedly" >&2
2131 993e2a1b 2020-07-23 stsp test_done "$testroot" "$ret"
2132 993e2a1b 2020-07-23 stsp return 1
2133 993e2a1b 2020-07-23 stsp fi
2134 993e2a1b 2020-07-23 stsp
2135 993e2a1b 2020-07-23 stsp (cd $testroot/repo && git rm -q alpha.link)
2136 993e2a1b 2020-07-23 stsp git_commit $testroot/repo -m "delete symlink"
2137 993e2a1b 2020-07-23 stsp
2138 993e2a1b 2020-07-23 stsp echo "D alpha.link" > $testroot/stdout.expected
2139 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
2140 993e2a1b 2020-07-23 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
2141 993e2a1b 2020-07-23 stsp echo >> $testroot/stdout.expected
2142 993e2a1b 2020-07-23 stsp
2143 993e2a1b 2020-07-23 stsp (cd $testroot/wt && got update > $testroot/stdout)
2144 993e2a1b 2020-07-23 stsp
2145 993e2a1b 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2146 fc414659 2022-04-16 thomas ret=$?
2147 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2148 993e2a1b 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2149 993e2a1b 2020-07-23 stsp test_done "$testroot" "$ret"
2150 993e2a1b 2020-07-23 stsp return 1
2151 993e2a1b 2020-07-23 stsp fi
2152 993e2a1b 2020-07-23 stsp
2153 993e2a1b 2020-07-23 stsp if [ -e $testroot/wt/alpha.link ]; then
2154 993e2a1b 2020-07-23 stsp echo "alpha.link still exists on disk"
2155 993e2a1b 2020-07-23 stsp test_done "$testroot" "1"
2156 993e2a1b 2020-07-23 stsp return 1
2157 993e2a1b 2020-07-23 stsp fi
2158 993e2a1b 2020-07-23 stsp
2159 993e2a1b 2020-07-23 stsp test_done "$testroot" "0"
2160 993e2a1b 2020-07-23 stsp }
2161 993e2a1b 2020-07-23 stsp
2162 f6cae3ed 2020-09-13 naddy test_update_symlink_conflicts() {
2163 993e2a1b 2020-07-23 stsp local testroot=`test_init update_symlink_conflicts`
2164 993e2a1b 2020-07-23 stsp
2165 993e2a1b 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
2166 993e2a1b 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
2167 993e2a1b 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
2168 993e2a1b 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
2169 993e2a1b 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
2170 993e2a1b 2020-07-23 stsp (cd $testroot/repo && ln -sf epsilon/zeta zeta.link)
2171 993e2a1b 2020-07-23 stsp (cd $testroot/repo && git add .)
2172 993e2a1b 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
2173 993e2a1b 2020-07-23 stsp local commit_id1=`git_show_head $testroot/repo`
2174 993e2a1b 2020-07-23 stsp
2175 993e2a1b 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2176 fc414659 2022-04-16 thomas ret=$?
2177 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2178 993e2a1b 2020-07-23 stsp echo "checkout failed unexpectedly" >&2
2179 993e2a1b 2020-07-23 stsp test_done "$testroot" "$ret"
2180 993e2a1b 2020-07-23 stsp return 1
2181 993e2a1b 2020-07-23 stsp fi
2182 993e2a1b 2020-07-23 stsp
2183 993e2a1b 2020-07-23 stsp (cd $testroot/repo && ln -sf beta alpha.link)
2184 e6f45b72 2023-03-03 thomas (cd $testroot/repo && rm epsilon.link && ln -s gamma epsilon.link)
2185 993e2a1b 2020-07-23 stsp (cd $testroot/repo && ln -sf ../gamma/delta epsilon/beta.link)
2186 993e2a1b 2020-07-23 stsp echo 'this is regular file foo' > $testroot/repo/dotgotfoo.link
2187 993e2a1b 2020-07-23 stsp (cd $testroot/repo && ln -sf .got/bar dotgotbar.link)
2188 993e2a1b 2020-07-23 stsp (cd $testroot/repo && git rm -q nonexistent.link)
2189 993e2a1b 2020-07-23 stsp (cd $testroot/repo && ln -sf gamma/delta zeta.link)
2190 993e2a1b 2020-07-23 stsp (cd $testroot/repo && ln -sf alpha new.link)
2191 993e2a1b 2020-07-23 stsp (cd $testroot/repo && git add .)
2192 993e2a1b 2020-07-23 stsp git_commit $testroot/repo -m "change symlinks"
2193 993e2a1b 2020-07-23 stsp local commit_id2=`git_show_head $testroot/repo`
2194 993e2a1b 2020-07-23 stsp
2195 993e2a1b 2020-07-23 stsp # modified symlink to file A vs modified symlink to file B
2196 993e2a1b 2020-07-23 stsp (cd $testroot/wt && ln -sf gamma/delta alpha.link)
2197 993e2a1b 2020-07-23 stsp # modified symlink to dir A vs modified symlink to file B
2198 e6f45b72 2023-03-03 thomas (cd $testroot/wt && rm epsilon.link && ln -s beta epsilon.link)
2199 993e2a1b 2020-07-23 stsp # modeified symlink to file A vs modified symlink to dir B
2200 e6f45b72 2023-03-03 thomas (cd $testroot/wt && rm epsilon/beta.link && ln -s ../gamma \
2201 e6f45b72 2023-03-03 thomas epsilon/beta.link)
2202 993e2a1b 2020-07-23 stsp # added regular file A vs added bad symlink to file A
2203 993e2a1b 2020-07-23 stsp (cd $testroot/wt && ln -sf .got/bar dotgotfoo.link)
2204 3b9f0f87 2020-07-23 stsp (cd $testroot/wt && got add dotgotfoo.link > /dev/null)
2205 993e2a1b 2020-07-23 stsp # added bad symlink to file A vs added regular file A
2206 993e2a1b 2020-07-23 stsp echo 'this is regular file bar' > $testroot/wt/dotgotbar.link
2207 3b9f0f87 2020-07-23 stsp (cd $testroot/wt && got add dotgotbar.link > /dev/null)
2208 993e2a1b 2020-07-23 stsp # removed symlink to non-existent file A vs modified symlink
2209 993e2a1b 2020-07-23 stsp # to nonexistent file B
2210 993e2a1b 2020-07-23 stsp (cd $testroot/wt && ln -sf nonexistent2 nonexistent.link)
2211 993e2a1b 2020-07-23 stsp # modified symlink to file A vs removed symlink to file A
2212 993e2a1b 2020-07-23 stsp (cd $testroot/wt && got rm zeta.link > /dev/null)
2213 993e2a1b 2020-07-23 stsp # added symlink to file A vs added symlink to file B
2214 993e2a1b 2020-07-23 stsp (cd $testroot/wt && ln -sf beta new.link)
2215 993e2a1b 2020-07-23 stsp (cd $testroot/wt && got add new.link > /dev/null)
2216 993e2a1b 2020-07-23 stsp
2217 993e2a1b 2020-07-23 stsp (cd $testroot/wt && got update > $testroot/stdout)
2218 993e2a1b 2020-07-23 stsp
2219 993e2a1b 2020-07-23 stsp echo "C alpha.link" >> $testroot/stdout.expected
2220 3b9f0f87 2020-07-23 stsp echo "C dotgotbar.link" >> $testroot/stdout.expected
2221 3b9f0f87 2020-07-23 stsp echo "C dotgotfoo.link" >> $testroot/stdout.expected
2222 993e2a1b 2020-07-23 stsp echo "C epsilon/beta.link" >> $testroot/stdout.expected
2223 993e2a1b 2020-07-23 stsp echo "C epsilon.link" >> $testroot/stdout.expected
2224 993e2a1b 2020-07-23 stsp echo "C new.link" >> $testroot/stdout.expected
2225 993e2a1b 2020-07-23 stsp echo "C nonexistent.link" >> $testroot/stdout.expected
2226 993e2a1b 2020-07-23 stsp echo "G zeta.link" >> $testroot/stdout.expected
2227 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
2228 993e2a1b 2020-07-23 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
2229 993e2a1b 2020-07-23 stsp echo >> $testroot/stdout.expected
2230 3b9f0f87 2020-07-23 stsp echo "Files with new merge conflicts: 7" >> $testroot/stdout.expected
2231 993e2a1b 2020-07-23 stsp
2232 993e2a1b 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2233 fc414659 2022-04-16 thomas ret=$?
2234 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2235 993e2a1b 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2236 993e2a1b 2020-07-23 stsp test_done "$testroot" "$ret"
2237 993e2a1b 2020-07-23 stsp return 1
2238 993e2a1b 2020-07-23 stsp fi
2239 993e2a1b 2020-07-23 stsp
2240 993e2a1b 2020-07-23 stsp if [ -h $testroot/wt/alpha.link ]; then
2241 993e2a1b 2020-07-23 stsp echo "alpha.link is a symlink"
2242 993e2a1b 2020-07-23 stsp test_done "$testroot" "1"
2243 993e2a1b 2020-07-23 stsp return 1
2244 993e2a1b 2020-07-23 stsp fi
2245 993e2a1b 2020-07-23 stsp
2246 993e2a1b 2020-07-23 stsp echo "<<<<<<< merged change: commit $commit_id2" \
2247 283102fc 2020-07-23 stsp > $testroot/content.expected
2248 993e2a1b 2020-07-23 stsp echo "beta" >> $testroot/content.expected
2249 993e2a1b 2020-07-23 stsp echo "3-way merge base: commit $commit_id1" \
2250 993e2a1b 2020-07-23 stsp >> $testroot/content.expected
2251 993e2a1b 2020-07-23 stsp echo "alpha" >> $testroot/content.expected
2252 993e2a1b 2020-07-23 stsp echo "=======" >> $testroot/content.expected
2253 993e2a1b 2020-07-23 stsp echo "gamma/delta" >> $testroot/content.expected
2254 993e2a1b 2020-07-23 stsp echo '>>>>>>>' >> $testroot/content.expected
2255 993e2a1b 2020-07-23 stsp echo -n "" >> $testroot/content.expected
2256 993e2a1b 2020-07-23 stsp
2257 993e2a1b 2020-07-23 stsp cp $testroot/wt/alpha.link $testroot/content
2258 993e2a1b 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2259 fc414659 2022-04-16 thomas ret=$?
2260 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2261 993e2a1b 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2262 993e2a1b 2020-07-23 stsp test_done "$testroot" "$ret"
2263 993e2a1b 2020-07-23 stsp return 1
2264 993e2a1b 2020-07-23 stsp fi
2265 993e2a1b 2020-07-23 stsp
2266 993e2a1b 2020-07-23 stsp if [ -h $testroot/wt/epsilon.link ]; then
2267 993e2a1b 2020-07-23 stsp echo "epsilon.link is a symlink"
2268 993e2a1b 2020-07-23 stsp test_done "$testroot" "1"
2269 993e2a1b 2020-07-23 stsp return 1
2270 993e2a1b 2020-07-23 stsp fi
2271 993e2a1b 2020-07-23 stsp
2272 993e2a1b 2020-07-23 stsp echo "<<<<<<< merged change: commit $commit_id2" \
2273 283102fc 2020-07-23 stsp > $testroot/content.expected
2274 993e2a1b 2020-07-23 stsp echo "gamma" >> $testroot/content.expected
2275 993e2a1b 2020-07-23 stsp echo "3-way merge base: commit $commit_id1" \
2276 993e2a1b 2020-07-23 stsp >> $testroot/content.expected
2277 993e2a1b 2020-07-23 stsp echo "epsilon" >> $testroot/content.expected
2278 993e2a1b 2020-07-23 stsp echo "=======" >> $testroot/content.expected
2279 993e2a1b 2020-07-23 stsp echo "beta" >> $testroot/content.expected
2280 993e2a1b 2020-07-23 stsp echo '>>>>>>>' >> $testroot/content.expected
2281 993e2a1b 2020-07-23 stsp echo -n "" >> $testroot/content.expected
2282 993e2a1b 2020-07-23 stsp
2283 993e2a1b 2020-07-23 stsp cp $testroot/wt/epsilon.link $testroot/content
2284 993e2a1b 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2285 fc414659 2022-04-16 thomas ret=$?
2286 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2287 993e2a1b 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2288 993e2a1b 2020-07-23 stsp test_done "$testroot" "$ret"
2289 993e2a1b 2020-07-23 stsp return 1
2290 993e2a1b 2020-07-23 stsp fi
2291 993e2a1b 2020-07-23 stsp
2292 993e2a1b 2020-07-23 stsp if [ -h $testroot/wt/passwd.link ]; then
2293 993e2a1b 2020-07-23 stsp echo -n "passwd.link symlink points outside of work tree: " >&2
2294 993e2a1b 2020-07-23 stsp readlink $testroot/wt/passwd.link >&2
2295 993e2a1b 2020-07-23 stsp test_done "$testroot" "1"
2296 993e2a1b 2020-07-23 stsp return 1
2297 993e2a1b 2020-07-23 stsp fi
2298 993e2a1b 2020-07-23 stsp
2299 993e2a1b 2020-07-23 stsp echo -n "/etc/passwd" > $testroot/content.expected
2300 993e2a1b 2020-07-23 stsp cp $testroot/wt/passwd.link $testroot/content
2301 993e2a1b 2020-07-23 stsp
2302 993e2a1b 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2303 fc414659 2022-04-16 thomas ret=$?
2304 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2305 993e2a1b 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2306 993e2a1b 2020-07-23 stsp test_done "$testroot" "$ret"
2307 993e2a1b 2020-07-23 stsp return 1
2308 993e2a1b 2020-07-23 stsp fi
2309 993e2a1b 2020-07-23 stsp
2310 993e2a1b 2020-07-23 stsp if [ -h $testroot/wt/epsilon/beta.link ]; then
2311 993e2a1b 2020-07-23 stsp echo "epsilon/beta.link is a symlink"
2312 993e2a1b 2020-07-23 stsp test_done "$testroot" "1"
2313 993e2a1b 2020-07-23 stsp return 1
2314 993e2a1b 2020-07-23 stsp fi
2315 993e2a1b 2020-07-23 stsp
2316 993e2a1b 2020-07-23 stsp echo "<<<<<<< merged change: commit $commit_id2" \
2317 283102fc 2020-07-23 stsp > $testroot/content.expected
2318 993e2a1b 2020-07-23 stsp echo "../gamma/delta" >> $testroot/content.expected
2319 993e2a1b 2020-07-23 stsp echo "3-way merge base: commit $commit_id1" \
2320 993e2a1b 2020-07-23 stsp >> $testroot/content.expected
2321 993e2a1b 2020-07-23 stsp echo "../beta" >> $testroot/content.expected
2322 993e2a1b 2020-07-23 stsp echo "=======" >> $testroot/content.expected
2323 993e2a1b 2020-07-23 stsp echo "../gamma" >> $testroot/content.expected
2324 993e2a1b 2020-07-23 stsp echo '>>>>>>>' >> $testroot/content.expected
2325 993e2a1b 2020-07-23 stsp echo -n "" >> $testroot/content.expected
2326 993e2a1b 2020-07-23 stsp
2327 993e2a1b 2020-07-23 stsp cp $testroot/wt/epsilon/beta.link $testroot/content
2328 993e2a1b 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2329 fc414659 2022-04-16 thomas ret=$?
2330 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2331 993e2a1b 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2332 993e2a1b 2020-07-23 stsp test_done "$testroot" "$ret"
2333 993e2a1b 2020-07-23 stsp return 1
2334 993e2a1b 2020-07-23 stsp fi
2335 993e2a1b 2020-07-23 stsp
2336 993e2a1b 2020-07-23 stsp if [ -h $testroot/wt/nonexistent.link ]; then
2337 993e2a1b 2020-07-23 stsp echo -n "nonexistent.link still exists on disk: " >&2
2338 993e2a1b 2020-07-23 stsp readlink $testroot/wt/nonexistent.link >&2
2339 993e2a1b 2020-07-23 stsp test_done "$testroot" "1"
2340 993e2a1b 2020-07-23 stsp return 1
2341 993e2a1b 2020-07-23 stsp fi
2342 993e2a1b 2020-07-23 stsp
2343 993e2a1b 2020-07-23 stsp echo "<<<<<<< merged change: commit $commit_id2" \
2344 283102fc 2020-07-23 stsp > $testroot/content.expected
2345 993e2a1b 2020-07-23 stsp echo "(symlink was deleted)" >> $testroot/content.expected
2346 993e2a1b 2020-07-23 stsp echo "=======" >> $testroot/content.expected
2347 993e2a1b 2020-07-23 stsp echo "nonexistent2" >> $testroot/content.expected
2348 993e2a1b 2020-07-23 stsp echo '>>>>>>>' >> $testroot/content.expected
2349 993e2a1b 2020-07-23 stsp echo -n "" >> $testroot/content.expected
2350 993e2a1b 2020-07-23 stsp
2351 993e2a1b 2020-07-23 stsp cp $testroot/wt/nonexistent.link $testroot/content
2352 993e2a1b 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2353 fc414659 2022-04-16 thomas ret=$?
2354 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2355 993e2a1b 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2356 993e2a1b 2020-07-23 stsp test_done "$testroot" "$ret"
2357 993e2a1b 2020-07-23 stsp return 1
2358 993e2a1b 2020-07-23 stsp fi
2359 993e2a1b 2020-07-23 stsp
2360 993e2a1b 2020-07-23 stsp if [ -h $testroot/wt/dotgotfoo.link ]; then
2361 993e2a1b 2020-07-23 stsp echo "dotgotfoo.link is a symlink"
2362 993e2a1b 2020-07-23 stsp test_done "$testroot" "1"
2363 993e2a1b 2020-07-23 stsp return 1
2364 993e2a1b 2020-07-23 stsp fi
2365 993e2a1b 2020-07-23 stsp
2366 3b9f0f87 2020-07-23 stsp echo "<<<<<<< merged change: commit $commit_id2" \
2367 3b9f0f87 2020-07-23 stsp > $testroot/content.expected
2368 3b9f0f87 2020-07-23 stsp echo "this is regular file foo" >> $testroot/content.expected
2369 3b9f0f87 2020-07-23 stsp echo "=======" >> $testroot/content.expected
2370 3b9f0f87 2020-07-23 stsp echo -n ".got/bar" >> $testroot/content.expected
2371 3b9f0f87 2020-07-23 stsp echo '>>>>>>>' >> $testroot/content.expected
2372 3b9f0f87 2020-07-23 stsp echo -n "" >> $testroot/content.expected
2373 3b9f0f87 2020-07-23 stsp
2374 993e2a1b 2020-07-23 stsp cp $testroot/wt/dotgotfoo.link $testroot/content
2375 993e2a1b 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2376 fc414659 2022-04-16 thomas ret=$?
2377 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2378 993e2a1b 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2379 993e2a1b 2020-07-23 stsp test_done "$testroot" "$ret"
2380 993e2a1b 2020-07-23 stsp return 1
2381 993e2a1b 2020-07-23 stsp fi
2382 993e2a1b 2020-07-23 stsp
2383 993e2a1b 2020-07-23 stsp if [ -h $testroot/wt/dotgotbar.link ]; then
2384 993e2a1b 2020-07-23 stsp echo "dotgotbar.link is a symlink"
2385 993e2a1b 2020-07-23 stsp test_done "$testroot" "1"
2386 993e2a1b 2020-07-23 stsp return 1
2387 993e2a1b 2020-07-23 stsp fi
2388 3b9f0f87 2020-07-23 stsp echo "<<<<<<< merged change: commit $commit_id2" \
2389 3b9f0f87 2020-07-23 stsp > $testroot/content.expected
2390 3b9f0f87 2020-07-23 stsp echo -n ".got/bar" >> $testroot/content.expected
2391 3b9f0f87 2020-07-23 stsp echo "=======" >> $testroot/content.expected
2392 3b9f0f87 2020-07-23 stsp echo "this is regular file bar" >> $testroot/content.expected
2393 3b9f0f87 2020-07-23 stsp echo '>>>>>>>' >> $testroot/content.expected
2394 3b9f0f87 2020-07-23 stsp echo -n "" >> $testroot/content.expected
2395 3b9f0f87 2020-07-23 stsp
2396 993e2a1b 2020-07-23 stsp cp $testroot/wt/dotgotbar.link $testroot/content
2397 993e2a1b 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2398 fc414659 2022-04-16 thomas ret=$?
2399 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2400 993e2a1b 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2401 993e2a1b 2020-07-23 stsp test_done "$testroot" "$ret"
2402 993e2a1b 2020-07-23 stsp return 1
2403 993e2a1b 2020-07-23 stsp fi
2404 993e2a1b 2020-07-23 stsp
2405 993e2a1b 2020-07-23 stsp if [ -h $testroot/wt/new.link ]; then
2406 993e2a1b 2020-07-23 stsp echo "new.link is a symlink"
2407 993e2a1b 2020-07-23 stsp test_done "$testroot" "1"
2408 993e2a1b 2020-07-23 stsp return 1
2409 993e2a1b 2020-07-23 stsp fi
2410 993e2a1b 2020-07-23 stsp
2411 993e2a1b 2020-07-23 stsp echo "<<<<<<< merged change: commit $commit_id2" \
2412 283102fc 2020-07-23 stsp > $testroot/content.expected
2413 993e2a1b 2020-07-23 stsp echo "alpha" >> $testroot/content.expected
2414 993e2a1b 2020-07-23 stsp echo "=======" >> $testroot/content.expected
2415 993e2a1b 2020-07-23 stsp echo "beta" >> $testroot/content.expected
2416 993e2a1b 2020-07-23 stsp echo '>>>>>>>' >> $testroot/content.expected
2417 993e2a1b 2020-07-23 stsp echo -n "" >> $testroot/content.expected
2418 993e2a1b 2020-07-23 stsp
2419 993e2a1b 2020-07-23 stsp cp $testroot/wt/new.link $testroot/content
2420 993e2a1b 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2421 fc414659 2022-04-16 thomas ret=$?
2422 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2423 993e2a1b 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2424 993e2a1b 2020-07-23 stsp test_done "$testroot" "$ret"
2425 993e2a1b 2020-07-23 stsp return 1
2426 993e2a1b 2020-07-23 stsp fi
2427 993e2a1b 2020-07-23 stsp
2428 993e2a1b 2020-07-23 stsp echo "A dotgotfoo.link" > $testroot/stdout.expected
2429 993e2a1b 2020-07-23 stsp echo "M new.link" >> $testroot/stdout.expected
2430 993e2a1b 2020-07-23 stsp echo "D nonexistent.link" >> $testroot/stdout.expected
2431 993e2a1b 2020-07-23 stsp (cd $testroot/wt && got status > $testroot/stdout)
2432 21850702 2022-06-13 thomas ret=$?
2433 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2434 993e2a1b 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2435 993e2a1b 2020-07-23 stsp test_done "$testroot" "$ret"
2436 993e2a1b 2020-07-23 stsp return 1
2437 993e2a1b 2020-07-23 stsp fi
2438 993e2a1b 2020-07-23 stsp
2439 993e2a1b 2020-07-23 stsp test_done "$testroot" "0"
2440 993e2a1b 2020-07-23 stsp
2441 f35fa46a 2020-07-23 stsp }
2442 194cb7cb 2021-01-19 stsp
2443 194cb7cb 2021-01-19 stsp test_update_single_file() {
2444 194cb7cb 2021-01-19 stsp local testroot=`test_init update_single_file 1`
2445 194cb7cb 2021-01-19 stsp
2446 194cb7cb 2021-01-19 stsp echo c1 > $testroot/repo/c
2447 194cb7cb 2021-01-19 stsp (cd $testroot/repo && git add .)
2448 79775c2f 2021-01-19 stsp git_commit $testroot/repo -m "adding file c"
2449 194cb7cb 2021-01-19 stsp local commit_id1=`git_show_head $testroot/repo`
2450 194cb7cb 2021-01-19 stsp
2451 194cb7cb 2021-01-19 stsp echo a > $testroot/repo/a
2452 194cb7cb 2021-01-19 stsp echo b > $testroot/repo/b
2453 194cb7cb 2021-01-19 stsp echo c2 > $testroot/repo/c
2454 194cb7cb 2021-01-19 stsp (cd $testroot/repo && git add .)
2455 79775c2f 2021-01-19 stsp git_commit $testroot/repo -m "add files a and b, change c"
2456 194cb7cb 2021-01-19 stsp local commit_id2=`git_show_head $testroot/repo`
2457 f35fa46a 2020-07-23 stsp
2458 d51387a0 2021-01-19 stsp (cd $testroot/repo && git rm -qf c)
2459 d51387a0 2021-01-19 stsp git_commit $testroot/repo -m "remove file c"
2460 d51387a0 2021-01-19 stsp local commit_id3=`git_show_head $testroot/repo`
2461 d51387a0 2021-01-19 stsp
2462 d51387a0 2021-01-19 stsp got checkout -c $commit_id2 $testroot/repo $testroot/wt > /dev/null
2463 fc414659 2022-04-16 thomas ret=$?
2464 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2465 194cb7cb 2021-01-19 stsp test_done "$testroot" "$ret"
2466 194cb7cb 2021-01-19 stsp return 1
2467 194cb7cb 2021-01-19 stsp fi
2468 194cb7cb 2021-01-19 stsp
2469 194cb7cb 2021-01-19 stsp echo "U c" > $testroot/stdout.expected
2470 4f3c844b 2021-09-14 stsp echo "Updated to refs/heads/master: $commit_id1" \
2471 4f3c844b 2021-09-14 stsp >> $testroot/stdout.expected
2472 194cb7cb 2021-01-19 stsp
2473 194cb7cb 2021-01-19 stsp (cd $testroot/wt && got update -c $commit_id1 c \
2474 194cb7cb 2021-01-19 stsp > $testroot/stdout)
2475 194cb7cb 2021-01-19 stsp
2476 194cb7cb 2021-01-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2477 fc414659 2022-04-16 thomas ret=$?
2478 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2479 194cb7cb 2021-01-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
2480 194cb7cb 2021-01-19 stsp test_done "$testroot" "$ret"
2481 194cb7cb 2021-01-19 stsp return 1
2482 194cb7cb 2021-01-19 stsp fi
2483 194cb7cb 2021-01-19 stsp
2484 194cb7cb 2021-01-19 stsp echo c1 > $testroot/content.expected
2485 194cb7cb 2021-01-19 stsp cat $testroot/wt/c > $testroot/content
2486 194cb7cb 2021-01-19 stsp
2487 194cb7cb 2021-01-19 stsp cmp -s $testroot/content.expected $testroot/content
2488 fc414659 2022-04-16 thomas ret=$?
2489 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2490 194cb7cb 2021-01-19 stsp diff -u $testroot/content.expected $testroot/content
2491 194cb7cb 2021-01-19 stsp test_done "$testroot" "$ret"
2492 194cb7cb 2021-01-19 stsp return 1
2493 194cb7cb 2021-01-19 stsp fi
2494 194cb7cb 2021-01-19 stsp
2495 194cb7cb 2021-01-19 stsp echo "U c" > $testroot/stdout.expected
2496 4f3c844b 2021-09-14 stsp echo "Updated to refs/heads/master: $commit_id2" \
2497 4f3c844b 2021-09-14 stsp >> $testroot/stdout.expected
2498 194cb7cb 2021-01-19 stsp
2499 d51387a0 2021-01-19 stsp (cd $testroot/wt && got update -c $commit_id2 c > $testroot/stdout)
2500 194cb7cb 2021-01-19 stsp
2501 194cb7cb 2021-01-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2502 fc414659 2022-04-16 thomas ret=$?
2503 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2504 194cb7cb 2021-01-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
2505 194cb7cb 2021-01-19 stsp test_done "$testroot" "$ret"
2506 194cb7cb 2021-01-19 stsp return 1
2507 194cb7cb 2021-01-19 stsp fi
2508 194cb7cb 2021-01-19 stsp
2509 194cb7cb 2021-01-19 stsp echo c2 > $testroot/content.expected
2510 194cb7cb 2021-01-19 stsp cat $testroot/wt/c > $testroot/content
2511 194cb7cb 2021-01-19 stsp
2512 194cb7cb 2021-01-19 stsp cmp -s $testroot/content.expected $testroot/content
2513 fc414659 2022-04-16 thomas ret=$?
2514 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2515 194cb7cb 2021-01-19 stsp diff -u $testroot/content.expected $testroot/content
2516 d51387a0 2021-01-19 stsp test_done "$testroot" "$ret"
2517 d51387a0 2021-01-19 stsp return 1
2518 194cb7cb 2021-01-19 stsp fi
2519 d51387a0 2021-01-19 stsp
2520 d51387a0 2021-01-19 stsp echo "D c" > $testroot/stdout.expected
2521 4f3c844b 2021-09-14 stsp echo "Updated to refs/heads/master: $commit_id3" \
2522 4f3c844b 2021-09-14 stsp >> $testroot/stdout.expected
2523 d51387a0 2021-01-19 stsp
2524 d51387a0 2021-01-19 stsp (cd $testroot/wt && got update -c $commit_id3 c \
2525 d51387a0 2021-01-19 stsp > $testroot/stdout 2> $testroot/stderr)
2526 d51387a0 2021-01-19 stsp
2527 d51387a0 2021-01-19 stsp echo "got: /c: no such entry found in tree" > $testroot/stderr.expected
2528 d51387a0 2021-01-19 stsp cmp -s $testroot/stderr.expected $testroot/stderr
2529 fc414659 2022-04-16 thomas ret=$?
2530 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2531 d51387a0 2021-01-19 stsp diff -u $testroot/stderr.expected $testroot/stderr
2532 d51387a0 2021-01-19 stsp test_done "$testroot" "$ret"
2533 d51387a0 2021-01-19 stsp return 1
2534 d51387a0 2021-01-19 stsp fi
2535 d51387a0 2021-01-19 stsp
2536 d51387a0 2021-01-19 stsp echo -n > $testroot/stdout.expected
2537 d51387a0 2021-01-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2538 fc414659 2022-04-16 thomas ret=$?
2539 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2540 d51387a0 2021-01-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
2541 d51387a0 2021-01-19 stsp test_done "$testroot" "$ret"
2542 d51387a0 2021-01-19 stsp return 1
2543 d51387a0 2021-01-19 stsp fi
2544 d51387a0 2021-01-19 stsp
2545 d51387a0 2021-01-19 stsp echo "D c" > $testroot/stdout.expected
2546 4f3c844b 2021-09-14 stsp echo "Updated to refs/heads/master: $commit_id3" \
2547 4f3c844b 2021-09-14 stsp >> $testroot/stdout.expected
2548 d51387a0 2021-01-19 stsp
2549 d51387a0 2021-01-19 stsp (cd $testroot/wt && got update -c $commit_id3 > $testroot/stdout)
2550 d51387a0 2021-01-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2551 fc414659 2022-04-16 thomas ret=$?
2552 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2553 d51387a0 2021-01-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
2554 d51387a0 2021-01-19 stsp test_done "$testroot" "$ret"
2555 d51387a0 2021-01-19 stsp return 1
2556 d51387a0 2021-01-19 stsp fi
2557 d51387a0 2021-01-19 stsp
2558 d51387a0 2021-01-19 stsp if [ -e $testroot/wt/c ]; then
2559 d51387a0 2021-01-19 stsp echo "removed file c still exists on disk" >&2
2560 d51387a0 2021-01-19 stsp test_done "$testroot" "1"
2561 d51387a0 2021-01-19 stsp return 1
2562 d51387a0 2021-01-19 stsp fi
2563 d51387a0 2021-01-19 stsp
2564 d51387a0 2021-01-19 stsp test_done "$testroot" "0"
2565 d51387a0 2021-01-19 stsp return 0
2566 a769b60b 2021-06-27 stsp }
2567 a769b60b 2021-06-27 stsp
2568 a769b60b 2021-06-27 stsp test_update_file_skipped_due_to_conflict() {
2569 a769b60b 2021-06-27 stsp local testroot=`test_init update_file_skipped_due_to_conflict`
2570 a769b60b 2021-06-27 stsp local commit_id0=`git_show_head $testroot/repo`
2571 a769b60b 2021-06-27 stsp blob_id0=`get_blob_id $testroot/repo "" beta`
2572 a769b60b 2021-06-27 stsp
2573 a769b60b 2021-06-27 stsp echo "changed beta" > $testroot/repo/beta
2574 a769b60b 2021-06-27 stsp git_commit $testroot/repo -m "changed beta"
2575 a769b60b 2021-06-27 stsp local commit_id1=`git_show_head $testroot/repo`
2576 a769b60b 2021-06-27 stsp blob_id1=`get_blob_id $testroot/repo "" beta`
2577 a769b60b 2021-06-27 stsp
2578 a769b60b 2021-06-27 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2579 fc414659 2022-04-16 thomas ret=$?
2580 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2581 a769b60b 2021-06-27 stsp test_done "$testroot" "$ret"
2582 a769b60b 2021-06-27 stsp return 1
2583 a769b60b 2021-06-27 stsp fi
2584 a769b60b 2021-06-27 stsp
2585 a769b60b 2021-06-27 stsp blob_id=`(cd $testroot/wt && got info beta | grep 'blob:' | \
2586 a769b60b 2021-06-27 stsp cut -d ':' -f 2 | tr -d ' ')`
2587 a769b60b 2021-06-27 stsp if [ "$blob_id" != "$blob_id1" ]; then
2588 a769b60b 2021-06-27 stsp echo "file beta has the wrong base blob ID" >&2
2589 a769b60b 2021-06-27 stsp test_done "$testroot" "1"
2590 a769b60b 2021-06-27 stsp return 1
2591 a769b60b 2021-06-27 stsp fi
2592 a769b60b 2021-06-27 stsp
2593 a769b60b 2021-06-27 stsp commit_id=`(cd $testroot/wt && got info beta | \
2594 a769b60b 2021-06-27 stsp grep 'based on commit:' | cut -d ':' -f 2 | tr -d ' ')`
2595 a769b60b 2021-06-27 stsp if [ "$commit_id" != "$commit_id1" ]; then
2596 a769b60b 2021-06-27 stsp echo "file beta has the wrong base commit ID" >&2
2597 a769b60b 2021-06-27 stsp test_done "$testroot" "1"
2598 a769b60b 2021-06-27 stsp return 1
2599 a769b60b 2021-06-27 stsp fi
2600 a769b60b 2021-06-27 stsp
2601 a769b60b 2021-06-27 stsp echo "modified beta" > $testroot/wt/beta
2602 a769b60b 2021-06-27 stsp
2603 a769b60b 2021-06-27 stsp (cd $testroot/wt && got update -c $commit_id0 > $testroot/stdout)
2604 a769b60b 2021-06-27 stsp
2605 a769b60b 2021-06-27 stsp echo "C beta" > $testroot/stdout.expected
2606 4f3c844b 2021-09-14 stsp echo "Updated to refs/heads/master: $commit_id0" \
2607 4f3c844b 2021-09-14 stsp >> $testroot/stdout.expected
2608 a769b60b 2021-06-27 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
2609 a769b60b 2021-06-27 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2610 fc414659 2022-04-16 thomas ret=$?
2611 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2612 a769b60b 2021-06-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
2613 a769b60b 2021-06-27 stsp test_done "$testroot" "$ret"
2614 a769b60b 2021-06-27 stsp return 1
2615 a769b60b 2021-06-27 stsp fi
2616 a769b60b 2021-06-27 stsp
2617 a769b60b 2021-06-27 stsp echo "<<<<<<< merged change: commit $commit_id0" \
2618 a769b60b 2021-06-27 stsp > $testroot/content.expected
2619 a769b60b 2021-06-27 stsp echo "beta" >> $testroot/content.expected
2620 a769b60b 2021-06-27 stsp echo "||||||| 3-way merge base: commit $commit_id1" \
2621 a769b60b 2021-06-27 stsp >> $testroot/content.expected
2622 a769b60b 2021-06-27 stsp echo "changed beta" >> $testroot/content.expected
2623 a769b60b 2021-06-27 stsp echo "=======" >> $testroot/content.expected
2624 a769b60b 2021-06-27 stsp echo "modified beta" >> $testroot/content.expected
2625 a769b60b 2021-06-27 stsp echo ">>>>>>>" >> $testroot/content.expected
2626 a769b60b 2021-06-27 stsp
2627 a769b60b 2021-06-27 stsp cat $testroot/wt/beta > $testroot/content
2628 a769b60b 2021-06-27 stsp
2629 a769b60b 2021-06-27 stsp cmp -s $testroot/content.expected $testroot/content
2630 fc414659 2022-04-16 thomas ret=$?
2631 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2632 a769b60b 2021-06-27 stsp diff -u $testroot/content.expected $testroot/content
2633 a769b60b 2021-06-27 stsp test_done "$testroot" "$ret"
2634 a769b60b 2021-06-27 stsp return 1
2635 a769b60b 2021-06-27 stsp fi
2636 a769b60b 2021-06-27 stsp
2637 a769b60b 2021-06-27 stsp blob_id=`(cd $testroot/wt && got info beta | grep 'blob:' | \
2638 a769b60b 2021-06-27 stsp cut -d ':' -f 2 | tr -d ' ')`
2639 a769b60b 2021-06-27 stsp if [ "$blob_id" != "$blob_id0" ]; then
2640 a769b60b 2021-06-27 stsp echo "file beta has the wrong base blob ID" >&2
2641 a769b60b 2021-06-27 stsp test_done "$testroot" "1"
2642 a769b60b 2021-06-27 stsp return 1
2643 a769b60b 2021-06-27 stsp fi
2644 a769b60b 2021-06-27 stsp
2645 a769b60b 2021-06-27 stsp commit_id=`(cd $testroot/wt && got info beta | \
2646 a769b60b 2021-06-27 stsp grep 'based on commit:' | cut -d ':' -f 2 | tr -d ' ')`
2647 a769b60b 2021-06-27 stsp if [ "$commit_id" != "$commit_id0" ]; then
2648 a769b60b 2021-06-27 stsp echo "file beta has the wrong base commit ID" >&2
2649 a769b60b 2021-06-27 stsp test_done "$testroot" "1"
2650 a769b60b 2021-06-27 stsp return 1
2651 a769b60b 2021-06-27 stsp fi
2652 a769b60b 2021-06-27 stsp
2653 a769b60b 2021-06-27 stsp # update to the latest commit again; this skips beta
2654 a769b60b 2021-06-27 stsp (cd $testroot/wt && got update > $testroot/stdout)
2655 a769b60b 2021-06-27 stsp echo "# beta" > $testroot/stdout.expected
2656 4f3c844b 2021-09-14 stsp echo "Updated to refs/heads/master: $commit_id1" \
2657 4f3c844b 2021-09-14 stsp >> $testroot/stdout.expected
2658 a769b60b 2021-06-27 stsp echo "Files not updated because of existing merge conflicts: 1" \
2659 a769b60b 2021-06-27 stsp >> $testroot/stdout.expected
2660 a769b60b 2021-06-27 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2661 fc414659 2022-04-16 thomas ret=$?
2662 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2663 a769b60b 2021-06-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
2664 a769b60b 2021-06-27 stsp test_done "$testroot" "$ret"
2665 a769b60b 2021-06-27 stsp return 1
2666 a769b60b 2021-06-27 stsp fi
2667 a769b60b 2021-06-27 stsp
2668 a769b60b 2021-06-27 stsp # blob ID of beta should not have changed
2669 a769b60b 2021-06-27 stsp blob_id=`(cd $testroot/wt && got info beta | grep 'blob:' | \
2670 a769b60b 2021-06-27 stsp cut -d ':' -f 2 | tr -d ' ')`
2671 a769b60b 2021-06-27 stsp if [ "$blob_id" != "$blob_id0" ]; then
2672 a769b60b 2021-06-27 stsp echo "file beta has the wrong base blob ID" >&2
2673 a769b60b 2021-06-27 stsp test_done "$testroot" "1"
2674 a769b60b 2021-06-27 stsp return 1
2675 a769b60b 2021-06-27 stsp fi
2676 a769b60b 2021-06-27 stsp
2677 a769b60b 2021-06-27 stsp # commit ID of beta should not have changed; There was a bug
2678 a769b60b 2021-06-27 stsp # here where the commit ID had been changed even though the
2679 a769b60b 2021-06-27 stsp # file was not updated.
2680 a769b60b 2021-06-27 stsp commit_id=`(cd $testroot/wt && got info beta | \
2681 a769b60b 2021-06-27 stsp grep 'based on commit:' | cut -d ':' -f 2 | tr -d ' ')`
2682 a769b60b 2021-06-27 stsp if [ "$commit_id" != "$commit_id0" ]; then
2683 a769b60b 2021-06-27 stsp echo "file beta has the wrong base commit ID: $commit_id" >&2
2684 a769b60b 2021-06-27 stsp test_done "$testroot" "1"
2685 a769b60b 2021-06-27 stsp return 1
2686 a769b60b 2021-06-27 stsp fi
2687 a769b60b 2021-06-27 stsp
2688 a769b60b 2021-06-27 stsp # beta is still conflicted and based on commit 0
2689 a769b60b 2021-06-27 stsp echo 'C beta' > $testroot/stdout.expected
2690 a769b60b 2021-06-27 stsp (cd $testroot/wt && got status > $testroot/stdout)
2691 a769b60b 2021-06-27 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2692 fc414659 2022-04-16 thomas ret=$?
2693 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2694 a769b60b 2021-06-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
2695 a769b60b 2021-06-27 stsp test_done "$testroot" "$ret"
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 # resolve the conflict via revert
2700 a769b60b 2021-06-27 stsp (cd $testroot/wt && got revert beta >/dev/null)
2701 a769b60b 2021-06-27 stsp
2702 a769b60b 2021-06-27 stsp # beta now matches its base blob which is still from commit 0
2703 a769b60b 2021-06-27 stsp echo "beta" > $testroot/content.expected
2704 a769b60b 2021-06-27 stsp cat $testroot/wt/beta > $testroot/content
2705 a769b60b 2021-06-27 stsp cmp -s $testroot/content.expected $testroot/content
2706 fc414659 2022-04-16 thomas ret=$?
2707 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2708 a769b60b 2021-06-27 stsp diff -u $testroot/content.expected $testroot/content
2709 a769b60b 2021-06-27 stsp test_done "$testroot" "$ret"
2710 a769b60b 2021-06-27 stsp return 1
2711 a769b60b 2021-06-27 stsp fi
2712 a769b60b 2021-06-27 stsp
2713 a769b60b 2021-06-27 stsp # updating to the latest commit should now update beta
2714 a769b60b 2021-06-27 stsp (cd $testroot/wt && got update > $testroot/stdout)
2715 a769b60b 2021-06-27 stsp echo "U beta" > $testroot/stdout.expected
2716 4f3c844b 2021-09-14 stsp echo "Updated to refs/heads/master: $commit_id1" \
2717 4f3c844b 2021-09-14 stsp >> $testroot/stdout.expected
2718 2c41dce7 2021-06-27 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2719 fc414659 2022-04-16 thomas ret=$?
2720 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2721 2c41dce7 2021-06-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
2722 2c41dce7 2021-06-27 stsp test_done "$testroot" "$ret"
2723 2c41dce7 2021-06-27 stsp return 1
2724 2c41dce7 2021-06-27 stsp fi
2725 2c41dce7 2021-06-27 stsp
2726 2c41dce7 2021-06-27 stsp blob_id=`(cd $testroot/wt && got info beta | grep 'blob:' | \
2727 2c41dce7 2021-06-27 stsp cut -d ':' -f 2 | tr -d ' ')`
2728 2c41dce7 2021-06-27 stsp if [ "$blob_id" != "$blob_id1" ]; then
2729 2c41dce7 2021-06-27 stsp echo "file beta has the wrong base blob ID" >&2
2730 2c41dce7 2021-06-27 stsp test_done "$testroot" "1"
2731 2c41dce7 2021-06-27 stsp return 1
2732 2c41dce7 2021-06-27 stsp fi
2733 2c41dce7 2021-06-27 stsp
2734 2c41dce7 2021-06-27 stsp commit_id=`(cd $testroot/wt && got info beta | \
2735 2c41dce7 2021-06-27 stsp grep 'based on commit:' | cut -d ':' -f 2 | tr -d ' ')`
2736 2c41dce7 2021-06-27 stsp if [ "$commit_id" != "$commit_id1" ]; then
2737 2c41dce7 2021-06-27 stsp echo "file beta has the wrong base commit ID: $commit_id" >&2
2738 2c41dce7 2021-06-27 stsp test_done "$testroot" "1"
2739 2c41dce7 2021-06-27 stsp return 1
2740 2c41dce7 2021-06-27 stsp fi
2741 2c41dce7 2021-06-27 stsp
2742 2c41dce7 2021-06-27 stsp echo "changed beta" > $testroot/content.expected
2743 2c41dce7 2021-06-27 stsp cat $testroot/wt/beta > $testroot/content
2744 2c41dce7 2021-06-27 stsp cmp -s $testroot/content.expected $testroot/content
2745 fc414659 2022-04-16 thomas ret=$?
2746 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2747 2c41dce7 2021-06-27 stsp diff -u $testroot/content.expected $testroot/content
2748 2c41dce7 2021-06-27 stsp fi
2749 2c41dce7 2021-06-27 stsp test_done "$testroot" "$ret"
2750 2c41dce7 2021-06-27 stsp }
2751 2c41dce7 2021-06-27 stsp
2752 2c41dce7 2021-06-27 stsp test_update_file_skipped_due_to_obstruction() {
2753 2c41dce7 2021-06-27 stsp local testroot=`test_init update_file_skipped_due_to_obstruction`
2754 2c41dce7 2021-06-27 stsp local commit_id0=`git_show_head $testroot/repo`
2755 2c41dce7 2021-06-27 stsp blob_id0=`get_blob_id $testroot/repo "" beta`
2756 2c41dce7 2021-06-27 stsp
2757 2c41dce7 2021-06-27 stsp echo "changed beta" > $testroot/repo/beta
2758 e6f4ba31 2021-09-24 thomas echo "new file" > $testroot/repo/new
2759 e6f4ba31 2021-09-24 thomas (cd $testroot/repo && git add new)
2760 2c41dce7 2021-06-27 stsp git_commit $testroot/repo -m "changed beta"
2761 2c41dce7 2021-06-27 stsp local commit_id1=`git_show_head $testroot/repo`
2762 2c41dce7 2021-06-27 stsp blob_id1=`get_blob_id $testroot/repo "" beta`
2763 2c41dce7 2021-06-27 stsp
2764 2c41dce7 2021-06-27 stsp got checkout -c $commit_id0 $testroot/repo $testroot/wt > /dev/null
2765 fc414659 2022-04-16 thomas ret=$?
2766 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2767 2c41dce7 2021-06-27 stsp test_done "$testroot" "$ret"
2768 2c41dce7 2021-06-27 stsp return 1
2769 2c41dce7 2021-06-27 stsp fi
2770 2c41dce7 2021-06-27 stsp
2771 2c41dce7 2021-06-27 stsp blob_id=`(cd $testroot/wt && got info beta | grep 'blob:' | \
2772 2c41dce7 2021-06-27 stsp cut -d ':' -f 2 | tr -d ' ')`
2773 2c41dce7 2021-06-27 stsp if [ "$blob_id" != "$blob_id0" ]; then
2774 2c41dce7 2021-06-27 stsp echo "file beta has the wrong base blob ID" >&2
2775 2c41dce7 2021-06-27 stsp test_done "$testroot" "1"
2776 2c41dce7 2021-06-27 stsp return 1
2777 2c41dce7 2021-06-27 stsp fi
2778 2c41dce7 2021-06-27 stsp
2779 2c41dce7 2021-06-27 stsp commit_id=`(cd $testroot/wt && got info beta | \
2780 2c41dce7 2021-06-27 stsp grep 'based on commit:' | cut -d ':' -f 2 | tr -d ' ')`
2781 2c41dce7 2021-06-27 stsp if [ "$commit_id" != "$commit_id0" ]; then
2782 2c41dce7 2021-06-27 stsp echo "file beta has the wrong base commit ID" >&2
2783 2c41dce7 2021-06-27 stsp test_done "$testroot" "1"
2784 2c41dce7 2021-06-27 stsp return 1
2785 2c41dce7 2021-06-27 stsp fi
2786 2c41dce7 2021-06-27 stsp
2787 2c41dce7 2021-06-27 stsp rm $testroot/wt/beta
2788 2c41dce7 2021-06-27 stsp mkdir -p $testroot/wt/beta/psi
2789 e6f4ba31 2021-09-24 thomas mkdir -p $testroot/wt/new
2790 2c41dce7 2021-06-27 stsp
2791 e6f4ba31 2021-09-24 thomas # update to the latest commit; this skips beta and the new file
2792 2c41dce7 2021-06-27 stsp (cd $testroot/wt && got update > $testroot/stdout)
2793 fc414659 2022-04-16 thomas ret=$?
2794 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2795 e6f4ba31 2021-09-24 thomas echo "update failed unexpectedly" >&2
2796 e6f4ba31 2021-09-24 thomas test_done "$testroot" "1"
2797 e6f4ba31 2021-09-24 thomas return 1
2798 e6f4ba31 2021-09-24 thomas fi
2799 2c41dce7 2021-06-27 stsp
2800 2c41dce7 2021-06-27 stsp echo "~ beta" > $testroot/stdout.expected
2801 e6f4ba31 2021-09-24 thomas echo "~ new" >> $testroot/stdout.expected
2802 4f3c844b 2021-09-14 stsp echo "Updated to refs/heads/master: $commit_id1" \
2803 4f3c844b 2021-09-14 stsp >> $testroot/stdout.expected
2804 e6f4ba31 2021-09-24 thomas echo "File paths obstructed by a non-regular file: 2" \
2805 4f3c844b 2021-09-14 stsp >> $testroot/stdout.expected
2806 a769b60b 2021-06-27 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2807 fc414659 2022-04-16 thomas ret=$?
2808 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2809 a769b60b 2021-06-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
2810 a769b60b 2021-06-27 stsp test_done "$testroot" "$ret"
2811 a769b60b 2021-06-27 stsp return 1
2812 a769b60b 2021-06-27 stsp fi
2813 a769b60b 2021-06-27 stsp
2814 a769b60b 2021-06-27 stsp blob_id=`(cd $testroot/wt && got info beta | grep 'blob:' | \
2815 a769b60b 2021-06-27 stsp cut -d ':' -f 2 | tr -d ' ')`
2816 2c41dce7 2021-06-27 stsp if [ "$blob_id" != "$blob_id0" ]; then
2817 2c41dce7 2021-06-27 stsp echo "file beta has the wrong base blob ID" >&2
2818 2c41dce7 2021-06-27 stsp test_done "$testroot" "1"
2819 2c41dce7 2021-06-27 stsp return 1
2820 2c41dce7 2021-06-27 stsp fi
2821 2c41dce7 2021-06-27 stsp
2822 2c41dce7 2021-06-27 stsp commit_id=`(cd $testroot/wt && got info beta | \
2823 2c41dce7 2021-06-27 stsp grep 'based on commit:' | cut -d ':' -f 2 | tr -d ' ')`
2824 2c41dce7 2021-06-27 stsp if [ "$commit_id" != "$commit_id0" ]; then
2825 2c41dce7 2021-06-27 stsp echo "file beta has the wrong base commit ID" >&2
2826 2c41dce7 2021-06-27 stsp test_done "$testroot" "1"
2827 2c41dce7 2021-06-27 stsp return 1
2828 2c41dce7 2021-06-27 stsp fi
2829 2c41dce7 2021-06-27 stsp
2830 2c41dce7 2021-06-27 stsp # remove the directory which obstructs file beta
2831 2c41dce7 2021-06-27 stsp rm -r $testroot/wt/beta
2832 2c41dce7 2021-06-27 stsp
2833 2c41dce7 2021-06-27 stsp # updating to the latest commit should now update beta
2834 2c41dce7 2021-06-27 stsp (cd $testroot/wt && got update > $testroot/stdout)
2835 2c41dce7 2021-06-27 stsp echo "! beta" > $testroot/stdout.expected
2836 e6f4ba31 2021-09-24 thomas echo "~ new" >> $testroot/stdout.expected
2837 4f3c844b 2021-09-14 stsp echo "Updated to refs/heads/master: $commit_id1" \
2838 4f3c844b 2021-09-14 stsp >> $testroot/stdout.expected
2839 e6f4ba31 2021-09-24 thomas echo "File paths obstructed by a non-regular file: 1" \
2840 e6f4ba31 2021-09-24 thomas >> $testroot/stdout.expected
2841 2c41dce7 2021-06-27 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2842 fc414659 2022-04-16 thomas ret=$?
2843 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2844 2c41dce7 2021-06-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
2845 2c41dce7 2021-06-27 stsp test_done "$testroot" "$ret"
2846 2c41dce7 2021-06-27 stsp return 1
2847 2c41dce7 2021-06-27 stsp fi
2848 2c41dce7 2021-06-27 stsp
2849 2c41dce7 2021-06-27 stsp blob_id=`(cd $testroot/wt && got info beta | grep 'blob:' | \
2850 2c41dce7 2021-06-27 stsp cut -d ':' -f 2 | tr -d ' ')`
2851 a769b60b 2021-06-27 stsp if [ "$blob_id" != "$blob_id1" ]; then
2852 a769b60b 2021-06-27 stsp echo "file beta has the wrong base blob ID" >&2
2853 a769b60b 2021-06-27 stsp test_done "$testroot" "1"
2854 a769b60b 2021-06-27 stsp return 1
2855 a769b60b 2021-06-27 stsp fi
2856 a769b60b 2021-06-27 stsp
2857 a769b60b 2021-06-27 stsp commit_id=`(cd $testroot/wt && got info beta | \
2858 a769b60b 2021-06-27 stsp grep 'based on commit:' | cut -d ':' -f 2 | tr -d ' ')`
2859 a769b60b 2021-06-27 stsp if [ "$commit_id" != "$commit_id1" ]; then
2860 a769b60b 2021-06-27 stsp echo "file beta has the wrong base commit ID: $commit_id" >&2
2861 a769b60b 2021-06-27 stsp test_done "$testroot" "1"
2862 a769b60b 2021-06-27 stsp return 1
2863 a769b60b 2021-06-27 stsp fi
2864 a769b60b 2021-06-27 stsp
2865 a769b60b 2021-06-27 stsp echo "changed beta" > $testroot/content.expected
2866 a769b60b 2021-06-27 stsp cat $testroot/wt/beta > $testroot/content
2867 a769b60b 2021-06-27 stsp cmp -s $testroot/content.expected $testroot/content
2868 fc414659 2022-04-16 thomas ret=$?
2869 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2870 a769b60b 2021-06-27 stsp diff -u $testroot/content.expected $testroot/content
2871 a769b60b 2021-06-27 stsp fi
2872 a769b60b 2021-06-27 stsp test_done "$testroot" "$ret"
2873 194cb7cb 2021-01-19 stsp }
2874 67c65ed7 2021-09-14 tracey
2875 67c65ed7 2021-09-14 tracey test_update_quiet() {
2876 67c65ed7 2021-09-14 tracey local testroot=`test_init update_quiet`
2877 67c65ed7 2021-09-14 tracey
2878 67c65ed7 2021-09-14 tracey got checkout $testroot/repo $testroot/wt > /dev/null
2879 fc414659 2022-04-16 thomas ret=$?
2880 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2881 67c65ed7 2021-09-14 tracey test_done "$testroot" "$ret"
2882 67c65ed7 2021-09-14 tracey return 1
2883 67c65ed7 2021-09-14 tracey fi
2884 67c65ed7 2021-09-14 tracey
2885 67c65ed7 2021-09-14 tracey echo "modified alpha" > $testroot/repo/alpha
2886 67c65ed7 2021-09-14 tracey git_commit $testroot/repo -m "modified alpha"
2887 67c65ed7 2021-09-14 tracey
2888 4f3c844b 2021-09-14 stsp echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
2889 67c65ed7 2021-09-14 tracey git_show_head $testroot/repo >> $testroot/stdout.expected
2890 67c65ed7 2021-09-14 tracey echo >> $testroot/stdout.expected
2891 67c65ed7 2021-09-14 tracey
2892 67c65ed7 2021-09-14 tracey (cd $testroot/wt && got update -q > $testroot/stdout)
2893 67c65ed7 2021-09-14 tracey
2894 67c65ed7 2021-09-14 tracey cmp -s $testroot/stdout.expected $testroot/stdout
2895 fc414659 2022-04-16 thomas ret=$?
2896 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2897 67c65ed7 2021-09-14 tracey diff -u $testroot/stdout.expected $testroot/stdout
2898 67c65ed7 2021-09-14 tracey test_done "$testroot" "$ret"
2899 67c65ed7 2021-09-14 tracey return 1
2900 67c65ed7 2021-09-14 tracey fi
2901 194cb7cb 2021-01-19 stsp
2902 67c65ed7 2021-09-14 tracey echo "modified alpha" > $testroot/content.expected
2903 67c65ed7 2021-09-14 tracey cat $testroot/wt/alpha > $testroot/content
2904 194cb7cb 2021-01-19 stsp
2905 67c65ed7 2021-09-14 tracey cmp -s $testroot/content.expected $testroot/content
2906 fc414659 2022-04-16 thomas ret=$?
2907 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2908 67c65ed7 2021-09-14 tracey diff -u $testroot/content.expected $testroot/content
2909 67c65ed7 2021-09-14 tracey fi
2910 67c65ed7 2021-09-14 tracey test_done "$testroot" "$ret"
2911 24f136e0 2021-11-20 thomas }
2912 24f136e0 2021-11-20 thomas
2913 24f136e0 2021-11-20 thomas test_update_binary_file() {
2914 24f136e0 2021-11-20 thomas local testroot=`test_init update_binary_file`
2915 24f136e0 2021-11-20 thomas local commit_id0=`git_show_head $testroot/repo`
2916 24f136e0 2021-11-20 thomas
2917 24f136e0 2021-11-20 thomas got checkout $testroot/repo $testroot/wt > /dev/null
2918 fc414659 2022-04-16 thomas ret=$?
2919 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2920 24f136e0 2021-11-20 thomas test_done "$testroot" "$ret"
2921 24f136e0 2021-11-20 thomas return 1
2922 24f136e0 2021-11-20 thomas fi
2923 24f136e0 2021-11-20 thomas
2924 24f136e0 2021-11-20 thomas cp /bin/ls $testroot/wt/foo
2925 24f136e0 2021-11-20 thomas chmod 755 $testroot/wt/foo
2926 24f136e0 2021-11-20 thomas (cd $testroot/wt && got add foo >/dev/null)
2927 24f136e0 2021-11-20 thomas (cd $testroot/wt && got commit -m 'add binary file' > /dev/null)
2928 24f136e0 2021-11-20 thomas local commit_id1=`git_show_head $testroot/repo`
2929 24f136e0 2021-11-20 thomas
2930 24f136e0 2021-11-20 thomas cp /bin/cat $testroot/wt/foo
2931 24f136e0 2021-11-20 thomas chmod 755 $testroot/wt/foo
2932 24f136e0 2021-11-20 thomas (cd $testroot/wt && got commit -m 'change binary file' > /dev/null)
2933 24f136e0 2021-11-20 thomas local commit_id2=`git_show_head $testroot/repo`
2934 24f136e0 2021-11-20 thomas
2935 24f136e0 2021-11-20 thomas cp /bin/cp $testroot/wt/foo
2936 24f136e0 2021-11-20 thomas chmod 755 $testroot/wt/foo
2937 24f136e0 2021-11-20 thomas (cd $testroot/wt && got commit -m 'change binary file' > /dev/null)
2938 24f136e0 2021-11-20 thomas local commit_id3=`git_show_head $testroot/repo`
2939 24f136e0 2021-11-20 thomas
2940 24f136e0 2021-11-20 thomas (cd $testroot/wt && got rm foo >/dev/null)
2941 24f136e0 2021-11-20 thomas (cd $testroot/wt && got commit -m 'remove binary file' > /dev/null)
2942 24f136e0 2021-11-20 thomas local commit_id4=`git_show_head $testroot/repo`
2943 24f136e0 2021-11-20 thomas
2944 24f136e0 2021-11-20 thomas # backdate the work tree to make it usable for updating
2945 24f136e0 2021-11-20 thomas (cd $testroot/wt && got up -c $commit_id0 > /dev/null)
2946 24f136e0 2021-11-20 thomas
2947 24f136e0 2021-11-20 thomas # update which adds a binary file
2948 24f136e0 2021-11-20 thomas (cd $testroot/wt && got up -c $commit_id1 > $testroot/stdout)
2949 24f136e0 2021-11-20 thomas
2950 24f136e0 2021-11-20 thomas echo "A foo" > $testroot/stdout.expected
2951 24f136e0 2021-11-20 thomas echo -n "Updated to refs/heads/master: $commit_id1" \
2952 24f136e0 2021-11-20 thomas >> $testroot/stdout.expected
2953 24f136e0 2021-11-20 thomas echo >> $testroot/stdout.expected
2954 24f136e0 2021-11-20 thomas cmp -s $testroot/stdout.expected $testroot/stdout
2955 fc414659 2022-04-16 thomas ret=$?
2956 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2957 24f136e0 2021-11-20 thomas diff -u $testroot/stdout.expected $testroot/stdout
2958 24f136e0 2021-11-20 thomas test_done "$testroot" "$ret"
2959 24f136e0 2021-11-20 thomas return 1
2960 24f136e0 2021-11-20 thomas fi
2961 24f136e0 2021-11-20 thomas
2962 24f136e0 2021-11-20 thomas cp /bin/ls $testroot/content.expected
2963 24f136e0 2021-11-20 thomas chmod 755 $testroot/content.expected
2964 24f136e0 2021-11-20 thomas cat $testroot/wt/foo > $testroot/content
2965 24f136e0 2021-11-20 thomas
2966 24f136e0 2021-11-20 thomas cmp -s $testroot/content.expected $testroot/content
2967 fc414659 2022-04-16 thomas ret=$?
2968 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2969 24f136e0 2021-11-20 thomas diff -u $testroot/content.expected $testroot/content
2970 24f136e0 2021-11-20 thomas test_done "$testroot" "$ret"
2971 24f136e0 2021-11-20 thomas return 1
2972 24f136e0 2021-11-20 thomas fi
2973 24f136e0 2021-11-20 thomas
2974 24f136e0 2021-11-20 thomas # update which adds a conflicting binary file
2975 24f136e0 2021-11-20 thomas (cd $testroot/wt && got up -c $commit_id0 > /dev/null)
2976 24f136e0 2021-11-20 thomas cp /bin/cat $testroot/wt/foo
2977 24f136e0 2021-11-20 thomas chmod 755 $testroot/wt/foo
2978 24f136e0 2021-11-20 thomas (cd $testroot/wt && got add foo > /dev/null)
2979 24f136e0 2021-11-20 thomas (cd $testroot/wt && got up -c $commit_id1 > $testroot/stdout)
2980 24f136e0 2021-11-20 thomas
2981 24f136e0 2021-11-20 thomas echo "C foo" > $testroot/stdout.expected
2982 24f136e0 2021-11-20 thomas echo "Updated to refs/heads/master: $commit_id1" \
2983 24f136e0 2021-11-20 thomas >> $testroot/stdout.expected
2984 24f136e0 2021-11-20 thomas echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
2985 24f136e0 2021-11-20 thomas cmp -s $testroot/stdout.expected $testroot/stdout
2986 fc414659 2022-04-16 thomas ret=$?
2987 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
2988 24f136e0 2021-11-20 thomas diff -u $testroot/stdout.expected $testroot/stdout
2989 24f136e0 2021-11-20 thomas test_done "$testroot" "$ret"
2990 24f136e0 2021-11-20 thomas return 1
2991 24f136e0 2021-11-20 thomas fi
2992 24f136e0 2021-11-20 thomas
2993 24f136e0 2021-11-20 thomas echo "Binary files differ and cannot be merged automatically:" \
2994 24f136e0 2021-11-20 thomas > $testroot/content.expected
2995 24f136e0 2021-11-20 thomas echo "<<<<<<< merged change: commit $commit_id1" \
2996 24f136e0 2021-11-20 thomas >> $testroot/content.expected
2997 24f136e0 2021-11-20 thomas echo -n "file " >> $testroot/content.expected
2998 24f136e0 2021-11-20 thomas ls $testroot/wt/foo-1-* >> $testroot/content.expected
2999 24f136e0 2021-11-20 thomas echo '=======' >> $testroot/content.expected
3000 24f136e0 2021-11-20 thomas echo -n "file " >> $testroot/content.expected
3001 24f136e0 2021-11-20 thomas ls $testroot/wt/foo-2-* >> $testroot/content.expected
3002 24f136e0 2021-11-20 thomas echo ">>>>>>>" >> $testroot/content.expected
3003 24f136e0 2021-11-20 thomas cat $testroot/wt/foo > $testroot/content
3004 24f136e0 2021-11-20 thomas
3005 24f136e0 2021-11-20 thomas cmp -s $testroot/content.expected $testroot/content
3006 fc414659 2022-04-16 thomas ret=$?
3007 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
3008 24f136e0 2021-11-20 thomas diff -u $testroot/content.expected $testroot/content
3009 24f136e0 2021-11-20 thomas test_done "$testroot" "$ret"
3010 24f136e0 2021-11-20 thomas return 1
3011 24f136e0 2021-11-20 thomas fi
3012 24f136e0 2021-11-20 thomas
3013 24f136e0 2021-11-20 thomas cp /bin/ls $testroot/content.expected
3014 24f136e0 2021-11-20 thomas chmod 755 $testroot/content.expected
3015 24f136e0 2021-11-20 thomas cat $testroot/wt/foo-1-* > $testroot/content
3016 24f136e0 2021-11-20 thomas
3017 24f136e0 2021-11-20 thomas cmp -s $testroot/content.expected $testroot/content
3018 fc414659 2022-04-16 thomas ret=$?
3019 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
3020 24f136e0 2021-11-20 thomas diff -u $testroot/content.expected $testroot/content
3021 24f136e0 2021-11-20 thomas test_done "$testroot" "$ret"
3022 24f136e0 2021-11-20 thomas return 1
3023 24f136e0 2021-11-20 thomas fi
3024 24f136e0 2021-11-20 thomas
3025 24f136e0 2021-11-20 thomas cp /bin/cat $testroot/content.expected
3026 24f136e0 2021-11-20 thomas chmod 755 $testroot/content.expected
3027 24f136e0 2021-11-20 thomas cat $testroot/wt/foo-2-* > $testroot/content
3028 24f136e0 2021-11-20 thomas
3029 24f136e0 2021-11-20 thomas cmp -s $testroot/content.expected $testroot/content
3030 fc414659 2022-04-16 thomas ret=$?
3031 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
3032 24f136e0 2021-11-20 thomas diff -u $testroot/content.expected $testroot/content
3033 24f136e0 2021-11-20 thomas test_done "$testroot" "$ret"
3034 24f136e0 2021-11-20 thomas return 1
3035 24f136e0 2021-11-20 thomas fi
3036 24f136e0 2021-11-20 thomas
3037 24f136e0 2021-11-20 thomas # tidy up
3038 24f136e0 2021-11-20 thomas (cd $testroot/wt && got revert -R . >/dev/null)
3039 24f136e0 2021-11-20 thomas rm $testroot/wt/foo-1-* $testroot/wt/foo-2-*
3040 24f136e0 2021-11-20 thomas (cd $testroot/wt && got up -c $commit_id1 > /dev/null)
3041 24f136e0 2021-11-20 thomas
3042 24f136e0 2021-11-20 thomas # update which changes a binary file
3043 24f136e0 2021-11-20 thomas (cd $testroot/wt && got up -c $commit_id2 > $testroot/stdout)
3044 24f136e0 2021-11-20 thomas
3045 24f136e0 2021-11-20 thomas echo "U foo" > $testroot/stdout.expected
3046 24f136e0 2021-11-20 thomas echo -n "Updated to refs/heads/master: $commit_id2" \
3047 24f136e0 2021-11-20 thomas >> $testroot/stdout.expected
3048 24f136e0 2021-11-20 thomas echo >> $testroot/stdout.expected
3049 24f136e0 2021-11-20 thomas cmp -s $testroot/stdout.expected $testroot/stdout
3050 fc414659 2022-04-16 thomas ret=$?
3051 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
3052 24f136e0 2021-11-20 thomas diff -u $testroot/stdout.expected $testroot/stdout
3053 24f136e0 2021-11-20 thomas test_done "$testroot" "$ret"
3054 24f136e0 2021-11-20 thomas return 1
3055 24f136e0 2021-11-20 thomas fi
3056 24f136e0 2021-11-20 thomas
3057 24f136e0 2021-11-20 thomas cp /bin/cat $testroot/content.expected
3058 24f136e0 2021-11-20 thomas chmod 755 $testroot/content.expected
3059 24f136e0 2021-11-20 thomas cat $testroot/wt/foo > $testroot/content
3060 24f136e0 2021-11-20 thomas
3061 24f136e0 2021-11-20 thomas cmp -s $testroot/content.expected $testroot/content
3062 fc414659 2022-04-16 thomas ret=$?
3063 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
3064 24f136e0 2021-11-20 thomas diff -u $testroot/content.expected $testroot/content
3065 24f136e0 2021-11-20 thomas test_done "$testroot" "$ret"
3066 24f136e0 2021-11-20 thomas return 1
3067 24f136e0 2021-11-20 thomas fi
3068 24f136e0 2021-11-20 thomas
3069 24f136e0 2021-11-20 thomas # update which changes a locally modified binary file
3070 24f136e0 2021-11-20 thomas cp /bin/ls $testroot/wt/foo
3071 24f136e0 2021-11-20 thomas chmod 755 $testroot/wt/foo
3072 24f136e0 2021-11-20 thomas (cd $testroot/wt && got up -c $commit_id3 > $testroot/stdout)
3073 24f136e0 2021-11-20 thomas
3074 24f136e0 2021-11-20 thomas echo "C foo" > $testroot/stdout.expected
3075 24f136e0 2021-11-20 thomas echo -n "Updated to refs/heads/master: $commit_id3" \
3076 24f136e0 2021-11-20 thomas >> $testroot/stdout.expected
3077 24f136e0 2021-11-20 thomas echo >> $testroot/stdout.expected
3078 24f136e0 2021-11-20 thomas echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
3079 24f136e0 2021-11-20 thomas cmp -s $testroot/stdout.expected $testroot/stdout
3080 fc414659 2022-04-16 thomas ret=$?
3081 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
3082 24f136e0 2021-11-20 thomas diff -u $testroot/stdout.expected $testroot/stdout
3083 24f136e0 2021-11-20 thomas test_done "$testroot" "$ret"
3084 24f136e0 2021-11-20 thomas return 1
3085 24f136e0 2021-11-20 thomas fi
3086 24f136e0 2021-11-20 thomas
3087 24f136e0 2021-11-20 thomas echo "Binary files differ and cannot be merged automatically:" \
3088 24f136e0 2021-11-20 thomas > $testroot/content.expected
3089 24f136e0 2021-11-20 thomas echo "<<<<<<< merged change: commit $commit_id3" \
3090 24f136e0 2021-11-20 thomas >> $testroot/content.expected
3091 24f136e0 2021-11-20 thomas echo -n "file " >> $testroot/content.expected
3092 24f136e0 2021-11-20 thomas ls $testroot/wt/foo-1-* >> $testroot/content.expected
3093 24f136e0 2021-11-20 thomas echo "||||||| 3-way merge base: commit $commit_id2" \
3094 24f136e0 2021-11-20 thomas >> $testroot/content.expected
3095 24f136e0 2021-11-20 thomas echo -n "file " >> $testroot/content.expected
3096 24f136e0 2021-11-20 thomas ls $testroot/wt/foo-orig-* >> $testroot/content.expected
3097 24f136e0 2021-11-20 thomas echo '=======' >> $testroot/content.expected
3098 24f136e0 2021-11-20 thomas echo -n "file " >> $testroot/content.expected
3099 24f136e0 2021-11-20 thomas ls $testroot/wt/foo-2-* >> $testroot/content.expected
3100 24f136e0 2021-11-20 thomas echo ">>>>>>>" >> $testroot/content.expected
3101 24f136e0 2021-11-20 thomas cat $testroot/wt/foo > $testroot/content
3102 24f136e0 2021-11-20 thomas
3103 24f136e0 2021-11-20 thomas cmp -s $testroot/content.expected $testroot/content
3104 fc414659 2022-04-16 thomas ret=$?
3105 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
3106 24f136e0 2021-11-20 thomas diff -u $testroot/content.expected $testroot/content
3107 24f136e0 2021-11-20 thomas test_done "$testroot" "$ret"
3108 24f136e0 2021-11-20 thomas return 1
3109 24f136e0 2021-11-20 thomas fi
3110 24f136e0 2021-11-20 thomas
3111 24f136e0 2021-11-20 thomas cp /bin/cp $testroot/content.expected
3112 24f136e0 2021-11-20 thomas chmod 755 $testroot/content.expected
3113 24f136e0 2021-11-20 thomas cp $testroot/wt/foo-1-* $testroot/content
3114 24f136e0 2021-11-20 thomas cmp -s $testroot/content.expected $testroot/content
3115 fc414659 2022-04-16 thomas ret=$?
3116 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
3117 24f136e0 2021-11-20 thomas diff -u $testroot/content.expected $testroot/content
3118 24f136e0 2021-11-20 thomas test_done "$testroot" "$ret"
3119 24f136e0 2021-11-20 thomas return 1
3120 24f136e0 2021-11-20 thomas fi
3121 24f136e0 2021-11-20 thomas
3122 24f136e0 2021-11-20 thomas cp /bin/ls $testroot/content.expected
3123 24f136e0 2021-11-20 thomas chmod 755 $testroot/content.expected
3124 24f136e0 2021-11-20 thomas cp $testroot/wt/foo-2-* $testroot/content
3125 24f136e0 2021-11-20 thomas cmp -s $testroot/content.expected $testroot/content
3126 fc414659 2022-04-16 thomas ret=$?
3127 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
3128 24f136e0 2021-11-20 thomas diff -u $testroot/content.expected $testroot/content
3129 24f136e0 2021-11-20 thomas test_done "$testroot" "$ret"
3130 24f136e0 2021-11-20 thomas return 1
3131 24f136e0 2021-11-20 thomas fi
3132 24f136e0 2021-11-20 thomas
3133 24f136e0 2021-11-20 thomas (cd $testroot/wt && got status > $testroot/stdout)
3134 8de9d8ad 2023-02-20 thomas echo 'C foo' > $testroot/stdout.expected
3135 24f136e0 2021-11-20 thomas echo -n '? ' >> $testroot/stdout.expected
3136 24f136e0 2021-11-20 thomas (cd $testroot/wt && ls foo-1-* >> $testroot/stdout.expected)
3137 24f136e0 2021-11-20 thomas echo -n '? ' >> $testroot/stdout.expected
3138 24f136e0 2021-11-20 thomas (cd $testroot/wt && ls foo-2-* >> $testroot/stdout.expected)
3139 24f136e0 2021-11-20 thomas echo -n '? ' >> $testroot/stdout.expected
3140 24f136e0 2021-11-20 thomas (cd $testroot/wt && ls foo-orig-* >> $testroot/stdout.expected)
3141 24f136e0 2021-11-20 thomas cmp -s $testroot/stdout.expected $testroot/stdout
3142 fc414659 2022-04-16 thomas ret=$?
3143 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
3144 24f136e0 2021-11-20 thomas diff -u $testroot/stdout.expected $testroot/stdout
3145 24f136e0 2021-11-20 thomas test_done "$testroot" "$ret"
3146 24f136e0 2021-11-20 thomas return 1
3147 24f136e0 2021-11-20 thomas fi
3148 24f136e0 2021-11-20 thomas
3149 24f136e0 2021-11-20 thomas # tidy up
3150 24f136e0 2021-11-20 thomas (cd $testroot/wt && got revert -R . > /dev/null)
3151 24f136e0 2021-11-20 thomas rm $testroot/wt/foo-orig-* $testroot/wt/foo-1-* $testroot/wt/foo-2-*
3152 24f136e0 2021-11-20 thomas
3153 24f136e0 2021-11-20 thomas # update which deletes a binary file
3154 24f136e0 2021-11-20 thomas (cd $testroot/wt && got up -c $commit_id4 > $testroot/stdout)
3155 24f136e0 2021-11-20 thomas echo "D foo" > $testroot/stdout.expected
3156 24f136e0 2021-11-20 thomas echo -n "Updated to refs/heads/master: $commit_id4" \
3157 24f136e0 2021-11-20 thomas >> $testroot/stdout.expected
3158 24f136e0 2021-11-20 thomas echo >> $testroot/stdout.expected
3159 24f136e0 2021-11-20 thomas cmp -s $testroot/stdout.expected $testroot/stdout
3160 fc414659 2022-04-16 thomas ret=$?
3161 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
3162 24f136e0 2021-11-20 thomas diff -u $testroot/stdout.expected $testroot/stdout
3163 24f136e0 2021-11-20 thomas test_done "$testroot" "$ret"
3164 24f136e0 2021-11-20 thomas fi
3165 24f136e0 2021-11-20 thomas
3166 24f136e0 2021-11-20 thomas if [ -e $testroot/wt/foo ]; then
3167 24f136e0 2021-11-20 thomas echo "removed file foo still exists on disk" >&2
3168 24f136e0 2021-11-20 thomas test_done "$testroot" "1"
3169 24f136e0 2021-11-20 thomas return 1
3170 24f136e0 2021-11-20 thomas fi
3171 24f136e0 2021-11-20 thomas test_done "$testroot" "0"
3172 67c65ed7 2021-09-14 tracey }
3173 a2c162eb 2022-10-30 thomas
3174 a2c162eb 2022-10-30 thomas test_update_umask() {
3175 a2c162eb 2022-10-30 thomas local testroot=`test_init update_binary_file`
3176 a2c162eb 2022-10-30 thomas
3177 a2c162eb 2022-10-30 thomas got checkout "$testroot/repo" "$testroot/wt" >/dev/null
3178 a2c162eb 2022-10-30 thomas ret=$?
3179 a2c162eb 2022-10-30 thomas if [ $ret -ne 0 ]; then
3180 a2c162eb 2022-10-30 thomas test_done "$testroot" "$ret"
3181 a2c162eb 2022-10-30 thomas return 1
3182 a2c162eb 2022-10-30 thomas fi
3183 a2c162eb 2022-10-30 thomas
3184 a2c162eb 2022-10-30 thomas rm "$testroot/wt/alpha"
3185 a2c162eb 2022-10-30 thomas
3186 a2c162eb 2022-10-30 thomas # using a subshell to avoid clobbering global umask
3187 a2c162eb 2022-10-30 thomas (umask 022 && cd "$testroot/wt" && got update alpha) \
3188 a2c162eb 2022-10-30 thomas >/dev/null 2>/dev/null
3189 a2c162eb 2022-10-30 thomas ret=$?
3190 a2c162eb 2022-10-30 thomas if [ $ret -ne 0 ]; then
3191 a2c162eb 2022-10-30 thomas test_done "$testroot" $ret
3192 a2c162eb 2022-10-30 thomas return 1
3193 a2c162eb 2022-10-30 thomas fi
3194 67c65ed7 2021-09-14 tracey
3195 a2c162eb 2022-10-30 thomas if ! ls -l "$testroot/wt/alpha" | grep -q ^-rw-r--r--; then
3196 a2c162eb 2022-10-30 thomas echo "alpha is not 0644" >&2
3197 a2c162eb 2022-10-30 thomas test_done "$testroot" 1
3198 a2c162eb 2022-10-30 thomas return 1
3199 a2c162eb 2022-10-30 thomas fi
3200 a2c162eb 2022-10-30 thomas
3201 a2c162eb 2022-10-30 thomas rm "$testroot/wt/alpha"
3202 a2c162eb 2022-10-30 thomas
3203 a2c162eb 2022-10-30 thomas # using a subshell to avoid clobbering global umask
3204 a2c162eb 2022-10-30 thomas (umask 044 && cd "$testroot/wt" && got update alpha) \
3205 a2c162eb 2022-10-30 thomas >/dev/null 2>/dev/null
3206 a2c162eb 2022-10-30 thomas ret=$?
3207 a2c162eb 2022-10-30 thomas if [ $ret -ne 0 ]; then
3208 a2c162eb 2022-10-30 thomas test_done "$testroot" $ret
3209 a2c162eb 2022-10-30 thomas return 1
3210 a2c162eb 2022-10-30 thomas fi
3211 a2c162eb 2022-10-30 thomas
3212 a2c162eb 2022-10-30 thomas if ! ls -l "$testroot/wt/alpha" | grep -q ^-rw-------; then
3213 a2c162eb 2022-10-30 thomas echo "alpha is not 0600" >&2
3214 a2c162eb 2022-10-30 thomas test_done "$testroot" 1
3215 a2c162eb 2022-10-30 thomas return 1
3216 a2c162eb 2022-10-30 thomas fi
3217 a2c162eb 2022-10-30 thomas
3218 a2c162eb 2022-10-30 thomas rm "$testroot/wt/alpha"
3219 a2c162eb 2022-10-30 thomas
3220 a2c162eb 2022-10-30 thomas # using a subshell to avoid clobbering global umask
3221 a2c162eb 2022-10-30 thomas (umask 222 && cd "$testroot/wt" && got update alpha) \
3222 a2c162eb 2022-10-30 thomas >/dev/null 2>/dev/null
3223 a2c162eb 2022-10-30 thomas ret=$?
3224 a2c162eb 2022-10-30 thomas if [ $ret -ne 0 ]; then
3225 a2c162eb 2022-10-30 thomas test_done "$testroot" $ret
3226 a2c162eb 2022-10-30 thomas return 1
3227 a2c162eb 2022-10-30 thomas fi
3228 a2c162eb 2022-10-30 thomas
3229 a2c162eb 2022-10-30 thomas if ! ls -l "$testroot/wt/alpha" | grep -q ^-r--r--r--; then
3230 a2c162eb 2022-10-30 thomas echo "alpha is not 0444" >&2
3231 a2c162eb 2022-10-30 thomas test_done "$testroot" 1
3232 a2c162eb 2022-10-30 thomas return 1;
3233 a2c162eb 2022-10-30 thomas fi
3234 a2c162eb 2022-10-30 thomas
3235 a2c162eb 2022-10-30 thomas test_done "$testroot" 0
3236 a2c162eb 2022-10-30 thomas }
3237 a2c162eb 2022-10-30 thomas
3238 7fb414ae 2020-08-08 stsp test_parseargs "$@"
3239 c84d8c75 2019-01-02 stsp run_test test_update_basic
3240 3b4d3732 2019-01-02 stsp run_test test_update_adds_file
3241 512f0d0e 2019-01-02 stsp run_test test_update_deletes_file
3242 f5c49f82 2019-01-06 stsp run_test test_update_deletes_dir
3243 5cc266ba 2019-01-06 stsp run_test test_update_deletes_dir_with_path_prefix
3244 90285c3b 2019-01-08 stsp run_test test_update_deletes_dir_recursively
3245 4482e97b 2019-01-08 stsp run_test test_update_sibling_dirs_with_common_prefix
3246 50952927 2019-01-12 stsp run_test test_update_dir_with_dot_sibling
3247 46cee7a3 2019-01-12 stsp run_test test_update_moves_files_upwards
3248 bd4792ec 2019-01-13 stsp run_test test_update_moves_files_to_new_dir
3249 4a1ddfc2 2019-01-12 stsp run_test test_update_creates_missing_parent
3250 bd4792ec 2019-01-13 stsp run_test test_update_creates_missing_parent_with_subdir
3251 21908da4 2019-01-13 stsp run_test test_update_file_in_subsubdir
3252 7b074ee1 2023-03-01 thomas run_test test_update_changes_file_to_dir
3253 8ed5d26b 2023-03-10 thomas run_test test_update_changes_dir_to_file
3254 9f323212 2023-03-10 thomas run_test test_update_changes_modified_file_to_dir
3255 6353ad76 2019-02-08 stsp run_test test_update_merges_file_edits
3256 68ed9ba5 2019-02-10 stsp run_test test_update_keeps_xbit
3257 ba8a0d4d 2019-02-10 stsp run_test test_update_clears_xbit
3258 a378724f 2019-02-10 stsp run_test test_update_restores_missing_file
3259 085d5bcf 2019-03-27 stsp run_test test_update_conflict_wt_add_vs_repo_add
3260 085d5bcf 2019-03-27 stsp run_test test_update_conflict_wt_edit_vs_repo_rm
3261 13d9040b 2019-03-27 stsp run_test test_update_conflict_wt_rm_vs_repo_edit
3262 66b11bf5 2019-03-27 stsp run_test test_update_conflict_wt_rm_vs_repo_rm
3263 c4cdcb68 2019-04-03 stsp run_test test_update_partial
3264 c4cdcb68 2019-04-03 stsp run_test test_update_partial_add
3265 c4cdcb68 2019-04-03 stsp run_test test_update_partial_rm
3266 c4cdcb68 2019-04-03 stsp run_test test_update_partial_dir
3267 d5bea539 2019-05-13 stsp run_test test_update_moved_branch_ref
3268 024e9686 2019-05-14 stsp run_test test_update_to_another_branch
3269 a367ff0f 2019-05-14 stsp run_test test_update_to_commit_on_wrong_branch
3270 c932eeeb 2019-05-22 stsp run_test test_update_bumps_base_commit_id
3271 303e2782 2019-08-09 stsp run_test test_update_tag
3272 523b8417 2019-10-19 stsp run_test test_update_toggles_xbit
3273 5036ab18 2020-04-18 stsp run_test test_update_preserves_conflicted_file
3274 e7303626 2020-05-14 stsp run_test test_update_modified_submodules
3275 e7303626 2020-05-14 stsp run_test test_update_adds_submodule
3276 e7303626 2020-05-14 stsp run_test test_update_conflict_wt_file_vs_repo_submodule
3277 f35fa46a 2020-07-23 stsp run_test test_update_adds_symlink
3278 993e2a1b 2020-07-23 stsp run_test test_update_deletes_symlink
3279 993e2a1b 2020-07-23 stsp run_test test_update_symlink_conflicts
3280 194cb7cb 2021-01-19 stsp run_test test_update_single_file
3281 a769b60b 2021-06-27 stsp run_test test_update_file_skipped_due_to_conflict
3282 2c41dce7 2021-06-27 stsp run_test test_update_file_skipped_due_to_obstruction
3283 67c65ed7 2021-09-14 tracey run_test test_update_quiet
3284 24f136e0 2021-11-20 thomas run_test test_update_binary_file
3285 a2c162eb 2022-10-30 thomas run_test test_update_umask