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 e60e7f5b 2019-02-10 stsp ret="$?"
24 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
25 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
26 c84d8c75 2019-01-02 stsp return 1
27 c84d8c75 2019-01-02 stsp fi
28 c84d8c75 2019-01-02 stsp
29 c84d8c75 2019-01-02 stsp echo "modified alpha" > $testroot/repo/alpha
30 c84d8c75 2019-01-02 stsp git_commit $testroot/repo -m "modified alpha"
31 c84d8c75 2019-01-02 stsp
32 c84d8c75 2019-01-02 stsp echo "U alpha" > $testroot/stdout.expected
33 9c4b8182 2019-01-02 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
34 9c4b8182 2019-01-02 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
35 9c4b8182 2019-01-02 stsp echo >> $testroot/stdout.expected
36 c84d8c75 2019-01-02 stsp
37 c84d8c75 2019-01-02 stsp (cd $testroot/wt && got update > $testroot/stdout)
38 c84d8c75 2019-01-02 stsp
39 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
40 e60e7f5b 2019-02-10 stsp ret="$?"
41 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
42 c84d8c75 2019-01-02 stsp diff -u $testroot/stdout.expected $testroot/stdout
43 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
44 c84d8c75 2019-01-02 stsp return 1
45 c84d8c75 2019-01-02 stsp fi
46 c84d8c75 2019-01-02 stsp
47 c84d8c75 2019-01-02 stsp echo "modified alpha" > $testroot/content.expected
48 52a3df9b 2019-01-06 stsp cat $testroot/wt/alpha > $testroot/content
49 c84d8c75 2019-01-02 stsp
50 8d301dd9 2019-05-14 stsp cmp -s $testroot/content.expected $testroot/content
51 693719bc 2019-01-03 stsp ret="$?"
52 693719bc 2019-01-03 stsp if [ "$ret" != "0" ]; then
53 c84d8c75 2019-01-02 stsp diff -u $testroot/content.expected $testroot/content
54 c84d8c75 2019-01-02 stsp fi
55 693719bc 2019-01-03 stsp test_done "$testroot" "$ret"
56 c84d8c75 2019-01-02 stsp }
57 c84d8c75 2019-01-02 stsp
58 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 e60e7f5b 2019-02-10 stsp ret="$?"
63 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
64 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
65 3b4d3732 2019-01-02 stsp return 1
66 3b4d3732 2019-01-02 stsp fi
67 3b4d3732 2019-01-02 stsp
68 3b4d3732 2019-01-02 stsp echo "new" > $testroot/repo/gamma/new
69 3b4d3732 2019-01-02 stsp (cd $testroot/repo && git add .)
70 3b4d3732 2019-01-02 stsp git_commit $testroot/repo -m "adding a new file"
71 3b4d3732 2019-01-02 stsp
72 3b4d3732 2019-01-02 stsp echo "A gamma/new" > $testroot/stdout.expected
73 3b4d3732 2019-01-02 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
74 3b4d3732 2019-01-02 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
75 3b4d3732 2019-01-02 stsp echo >> $testroot/stdout.expected
76 3b4d3732 2019-01-02 stsp
77 3b4d3732 2019-01-02 stsp (cd $testroot/wt && got update > $testroot/stdout)
78 3b4d3732 2019-01-02 stsp
79 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
80 e60e7f5b 2019-02-10 stsp ret="$?"
81 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
82 3b4d3732 2019-01-02 stsp diff -u $testroot/stdout.expected $testroot/stdout
83 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
84 3b4d3732 2019-01-02 stsp return 1
85 3b4d3732 2019-01-02 stsp fi
86 3b4d3732 2019-01-02 stsp
87 3b4d3732 2019-01-02 stsp echo "new" >> $testroot/content.expected
88 52a3df9b 2019-01-06 stsp cat $testroot/wt/gamma/new > $testroot/content
89 3b4d3732 2019-01-02 stsp
90 8d301dd9 2019-05-14 stsp cmp -s $testroot/content.expected $testroot/content
91 693719bc 2019-01-03 stsp ret="$?"
92 693719bc 2019-01-03 stsp if [ "$ret" != "0" ]; then
93 3b4d3732 2019-01-02 stsp diff -u $testroot/content.expected $testroot/content
94 3b4d3732 2019-01-02 stsp fi
95 693719bc 2019-01-03 stsp test_done "$testroot" "$ret"
96 3b4d3732 2019-01-02 stsp }
97 3b4d3732 2019-01-02 stsp
98 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 e60e7f5b 2019-02-10 stsp ret="$?"
104 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
105 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
106 512f0d0e 2019-01-02 stsp return 1
107 512f0d0e 2019-01-02 stsp fi
108 512f0d0e 2019-01-02 stsp
109 512f0d0e 2019-01-02 stsp (cd $testroot/repo && git_rm $testroot/repo beta)
110 512f0d0e 2019-01-02 stsp git_commit $testroot/repo -m "deleting a file"
111 512f0d0e 2019-01-02 stsp
112 512f0d0e 2019-01-02 stsp echo "D beta" > $testroot/stdout.expected
113 512f0d0e 2019-01-02 stsp echo -n "Updated to commit " >> $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 e60e7f5b 2019-02-10 stsp ret="$?"
125 e60e7f5b 2019-02-10 stsp if [ "$ret" != "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 e60e7f5b 2019-02-10 stsp ret="$?"
145 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
146 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
147 f5c49f82 2019-01-06 stsp return 1
148 f5c49f82 2019-01-06 stsp fi
149 f5c49f82 2019-01-06 stsp
150 f5c49f82 2019-01-06 stsp (cd $testroot/repo && git_rm $testroot/repo -r epsilon)
151 f5c49f82 2019-01-06 stsp git_commit $testroot/repo -m "deleting a directory"
152 f5c49f82 2019-01-06 stsp
153 f5c49f82 2019-01-06 stsp echo "D epsilon/zeta" > $testroot/stdout.expected
154 f5c49f82 2019-01-06 stsp echo -n "Updated to commit " >> $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 e60e7f5b 2019-02-10 stsp ret="$?"
162 e60e7f5b 2019-02-10 stsp if [ "$ret" != "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 e60e7f5b 2019-02-10 stsp ret="$?"
189 e60e7f5b 2019-02-10 stsp if [ "$ret" != "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 5cc266ba 2019-01-06 stsp echo "Updated to commit $first_rev" >> $testroot/stdout.expected
197 5cc266ba 2019-01-06 stsp
198 5cc266ba 2019-01-06 stsp (cd $testroot/wt && got update -c $first_rev > $testroot/stdout)
199 5cc266ba 2019-01-06 stsp
200 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
201 e60e7f5b 2019-02-10 stsp ret="$?"
202 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
203 5cc266ba 2019-01-06 stsp diff -u $testroot/stdout.expected $testroot/stdout
204 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
205 5cc266ba 2019-01-06 stsp return 1
206 5cc266ba 2019-01-06 stsp fi
207 5cc266ba 2019-01-06 stsp
208 5cc266ba 2019-01-06 stsp if [ -e $testroot/wt/psi ]; then
209 5cc266ba 2019-01-06 stsp echo "removed dir psi still exists on disk" >&2
210 5cc266ba 2019-01-06 stsp test_done "$testroot" "1"
211 5cc266ba 2019-01-06 stsp return 1
212 5cc266ba 2019-01-06 stsp fi
213 5cc266ba 2019-01-06 stsp
214 52a3df9b 2019-01-06 stsp test_done "$testroot" "0"
215 5cc266ba 2019-01-06 stsp }
216 5cc266ba 2019-01-06 stsp
217 f6cae3ed 2020-09-13 naddy test_update_deletes_dir_recursively() {
218 90285c3b 2019-01-08 stsp local testroot=`test_init update_deletes_dir_recursively`
219 90285c3b 2019-01-08 stsp local first_rev=`git_show_head $testroot/repo`
220 90285c3b 2019-01-08 stsp
221 90285c3b 2019-01-08 stsp mkdir $testroot/repo/epsilon/psi
222 90285c3b 2019-01-08 stsp echo mu > $testroot/repo/epsilon/psi/mu
223 90285c3b 2019-01-08 stsp mkdir $testroot/repo/epsilon/psi/chi
224 90285c3b 2019-01-08 stsp echo tau > $testroot/repo/epsilon/psi/chi/tau
225 90285c3b 2019-01-08 stsp (cd $testroot/repo && git add .)
226 90285c3b 2019-01-08 stsp git_commit $testroot/repo -m "adding a sub-directory beneath epsilon"
227 90285c3b 2019-01-08 stsp
228 90285c3b 2019-01-08 stsp # check out the epsilon/ sub-tree
229 90285c3b 2019-01-08 stsp got checkout -p epsilon $testroot/repo $testroot/wt > /dev/null
230 e60e7f5b 2019-02-10 stsp ret="$?"
231 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
232 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
233 90285c3b 2019-01-08 stsp return 1
234 90285c3b 2019-01-08 stsp fi
235 90285c3b 2019-01-08 stsp
236 90285c3b 2019-01-08 stsp # update back to first commit and expect psi/mu to be deleted
237 90285c3b 2019-01-08 stsp echo "D psi/chi/tau" > $testroot/stdout.expected
238 90285c3b 2019-01-08 stsp echo "D psi/mu" >> $testroot/stdout.expected
239 90285c3b 2019-01-08 stsp echo "Updated to commit $first_rev" >> $testroot/stdout.expected
240 90285c3b 2019-01-08 stsp
241 90285c3b 2019-01-08 stsp (cd $testroot/wt && got update -c $first_rev > $testroot/stdout)
242 90285c3b 2019-01-08 stsp
243 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
244 e60e7f5b 2019-02-10 stsp ret="$?"
245 90285c3b 2019-01-08 stsp if [ "$?" != "0" ]; then
246 90285c3b 2019-01-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
247 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
248 90285c3b 2019-01-08 stsp return 1
249 90285c3b 2019-01-08 stsp fi
250 90285c3b 2019-01-08 stsp
251 90285c3b 2019-01-08 stsp if [ -e $testroot/wt/psi ]; then
252 90285c3b 2019-01-08 stsp echo "removed dir psi still exists on disk" >&2
253 90285c3b 2019-01-08 stsp test_done "$testroot" "1"
254 90285c3b 2019-01-08 stsp return 1
255 90285c3b 2019-01-08 stsp fi
256 90285c3b 2019-01-08 stsp
257 90285c3b 2019-01-08 stsp test_done "$testroot" "0"
258 90285c3b 2019-01-08 stsp }
259 90285c3b 2019-01-08 stsp
260 f6cae3ed 2020-09-13 naddy test_update_sibling_dirs_with_common_prefix() {
261 4482e97b 2019-01-08 stsp local testroot=`test_init update_sibling_dirs_with_common_prefix`
262 81a30460 2019-01-08 stsp
263 81a30460 2019-01-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
264 e60e7f5b 2019-02-10 stsp ret="$?"
265 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
266 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
267 81a30460 2019-01-08 stsp return 1
268 81a30460 2019-01-08 stsp fi
269 81a30460 2019-01-08 stsp
270 81a30460 2019-01-08 stsp mkdir $testroot/repo/epsilon2
271 81a30460 2019-01-08 stsp echo mu > $testroot/repo/epsilon2/mu
272 81a30460 2019-01-08 stsp (cd $testroot/repo && git add epsilon2/mu)
273 81a30460 2019-01-08 stsp git_commit $testroot/repo -m "adding sibling of epsilon"
274 81a30460 2019-01-08 stsp echo change > $testroot/repo/epsilon/zeta
275 81a30460 2019-01-08 stsp git_commit $testroot/repo -m "changing epsilon/zeta"
276 81a30460 2019-01-08 stsp
277 81a30460 2019-01-08 stsp echo "U epsilon/zeta" > $testroot/stdout.expected
278 81a30460 2019-01-08 stsp echo "A epsilon2/mu" >> $testroot/stdout.expected
279 81a30460 2019-01-08 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
280 81a30460 2019-01-08 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
281 81a30460 2019-01-08 stsp echo >> $testroot/stdout.expected
282 81a30460 2019-01-08 stsp
283 81a30460 2019-01-08 stsp (cd $testroot/wt && got update > $testroot/stdout)
284 81a30460 2019-01-08 stsp
285 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
286 e60e7f5b 2019-02-10 stsp ret="$?"
287 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
288 81a30460 2019-01-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
289 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
290 81a30460 2019-01-08 stsp return 1
291 81a30460 2019-01-08 stsp fi
292 81a30460 2019-01-08 stsp
293 81a30460 2019-01-08 stsp echo "another change" > $testroot/repo/epsilon/zeta
294 81a30460 2019-01-08 stsp git_commit $testroot/repo -m "changing epsilon/zeta again"
295 81a30460 2019-01-08 stsp
296 81a30460 2019-01-08 stsp echo "U epsilon/zeta" > $testroot/stdout.expected
297 81a30460 2019-01-08 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
298 81a30460 2019-01-08 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
299 81a30460 2019-01-08 stsp echo >> $testroot/stdout.expected
300 81a30460 2019-01-08 stsp
301 81a30460 2019-01-08 stsp # Bug: This update used to do delete/add epsilon2/mu again:
302 81a30460 2019-01-08 stsp # U epsilon/zeta
303 81a30460 2019-01-08 stsp # D epsilon2/mu <--- not intended
304 81a30460 2019-01-08 stsp # A epsilon2/mu <--- not intended
305 50952927 2019-01-12 stsp (cd $testroot/wt && got update > $testroot/stdout)
306 50952927 2019-01-12 stsp
307 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
308 e60e7f5b 2019-02-10 stsp ret="$?"
309 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
310 50952927 2019-01-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
311 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
312 50952927 2019-01-12 stsp return 1
313 50952927 2019-01-12 stsp fi
314 50952927 2019-01-12 stsp
315 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
316 e60e7f5b 2019-02-10 stsp ret="$?"
317 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
318 50952927 2019-01-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
319 50952927 2019-01-12 stsp fi
320 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
321 50952927 2019-01-12 stsp }
322 50952927 2019-01-12 stsp
323 f6cae3ed 2020-09-13 naddy test_update_dir_with_dot_sibling() {
324 50952927 2019-01-12 stsp local testroot=`test_init update_dir_with_dot_sibling`
325 50952927 2019-01-12 stsp
326 50952927 2019-01-12 stsp got checkout $testroot/repo $testroot/wt > /dev/null
327 e60e7f5b 2019-02-10 stsp ret="$ret"
328 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
329 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
330 50952927 2019-01-12 stsp return 1
331 50952927 2019-01-12 stsp fi
332 50952927 2019-01-12 stsp
333 50952927 2019-01-12 stsp echo text > $testroot/repo/epsilon.txt
334 50952927 2019-01-12 stsp (cd $testroot/repo && git add epsilon.txt)
335 50952927 2019-01-12 stsp git_commit $testroot/repo -m "adding sibling of epsilon"
336 50952927 2019-01-12 stsp echo change > $testroot/repo/epsilon/zeta
337 50952927 2019-01-12 stsp git_commit $testroot/repo -m "changing epsilon/zeta"
338 50952927 2019-01-12 stsp
339 f5d3d7af 2019-02-05 stsp echo "U epsilon/zeta" > $testroot/stdout.expected
340 f5d3d7af 2019-02-05 stsp echo "A epsilon.txt" >> $testroot/stdout.expected
341 50952927 2019-01-12 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
342 50952927 2019-01-12 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
343 50952927 2019-01-12 stsp echo >> $testroot/stdout.expected
344 50952927 2019-01-12 stsp
345 81a30460 2019-01-08 stsp (cd $testroot/wt && got update > $testroot/stdout)
346 81a30460 2019-01-08 stsp
347 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
348 e60e7f5b 2019-02-10 stsp ret="$?"
349 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
350 81a30460 2019-01-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
351 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
352 81a30460 2019-01-08 stsp return 1
353 81a30460 2019-01-08 stsp fi
354 81a30460 2019-01-08 stsp
355 50952927 2019-01-12 stsp echo "another change" > $testroot/repo/epsilon/zeta
356 50952927 2019-01-12 stsp git_commit $testroot/repo -m "changing epsilon/zeta again"
357 50952927 2019-01-12 stsp
358 50952927 2019-01-12 stsp echo "U epsilon/zeta" > $testroot/stdout.expected
359 50952927 2019-01-12 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
360 50952927 2019-01-12 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
361 50952927 2019-01-12 stsp echo >> $testroot/stdout.expected
362 50952927 2019-01-12 stsp
363 50952927 2019-01-12 stsp (cd $testroot/wt && got update > $testroot/stdout)
364 50952927 2019-01-12 stsp
365 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
366 e60e7f5b 2019-02-10 stsp ret="$?"
367 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
368 81a30460 2019-01-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
369 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
370 81a30460 2019-01-08 stsp return 1
371 81a30460 2019-01-08 stsp fi
372 81a30460 2019-01-08 stsp
373 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
374 e60e7f5b 2019-02-10 stsp ret="$?"
375 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
376 50952927 2019-01-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
377 50952927 2019-01-12 stsp fi
378 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
379 81a30460 2019-01-08 stsp }
380 46cee7a3 2019-01-12 stsp
381 f6cae3ed 2020-09-13 naddy test_update_moves_files_upwards() {
382 46cee7a3 2019-01-12 stsp local testroot=`test_init update_moves_files_upwards`
383 46cee7a3 2019-01-12 stsp
384 46cee7a3 2019-01-12 stsp mkdir $testroot/repo/epsilon/psi
385 46cee7a3 2019-01-12 stsp echo mu > $testroot/repo/epsilon/psi/mu
386 46cee7a3 2019-01-12 stsp mkdir $testroot/repo/epsilon/psi/chi
387 46cee7a3 2019-01-12 stsp echo tau > $testroot/repo/epsilon/psi/chi/tau
388 46cee7a3 2019-01-12 stsp (cd $testroot/repo && git add .)
389 46cee7a3 2019-01-12 stsp git_commit $testroot/repo -m "adding a sub-directory beneath epsilon"
390 46cee7a3 2019-01-12 stsp
391 46cee7a3 2019-01-12 stsp got checkout $testroot/repo $testroot/wt > /dev/null
392 e60e7f5b 2019-02-10 stsp ret="$?"
393 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
394 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
395 46cee7a3 2019-01-12 stsp return 1
396 46cee7a3 2019-01-12 stsp fi
397 81a30460 2019-01-08 stsp
398 46cee7a3 2019-01-12 stsp (cd $testroot/repo && git mv epsilon/psi/mu epsilon/mu)
399 46cee7a3 2019-01-12 stsp (cd $testroot/repo && git mv epsilon/psi/chi/tau epsilon/psi/tau)
400 46cee7a3 2019-01-12 stsp git_commit $testroot/repo -m "moving files upwards"
401 46cee7a3 2019-01-12 stsp
402 21908da4 2019-01-13 stsp echo "A epsilon/mu" > $testroot/stdout.expected
403 21908da4 2019-01-13 stsp echo "D epsilon/psi/chi/tau" >> $testroot/stdout.expected
404 46cee7a3 2019-01-12 stsp echo "D epsilon/psi/mu" >> $testroot/stdout.expected
405 bd4792ec 2019-01-13 stsp echo "A epsilon/psi/tau" >> $testroot/stdout.expected
406 46cee7a3 2019-01-12 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
407 46cee7a3 2019-01-12 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
408 46cee7a3 2019-01-12 stsp echo >> $testroot/stdout.expected
409 46cee7a3 2019-01-12 stsp
410 46cee7a3 2019-01-12 stsp (cd $testroot/wt && got update > $testroot/stdout)
411 46cee7a3 2019-01-12 stsp
412 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
413 e60e7f5b 2019-02-10 stsp ret="$?"
414 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
415 46cee7a3 2019-01-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
416 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
417 46cee7a3 2019-01-12 stsp return 1
418 46cee7a3 2019-01-12 stsp fi
419 46cee7a3 2019-01-12 stsp
420 46cee7a3 2019-01-12 stsp if [ -e $testroot/wt/epsilon/psi/chi ]; then
421 46cee7a3 2019-01-12 stsp echo "removed dir epsilon/psi/chi still exists on disk" >&2
422 46cee7a3 2019-01-12 stsp test_done "$testroot" "1"
423 46cee7a3 2019-01-12 stsp return 1
424 46cee7a3 2019-01-12 stsp fi
425 46cee7a3 2019-01-12 stsp
426 46cee7a3 2019-01-12 stsp if [ -e $testroot/wt/epsilon/psi/mu ]; then
427 46cee7a3 2019-01-12 stsp echo "removed file epsilon/psi/mu still exists on disk" >&2
428 46cee7a3 2019-01-12 stsp test_done "$testroot" "1"
429 46cee7a3 2019-01-12 stsp return 1
430 46cee7a3 2019-01-12 stsp fi
431 46cee7a3 2019-01-12 stsp
432 46cee7a3 2019-01-12 stsp test_done "$testroot" "0"
433 46cee7a3 2019-01-12 stsp }
434 46cee7a3 2019-01-12 stsp
435 f6cae3ed 2020-09-13 naddy test_update_moves_files_to_new_dir() {
436 46cee7a3 2019-01-12 stsp local testroot=`test_init update_moves_files_to_new_dir`
437 46cee7a3 2019-01-12 stsp
438 46cee7a3 2019-01-12 stsp mkdir $testroot/repo/epsilon/psi
439 46cee7a3 2019-01-12 stsp echo mu > $testroot/repo/epsilon/psi/mu
440 46cee7a3 2019-01-12 stsp mkdir $testroot/repo/epsilon/psi/chi
441 46cee7a3 2019-01-12 stsp echo tau > $testroot/repo/epsilon/psi/chi/tau
442 46cee7a3 2019-01-12 stsp (cd $testroot/repo && git add .)
443 46cee7a3 2019-01-12 stsp git_commit $testroot/repo -m "adding a sub-directory beneath epsilon"
444 46cee7a3 2019-01-12 stsp
445 46cee7a3 2019-01-12 stsp got checkout $testroot/repo $testroot/wt > /dev/null
446 e60e7f5b 2019-02-10 stsp ret="$?"
447 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
448 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
449 46cee7a3 2019-01-12 stsp return 1
450 46cee7a3 2019-01-12 stsp fi
451 46cee7a3 2019-01-12 stsp
452 46cee7a3 2019-01-12 stsp mkdir -p $testroot/repo/epsilon-new/psi
453 46cee7a3 2019-01-12 stsp (cd $testroot/repo && git mv epsilon/psi/mu epsilon-new/mu)
454 46cee7a3 2019-01-12 stsp (cd $testroot/repo && git mv epsilon/psi/chi/tau epsilon-new/psi/tau)
455 46cee7a3 2019-01-12 stsp git_commit $testroot/repo -m "moving files upwards"
456 46cee7a3 2019-01-12 stsp
457 f5d3d7af 2019-02-05 stsp echo "D epsilon/psi/chi/tau" > $testroot/stdout.expected
458 46cee7a3 2019-01-12 stsp echo "D epsilon/psi/mu" >> $testroot/stdout.expected
459 f5d3d7af 2019-02-05 stsp echo "A epsilon-new/mu" >> $testroot/stdout.expected
460 f5d3d7af 2019-02-05 stsp echo "A epsilon-new/psi/tau" >> $testroot/stdout.expected
461 46cee7a3 2019-01-12 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
462 46cee7a3 2019-01-12 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
463 46cee7a3 2019-01-12 stsp echo >> $testroot/stdout.expected
464 46cee7a3 2019-01-12 stsp
465 46cee7a3 2019-01-12 stsp (cd $testroot/wt && got update > $testroot/stdout)
466 46cee7a3 2019-01-12 stsp
467 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
468 e60e7f5b 2019-02-10 stsp ret="$?"
469 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
470 46cee7a3 2019-01-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
471 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
472 46cee7a3 2019-01-12 stsp return 1
473 46cee7a3 2019-01-12 stsp fi
474 46cee7a3 2019-01-12 stsp
475 46cee7a3 2019-01-12 stsp if [ -e $testroot/wt/epsilon/psi/chi ]; then
476 46cee7a3 2019-01-12 stsp echo "removed dir epsilon/psi/chi still exists on disk" >&2
477 46cee7a3 2019-01-12 stsp test_done "$testroot" "1"
478 46cee7a3 2019-01-12 stsp return 1
479 46cee7a3 2019-01-12 stsp fi
480 46cee7a3 2019-01-12 stsp
481 46cee7a3 2019-01-12 stsp if [ -e $testroot/wt/epsilon/psi/mu ]; then
482 46cee7a3 2019-01-12 stsp echo "removed file epsilon/psi/mu still exists on disk" >&2
483 46cee7a3 2019-01-12 stsp test_done "$testroot" "1"
484 4a1ddfc2 2019-01-12 stsp return 1
485 4a1ddfc2 2019-01-12 stsp fi
486 4a1ddfc2 2019-01-12 stsp
487 4a1ddfc2 2019-01-12 stsp test_done "$testroot" "0"
488 4a1ddfc2 2019-01-12 stsp }
489 4a1ddfc2 2019-01-12 stsp
490 f6cae3ed 2020-09-13 naddy test_update_creates_missing_parent() {
491 1aad446a 2019-01-13 stsp local testroot=`test_init update_creates_missing_parent 1`
492 4a1ddfc2 2019-01-12 stsp
493 4a1ddfc2 2019-01-12 stsp touch $testroot/repo/Makefile
494 4a1ddfc2 2019-01-12 stsp touch $testroot/repo/snake.6
495 4a1ddfc2 2019-01-12 stsp touch $testroot/repo/snake.c
496 4a1ddfc2 2019-01-12 stsp (cd $testroot/repo && git add .)
497 4a1ddfc2 2019-01-12 stsp git_commit $testroot/repo -m "adding initial snake tree"
498 4a1ddfc2 2019-01-12 stsp
499 4a1ddfc2 2019-01-12 stsp got checkout $testroot/repo $testroot/wt > /dev/null
500 e60e7f5b 2019-02-10 stsp ret="$?"
501 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
502 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
503 4a1ddfc2 2019-01-12 stsp return 1
504 4a1ddfc2 2019-01-12 stsp fi
505 4a1ddfc2 2019-01-12 stsp
506 4a1ddfc2 2019-01-12 stsp mkdir -p $testroot/repo/snake
507 4a1ddfc2 2019-01-12 stsp (cd $testroot/repo && git mv Makefile snake.6 snake.c snake)
508 4a1ddfc2 2019-01-12 stsp touch $testroot/repo/snake/move.c
509 4a1ddfc2 2019-01-12 stsp touch $testroot/repo/snake/pathnames.h
510 4a1ddfc2 2019-01-12 stsp touch $testroot/repo/snake/snake.h
511 4a1ddfc2 2019-01-12 stsp mkdir -p $testroot/repo/snscore
512 4a1ddfc2 2019-01-12 stsp touch $testroot/repo/snscore/Makefile
513 4a1ddfc2 2019-01-12 stsp touch $testroot/repo/snscore/snscore.c
514 4a1ddfc2 2019-01-12 stsp (cd $testroot/repo && git add .)
515 4a1ddfc2 2019-01-12 stsp git_commit $testroot/repo -m "restructuring snake tree"
516 4a1ddfc2 2019-01-12 stsp
517 4a1ddfc2 2019-01-12 stsp echo "D Makefile" > $testroot/stdout.expected
518 4a1ddfc2 2019-01-12 stsp echo "A snake/Makefile" >> $testroot/stdout.expected
519 4a1ddfc2 2019-01-12 stsp echo "A snake/move.c" >> $testroot/stdout.expected
520 4a1ddfc2 2019-01-12 stsp echo "A snake/pathnames.h" >> $testroot/stdout.expected
521 4a1ddfc2 2019-01-12 stsp echo "A snake/snake.6" >> $testroot/stdout.expected
522 4a1ddfc2 2019-01-12 stsp echo "A snake/snake.c" >> $testroot/stdout.expected
523 4a1ddfc2 2019-01-12 stsp echo "A snake/snake.h" >> $testroot/stdout.expected
524 18831e78 2019-02-10 stsp echo "D snake.6" >> $testroot/stdout.expected
525 18831e78 2019-02-10 stsp echo "D snake.c" >> $testroot/stdout.expected
526 bd4792ec 2019-01-13 stsp echo "A snscore/Makefile" >> $testroot/stdout.expected
527 bd4792ec 2019-01-13 stsp echo "A snscore/snscore.c" >> $testroot/stdout.expected
528 bd4792ec 2019-01-13 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
529 bd4792ec 2019-01-13 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
530 bd4792ec 2019-01-13 stsp echo >> $testroot/stdout.expected
531 bd4792ec 2019-01-13 stsp
532 bd4792ec 2019-01-13 stsp (cd $testroot/wt && got update > $testroot/stdout)
533 bd4792ec 2019-01-13 stsp
534 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
535 e60e7f5b 2019-02-10 stsp ret="$?"
536 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
537 e60e7f5b 2019-02-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
538 bd4792ec 2019-01-13 stsp fi
539 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
540 bd4792ec 2019-01-13 stsp }
541 bd4792ec 2019-01-13 stsp
542 f6cae3ed 2020-09-13 naddy test_update_creates_missing_parent_with_subdir() {
543 1aad446a 2019-01-13 stsp local testroot=`test_init update_creates_missing_parent_with_subdir 1`
544 bd4792ec 2019-01-13 stsp
545 bd4792ec 2019-01-13 stsp touch $testroot/repo/Makefile
546 bd4792ec 2019-01-13 stsp touch $testroot/repo/snake.6
547 bd4792ec 2019-01-13 stsp touch $testroot/repo/snake.c
548 bd4792ec 2019-01-13 stsp (cd $testroot/repo && git add .)
549 bd4792ec 2019-01-13 stsp git_commit $testroot/repo -m "adding initial snake tree"
550 bd4792ec 2019-01-13 stsp
551 bd4792ec 2019-01-13 stsp got checkout $testroot/repo $testroot/wt > /dev/null
552 e60e7f5b 2019-02-10 stsp ret="$?"
553 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
554 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
555 bd4792ec 2019-01-13 stsp return 1
556 bd4792ec 2019-01-13 stsp fi
557 bd4792ec 2019-01-13 stsp
558 bd4792ec 2019-01-13 stsp mkdir -p $testroot/repo/sss/snake
559 bd4792ec 2019-01-13 stsp (cd $testroot/repo && git mv Makefile snake.6 snake.c sss/snake)
560 bd4792ec 2019-01-13 stsp touch $testroot/repo/sss/snake/move.c
561 bd4792ec 2019-01-13 stsp touch $testroot/repo/sss/snake/pathnames.h
562 bd4792ec 2019-01-13 stsp touch $testroot/repo/sss/snake/snake.h
563 bd4792ec 2019-01-13 stsp mkdir -p $testroot/repo/snscore
564 bd4792ec 2019-01-13 stsp touch $testroot/repo/snscore/Makefile
565 bd4792ec 2019-01-13 stsp touch $testroot/repo/snscore/snscore.c
566 bd4792ec 2019-01-13 stsp (cd $testroot/repo && git add .)
567 bd4792ec 2019-01-13 stsp git_commit $testroot/repo -m "restructuring snake tree"
568 bd4792ec 2019-01-13 stsp
569 bd4792ec 2019-01-13 stsp echo "D Makefile" > $testroot/stdout.expected
570 4a1ddfc2 2019-01-12 stsp echo "D snake.6" >> $testroot/stdout.expected
571 4a1ddfc2 2019-01-12 stsp echo "D snake.c" >> $testroot/stdout.expected
572 4a1ddfc2 2019-01-12 stsp echo "A snscore/Makefile" >> $testroot/stdout.expected
573 4a1ddfc2 2019-01-12 stsp echo "A snscore/snscore.c" >> $testroot/stdout.expected
574 bd4792ec 2019-01-13 stsp echo "A sss/snake/Makefile" >> $testroot/stdout.expected
575 bd4792ec 2019-01-13 stsp echo "A sss/snake/move.c" >> $testroot/stdout.expected
576 bd4792ec 2019-01-13 stsp echo "A sss/snake/pathnames.h" >> $testroot/stdout.expected
577 bd4792ec 2019-01-13 stsp echo "A sss/snake/snake.6" >> $testroot/stdout.expected
578 bd4792ec 2019-01-13 stsp echo "A sss/snake/snake.c" >> $testroot/stdout.expected
579 bd4792ec 2019-01-13 stsp echo "A sss/snake/snake.h" >> $testroot/stdout.expected
580 4a1ddfc2 2019-01-12 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
581 4a1ddfc2 2019-01-12 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
582 4a1ddfc2 2019-01-12 stsp echo >> $testroot/stdout.expected
583 4a1ddfc2 2019-01-12 stsp
584 4a1ddfc2 2019-01-12 stsp (cd $testroot/wt && got update > $testroot/stdout)
585 4a1ddfc2 2019-01-12 stsp
586 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
587 e60e7f5b 2019-02-10 stsp ret="$?"
588 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
589 4a1ddfc2 2019-01-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
590 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
591 46cee7a3 2019-01-12 stsp return 1
592 46cee7a3 2019-01-12 stsp fi
593 46cee7a3 2019-01-12 stsp
594 46cee7a3 2019-01-12 stsp test_done "$testroot" "0"
595 46cee7a3 2019-01-12 stsp }
596 21908da4 2019-01-13 stsp
597 f6cae3ed 2020-09-13 naddy test_update_file_in_subsubdir() {
598 1aad446a 2019-01-13 stsp local testroot=`test_init update_fle_in_subsubdir 1`
599 46cee7a3 2019-01-12 stsp
600 21908da4 2019-01-13 stsp touch $testroot/repo/Makefile
601 21908da4 2019-01-13 stsp mkdir -p $testroot/repo/altq
602 21908da4 2019-01-13 stsp touch $testroot/repo/altq/if_altq.h
603 21908da4 2019-01-13 stsp mkdir -p $testroot/repo/arch/alpha
604 21908da4 2019-01-13 stsp touch $testroot/repo/arch/alpha/Makefile
605 21908da4 2019-01-13 stsp (cd $testroot/repo && git add .)
606 21908da4 2019-01-13 stsp git_commit $testroot/repo -m "adding initial tree"
607 21908da4 2019-01-13 stsp
608 21908da4 2019-01-13 stsp got checkout $testroot/repo $testroot/wt > /dev/null
609 e60e7f5b 2019-02-10 stsp ret="$?"
610 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
611 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
612 21908da4 2019-01-13 stsp return 1
613 21908da4 2019-01-13 stsp fi
614 21908da4 2019-01-13 stsp
615 21908da4 2019-01-13 stsp echo change > $testroot/repo/arch/alpha/Makefile
616 21908da4 2019-01-13 stsp (cd $testroot/repo && git add .)
617 21908da4 2019-01-13 stsp git_commit $testroot/repo -m "changed a file"
618 21908da4 2019-01-13 stsp
619 21908da4 2019-01-13 stsp echo "U arch/alpha/Makefile" > $testroot/stdout.expected
620 21908da4 2019-01-13 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
621 21908da4 2019-01-13 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
622 21908da4 2019-01-13 stsp echo >> $testroot/stdout.expected
623 21908da4 2019-01-13 stsp
624 21908da4 2019-01-13 stsp (cd $testroot/wt && got update > $testroot/stdout)
625 21908da4 2019-01-13 stsp
626 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
627 e60e7f5b 2019-02-10 stsp ret="$?"
628 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
629 21908da4 2019-01-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
630 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
631 21908da4 2019-01-13 stsp return 1
632 21908da4 2019-01-13 stsp fi
633 21908da4 2019-01-13 stsp
634 21908da4 2019-01-13 stsp test_done "$testroot" "0"
635 21908da4 2019-01-13 stsp }
636 6353ad76 2019-02-08 stsp
637 f6cae3ed 2020-09-13 naddy test_update_merges_file_edits() {
638 6353ad76 2019-02-08 stsp local testroot=`test_init update_merges_file_edits`
639 6353ad76 2019-02-08 stsp
640 6353ad76 2019-02-08 stsp echo "1" > $testroot/repo/numbers
641 6353ad76 2019-02-08 stsp echo "2" >> $testroot/repo/numbers
642 6353ad76 2019-02-08 stsp echo "3" >> $testroot/repo/numbers
643 6353ad76 2019-02-08 stsp echo "4" >> $testroot/repo/numbers
644 6353ad76 2019-02-08 stsp echo "5" >> $testroot/repo/numbers
645 6353ad76 2019-02-08 stsp echo "6" >> $testroot/repo/numbers
646 6353ad76 2019-02-08 stsp echo "7" >> $testroot/repo/numbers
647 6353ad76 2019-02-08 stsp echo "8" >> $testroot/repo/numbers
648 6353ad76 2019-02-08 stsp (cd $testroot/repo && git add numbers)
649 6353ad76 2019-02-08 stsp git_commit $testroot/repo -m "added numbers file"
650 f69721c3 2019-10-21 stsp local base_commit=`git_show_head $testroot/repo`
651 21908da4 2019-01-13 stsp
652 6353ad76 2019-02-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
653 e60e7f5b 2019-02-10 stsp ret="$?"
654 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
655 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
656 6353ad76 2019-02-08 stsp return 1
657 6353ad76 2019-02-08 stsp fi
658 6353ad76 2019-02-08 stsp
659 6353ad76 2019-02-08 stsp echo "modified alpha" > $testroot/repo/alpha
660 6353ad76 2019-02-08 stsp echo "modified beta" > $testroot/repo/beta
661 6353ad76 2019-02-08 stsp sed -i 's/2/22/' $testroot/repo/numbers
662 6353ad76 2019-02-08 stsp git_commit $testroot/repo -m "modified 3 files"
663 6353ad76 2019-02-08 stsp
664 6353ad76 2019-02-08 stsp echo "modified alpha, too" > $testroot/wt/alpha
665 6353ad76 2019-02-08 stsp touch $testroot/wt/beta
666 6353ad76 2019-02-08 stsp sed -i 's/7/77/' $testroot/wt/numbers
667 6353ad76 2019-02-08 stsp
668 6353ad76 2019-02-08 stsp echo "C alpha" > $testroot/stdout.expected
669 6353ad76 2019-02-08 stsp echo "U beta" >> $testroot/stdout.expected
670 6353ad76 2019-02-08 stsp echo "G numbers" >> $testroot/stdout.expected
671 6353ad76 2019-02-08 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
672 6353ad76 2019-02-08 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
673 6353ad76 2019-02-08 stsp echo >> $testroot/stdout.expected
674 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
675 6353ad76 2019-02-08 stsp
676 6353ad76 2019-02-08 stsp (cd $testroot/wt && got update > $testroot/stdout)
677 6353ad76 2019-02-08 stsp
678 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
679 e60e7f5b 2019-02-10 stsp ret="$?"
680 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
681 6353ad76 2019-02-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
682 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
683 6353ad76 2019-02-08 stsp return 1
684 6353ad76 2019-02-08 stsp fi
685 6353ad76 2019-02-08 stsp
686 f69721c3 2019-10-21 stsp echo -n "<<<<<<< merged change: commit " > $testroot/content.expected
687 6353ad76 2019-02-08 stsp git_show_head $testroot/repo >> $testroot/content.expected
688 6353ad76 2019-02-08 stsp echo >> $testroot/content.expected
689 6353ad76 2019-02-08 stsp echo "modified alpha" >> $testroot/content.expected
690 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $base_commit" \
691 f69721c3 2019-10-21 stsp >> $testroot/content.expected
692 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
693 6353ad76 2019-02-08 stsp echo "=======" >> $testroot/content.expected
694 6353ad76 2019-02-08 stsp echo "modified alpha, too" >> $testroot/content.expected
695 f69721c3 2019-10-21 stsp echo '>>>>>>>' >> $testroot/content.expected
696 6353ad76 2019-02-08 stsp echo "modified beta" >> $testroot/content.expected
697 6353ad76 2019-02-08 stsp echo "1" >> $testroot/content.expected
698 6353ad76 2019-02-08 stsp echo "22" >> $testroot/content.expected
699 6353ad76 2019-02-08 stsp echo "3" >> $testroot/content.expected
700 6353ad76 2019-02-08 stsp echo "4" >> $testroot/content.expected
701 6353ad76 2019-02-08 stsp echo "5" >> $testroot/content.expected
702 6353ad76 2019-02-08 stsp echo "6" >> $testroot/content.expected
703 6353ad76 2019-02-08 stsp echo "77" >> $testroot/content.expected
704 6353ad76 2019-02-08 stsp echo "8" >> $testroot/content.expected
705 6353ad76 2019-02-08 stsp
706 6353ad76 2019-02-08 stsp cat $testroot/wt/alpha > $testroot/content
707 6353ad76 2019-02-08 stsp cat $testroot/wt/beta >> $testroot/content
708 6353ad76 2019-02-08 stsp cat $testroot/wt/numbers >> $testroot/content
709 6353ad76 2019-02-08 stsp
710 8d301dd9 2019-05-14 stsp cmp -s $testroot/content.expected $testroot/content
711 6353ad76 2019-02-08 stsp ret="$?"
712 6353ad76 2019-02-08 stsp if [ "$ret" != "0" ]; then
713 6353ad76 2019-02-08 stsp diff -u $testroot/content.expected $testroot/content
714 68ed9ba5 2019-02-10 stsp fi
715 68ed9ba5 2019-02-10 stsp test_done "$testroot" "$ret"
716 68ed9ba5 2019-02-10 stsp }
717 68ed9ba5 2019-02-10 stsp
718 f6cae3ed 2020-09-13 naddy test_update_keeps_xbit() {
719 68ed9ba5 2019-02-10 stsp local testroot=`test_init update_keeps_xbit 1`
720 68ed9ba5 2019-02-10 stsp
721 68ed9ba5 2019-02-10 stsp touch $testroot/repo/xfile
722 68ed9ba5 2019-02-10 stsp chmod +x $testroot/repo/xfile
723 68ed9ba5 2019-02-10 stsp (cd $testroot/repo && git add .)
724 68ed9ba5 2019-02-10 stsp git_commit $testroot/repo -m "adding executable file"
725 68ed9ba5 2019-02-10 stsp
726 68ed9ba5 2019-02-10 stsp got checkout $testroot/repo $testroot/wt > $testroot/stdout
727 68ed9ba5 2019-02-10 stsp ret="$?"
728 68ed9ba5 2019-02-10 stsp if [ "$ret" != "0" ]; then
729 68ed9ba5 2019-02-10 stsp test_done "$testroot" "$ret"
730 68ed9ba5 2019-02-10 stsp return 1
731 68ed9ba5 2019-02-10 stsp fi
732 68ed9ba5 2019-02-10 stsp
733 68ed9ba5 2019-02-10 stsp echo foo > $testroot/repo/xfile
734 68ed9ba5 2019-02-10 stsp git_commit $testroot/repo -m "changed executable file"
735 68ed9ba5 2019-02-10 stsp
736 68ed9ba5 2019-02-10 stsp echo "U xfile" > $testroot/stdout.expected
737 68ed9ba5 2019-02-10 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
738 68ed9ba5 2019-02-10 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
739 68ed9ba5 2019-02-10 stsp echo >> $testroot/stdout.expected
740 68ed9ba5 2019-02-10 stsp
741 68ed9ba5 2019-02-10 stsp (cd $testroot/wt && got update > $testroot/stdout)
742 68ed9ba5 2019-02-10 stsp ret="$?"
743 68ed9ba5 2019-02-10 stsp if [ "$ret" != "0" ]; then
744 68ed9ba5 2019-02-10 stsp test_done "$testroot" "$ret"
745 68ed9ba5 2019-02-10 stsp return 1
746 6353ad76 2019-02-08 stsp fi
747 68ed9ba5 2019-02-10 stsp
748 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
749 68ed9ba5 2019-02-10 stsp ret="$?"
750 68ed9ba5 2019-02-10 stsp if [ "$ret" != "0" ]; then
751 68ed9ba5 2019-02-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
752 68ed9ba5 2019-02-10 stsp test_done "$testroot" "$ret"
753 68ed9ba5 2019-02-10 stsp return 1
754 68ed9ba5 2019-02-10 stsp fi
755 68ed9ba5 2019-02-10 stsp
756 68ed9ba5 2019-02-10 stsp ls -l $testroot/wt/xfile | grep -q '^-rwx'
757 68ed9ba5 2019-02-10 stsp ret="$?"
758 68ed9ba5 2019-02-10 stsp if [ "$ret" != "0" ]; then
759 68ed9ba5 2019-02-10 stsp echo "file is not executable" >&2
760 68ed9ba5 2019-02-10 stsp ls -l $testroot/wt/xfile >&2
761 68ed9ba5 2019-02-10 stsp fi
762 6353ad76 2019-02-08 stsp test_done "$testroot" "$ret"
763 6353ad76 2019-02-08 stsp }
764 ba8a0d4d 2019-02-10 stsp
765 f6cae3ed 2020-09-13 naddy test_update_clears_xbit() {
766 ba8a0d4d 2019-02-10 stsp local testroot=`test_init update_clears_xbit 1`
767 ba8a0d4d 2019-02-10 stsp
768 ba8a0d4d 2019-02-10 stsp touch $testroot/repo/xfile
769 ba8a0d4d 2019-02-10 stsp chmod +x $testroot/repo/xfile
770 ba8a0d4d 2019-02-10 stsp (cd $testroot/repo && git add .)
771 ba8a0d4d 2019-02-10 stsp git_commit $testroot/repo -m "adding executable file"
772 6353ad76 2019-02-08 stsp
773 ba8a0d4d 2019-02-10 stsp got checkout $testroot/repo $testroot/wt > $testroot/stdout
774 ba8a0d4d 2019-02-10 stsp ret="$?"
775 ba8a0d4d 2019-02-10 stsp if [ "$ret" != "0" ]; then
776 ba8a0d4d 2019-02-10 stsp test_done "$testroot" "$ret"
777 ba8a0d4d 2019-02-10 stsp return 1
778 ba8a0d4d 2019-02-10 stsp fi
779 ba8a0d4d 2019-02-10 stsp
780 ba8a0d4d 2019-02-10 stsp ls -l $testroot/wt/xfile | grep -q '^-rwx'
781 ba8a0d4d 2019-02-10 stsp ret="$?"
782 ba8a0d4d 2019-02-10 stsp if [ "$ret" != "0" ]; then
783 ba8a0d4d 2019-02-10 stsp echo "file is not executable" >&2
784 ba8a0d4d 2019-02-10 stsp ls -l $testroot/wt/xfile >&2
785 ba8a0d4d 2019-02-10 stsp test_done "$testroot" "$ret"
786 ba8a0d4d 2019-02-10 stsp return 1
787 ba8a0d4d 2019-02-10 stsp fi
788 ba8a0d4d 2019-02-10 stsp
789 ba8a0d4d 2019-02-10 stsp # XXX git seems to require a file edit when flipping the x bit?
790 ba8a0d4d 2019-02-10 stsp echo foo > $testroot/repo/xfile
791 ba8a0d4d 2019-02-10 stsp chmod -x $testroot/repo/xfile
792 ba8a0d4d 2019-02-10 stsp git_commit $testroot/repo -m "not an executable file anymore"
793 ba8a0d4d 2019-02-10 stsp
794 ba8a0d4d 2019-02-10 stsp echo "U xfile" > $testroot/stdout.expected
795 ba8a0d4d 2019-02-10 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
796 ba8a0d4d 2019-02-10 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
797 ba8a0d4d 2019-02-10 stsp echo >> $testroot/stdout.expected
798 ba8a0d4d 2019-02-10 stsp
799 ba8a0d4d 2019-02-10 stsp (cd $testroot/wt && got update > $testroot/stdout)
800 ba8a0d4d 2019-02-10 stsp ret="$?"
801 ba8a0d4d 2019-02-10 stsp if [ "$ret" != "0" ]; then
802 ba8a0d4d 2019-02-10 stsp test_done "$testroot" "$ret"
803 ba8a0d4d 2019-02-10 stsp return 1
804 ba8a0d4d 2019-02-10 stsp fi
805 ba8a0d4d 2019-02-10 stsp
806 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
807 ba8a0d4d 2019-02-10 stsp ret="$?"
808 ba8a0d4d 2019-02-10 stsp if [ "$ret" != "0" ]; then
809 ba8a0d4d 2019-02-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
810 ba8a0d4d 2019-02-10 stsp test_done "$testroot" "$ret"
811 ba8a0d4d 2019-02-10 stsp return 1
812 ba8a0d4d 2019-02-10 stsp fi
813 ba8a0d4d 2019-02-10 stsp
814 ba8a0d4d 2019-02-10 stsp ls -l $testroot/wt/xfile | grep -q '^-rw-'
815 ba8a0d4d 2019-02-10 stsp ret="$?"
816 ba8a0d4d 2019-02-10 stsp if [ "$ret" != "0" ]; then
817 ba8a0d4d 2019-02-10 stsp echo "file is unexpectedly executable" >&2
818 ba8a0d4d 2019-02-10 stsp ls -l $testroot/wt/xfile >&2
819 ba8a0d4d 2019-02-10 stsp fi
820 ba8a0d4d 2019-02-10 stsp test_done "$testroot" "$ret"
821 ba8a0d4d 2019-02-10 stsp }
822 a378724f 2019-02-10 stsp
823 f6cae3ed 2020-09-13 naddy test_update_restores_missing_file() {
824 a378724f 2019-02-10 stsp local testroot=`test_init update_restores_missing_file`
825 a378724f 2019-02-10 stsp
826 a378724f 2019-02-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
827 a378724f 2019-02-10 stsp ret="$?"
828 a378724f 2019-02-10 stsp if [ "$ret" != "0" ]; then
829 a378724f 2019-02-10 stsp test_done "$testroot" "$ret"
830 a378724f 2019-02-10 stsp return 1
831 a378724f 2019-02-10 stsp fi
832 ba8a0d4d 2019-02-10 stsp
833 a378724f 2019-02-10 stsp rm $testroot/wt/alpha
834 a378724f 2019-02-10 stsp
835 a378724f 2019-02-10 stsp echo "! alpha" > $testroot/stdout.expected
836 1545c615 2019-02-10 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
837 1545c615 2019-02-10 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
838 1545c615 2019-02-10 stsp echo >> $testroot/stdout.expected
839 a378724f 2019-02-10 stsp (cd $testroot/wt && got update > $testroot/stdout)
840 a378724f 2019-02-10 stsp
841 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
842 a378724f 2019-02-10 stsp ret="$?"
843 a378724f 2019-02-10 stsp if [ "$ret" != "0" ]; then
844 a378724f 2019-02-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
845 a378724f 2019-02-10 stsp test_done "$testroot" "$ret"
846 a378724f 2019-02-10 stsp return 1
847 a378724f 2019-02-10 stsp fi
848 a378724f 2019-02-10 stsp
849 a378724f 2019-02-10 stsp echo "alpha" > $testroot/content.expected
850 a378724f 2019-02-10 stsp
851 a378724f 2019-02-10 stsp cat $testroot/wt/alpha > $testroot/content
852 1430b4e0 2019-03-27 stsp
853 8d301dd9 2019-05-14 stsp cmp -s $testroot/content.expected $testroot/content
854 1430b4e0 2019-03-27 stsp ret="$?"
855 1430b4e0 2019-03-27 stsp if [ "$ret" != "0" ]; then
856 1430b4e0 2019-03-27 stsp diff -u $testroot/content.expected $testroot/content
857 1430b4e0 2019-03-27 stsp fi
858 1430b4e0 2019-03-27 stsp test_done "$testroot" "$ret"
859 1430b4e0 2019-03-27 stsp }
860 1430b4e0 2019-03-27 stsp
861 f6cae3ed 2020-09-13 naddy test_update_conflict_wt_add_vs_repo_add() {
862 085d5bcf 2019-03-27 stsp local testroot=`test_init update_conflict_wt_add_vs_repo_add`
863 1430b4e0 2019-03-27 stsp
864 1430b4e0 2019-03-27 stsp got checkout $testroot/repo $testroot/wt > /dev/null
865 1430b4e0 2019-03-27 stsp ret="$?"
866 1430b4e0 2019-03-27 stsp if [ "$ret" != "0" ]; then
867 1430b4e0 2019-03-27 stsp test_done "$testroot" "$ret"
868 1430b4e0 2019-03-27 stsp return 1
869 1430b4e0 2019-03-27 stsp fi
870 1430b4e0 2019-03-27 stsp
871 1430b4e0 2019-03-27 stsp echo "new" > $testroot/repo/gamma/new
872 1430b4e0 2019-03-27 stsp (cd $testroot/repo && git add .)
873 1430b4e0 2019-03-27 stsp git_commit $testroot/repo -m "adding a new file"
874 1430b4e0 2019-03-27 stsp
875 1430b4e0 2019-03-27 stsp echo "also new" > $testroot/wt/gamma/new
876 1430b4e0 2019-03-27 stsp (cd $testroot/wt && got add gamma/new >/dev/null)
877 1430b4e0 2019-03-27 stsp
878 1430b4e0 2019-03-27 stsp (cd $testroot/wt && got update > $testroot/stdout)
879 a378724f 2019-02-10 stsp
880 1430b4e0 2019-03-27 stsp echo "C gamma/new" > $testroot/stdout.expected
881 1430b4e0 2019-03-27 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
882 1430b4e0 2019-03-27 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
883 1430b4e0 2019-03-27 stsp echo >> $testroot/stdout.expected
884 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
885 9627c110 2020-04-18 stsp
886 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
887 1430b4e0 2019-03-27 stsp ret="$?"
888 1430b4e0 2019-03-27 stsp if [ "$ret" != "0" ]; then
889 1430b4e0 2019-03-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
890 1430b4e0 2019-03-27 stsp test_done "$testroot" "$ret"
891 1430b4e0 2019-03-27 stsp return 1
892 1430b4e0 2019-03-27 stsp fi
893 1430b4e0 2019-03-27 stsp
894 f69721c3 2019-10-21 stsp echo -n "<<<<<<< merged change: commit " > $testroot/content.expected
895 1430b4e0 2019-03-27 stsp git_show_head $testroot/repo >> $testroot/content.expected
896 1430b4e0 2019-03-27 stsp echo >> $testroot/content.expected
897 1430b4e0 2019-03-27 stsp echo "new" >> $testroot/content.expected
898 1430b4e0 2019-03-27 stsp echo "=======" >> $testroot/content.expected
899 1430b4e0 2019-03-27 stsp echo "also new" >> $testroot/content.expected
900 f69721c3 2019-10-21 stsp echo '>>>>>>>' >> $testroot/content.expected
901 1430b4e0 2019-03-27 stsp
902 1430b4e0 2019-03-27 stsp cat $testroot/wt/gamma/new > $testroot/content
903 1430b4e0 2019-03-27 stsp
904 8d301dd9 2019-05-14 stsp cmp -s $testroot/content.expected $testroot/content
905 a378724f 2019-02-10 stsp ret="$?"
906 a378724f 2019-02-10 stsp if [ "$ret" != "0" ]; then
907 a378724f 2019-02-10 stsp diff -u $testroot/content.expected $testroot/content
908 3165301c 2019-03-27 stsp test_done "$testroot" "$ret"
909 3165301c 2019-03-27 stsp return 1
910 3165301c 2019-03-27 stsp fi
911 3165301c 2019-03-27 stsp
912 3165301c 2019-03-27 stsp # resolve the conflict
913 3165301c 2019-03-27 stsp echo "new and also new" > $testroot/wt/gamma/new
914 3165301c 2019-03-27 stsp echo 'M gamma/new' > $testroot/stdout.expected
915 3165301c 2019-03-27 stsp (cd $testroot/wt && got status > $testroot/stdout)
916 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
917 3165301c 2019-03-27 stsp ret="$?"
918 3165301c 2019-03-27 stsp if [ "$ret" != "0" ]; then
919 3165301c 2019-03-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
920 a378724f 2019-02-10 stsp fi
921 a378724f 2019-02-10 stsp test_done "$testroot" "$ret"
922 a378724f 2019-02-10 stsp }
923 708d8e67 2019-03-27 stsp
924 f6cae3ed 2020-09-13 naddy test_update_conflict_wt_edit_vs_repo_rm() {
925 085d5bcf 2019-03-27 stsp local testroot=`test_init update_conflict_wt_edit_vs_repo_rm`
926 708d8e67 2019-03-27 stsp
927 708d8e67 2019-03-27 stsp got checkout $testroot/repo $testroot/wt > /dev/null
928 708d8e67 2019-03-27 stsp ret="$?"
929 708d8e67 2019-03-27 stsp if [ "$ret" != "0" ]; then
930 708d8e67 2019-03-27 stsp test_done "$testroot" "$ret"
931 708d8e67 2019-03-27 stsp return 1
932 708d8e67 2019-03-27 stsp fi
933 708d8e67 2019-03-27 stsp
934 708d8e67 2019-03-27 stsp (cd $testroot/repo && git rm -q beta)
935 708d8e67 2019-03-27 stsp git_commit $testroot/repo -m "removing a file"
936 708d8e67 2019-03-27 stsp
937 708d8e67 2019-03-27 stsp echo "modified beta" > $testroot/wt/beta
938 a378724f 2019-02-10 stsp
939 708d8e67 2019-03-27 stsp (cd $testroot/wt && got update > $testroot/stdout)
940 708d8e67 2019-03-27 stsp
941 fc6346c4 2019-03-27 stsp echo "G beta" > $testroot/stdout.expected
942 708d8e67 2019-03-27 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
943 708d8e67 2019-03-27 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
944 708d8e67 2019-03-27 stsp echo >> $testroot/stdout.expected
945 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
946 708d8e67 2019-03-27 stsp ret="$?"
947 708d8e67 2019-03-27 stsp if [ "$ret" != "0" ]; then
948 708d8e67 2019-03-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
949 708d8e67 2019-03-27 stsp test_done "$testroot" "$ret"
950 708d8e67 2019-03-27 stsp return 1
951 708d8e67 2019-03-27 stsp fi
952 708d8e67 2019-03-27 stsp
953 708d8e67 2019-03-27 stsp echo "modified beta" > $testroot/content.expected
954 708d8e67 2019-03-27 stsp
955 708d8e67 2019-03-27 stsp cat $testroot/wt/beta > $testroot/content
956 708d8e67 2019-03-27 stsp
957 8d301dd9 2019-05-14 stsp cmp -s $testroot/content.expected $testroot/content
958 708d8e67 2019-03-27 stsp ret="$?"
959 708d8e67 2019-03-27 stsp if [ "$ret" != "0" ]; then
960 708d8e67 2019-03-27 stsp diff -u $testroot/content.expected $testroot/content
961 708d8e67 2019-03-27 stsp test_done "$testroot" "$ret"
962 708d8e67 2019-03-27 stsp return 1
963 708d8e67 2019-03-27 stsp fi
964 708d8e67 2019-03-27 stsp
965 fc6346c4 2019-03-27 stsp # beta is now an added file... we don't flag tree conflicts yet
966 fc6346c4 2019-03-27 stsp echo 'A beta' > $testroot/stdout.expected
967 13d9040b 2019-03-27 stsp (cd $testroot/wt && got status > $testroot/stdout)
968 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
969 13d9040b 2019-03-27 stsp ret="$?"
970 13d9040b 2019-03-27 stsp if [ "$ret" != "0" ]; then
971 13d9040b 2019-03-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
972 13d9040b 2019-03-27 stsp fi
973 13d9040b 2019-03-27 stsp test_done "$testroot" "$ret"
974 13d9040b 2019-03-27 stsp }
975 13d9040b 2019-03-27 stsp
976 f6cae3ed 2020-09-13 naddy test_update_conflict_wt_rm_vs_repo_edit() {
977 13d9040b 2019-03-27 stsp local testroot=`test_init update_conflict_wt_rm_vs_repo_edit`
978 13d9040b 2019-03-27 stsp
979 13d9040b 2019-03-27 stsp got checkout $testroot/repo $testroot/wt > /dev/null
980 13d9040b 2019-03-27 stsp ret="$?"
981 13d9040b 2019-03-27 stsp if [ "$ret" != "0" ]; then
982 13d9040b 2019-03-27 stsp test_done "$testroot" "$ret"
983 13d9040b 2019-03-27 stsp return 1
984 13d9040b 2019-03-27 stsp fi
985 13d9040b 2019-03-27 stsp
986 13d9040b 2019-03-27 stsp echo "modified beta" > $testroot/repo/beta
987 13d9040b 2019-03-27 stsp git_commit $testroot/repo -m "modified a file"
988 13d9040b 2019-03-27 stsp
989 13d9040b 2019-03-27 stsp (cd $testroot/wt && got rm beta > /dev/null)
990 13d9040b 2019-03-27 stsp
991 13d9040b 2019-03-27 stsp (cd $testroot/wt && got update > $testroot/stdout)
992 13d9040b 2019-03-27 stsp
993 13d9040b 2019-03-27 stsp echo "G beta" > $testroot/stdout.expected
994 13d9040b 2019-03-27 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
995 13d9040b 2019-03-27 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
996 13d9040b 2019-03-27 stsp echo >> $testroot/stdout.expected
997 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
998 13d9040b 2019-03-27 stsp ret="$?"
999 13d9040b 2019-03-27 stsp if [ "$ret" != "0" ]; then
1000 13d9040b 2019-03-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
1001 13d9040b 2019-03-27 stsp test_done "$testroot" "$ret"
1002 13d9040b 2019-03-27 stsp return 1
1003 13d9040b 2019-03-27 stsp fi
1004 13d9040b 2019-03-27 stsp
1005 13d9040b 2019-03-27 stsp # beta remains a deleted file... we don't flag tree conflicts yet
1006 13d9040b 2019-03-27 stsp echo 'D beta' > $testroot/stdout.expected
1007 708d8e67 2019-03-27 stsp (cd $testroot/wt && got status > $testroot/stdout)
1008 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1009 708d8e67 2019-03-27 stsp ret="$?"
1010 708d8e67 2019-03-27 stsp if [ "$ret" != "0" ]; then
1011 708d8e67 2019-03-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
1012 13d9040b 2019-03-27 stsp test_done "$testroot" "$ret"
1013 13d9040b 2019-03-27 stsp return 1
1014 708d8e67 2019-03-27 stsp fi
1015 13d9040b 2019-03-27 stsp
1016 13d9040b 2019-03-27 stsp # 'got diff' should show post-update contents of beta being deleted
1017 13d9040b 2019-03-27 stsp local head_rev=`git_show_head $testroot/repo`
1018 13d9040b 2019-03-27 stsp echo "diff $head_rev $testroot/wt" > $testroot/stdout.expected
1019 13d9040b 2019-03-27 stsp echo -n 'blob - ' >> $testroot/stdout.expected
1020 13d9040b 2019-03-27 stsp got tree -r $testroot/repo -i | grep 'beta$' | cut -d' ' -f 1 \
1021 13d9040b 2019-03-27 stsp >> $testroot/stdout.expected
1022 13d9040b 2019-03-27 stsp echo 'file + /dev/null' >> $testroot/stdout.expected
1023 13d9040b 2019-03-27 stsp echo '--- beta' >> $testroot/stdout.expected
1024 1cb46f00 2020-11-21 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
1025 13d9040b 2019-03-27 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
1026 13d9040b 2019-03-27 stsp echo '-modified beta' >> $testroot/stdout.expected
1027 13d9040b 2019-03-27 stsp
1028 13d9040b 2019-03-27 stsp (cd $testroot/wt && got diff > $testroot/stdout)
1029 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1030 13d9040b 2019-03-27 stsp ret="$?"
1031 13d9040b 2019-03-27 stsp if [ "$ret" != "0" ]; then
1032 13d9040b 2019-03-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
1033 13d9040b 2019-03-27 stsp fi
1034 708d8e67 2019-03-27 stsp test_done "$testroot" "$ret"
1035 66b11bf5 2019-03-27 stsp }
1036 66b11bf5 2019-03-27 stsp
1037 f6cae3ed 2020-09-13 naddy test_update_conflict_wt_rm_vs_repo_rm() {
1038 66b11bf5 2019-03-27 stsp local testroot=`test_init update_conflict_wt_rm_vs_repo_rm`
1039 66b11bf5 2019-03-27 stsp
1040 66b11bf5 2019-03-27 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1041 66b11bf5 2019-03-27 stsp ret="$?"
1042 66b11bf5 2019-03-27 stsp if [ "$ret" != "0" ]; then
1043 66b11bf5 2019-03-27 stsp test_done "$testroot" "$ret"
1044 66b11bf5 2019-03-27 stsp return 1
1045 66b11bf5 2019-03-27 stsp fi
1046 66b11bf5 2019-03-27 stsp
1047 66b11bf5 2019-03-27 stsp (cd $testroot/repo && git rm -q beta)
1048 66b11bf5 2019-03-27 stsp git_commit $testroot/repo -m "removing a file"
1049 66b11bf5 2019-03-27 stsp
1050 66b11bf5 2019-03-27 stsp (cd $testroot/wt && got rm beta > /dev/null)
1051 66b11bf5 2019-03-27 stsp
1052 66b11bf5 2019-03-27 stsp (cd $testroot/wt && got update > $testroot/stdout)
1053 66b11bf5 2019-03-27 stsp
1054 66b11bf5 2019-03-27 stsp echo "D beta" > $testroot/stdout.expected
1055 66b11bf5 2019-03-27 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
1056 66b11bf5 2019-03-27 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1057 66b11bf5 2019-03-27 stsp echo >> $testroot/stdout.expected
1058 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1059 66b11bf5 2019-03-27 stsp ret="$?"
1060 66b11bf5 2019-03-27 stsp if [ "$ret" != "0" ]; then
1061 66b11bf5 2019-03-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
1062 66b11bf5 2019-03-27 stsp test_done "$testroot" "$ret"
1063 66b11bf5 2019-03-27 stsp return 1
1064 66b11bf5 2019-03-27 stsp fi
1065 66b11bf5 2019-03-27 stsp
1066 66b11bf5 2019-03-27 stsp # beta is now gone... we don't flag tree conflicts yet
1067 2a06fe5f 2019-08-24 stsp echo "N beta" > $testroot/stdout.expected
1068 54817d72 2019-07-27 stsp echo -n > $testroot/stderr.expected
1069 54817d72 2019-07-27 stsp (cd $testroot/wt && got status beta > $testroot/stdout \
1070 54817d72 2019-07-27 stsp 2> $testroot/stderr)
1071 54817d72 2019-07-27 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1072 54817d72 2019-07-27 stsp ret="$?"
1073 54817d72 2019-07-27 stsp if [ "$ret" != "0" ]; then
1074 54817d72 2019-07-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
1075 54817d72 2019-07-27 stsp test_done "$testroot" "$ret"
1076 54817d72 2019-07-27 stsp return 1
1077 54817d72 2019-07-27 stsp fi
1078 8d301dd9 2019-05-14 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1079 66b11bf5 2019-03-27 stsp ret="$?"
1080 66b11bf5 2019-03-27 stsp if [ "$ret" != "0" ]; then
1081 66b11bf5 2019-03-27 stsp diff -u $testroot/stderr.expected $testroot/stderr
1082 66b11bf5 2019-03-27 stsp test_done "$testroot" "$ret"
1083 66b11bf5 2019-03-27 stsp return 1
1084 66b11bf5 2019-03-27 stsp fi
1085 66b11bf5 2019-03-27 stsp
1086 66b11bf5 2019-03-27 stsp if [ -e $testroot/wt/beta ]; then
1087 66b11bf5 2019-03-27 stsp echo "removed file beta still exists on disk" >&2
1088 66b11bf5 2019-03-27 stsp test_done "$testroot" "1"
1089 66b11bf5 2019-03-27 stsp return 1
1090 66b11bf5 2019-03-27 stsp fi
1091 66b11bf5 2019-03-27 stsp
1092 66b11bf5 2019-03-27 stsp test_done "$testroot" "0"
1093 708d8e67 2019-03-27 stsp }
1094 c4cdcb68 2019-04-03 stsp
1095 f6cae3ed 2020-09-13 naddy test_update_partial() {
1096 c4cdcb68 2019-04-03 stsp local testroot=`test_init update_partial`
1097 c4cdcb68 2019-04-03 stsp
1098 c4cdcb68 2019-04-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1099 c4cdcb68 2019-04-03 stsp ret="$?"
1100 c4cdcb68 2019-04-03 stsp if [ "$ret" != "0" ]; then
1101 c4cdcb68 2019-04-03 stsp test_done "$testroot" "$ret"
1102 c4cdcb68 2019-04-03 stsp return 1
1103 c4cdcb68 2019-04-03 stsp fi
1104 708d8e67 2019-03-27 stsp
1105 c4cdcb68 2019-04-03 stsp echo "modified alpha" > $testroot/repo/alpha
1106 c4cdcb68 2019-04-03 stsp echo "modified beta" > $testroot/repo/beta
1107 c4cdcb68 2019-04-03 stsp echo "modified epsilon/zeta" > $testroot/repo/epsilon/zeta
1108 c4cdcb68 2019-04-03 stsp git_commit $testroot/repo -m "modified two files"
1109 c4cdcb68 2019-04-03 stsp
1110 f2ea84fa 2019-07-27 stsp echo "U alpha" > $testroot/stdout.expected
1111 f2ea84fa 2019-07-27 stsp echo "U beta" >> $testroot/stdout.expected
1112 f2ea84fa 2019-07-27 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
1113 f2ea84fa 2019-07-27 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1114 f2ea84fa 2019-07-27 stsp echo >> $testroot/stdout.expected
1115 c4cdcb68 2019-04-03 stsp
1116 f2ea84fa 2019-07-27 stsp (cd $testroot/wt && got update alpha beta > $testroot/stdout)
1117 c4cdcb68 2019-04-03 stsp
1118 f2ea84fa 2019-07-27 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1119 f2ea84fa 2019-07-27 stsp ret="$?"
1120 f2ea84fa 2019-07-27 stsp if [ "$ret" != "0" ]; then
1121 f2ea84fa 2019-07-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
1122 f2ea84fa 2019-07-27 stsp test_done "$testroot" "$ret"
1123 f2ea84fa 2019-07-27 stsp return 1
1124 f2ea84fa 2019-07-27 stsp fi
1125 c4cdcb68 2019-04-03 stsp
1126 f2ea84fa 2019-07-27 stsp echo "modified alpha" > $testroot/content.expected
1127 f2ea84fa 2019-07-27 stsp echo "modified beta" >> $testroot/content.expected
1128 f2ea84fa 2019-07-27 stsp
1129 f2ea84fa 2019-07-27 stsp cat $testroot/wt/alpha $testroot/wt/beta > $testroot/content
1130 f2ea84fa 2019-07-27 stsp cmp -s $testroot/content.expected $testroot/content
1131 f2ea84fa 2019-07-27 stsp ret="$?"
1132 f2ea84fa 2019-07-27 stsp if [ "$ret" != "0" ]; then
1133 f2ea84fa 2019-07-27 stsp diff -u $testroot/content.expected $testroot/content
1134 f2ea84fa 2019-07-27 stsp test_done "$testroot" "$ret"
1135 f2ea84fa 2019-07-27 stsp return 1
1136 f2ea84fa 2019-07-27 stsp fi
1137 e4d984c2 2019-05-22 stsp
1138 e4d984c2 2019-05-22 stsp echo "U epsilon/zeta" > $testroot/stdout.expected
1139 e4d984c2 2019-05-22 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
1140 e4d984c2 2019-05-22 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1141 e4d984c2 2019-05-22 stsp echo >> $testroot/stdout.expected
1142 e4d984c2 2019-05-22 stsp
1143 e4d984c2 2019-05-22 stsp (cd $testroot/wt && got update epsilon > $testroot/stdout)
1144 e4d984c2 2019-05-22 stsp
1145 e4d984c2 2019-05-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1146 e4d984c2 2019-05-22 stsp ret="$?"
1147 e4d984c2 2019-05-22 stsp if [ "$ret" != "0" ]; then
1148 e4d984c2 2019-05-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1149 e4d984c2 2019-05-22 stsp test_done "$testroot" "$ret"
1150 e4d984c2 2019-05-22 stsp return 1
1151 e4d984c2 2019-05-22 stsp fi
1152 e4d984c2 2019-05-22 stsp
1153 e4d984c2 2019-05-22 stsp echo "modified epsilon/zeta" > $testroot/content.expected
1154 e4d984c2 2019-05-22 stsp cat $testroot/wt/epsilon/zeta > $testroot/content
1155 e4d984c2 2019-05-22 stsp
1156 e4d984c2 2019-05-22 stsp cmp -s $testroot/content.expected $testroot/content
1157 e4d984c2 2019-05-22 stsp ret="$?"
1158 e4d984c2 2019-05-22 stsp if [ "$ret" != "0" ]; then
1159 e4d984c2 2019-05-22 stsp diff -u $testroot/content.expected $testroot/content
1160 e4d984c2 2019-05-22 stsp test_done "$testroot" "$ret"
1161 e4d984c2 2019-05-22 stsp return 1
1162 e4d984c2 2019-05-22 stsp fi
1163 e4d984c2 2019-05-22 stsp
1164 c4cdcb68 2019-04-03 stsp test_done "$testroot" "$ret"
1165 c4cdcb68 2019-04-03 stsp }
1166 c4cdcb68 2019-04-03 stsp
1167 f6cae3ed 2020-09-13 naddy test_update_partial_add() {
1168 c4cdcb68 2019-04-03 stsp local testroot=`test_init update_partial_add`
1169 c4cdcb68 2019-04-03 stsp
1170 c4cdcb68 2019-04-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1171 c4cdcb68 2019-04-03 stsp ret="$?"
1172 c4cdcb68 2019-04-03 stsp if [ "$ret" != "0" ]; then
1173 c4cdcb68 2019-04-03 stsp test_done "$testroot" "$ret"
1174 c4cdcb68 2019-04-03 stsp return 1
1175 c4cdcb68 2019-04-03 stsp fi
1176 c4cdcb68 2019-04-03 stsp
1177 c4cdcb68 2019-04-03 stsp echo "new" > $testroot/repo/new
1178 c4cdcb68 2019-04-03 stsp echo "epsilon/new2" > $testroot/repo/epsilon/new2
1179 c4cdcb68 2019-04-03 stsp (cd $testroot/repo && git add .)
1180 c4cdcb68 2019-04-03 stsp git_commit $testroot/repo -m "added two files"
1181 c4cdcb68 2019-04-03 stsp
1182 f2ea84fa 2019-07-27 stsp echo "A new" > $testroot/stdout.expected
1183 f2ea84fa 2019-07-27 stsp echo "A epsilon/new2" >> $testroot/stdout.expected
1184 f2ea84fa 2019-07-27 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
1185 f2ea84fa 2019-07-27 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1186 f2ea84fa 2019-07-27 stsp echo >> $testroot/stdout.expected
1187 c4cdcb68 2019-04-03 stsp
1188 f2ea84fa 2019-07-27 stsp (cd $testroot/wt && got update new epsilon/new2 > $testroot/stdout)
1189 c4cdcb68 2019-04-03 stsp
1190 f2ea84fa 2019-07-27 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1191 f2ea84fa 2019-07-27 stsp ret="$?"
1192 f2ea84fa 2019-07-27 stsp if [ "$ret" != "0" ]; then
1193 f2ea84fa 2019-07-27 stsp diff -u $testroot/stdout.expected $testroot/stdout
1194 f2ea84fa 2019-07-27 stsp test_done "$testroot" "$ret"
1195 f2ea84fa 2019-07-27 stsp return 1
1196 f2ea84fa 2019-07-27 stsp fi
1197 c4cdcb68 2019-04-03 stsp
1198 f2ea84fa 2019-07-27 stsp echo "new" > $testroot/content.expected
1199 f2ea84fa 2019-07-27 stsp echo "epsilon/new2" >> $testroot/content.expected
1200 c4cdcb68 2019-04-03 stsp
1201 f2ea84fa 2019-07-27 stsp cat $testroot/wt/new $testroot/wt/epsilon/new2 > $testroot/content
1202 f2ea84fa 2019-07-27 stsp
1203 f2ea84fa 2019-07-27 stsp cmp -s $testroot/content.expected $testroot/content
1204 f2ea84fa 2019-07-27 stsp ret="$?"
1205 f2ea84fa 2019-07-27 stsp if [ "$ret" != "0" ]; then
1206 f2ea84fa 2019-07-27 stsp diff -u $testroot/content.expected $testroot/content
1207 f2ea84fa 2019-07-27 stsp fi
1208 c4cdcb68 2019-04-03 stsp test_done "$testroot" "$ret"
1209 c4cdcb68 2019-04-03 stsp }
1210 c4cdcb68 2019-04-03 stsp
1211 f6cae3ed 2020-09-13 naddy test_update_partial_rm() {
1212 c4cdcb68 2019-04-03 stsp local testroot=`test_init update_partial_rm`
1213 c4cdcb68 2019-04-03 stsp
1214 c4cdcb68 2019-04-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1215 c4cdcb68 2019-04-03 stsp ret="$?"
1216 c4cdcb68 2019-04-03 stsp if [ "$ret" != "0" ]; then
1217 c4cdcb68 2019-04-03 stsp test_done "$testroot" "$ret"
1218 c4cdcb68 2019-04-03 stsp return 1
1219 c4cdcb68 2019-04-03 stsp fi
1220 c4cdcb68 2019-04-03 stsp
1221 f2ea84fa 2019-07-27 stsp (cd $testroot/repo && git rm -q alpha epsilon/zeta)
1222 c4cdcb68 2019-04-03 stsp git_commit $testroot/repo -m "removed two files"
1223 c4cdcb68 2019-04-03 stsp
1224 b66cd6f3 2020-07-31 stsp echo "got: /alpha: no such entry found in tree" \
1225 f2ea84fa 2019-07-27 stsp > $testroot/stderr.expected
1226 f2ea84fa 2019-07-27 stsp
1227 f2ea84fa 2019-07-27 stsp (cd $testroot/wt && got update alpha epsilon/zeta 2> $testroot/stderr)
1228 f2ea84fa 2019-07-27 stsp ret="$?"
1229 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
1230 f2ea84fa 2019-07-27 stsp echo "update succeeded unexpectedly" >&2
1231 f2ea84fa 2019-07-27 stsp test_done "$testroot" "1"
1232 f2ea84fa 2019-07-27 stsp return 1
1233 f2ea84fa 2019-07-27 stsp fi
1234 c4cdcb68 2019-04-03 stsp
1235 f2ea84fa 2019-07-27 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1236 f2ea84fa 2019-07-27 stsp ret="$?"
1237 f2ea84fa 2019-07-27 stsp if [ "$ret" != "0" ]; then
1238 f2ea84fa 2019-07-27 stsp diff -u $testroot/stderr.expected $testroot/stderr
1239 f2ea84fa 2019-07-27 stsp test_done "$testroot" "$ret"
1240 f2ea84fa 2019-07-27 stsp return 1
1241 f2ea84fa 2019-07-27 stsp fi
1242 c4cdcb68 2019-04-03 stsp test_done "$testroot" "$ret"
1243 c4cdcb68 2019-04-03 stsp }
1244 c4cdcb68 2019-04-03 stsp
1245 f6cae3ed 2020-09-13 naddy test_update_partial_dir() {
1246 c4cdcb68 2019-04-03 stsp local testroot=`test_init update_partial_dir`
1247 c4cdcb68 2019-04-03 stsp
1248 c4cdcb68 2019-04-03 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1249 c4cdcb68 2019-04-03 stsp ret="$?"
1250 c4cdcb68 2019-04-03 stsp if [ "$ret" != "0" ]; then
1251 c4cdcb68 2019-04-03 stsp test_done "$testroot" "$ret"
1252 c4cdcb68 2019-04-03 stsp return 1
1253 c4cdcb68 2019-04-03 stsp fi
1254 c4cdcb68 2019-04-03 stsp
1255 c4cdcb68 2019-04-03 stsp echo "modified alpha" > $testroot/repo/alpha
1256 c4cdcb68 2019-04-03 stsp echo "modified beta" > $testroot/repo/beta
1257 c4cdcb68 2019-04-03 stsp echo "modified epsilon/zeta" > $testroot/repo/epsilon/zeta
1258 c4cdcb68 2019-04-03 stsp git_commit $testroot/repo -m "modified two files"
1259 c4cdcb68 2019-04-03 stsp
1260 c4cdcb68 2019-04-03 stsp echo "U epsilon/zeta" > $testroot/stdout.expected
1261 c4cdcb68 2019-04-03 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
1262 c4cdcb68 2019-04-03 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1263 c4cdcb68 2019-04-03 stsp echo >> $testroot/stdout.expected
1264 c4cdcb68 2019-04-03 stsp
1265 c4cdcb68 2019-04-03 stsp (cd $testroot/wt && got update epsilon > $testroot/stdout)
1266 c4cdcb68 2019-04-03 stsp
1267 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1268 c4cdcb68 2019-04-03 stsp ret="$?"
1269 c4cdcb68 2019-04-03 stsp if [ "$ret" != "0" ]; then
1270 c4cdcb68 2019-04-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
1271 c4cdcb68 2019-04-03 stsp test_done "$testroot" "$ret"
1272 c4cdcb68 2019-04-03 stsp return 1
1273 c4cdcb68 2019-04-03 stsp fi
1274 c4cdcb68 2019-04-03 stsp
1275 c4cdcb68 2019-04-03 stsp echo "modified epsilon/zeta" > $testroot/content.expected
1276 c4cdcb68 2019-04-03 stsp cat $testroot/wt/epsilon/zeta > $testroot/content
1277 c4cdcb68 2019-04-03 stsp
1278 8d301dd9 2019-05-14 stsp cmp -s $testroot/content.expected $testroot/content
1279 c4cdcb68 2019-04-03 stsp ret="$?"
1280 c4cdcb68 2019-04-03 stsp if [ "$ret" != "0" ]; then
1281 c4cdcb68 2019-04-03 stsp diff -u $testroot/content.expected $testroot/content
1282 c4cdcb68 2019-04-03 stsp test_done "$testroot" "$ret"
1283 c4cdcb68 2019-04-03 stsp return 1
1284 c4cdcb68 2019-04-03 stsp fi
1285 c4cdcb68 2019-04-03 stsp test_done "$testroot" "$ret"
1286 d5bea539 2019-05-13 stsp
1287 d5bea539 2019-05-13 stsp }
1288 d5bea539 2019-05-13 stsp
1289 f6cae3ed 2020-09-13 naddy test_update_moved_branch_ref() {
1290 d5bea539 2019-05-13 stsp local testroot=`test_init update_moved_branch_ref`
1291 d5bea539 2019-05-13 stsp
1292 d5bea539 2019-05-13 stsp git clone -q --mirror $testroot/repo $testroot/repo2
1293 d5bea539 2019-05-13 stsp
1294 d5bea539 2019-05-13 stsp echo "modified alpha with git" > $testroot/repo/alpha
1295 d5bea539 2019-05-13 stsp git_commit $testroot/repo -m "modified alpha with git"
1296 d5bea539 2019-05-13 stsp
1297 d5bea539 2019-05-13 stsp got checkout $testroot/repo2 $testroot/wt > /dev/null
1298 d5bea539 2019-05-13 stsp ret="$?"
1299 d5bea539 2019-05-13 stsp if [ "$ret" != "0" ]; then
1300 d5bea539 2019-05-13 stsp test_done "$testroot" "$ret"
1301 d5bea539 2019-05-13 stsp return 1
1302 d5bea539 2019-05-13 stsp fi
1303 d5bea539 2019-05-13 stsp
1304 d5bea539 2019-05-13 stsp echo "modified alpha with got" > $testroot/wt/alpha
1305 d5bea539 2019-05-13 stsp (cd $testroot/wt && got commit -m "modified alpha with got" > /dev/null)
1306 d5bea539 2019-05-13 stsp
1307 d5bea539 2019-05-13 stsp # + xxxxxxx...yyyyyyy master -> master (forced update)
1308 d5bea539 2019-05-13 stsp (cd $testroot/repo2 && git fetch -q --all)
1309 c4cdcb68 2019-04-03 stsp
1310 d5bea539 2019-05-13 stsp echo -n > $testroot/stdout.expected
1311 a1fb16d8 2019-05-24 stsp echo -n "got: work tree's head reference now points to a different " \
1312 a367ff0f 2019-05-14 stsp > $testroot/stderr.expected
1313 a1fb16d8 2019-05-24 stsp echo "branch; new head reference and/or update -b required" \
1314 a1fb16d8 2019-05-24 stsp >> $testroot/stderr.expected
1315 d5bea539 2019-05-13 stsp
1316 d5bea539 2019-05-13 stsp (cd $testroot/wt && got update > $testroot/stdout 2> $testroot/stderr)
1317 d5bea539 2019-05-13 stsp
1318 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1319 d5bea539 2019-05-13 stsp ret="$?"
1320 d5bea539 2019-05-13 stsp if [ "$ret" != "0" ]; then
1321 d5bea539 2019-05-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
1322 d5bea539 2019-05-13 stsp test_done "$testroot" "$ret"
1323 d5bea539 2019-05-13 stsp return 1
1324 d5bea539 2019-05-13 stsp fi
1325 d5bea539 2019-05-13 stsp
1326 8d301dd9 2019-05-14 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1327 d5bea539 2019-05-13 stsp ret="$?"
1328 d5bea539 2019-05-13 stsp if [ "$ret" != "0" ]; then
1329 d5bea539 2019-05-13 stsp diff -u $testroot/stderr.expected $testroot/stderr
1330 d5bea539 2019-05-13 stsp fi
1331 d5bea539 2019-05-13 stsp test_done "$testroot" "$ret"
1332 c4cdcb68 2019-04-03 stsp }
1333 024e9686 2019-05-14 stsp
1334 f6cae3ed 2020-09-13 naddy test_update_to_another_branch() {
1335 024e9686 2019-05-14 stsp local testroot=`test_init update_to_another_branch`
1336 f69721c3 2019-10-21 stsp local base_commit=`git_show_head $testroot/repo`
1337 024e9686 2019-05-14 stsp
1338 024e9686 2019-05-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1339 024e9686 2019-05-14 stsp ret="$?"
1340 024e9686 2019-05-14 stsp if [ "$ret" != "0" ]; then
1341 024e9686 2019-05-14 stsp test_done "$testroot" "$ret"
1342 024e9686 2019-05-14 stsp return 1
1343 024e9686 2019-05-14 stsp fi
1344 024e9686 2019-05-14 stsp
1345 024e9686 2019-05-14 stsp echo 'refs/heads/master'> $testroot/head-ref.expected
1346 024e9686 2019-05-14 stsp cmp -s $testroot/head-ref.expected $testroot/wt/.got/head-ref
1347 024e9686 2019-05-14 stsp ret="$?"
1348 024e9686 2019-05-14 stsp if [ "$ret" != "0" ]; then
1349 024e9686 2019-05-14 stsp diff -u $testroot/head-ref.expected $testroot/wt/.got/head-ref
1350 024e9686 2019-05-14 stsp test_done "$testroot" "$ret"
1351 024e9686 2019-05-14 stsp return 1
1352 024e9686 2019-05-14 stsp fi
1353 024e9686 2019-05-14 stsp
1354 024e9686 2019-05-14 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1355 024e9686 2019-05-14 stsp echo "modified alpha on new branch" > $testroot/repo/alpha
1356 024e9686 2019-05-14 stsp git_commit $testroot/repo -m "modified alpha on new branch"
1357 024e9686 2019-05-14 stsp
1358 024e9686 2019-05-14 stsp echo "modified alpha in work tree" > $testroot/wt/alpha
1359 024e9686 2019-05-14 stsp
1360 d969fa15 2019-05-22 stsp echo "Switching work tree from refs/heads/master to refs/heads/newbranch" > $testroot/stdout.expected
1361 d969fa15 2019-05-22 stsp echo "C alpha" >> $testroot/stdout.expected
1362 024e9686 2019-05-14 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
1363 024e9686 2019-05-14 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1364 024e9686 2019-05-14 stsp echo >> $testroot/stdout.expected
1365 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
1366 024e9686 2019-05-14 stsp
1367 024e9686 2019-05-14 stsp (cd $testroot/wt && got update -b newbranch > $testroot/stdout)
1368 024e9686 2019-05-14 stsp
1369 024e9686 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1370 024e9686 2019-05-14 stsp ret="$?"
1371 024e9686 2019-05-14 stsp if [ "$ret" != "0" ]; then
1372 024e9686 2019-05-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1373 024e9686 2019-05-14 stsp test_done "$testroot" "$ret"
1374 024e9686 2019-05-14 stsp return 1
1375 024e9686 2019-05-14 stsp fi
1376 c4cdcb68 2019-04-03 stsp
1377 f69721c3 2019-10-21 stsp echo -n "<<<<<<< merged change: commit " > $testroot/content.expected
1378 024e9686 2019-05-14 stsp git_show_head $testroot/repo >> $testroot/content.expected
1379 024e9686 2019-05-14 stsp echo >> $testroot/content.expected
1380 024e9686 2019-05-14 stsp echo "modified alpha on new branch" >> $testroot/content.expected
1381 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $base_commit" \
1382 f69721c3 2019-10-21 stsp >> $testroot/content.expected
1383 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
1384 024e9686 2019-05-14 stsp echo "=======" >> $testroot/content.expected
1385 024e9686 2019-05-14 stsp echo "modified alpha in work tree" >> $testroot/content.expected
1386 f69721c3 2019-10-21 stsp echo '>>>>>>>' >> $testroot/content.expected
1387 d5bea539 2019-05-13 stsp
1388 024e9686 2019-05-14 stsp cat $testroot/wt/alpha > $testroot/content
1389 024e9686 2019-05-14 stsp
1390 024e9686 2019-05-14 stsp cmp -s $testroot/content.expected $testroot/content
1391 024e9686 2019-05-14 stsp ret="$?"
1392 024e9686 2019-05-14 stsp if [ "$ret" != "0" ]; then
1393 024e9686 2019-05-14 stsp diff -u $testroot/content.expected $testroot/content
1394 024e9686 2019-05-14 stsp test_done "$testroot" "$ret"
1395 024e9686 2019-05-14 stsp return 1
1396 024e9686 2019-05-14 stsp fi
1397 024e9686 2019-05-14 stsp
1398 024e9686 2019-05-14 stsp echo 'refs/heads/newbranch'> $testroot/head-ref.expected
1399 024e9686 2019-05-14 stsp cmp -s $testroot/head-ref.expected $testroot/wt/.got/head-ref
1400 024e9686 2019-05-14 stsp ret="$?"
1401 024e9686 2019-05-14 stsp if [ "$ret" != "0" ]; then
1402 024e9686 2019-05-14 stsp diff -u $testroot/head-ref.expected $testroot/wt/.got/head-ref
1403 a367ff0f 2019-05-14 stsp test_done "$testroot" "$ret"
1404 a367ff0f 2019-05-14 stsp return 1
1405 a367ff0f 2019-05-14 stsp fi
1406 a367ff0f 2019-05-14 stsp
1407 a367ff0f 2019-05-14 stsp test_done "$testroot" "$ret"
1408 a367ff0f 2019-05-14 stsp }
1409 a367ff0f 2019-05-14 stsp
1410 f6cae3ed 2020-09-13 naddy test_update_to_commit_on_wrong_branch() {
1411 a367ff0f 2019-05-14 stsp local testroot=`test_init update_to_commit_on_wrong_branch`
1412 a367ff0f 2019-05-14 stsp
1413 a367ff0f 2019-05-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1414 a367ff0f 2019-05-14 stsp ret="$?"
1415 a367ff0f 2019-05-14 stsp if [ "$ret" != "0" ]; then
1416 a367ff0f 2019-05-14 stsp test_done "$testroot" "$ret"
1417 a367ff0f 2019-05-14 stsp return 1
1418 a367ff0f 2019-05-14 stsp fi
1419 a367ff0f 2019-05-14 stsp
1420 a367ff0f 2019-05-14 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1421 a367ff0f 2019-05-14 stsp echo "modified alpha on new branch" > $testroot/repo/alpha
1422 a367ff0f 2019-05-14 stsp git_commit $testroot/repo -m "modified alpha on new branch"
1423 a367ff0f 2019-05-14 stsp
1424 a367ff0f 2019-05-14 stsp echo -n "" > $testroot/stdout.expected
1425 a367ff0f 2019-05-14 stsp echo "got: target commit is on a different branch" \
1426 a367ff0f 2019-05-14 stsp > $testroot/stderr.expected
1427 a367ff0f 2019-05-14 stsp
1428 a367ff0f 2019-05-14 stsp local head_rev=`git_show_head $testroot/repo`
1429 a367ff0f 2019-05-14 stsp (cd $testroot/wt && got update -c $head_rev > $testroot/stdout \
1430 a367ff0f 2019-05-14 stsp 2> $testroot/stderr)
1431 a367ff0f 2019-05-14 stsp
1432 a367ff0f 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1433 a367ff0f 2019-05-14 stsp ret="$?"
1434 a367ff0f 2019-05-14 stsp if [ "$ret" != "0" ]; then
1435 a367ff0f 2019-05-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1436 024e9686 2019-05-14 stsp test_done "$testroot" "$ret"
1437 024e9686 2019-05-14 stsp return 1
1438 024e9686 2019-05-14 stsp fi
1439 024e9686 2019-05-14 stsp
1440 a367ff0f 2019-05-14 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1441 a367ff0f 2019-05-14 stsp ret="$?"
1442 a367ff0f 2019-05-14 stsp if [ "$ret" != "0" ]; then
1443 a367ff0f 2019-05-14 stsp diff -u $testroot/stderr.expected $testroot/stderr
1444 a367ff0f 2019-05-14 stsp test_done "$testroot" "$ret"
1445 a367ff0f 2019-05-14 stsp return 1
1446 a367ff0f 2019-05-14 stsp fi
1447 a367ff0f 2019-05-14 stsp
1448 024e9686 2019-05-14 stsp test_done "$testroot" "$ret"
1449 024e9686 2019-05-14 stsp }
1450 c932eeeb 2019-05-22 stsp
1451 f6cae3ed 2020-09-13 naddy test_update_bumps_base_commit_id() {
1452 a5e55564 2019-06-10 stsp local testroot=`test_init update_bumps_base_commit_id`
1453 c932eeeb 2019-05-22 stsp
1454 1a36436d 2019-06-10 stsp echo "psi" > $testroot/repo/epsilon/psi
1455 1a36436d 2019-06-10 stsp (cd $testroot/repo && git add .)
1456 1a36436d 2019-06-10 stsp git_commit $testroot/repo -m "adding another file"
1457 1a36436d 2019-06-10 stsp
1458 c932eeeb 2019-05-22 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1459 c932eeeb 2019-05-22 stsp ret="$?"
1460 c932eeeb 2019-05-22 stsp if [ "$ret" != "0" ]; then
1461 c932eeeb 2019-05-22 stsp test_done "$testroot" "$ret"
1462 c932eeeb 2019-05-22 stsp return 1
1463 c932eeeb 2019-05-22 stsp fi
1464 024e9686 2019-05-14 stsp
1465 1a36436d 2019-06-10 stsp echo "modified psi" > $testroot/wt/epsilon/psi
1466 1a36436d 2019-06-10 stsp (cd $testroot/wt && got commit -m "changed psi" > $testroot/stdout)
1467 c932eeeb 2019-05-22 stsp
1468 c932eeeb 2019-05-22 stsp local head_rev=`git_show_head $testroot/repo`
1469 1a36436d 2019-06-10 stsp echo "M epsilon/psi" > $testroot/stdout.expected
1470 a7648d7a 2019-06-02 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1471 c932eeeb 2019-05-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1472 c932eeeb 2019-05-22 stsp ret="$?"
1473 c932eeeb 2019-05-22 stsp if [ "$ret" != "0" ]; then
1474 c932eeeb 2019-05-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1475 c932eeeb 2019-05-22 stsp test_done "$testroot" "$ret"
1476 c932eeeb 2019-05-22 stsp return 1
1477 c932eeeb 2019-05-22 stsp fi
1478 9bead371 2019-07-28 stsp
1479 305993b9 2019-07-28 stsp echo "changed zeta with git" > $testroot/repo/epsilon/zeta
1480 9bead371 2019-07-28 stsp (cd $testroot/repo && git add .)
1481 9bead371 2019-07-28 stsp git_commit $testroot/repo -m "changing zeta with git"
1482 c932eeeb 2019-05-22 stsp
1483 1a36436d 2019-06-10 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
1484 1a36436d 2019-06-10 stsp (cd $testroot/wt && got commit -m "changed zeta" > $testroot/stdout \
1485 c932eeeb 2019-05-22 stsp 2> $testroot/stderr)
1486 c932eeeb 2019-05-22 stsp
1487 c932eeeb 2019-05-22 stsp echo -n "" > $testroot/stdout.expected
1488 c932eeeb 2019-05-22 stsp echo "got: work tree must be updated before these changes can be committed" > $testroot/stderr.expected
1489 c932eeeb 2019-05-22 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1490 c932eeeb 2019-05-22 stsp ret="$?"
1491 c932eeeb 2019-05-22 stsp if [ "$ret" != "0" ]; then
1492 c932eeeb 2019-05-22 stsp diff -u $testroot/stderr.expected $testroot/stderr
1493 c932eeeb 2019-05-22 stsp test_done "$testroot" "$ret"
1494 c932eeeb 2019-05-22 stsp return 1
1495 c932eeeb 2019-05-22 stsp fi
1496 c932eeeb 2019-05-22 stsp
1497 c932eeeb 2019-05-22 stsp (cd $testroot/wt && got update > $testroot/stdout)
1498 c932eeeb 2019-05-22 stsp
1499 9bead371 2019-07-28 stsp echo "U epsilon/psi" > $testroot/stdout.expected
1500 9bead371 2019-07-28 stsp echo "C epsilon/zeta" >> $testroot/stdout.expected
1501 a484d721 2019-06-10 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
1502 a484d721 2019-06-10 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1503 a484d721 2019-06-10 stsp echo >> $testroot/stdout.expected
1504 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
1505 9627c110 2020-04-18 stsp
1506 c932eeeb 2019-05-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1507 c932eeeb 2019-05-22 stsp ret="$?"
1508 c932eeeb 2019-05-22 stsp if [ "$ret" != "0" ]; then
1509 c932eeeb 2019-05-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1510 c932eeeb 2019-05-22 stsp test_done "$testroot" "$ret"
1511 c932eeeb 2019-05-22 stsp return 1
1512 c932eeeb 2019-05-22 stsp fi
1513 c932eeeb 2019-05-22 stsp
1514 9bead371 2019-07-28 stsp # resolve conflict
1515 9bead371 2019-07-28 stsp echo "modified zeta with got and git" > $testroot/wt/epsilon/zeta
1516 9bead371 2019-07-28 stsp
1517 1a36436d 2019-06-10 stsp (cd $testroot/wt && got commit -m "changed zeta" > $testroot/stdout)
1518 c932eeeb 2019-05-22 stsp
1519 c932eeeb 2019-05-22 stsp local head_rev=`git_show_head $testroot/repo`
1520 1a36436d 2019-06-10 stsp echo "M epsilon/zeta" > $testroot/stdout.expected
1521 a7648d7a 2019-06-02 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1522 303e2782 2019-08-09 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1523 303e2782 2019-08-09 stsp ret="$?"
1524 303e2782 2019-08-09 stsp if [ "$ret" != "0" ]; then
1525 303e2782 2019-08-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
1526 303e2782 2019-08-09 stsp test_done "$testroot" "$ret"
1527 303e2782 2019-08-09 stsp return 1
1528 303e2782 2019-08-09 stsp fi
1529 303e2782 2019-08-09 stsp
1530 303e2782 2019-08-09 stsp test_done "$testroot" "$ret"
1531 303e2782 2019-08-09 stsp }
1532 303e2782 2019-08-09 stsp
1533 f6cae3ed 2020-09-13 naddy test_update_tag() {
1534 303e2782 2019-08-09 stsp local testroot=`test_init update_tag`
1535 303e2782 2019-08-09 stsp local tag="1.0.0"
1536 303e2782 2019-08-09 stsp
1537 303e2782 2019-08-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1538 303e2782 2019-08-09 stsp ret="$?"
1539 303e2782 2019-08-09 stsp if [ "$ret" != "0" ]; then
1540 303e2782 2019-08-09 stsp test_done "$testroot" "$ret"
1541 303e2782 2019-08-09 stsp return 1
1542 303e2782 2019-08-09 stsp fi
1543 303e2782 2019-08-09 stsp
1544 303e2782 2019-08-09 stsp echo "modified alpha" > $testroot/repo/alpha
1545 303e2782 2019-08-09 stsp git_commit $testroot/repo -m "modified alpha"
1546 303e2782 2019-08-09 stsp (cd $testroot/repo && git tag -m "test" -a $tag)
1547 303e2782 2019-08-09 stsp
1548 303e2782 2019-08-09 stsp echo "U alpha" > $testroot/stdout.expected
1549 303e2782 2019-08-09 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
1550 303e2782 2019-08-09 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1551 303e2782 2019-08-09 stsp echo >> $testroot/stdout.expected
1552 303e2782 2019-08-09 stsp
1553 303e2782 2019-08-09 stsp (cd $testroot/wt && got update -c $tag > $testroot/stdout)
1554 303e2782 2019-08-09 stsp
1555 c932eeeb 2019-05-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1556 c932eeeb 2019-05-22 stsp ret="$?"
1557 c932eeeb 2019-05-22 stsp if [ "$ret" != "0" ]; then
1558 c932eeeb 2019-05-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1559 c932eeeb 2019-05-22 stsp test_done "$testroot" "$ret"
1560 c932eeeb 2019-05-22 stsp return 1
1561 c932eeeb 2019-05-22 stsp fi
1562 c932eeeb 2019-05-22 stsp
1563 303e2782 2019-08-09 stsp echo "modified alpha" > $testroot/content.expected
1564 303e2782 2019-08-09 stsp cat $testroot/wt/alpha > $testroot/content
1565 303e2782 2019-08-09 stsp
1566 303e2782 2019-08-09 stsp cmp -s $testroot/content.expected $testroot/content
1567 303e2782 2019-08-09 stsp ret="$?"
1568 303e2782 2019-08-09 stsp if [ "$ret" != "0" ]; then
1569 303e2782 2019-08-09 stsp diff -u $testroot/content.expected $testroot/content
1570 523b8417 2019-10-19 stsp fi
1571 523b8417 2019-10-19 stsp test_done "$testroot" "$ret"
1572 523b8417 2019-10-19 stsp }
1573 523b8417 2019-10-19 stsp
1574 f6cae3ed 2020-09-13 naddy test_update_toggles_xbit() {
1575 523b8417 2019-10-19 stsp local testroot=`test_init update_toggles_xbit 1`
1576 523b8417 2019-10-19 stsp
1577 523b8417 2019-10-19 stsp touch $testroot/repo/xfile
1578 523b8417 2019-10-19 stsp chmod +x $testroot/repo/xfile
1579 523b8417 2019-10-19 stsp (cd $testroot/repo && git add .)
1580 523b8417 2019-10-19 stsp git_commit $testroot/repo -m "adding executable file"
1581 523b8417 2019-10-19 stsp local commit_id1=`git_show_head $testroot/repo`
1582 523b8417 2019-10-19 stsp
1583 523b8417 2019-10-19 stsp got checkout $testroot/repo $testroot/wt > $testroot/stdout
1584 523b8417 2019-10-19 stsp ret="$?"
1585 523b8417 2019-10-19 stsp if [ "$ret" != "0" ]; then
1586 523b8417 2019-10-19 stsp test_done "$testroot" "$ret"
1587 523b8417 2019-10-19 stsp return 1
1588 523b8417 2019-10-19 stsp fi
1589 523b8417 2019-10-19 stsp
1590 523b8417 2019-10-19 stsp ls -l $testroot/wt/xfile | grep -q '^-rwx'
1591 523b8417 2019-10-19 stsp ret="$?"
1592 523b8417 2019-10-19 stsp if [ "$ret" != "0" ]; then
1593 523b8417 2019-10-19 stsp echo "file is not executable" >&2
1594 523b8417 2019-10-19 stsp ls -l $testroot/wt/xfile >&2
1595 523b8417 2019-10-19 stsp test_done "$testroot" "$ret"
1596 523b8417 2019-10-19 stsp return 1
1597 523b8417 2019-10-19 stsp fi
1598 523b8417 2019-10-19 stsp
1599 523b8417 2019-10-19 stsp chmod -x $testroot/wt/xfile
1600 523b8417 2019-10-19 stsp (cd $testroot/wt && got commit -m "clear x bit" >/dev/null)
1601 523b8417 2019-10-19 stsp local commit_id2=`git_show_head $testroot/repo`
1602 523b8417 2019-10-19 stsp
1603 523b8417 2019-10-19 stsp echo "U xfile" > $testroot/stdout.expected
1604 523b8417 2019-10-19 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
1605 523b8417 2019-10-19 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1606 523b8417 2019-10-19 stsp echo >> $testroot/stdout.expected
1607 523b8417 2019-10-19 stsp
1608 523b8417 2019-10-19 stsp (cd $testroot/wt && got update -c $commit_id1 > $testroot/stdout)
1609 523b8417 2019-10-19 stsp ret="$?"
1610 523b8417 2019-10-19 stsp if [ "$ret" != "0" ]; then
1611 523b8417 2019-10-19 stsp test_done "$testroot" "$ret"
1612 523b8417 2019-10-19 stsp return 1
1613 523b8417 2019-10-19 stsp fi
1614 523b8417 2019-10-19 stsp
1615 523b8417 2019-10-19 stsp echo "U xfile" > $testroot/stdout.expected
1616 523b8417 2019-10-19 stsp echo "Updated to commit $commit_id1" >> $testroot/stdout.expected
1617 523b8417 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1618 523b8417 2019-10-19 stsp ret="$?"
1619 523b8417 2019-10-19 stsp if [ "$ret" != "0" ]; then
1620 523b8417 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
1621 523b8417 2019-10-19 stsp test_done "$testroot" "$ret"
1622 523b8417 2019-10-19 stsp return 1
1623 303e2782 2019-08-09 stsp fi
1624 523b8417 2019-10-19 stsp
1625 523b8417 2019-10-19 stsp
1626 523b8417 2019-10-19 stsp ls -l $testroot/wt/xfile | grep -q '^-rwx'
1627 523b8417 2019-10-19 stsp ret="$?"
1628 523b8417 2019-10-19 stsp if [ "$ret" != "0" ]; then
1629 523b8417 2019-10-19 stsp echo "file is not executable" >&2
1630 523b8417 2019-10-19 stsp ls -l $testroot/wt/xfile >&2
1631 523b8417 2019-10-19 stsp test_done "$testroot" "$ret"
1632 523b8417 2019-10-19 stsp return 1
1633 523b8417 2019-10-19 stsp fi
1634 523b8417 2019-10-19 stsp
1635 523b8417 2019-10-19 stsp (cd $testroot/wt && got update > $testroot/stdout)
1636 523b8417 2019-10-19 stsp ret="$?"
1637 523b8417 2019-10-19 stsp if [ "$ret" != "0" ]; then
1638 523b8417 2019-10-19 stsp test_done "$testroot" "$ret"
1639 523b8417 2019-10-19 stsp return 1
1640 523b8417 2019-10-19 stsp fi
1641 523b8417 2019-10-19 stsp
1642 523b8417 2019-10-19 stsp echo "U xfile" > $testroot/stdout.expected
1643 523b8417 2019-10-19 stsp echo "Updated to commit $commit_id2" >> $testroot/stdout.expected
1644 523b8417 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1645 523b8417 2019-10-19 stsp ret="$?"
1646 523b8417 2019-10-19 stsp if [ "$ret" != "0" ]; then
1647 523b8417 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
1648 523b8417 2019-10-19 stsp test_done "$testroot" "$ret"
1649 523b8417 2019-10-19 stsp return 1
1650 523b8417 2019-10-19 stsp fi
1651 523b8417 2019-10-19 stsp
1652 523b8417 2019-10-19 stsp ls -l $testroot/wt/xfile | grep -q '^-rw-'
1653 523b8417 2019-10-19 stsp ret="$?"
1654 523b8417 2019-10-19 stsp if [ "$ret" != "0" ]; then
1655 523b8417 2019-10-19 stsp echo "file is unexpectedly executable" >&2
1656 523b8417 2019-10-19 stsp ls -l $testroot/wt/xfile >&2
1657 5036ab18 2020-04-18 stsp fi
1658 5036ab18 2020-04-18 stsp test_done "$testroot" "$ret"
1659 5036ab18 2020-04-18 stsp }
1660 5036ab18 2020-04-18 stsp
1661 f6cae3ed 2020-09-13 naddy test_update_preserves_conflicted_file() {
1662 5036ab18 2020-04-18 stsp local testroot=`test_init update_preserves_conflicted_file`
1663 5036ab18 2020-04-18 stsp local commit_id0=`git_show_head $testroot/repo`
1664 5036ab18 2020-04-18 stsp
1665 5036ab18 2020-04-18 stsp echo "modified alpha" > $testroot/repo/alpha
1666 5036ab18 2020-04-18 stsp git_commit $testroot/repo -m "modified alpha"
1667 5036ab18 2020-04-18 stsp local commit_id1=`git_show_head $testroot/repo`
1668 5036ab18 2020-04-18 stsp
1669 5036ab18 2020-04-18 stsp got checkout -c $commit_id0 $testroot/repo $testroot/wt > /dev/null
1670 5036ab18 2020-04-18 stsp ret="$?"
1671 5036ab18 2020-04-18 stsp if [ "$ret" != "0" ]; then
1672 5036ab18 2020-04-18 stsp test_done "$testroot" "$ret"
1673 5036ab18 2020-04-18 stsp return 1
1674 5036ab18 2020-04-18 stsp fi
1675 5036ab18 2020-04-18 stsp
1676 5036ab18 2020-04-18 stsp # fake a merge conflict
1677 5036ab18 2020-04-18 stsp echo '<<<<<<<' > $testroot/wt/alpha
1678 5036ab18 2020-04-18 stsp echo 'alpha' >> $testroot/wt/alpha
1679 5036ab18 2020-04-18 stsp echo '=======' >> $testroot/wt/alpha
1680 5036ab18 2020-04-18 stsp echo 'alpha, too' >> $testroot/wt/alpha
1681 5036ab18 2020-04-18 stsp echo '>>>>>>>' >> $testroot/wt/alpha
1682 5036ab18 2020-04-18 stsp cp $testroot/wt/alpha $testroot/content.expected
1683 5036ab18 2020-04-18 stsp
1684 5036ab18 2020-04-18 stsp echo "C alpha" > $testroot/stdout.expected
1685 5036ab18 2020-04-18 stsp (cd $testroot/wt && got status > $testroot/stdout)
1686 5036ab18 2020-04-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1687 5036ab18 2020-04-18 stsp ret="$?"
1688 5036ab18 2020-04-18 stsp if [ "$ret" != "0" ]; then
1689 5036ab18 2020-04-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
1690 5036ab18 2020-04-18 stsp test_done "$testroot" "$ret"
1691 5036ab18 2020-04-18 stsp return 1
1692 523b8417 2019-10-19 stsp fi
1693 5036ab18 2020-04-18 stsp
1694 5036ab18 2020-04-18 stsp echo "# alpha" > $testroot/stdout.expected
1695 5036ab18 2020-04-18 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
1696 5036ab18 2020-04-18 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1697 5036ab18 2020-04-18 stsp echo >> $testroot/stdout.expected
1698 9627c110 2020-04-18 stsp echo "Files not updated because of existing merge conflicts: 1" \
1699 9627c110 2020-04-18 stsp >> $testroot/stdout.expected
1700 5036ab18 2020-04-18 stsp (cd $testroot/wt && got update > $testroot/stdout)
1701 5036ab18 2020-04-18 stsp
1702 5036ab18 2020-04-18 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1703 5036ab18 2020-04-18 stsp ret="$?"
1704 5036ab18 2020-04-18 stsp if [ "$ret" != "0" ]; then
1705 5036ab18 2020-04-18 stsp diff -u $testroot/stdout.expected $testroot/stdout
1706 5036ab18 2020-04-18 stsp test_done "$testroot" "$ret"
1707 5036ab18 2020-04-18 stsp return 1
1708 5036ab18 2020-04-18 stsp fi
1709 5036ab18 2020-04-18 stsp
1710 5036ab18 2020-04-18 stsp cmp -s $testroot/content.expected $testroot/wt/alpha
1711 5036ab18 2020-04-18 stsp ret="$?"
1712 5036ab18 2020-04-18 stsp if [ "$ret" != "0" ]; then
1713 5036ab18 2020-04-18 stsp diff -u $testroot/content.expected $testroot/wt/alpha
1714 5036ab18 2020-04-18 stsp fi
1715 c932eeeb 2019-05-22 stsp test_done "$testroot" "$ret"
1716 c932eeeb 2019-05-22 stsp }
1717 e7303626 2020-05-14 stsp
1718 f6cae3ed 2020-09-13 naddy test_update_modified_submodules() {
1719 e7303626 2020-05-14 stsp local testroot=`test_init update_modified_submodules`
1720 e7303626 2020-05-14 stsp
1721 e7303626 2020-05-14 stsp make_single_file_repo $testroot/repo2 foo
1722 e7303626 2020-05-14 stsp
1723 e7303626 2020-05-14 stsp (cd $testroot/repo && git submodule -q add ../repo2)
1724 e7303626 2020-05-14 stsp (cd $testroot/repo && git commit -q -m 'adding submodule')
1725 c932eeeb 2019-05-22 stsp
1726 e7303626 2020-05-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1727 e7303626 2020-05-14 stsp
1728 e7303626 2020-05-14 stsp echo "modified foo" > $testroot/repo2/foo
1729 e7303626 2020-05-14 stsp (cd $testroot/repo2 && git commit -q -a -m 'modified a submodule')
1730 e7303626 2020-05-14 stsp
1731 e7303626 2020-05-14 stsp # Update the repo/repo2 submodule link
1732 e7303626 2020-05-14 stsp (cd $testroot/repo && git -C repo2 pull -q)
1733 e7303626 2020-05-14 stsp (cd $testroot/repo && git add repo2)
1734 e7303626 2020-05-14 stsp git_commit $testroot/repo -m "modified submodule link"
1735 e7303626 2020-05-14 stsp
1736 e7303626 2020-05-14 stsp # This update only records the new base commit. Otherwise it is a
1737 e7303626 2020-05-14 stsp # no-op change because Got's file index does not track submodules.
1738 e7303626 2020-05-14 stsp echo -n "Updated to commit " > $testroot/stdout.expected
1739 e7303626 2020-05-14 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1740 e7303626 2020-05-14 stsp echo >> $testroot/stdout.expected
1741 e7303626 2020-05-14 stsp
1742 e7303626 2020-05-14 stsp (cd $testroot/wt && got update > $testroot/stdout)
1743 e7303626 2020-05-14 stsp
1744 e7303626 2020-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1745 e7303626 2020-05-14 stsp ret="$?"
1746 e7303626 2020-05-14 stsp if [ "$ret" != "0" ]; then
1747 e7303626 2020-05-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1748 e7303626 2020-05-14 stsp fi
1749 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
1750 e7303626 2020-05-14 stsp }
1751 e7303626 2020-05-14 stsp
1752 f6cae3ed 2020-09-13 naddy test_update_adds_submodule() {
1753 e7303626 2020-05-14 stsp local testroot=`test_init update_adds_submodule`
1754 e7303626 2020-05-14 stsp
1755 e7303626 2020-05-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1756 e7303626 2020-05-14 stsp
1757 e7303626 2020-05-14 stsp make_single_file_repo $testroot/repo2 foo
1758 e7303626 2020-05-14 stsp
1759 e7303626 2020-05-14 stsp echo "modified foo" > $testroot/repo2/foo
1760 e7303626 2020-05-14 stsp (cd $testroot/repo2 && git commit -q -a -m 'modified a submodule')
1761 e7303626 2020-05-14 stsp
1762 e7303626 2020-05-14 stsp (cd $testroot/repo && git submodule -q add ../repo2)
1763 e7303626 2020-05-14 stsp (cd $testroot/repo && git commit -q -m 'adding submodule')
1764 e7303626 2020-05-14 stsp
1765 e7303626 2020-05-14 stsp echo "A .gitmodules" > $testroot/stdout.expected
1766 e7303626 2020-05-14 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
1767 e7303626 2020-05-14 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1768 e7303626 2020-05-14 stsp echo >> $testroot/stdout.expected
1769 e7303626 2020-05-14 stsp
1770 e7303626 2020-05-14 stsp (cd $testroot/wt && got update > $testroot/stdout)
1771 e7303626 2020-05-14 stsp
1772 e7303626 2020-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1773 e7303626 2020-05-14 stsp ret="$?"
1774 e7303626 2020-05-14 stsp if [ "$ret" != "0" ]; then
1775 e7303626 2020-05-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1776 e7303626 2020-05-14 stsp fi
1777 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
1778 e7303626 2020-05-14 stsp }
1779 e7303626 2020-05-14 stsp
1780 f6cae3ed 2020-09-13 naddy test_update_conflict_wt_file_vs_repo_submodule() {
1781 e7303626 2020-05-14 stsp local testroot=`test_init update_conflict_wt_file_vs_repo_submodule`
1782 e7303626 2020-05-14 stsp
1783 e7303626 2020-05-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1784 e7303626 2020-05-14 stsp
1785 e7303626 2020-05-14 stsp make_single_file_repo $testroot/repo2 foo
1786 e7303626 2020-05-14 stsp
1787 e7303626 2020-05-14 stsp # Add a file which will clash with the submodule
1788 e7303626 2020-05-14 stsp echo "This is a file called repo2" > $testroot/wt/repo2
1789 e7303626 2020-05-14 stsp (cd $testroot/wt && got add repo2 > /dev/null)
1790 e7303626 2020-05-14 stsp (cd $testroot/wt && got commit -m 'add file repo2' > /dev/null)
1791 e7303626 2020-05-14 stsp ret="$?"
1792 e7303626 2020-05-14 stsp if [ "$ret" != "0" ]; then
1793 e7303626 2020-05-14 stsp echo "commit failed unexpectedly" >&2
1794 e7303626 2020-05-14 stsp test_done "$testroot" "1"
1795 e7303626 2020-05-14 stsp return 1
1796 e7303626 2020-05-14 stsp fi
1797 e7303626 2020-05-14 stsp
1798 e7303626 2020-05-14 stsp (cd $testroot/repo && git submodule -q add ../repo2)
1799 e7303626 2020-05-14 stsp (cd $testroot/repo && git commit -q -m 'adding submodule')
1800 e7303626 2020-05-14 stsp
1801 e7303626 2020-05-14 stsp # Modify the clashing file such that any modifications brought
1802 e7303626 2020-05-14 stsp # in by 'got update' would require a merge.
1803 e7303626 2020-05-14 stsp echo "This file was changed" > $testroot/wt/repo2
1804 e7303626 2020-05-14 stsp
1805 e7303626 2020-05-14 stsp # No conflict occurs because 'got update' ignores the submodule
1806 e7303626 2020-05-14 stsp # and leaves the clashing file as it was.
1807 e7303626 2020-05-14 stsp echo "A .gitmodules" > $testroot/stdout.expected
1808 e7303626 2020-05-14 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
1809 e7303626 2020-05-14 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1810 e7303626 2020-05-14 stsp echo >> $testroot/stdout.expected
1811 e7303626 2020-05-14 stsp
1812 e7303626 2020-05-14 stsp (cd $testroot/wt && got update > $testroot/stdout)
1813 e7303626 2020-05-14 stsp
1814 e7303626 2020-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1815 e7303626 2020-05-14 stsp ret="$?"
1816 e7303626 2020-05-14 stsp if [ "$ret" != "0" ]; then
1817 e7303626 2020-05-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1818 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
1819 e7303626 2020-05-14 stsp return 1
1820 e7303626 2020-05-14 stsp fi
1821 e7303626 2020-05-14 stsp
1822 e7303626 2020-05-14 stsp (cd $testroot/wt && got status > $testroot/stdout)
1823 e7303626 2020-05-14 stsp
1824 e7303626 2020-05-14 stsp echo "M repo2" > $testroot/stdout.expected
1825 e7303626 2020-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1826 e7303626 2020-05-14 stsp ret="$?"
1827 e7303626 2020-05-14 stsp if [ "$ret" != "0" ]; then
1828 e7303626 2020-05-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1829 e7303626 2020-05-14 stsp fi
1830 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
1831 e7303626 2020-05-14 stsp }
1832 f35fa46a 2020-07-23 stsp
1833 f6cae3ed 2020-09-13 naddy test_update_adds_symlink() {
1834 f35fa46a 2020-07-23 stsp local testroot=`test_init update_adds_symlink`
1835 f35fa46a 2020-07-23 stsp
1836 f35fa46a 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1837 f35fa46a 2020-07-23 stsp ret="$?"
1838 f35fa46a 2020-07-23 stsp if [ "$ret" != "0" ]; then
1839 f35fa46a 2020-07-23 stsp echo "checkout failed unexpectedly" >&2
1840 f35fa46a 2020-07-23 stsp test_done "$testroot" "$ret"
1841 f35fa46a 2020-07-23 stsp return 1
1842 f35fa46a 2020-07-23 stsp fi
1843 f35fa46a 2020-07-23 stsp
1844 f35fa46a 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
1845 f35fa46a 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
1846 f35fa46a 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
1847 f35fa46a 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
1848 f35fa46a 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
1849 f35fa46a 2020-07-23 stsp (cd $testroot/repo && git add .)
1850 f35fa46a 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
1851 f35fa46a 2020-07-23 stsp
1852 f35fa46a 2020-07-23 stsp echo "A alpha.link" > $testroot/stdout.expected
1853 f35fa46a 2020-07-23 stsp echo "A epsilon/beta.link" >> $testroot/stdout.expected
1854 f35fa46a 2020-07-23 stsp echo "A epsilon.link" >> $testroot/stdout.expected
1855 f35fa46a 2020-07-23 stsp echo "A nonexistent.link" >> $testroot/stdout.expected
1856 f35fa46a 2020-07-23 stsp echo "A passwd.link" >> $testroot/stdout.expected
1857 f35fa46a 2020-07-23 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
1858 f35fa46a 2020-07-23 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1859 f35fa46a 2020-07-23 stsp echo >> $testroot/stdout.expected
1860 f35fa46a 2020-07-23 stsp
1861 f35fa46a 2020-07-23 stsp (cd $testroot/wt && got update > $testroot/stdout)
1862 f35fa46a 2020-07-23 stsp
1863 f35fa46a 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1864 f35fa46a 2020-07-23 stsp ret="$?"
1865 f35fa46a 2020-07-23 stsp if [ "$ret" != "0" ]; then
1866 f35fa46a 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1867 f35fa46a 2020-07-23 stsp test_done "$testroot" "$ret"
1868 f35fa46a 2020-07-23 stsp return 1
1869 f35fa46a 2020-07-23 stsp fi
1870 f35fa46a 2020-07-23 stsp
1871 f35fa46a 2020-07-23 stsp if ! [ -h $testroot/wt/alpha.link ]; then
1872 f35fa46a 2020-07-23 stsp echo "alpha.link is not a symlink"
1873 f35fa46a 2020-07-23 stsp test_done "$testroot" "1"
1874 f35fa46a 2020-07-23 stsp return 1
1875 f35fa46a 2020-07-23 stsp fi
1876 f35fa46a 2020-07-23 stsp
1877 f35fa46a 2020-07-23 stsp readlink $testroot/wt/alpha.link > $testroot/stdout
1878 f35fa46a 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
1879 f35fa46a 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1880 f35fa46a 2020-07-23 stsp ret="$?"
1881 f35fa46a 2020-07-23 stsp if [ "$ret" != "0" ]; then
1882 f35fa46a 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1883 f35fa46a 2020-07-23 stsp test_done "$testroot" "$ret"
1884 f35fa46a 2020-07-23 stsp return 1
1885 f35fa46a 2020-07-23 stsp fi
1886 f35fa46a 2020-07-23 stsp
1887 f35fa46a 2020-07-23 stsp if ! [ -h $testroot/wt/epsilon.link ]; then
1888 f35fa46a 2020-07-23 stsp echo "epsilon.link is not a symlink"
1889 f35fa46a 2020-07-23 stsp test_done "$testroot" "1"
1890 f35fa46a 2020-07-23 stsp return 1
1891 f35fa46a 2020-07-23 stsp fi
1892 e7303626 2020-05-14 stsp
1893 f35fa46a 2020-07-23 stsp readlink $testroot/wt/epsilon.link > $testroot/stdout
1894 f35fa46a 2020-07-23 stsp echo "epsilon" > $testroot/stdout.expected
1895 f35fa46a 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1896 f35fa46a 2020-07-23 stsp ret="$?"
1897 f35fa46a 2020-07-23 stsp if [ "$ret" != "0" ]; then
1898 f35fa46a 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1899 f35fa46a 2020-07-23 stsp test_done "$testroot" "$ret"
1900 f35fa46a 2020-07-23 stsp return 1
1901 f35fa46a 2020-07-23 stsp fi
1902 e7303626 2020-05-14 stsp
1903 f35fa46a 2020-07-23 stsp if [ -h $testroot/wt/passwd.link ]; then
1904 f35fa46a 2020-07-23 stsp echo -n "passwd.link symlink points outside of work tree: " >&2
1905 f35fa46a 2020-07-23 stsp readlink $testroot/wt/passwd.link >&2
1906 f35fa46a 2020-07-23 stsp test_done "$testroot" "1"
1907 f35fa46a 2020-07-23 stsp return 1
1908 f35fa46a 2020-07-23 stsp fi
1909 f35fa46a 2020-07-23 stsp
1910 f35fa46a 2020-07-23 stsp echo -n "/etc/passwd" > $testroot/content.expected
1911 f35fa46a 2020-07-23 stsp cp $testroot/wt/passwd.link $testroot/content
1912 f35fa46a 2020-07-23 stsp
1913 f35fa46a 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
1914 f35fa46a 2020-07-23 stsp ret="$?"
1915 f35fa46a 2020-07-23 stsp if [ "$ret" != "0" ]; then
1916 f35fa46a 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
1917 f35fa46a 2020-07-23 stsp test_done "$testroot" "$ret"
1918 f35fa46a 2020-07-23 stsp return 1
1919 f35fa46a 2020-07-23 stsp fi
1920 f35fa46a 2020-07-23 stsp
1921 f35fa46a 2020-07-23 stsp readlink $testroot/wt/epsilon/beta.link > $testroot/stdout
1922 f35fa46a 2020-07-23 stsp echo "../beta" > $testroot/stdout.expected
1923 f35fa46a 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1924 f35fa46a 2020-07-23 stsp ret="$?"
1925 f35fa46a 2020-07-23 stsp if [ "$ret" != "0" ]; then
1926 f35fa46a 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1927 f35fa46a 2020-07-23 stsp test_done "$testroot" "$ret"
1928 f35fa46a 2020-07-23 stsp return 1
1929 f35fa46a 2020-07-23 stsp fi
1930 f35fa46a 2020-07-23 stsp
1931 f35fa46a 2020-07-23 stsp readlink $testroot/wt/nonexistent.link > $testroot/stdout
1932 f35fa46a 2020-07-23 stsp echo "nonexistent" > $testroot/stdout.expected
1933 f35fa46a 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1934 f35fa46a 2020-07-23 stsp ret="$?"
1935 f35fa46a 2020-07-23 stsp if [ "$ret" != "0" ]; then
1936 f35fa46a 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1937 c6e8a826 2021-04-05 stsp test_done "$testroot" "$ret"
1938 c6e8a826 2021-04-05 stsp return 1
1939 f35fa46a 2020-07-23 stsp fi
1940 c6e8a826 2021-04-05 stsp
1941 c6e8a826 2021-04-05 stsp # Updating an up-to-date symlink should be a no-op.
1942 c6e8a826 2021-04-05 stsp echo 'Already up-to-date' > $testroot/stdout.expected
1943 c6e8a826 2021-04-05 stsp (cd $testroot/wt && got update > $testroot/stdout)
1944 c6e8a826 2021-04-05 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1945 c6e8a826 2021-04-05 stsp ret="$?"
1946 c6e8a826 2021-04-05 stsp if [ "$ret" != "0" ]; then
1947 c6e8a826 2021-04-05 stsp diff -u $testroot/stdout.expected $testroot/stdout
1948 c6e8a826 2021-04-05 stsp fi
1949 f35fa46a 2020-07-23 stsp test_done "$testroot" "$ret"
1950 993e2a1b 2020-07-23 stsp }
1951 993e2a1b 2020-07-23 stsp
1952 f6cae3ed 2020-09-13 naddy test_update_deletes_symlink() {
1953 993e2a1b 2020-07-23 stsp local testroot=`test_init update_deletes_symlink`
1954 993e2a1b 2020-07-23 stsp
1955 993e2a1b 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
1956 993e2a1b 2020-07-23 stsp (cd $testroot/repo && git add .)
1957 993e2a1b 2020-07-23 stsp git_commit $testroot/repo -m "add symlink"
1958 993e2a1b 2020-07-23 stsp
1959 993e2a1b 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1960 993e2a1b 2020-07-23 stsp ret="$?"
1961 993e2a1b 2020-07-23 stsp if [ "$ret" != "0" ]; then
1962 993e2a1b 2020-07-23 stsp echo "checkout failed unexpectedly" >&2
1963 993e2a1b 2020-07-23 stsp test_done "$testroot" "$ret"
1964 993e2a1b 2020-07-23 stsp return 1
1965 993e2a1b 2020-07-23 stsp fi
1966 993e2a1b 2020-07-23 stsp
1967 993e2a1b 2020-07-23 stsp (cd $testroot/repo && git rm -q alpha.link)
1968 993e2a1b 2020-07-23 stsp git_commit $testroot/repo -m "delete symlink"
1969 993e2a1b 2020-07-23 stsp
1970 993e2a1b 2020-07-23 stsp echo "D alpha.link" > $testroot/stdout.expected
1971 993e2a1b 2020-07-23 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
1972 993e2a1b 2020-07-23 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
1973 993e2a1b 2020-07-23 stsp echo >> $testroot/stdout.expected
1974 993e2a1b 2020-07-23 stsp
1975 993e2a1b 2020-07-23 stsp (cd $testroot/wt && got update > $testroot/stdout)
1976 993e2a1b 2020-07-23 stsp
1977 993e2a1b 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1978 993e2a1b 2020-07-23 stsp ret="$?"
1979 993e2a1b 2020-07-23 stsp if [ "$ret" != "0" ]; then
1980 993e2a1b 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1981 993e2a1b 2020-07-23 stsp test_done "$testroot" "$ret"
1982 993e2a1b 2020-07-23 stsp return 1
1983 993e2a1b 2020-07-23 stsp fi
1984 993e2a1b 2020-07-23 stsp
1985 993e2a1b 2020-07-23 stsp if [ -e $testroot/wt/alpha.link ]; then
1986 993e2a1b 2020-07-23 stsp echo "alpha.link still exists on disk"
1987 993e2a1b 2020-07-23 stsp test_done "$testroot" "1"
1988 993e2a1b 2020-07-23 stsp return 1
1989 993e2a1b 2020-07-23 stsp fi
1990 993e2a1b 2020-07-23 stsp
1991 993e2a1b 2020-07-23 stsp test_done "$testroot" "0"
1992 993e2a1b 2020-07-23 stsp }
1993 993e2a1b 2020-07-23 stsp
1994 f6cae3ed 2020-09-13 naddy test_update_symlink_conflicts() {
1995 993e2a1b 2020-07-23 stsp local testroot=`test_init update_symlink_conflicts`
1996 993e2a1b 2020-07-23 stsp
1997 993e2a1b 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
1998 993e2a1b 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
1999 993e2a1b 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
2000 993e2a1b 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
2001 993e2a1b 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
2002 993e2a1b 2020-07-23 stsp (cd $testroot/repo && ln -sf epsilon/zeta zeta.link)
2003 993e2a1b 2020-07-23 stsp (cd $testroot/repo && git add .)
2004 993e2a1b 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
2005 993e2a1b 2020-07-23 stsp local commit_id1=`git_show_head $testroot/repo`
2006 993e2a1b 2020-07-23 stsp
2007 993e2a1b 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
2008 993e2a1b 2020-07-23 stsp ret="$?"
2009 993e2a1b 2020-07-23 stsp if [ "$ret" != "0" ]; then
2010 993e2a1b 2020-07-23 stsp echo "checkout failed unexpectedly" >&2
2011 993e2a1b 2020-07-23 stsp test_done "$testroot" "$ret"
2012 993e2a1b 2020-07-23 stsp return 1
2013 993e2a1b 2020-07-23 stsp fi
2014 993e2a1b 2020-07-23 stsp
2015 993e2a1b 2020-07-23 stsp (cd $testroot/repo && ln -sf beta alpha.link)
2016 993e2a1b 2020-07-23 stsp (cd $testroot/repo && ln -sfh gamma epsilon.link)
2017 993e2a1b 2020-07-23 stsp (cd $testroot/repo && ln -sf ../gamma/delta epsilon/beta.link)
2018 993e2a1b 2020-07-23 stsp echo 'this is regular file foo' > $testroot/repo/dotgotfoo.link
2019 993e2a1b 2020-07-23 stsp (cd $testroot/repo && ln -sf .got/bar dotgotbar.link)
2020 993e2a1b 2020-07-23 stsp (cd $testroot/repo && git rm -q nonexistent.link)
2021 993e2a1b 2020-07-23 stsp (cd $testroot/repo && ln -sf gamma/delta zeta.link)
2022 993e2a1b 2020-07-23 stsp (cd $testroot/repo && ln -sf alpha new.link)
2023 993e2a1b 2020-07-23 stsp (cd $testroot/repo && git add .)
2024 993e2a1b 2020-07-23 stsp git_commit $testroot/repo -m "change symlinks"
2025 993e2a1b 2020-07-23 stsp local commit_id2=`git_show_head $testroot/repo`
2026 993e2a1b 2020-07-23 stsp
2027 993e2a1b 2020-07-23 stsp # modified symlink to file A vs modified symlink to file B
2028 993e2a1b 2020-07-23 stsp (cd $testroot/wt && ln -sf gamma/delta alpha.link)
2029 993e2a1b 2020-07-23 stsp # modified symlink to dir A vs modified symlink to file B
2030 993e2a1b 2020-07-23 stsp (cd $testroot/wt && ln -sfh beta epsilon.link)
2031 993e2a1b 2020-07-23 stsp # modeified symlink to file A vs modified symlink to dir B
2032 993e2a1b 2020-07-23 stsp (cd $testroot/wt && ln -sfh ../gamma epsilon/beta.link)
2033 993e2a1b 2020-07-23 stsp # added regular file A vs added bad symlink to file A
2034 993e2a1b 2020-07-23 stsp (cd $testroot/wt && ln -sf .got/bar dotgotfoo.link)
2035 3b9f0f87 2020-07-23 stsp (cd $testroot/wt && got add dotgotfoo.link > /dev/null)
2036 993e2a1b 2020-07-23 stsp # added bad symlink to file A vs added regular file A
2037 993e2a1b 2020-07-23 stsp echo 'this is regular file bar' > $testroot/wt/dotgotbar.link
2038 3b9f0f87 2020-07-23 stsp (cd $testroot/wt && got add dotgotbar.link > /dev/null)
2039 993e2a1b 2020-07-23 stsp # removed symlink to non-existent file A vs modified symlink
2040 993e2a1b 2020-07-23 stsp # to nonexistent file B
2041 993e2a1b 2020-07-23 stsp (cd $testroot/wt && ln -sf nonexistent2 nonexistent.link)
2042 993e2a1b 2020-07-23 stsp # modified symlink to file A vs removed symlink to file A
2043 993e2a1b 2020-07-23 stsp (cd $testroot/wt && got rm zeta.link > /dev/null)
2044 993e2a1b 2020-07-23 stsp # added symlink to file A vs added symlink to file B
2045 993e2a1b 2020-07-23 stsp (cd $testroot/wt && ln -sf beta new.link)
2046 993e2a1b 2020-07-23 stsp (cd $testroot/wt && got add new.link > /dev/null)
2047 993e2a1b 2020-07-23 stsp
2048 993e2a1b 2020-07-23 stsp (cd $testroot/wt && got update > $testroot/stdout)
2049 993e2a1b 2020-07-23 stsp
2050 993e2a1b 2020-07-23 stsp echo "C alpha.link" >> $testroot/stdout.expected
2051 3b9f0f87 2020-07-23 stsp echo "C dotgotbar.link" >> $testroot/stdout.expected
2052 3b9f0f87 2020-07-23 stsp echo "C dotgotfoo.link" >> $testroot/stdout.expected
2053 993e2a1b 2020-07-23 stsp echo "C epsilon/beta.link" >> $testroot/stdout.expected
2054 993e2a1b 2020-07-23 stsp echo "C epsilon.link" >> $testroot/stdout.expected
2055 993e2a1b 2020-07-23 stsp echo "C new.link" >> $testroot/stdout.expected
2056 993e2a1b 2020-07-23 stsp echo "C nonexistent.link" >> $testroot/stdout.expected
2057 993e2a1b 2020-07-23 stsp echo "G zeta.link" >> $testroot/stdout.expected
2058 993e2a1b 2020-07-23 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
2059 993e2a1b 2020-07-23 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
2060 993e2a1b 2020-07-23 stsp echo >> $testroot/stdout.expected
2061 3b9f0f87 2020-07-23 stsp echo "Files with new merge conflicts: 7" >> $testroot/stdout.expected
2062 993e2a1b 2020-07-23 stsp
2063 993e2a1b 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2064 993e2a1b 2020-07-23 stsp ret="$?"
2065 993e2a1b 2020-07-23 stsp if [ "$ret" != "0" ]; then
2066 993e2a1b 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2067 993e2a1b 2020-07-23 stsp test_done "$testroot" "$ret"
2068 993e2a1b 2020-07-23 stsp return 1
2069 993e2a1b 2020-07-23 stsp fi
2070 993e2a1b 2020-07-23 stsp
2071 993e2a1b 2020-07-23 stsp if [ -h $testroot/wt/alpha.link ]; then
2072 993e2a1b 2020-07-23 stsp echo "alpha.link is a symlink"
2073 993e2a1b 2020-07-23 stsp test_done "$testroot" "1"
2074 993e2a1b 2020-07-23 stsp return 1
2075 993e2a1b 2020-07-23 stsp fi
2076 993e2a1b 2020-07-23 stsp
2077 993e2a1b 2020-07-23 stsp echo "<<<<<<< merged change: commit $commit_id2" \
2078 283102fc 2020-07-23 stsp > $testroot/content.expected
2079 993e2a1b 2020-07-23 stsp echo "beta" >> $testroot/content.expected
2080 993e2a1b 2020-07-23 stsp echo "3-way merge base: commit $commit_id1" \
2081 993e2a1b 2020-07-23 stsp >> $testroot/content.expected
2082 993e2a1b 2020-07-23 stsp echo "alpha" >> $testroot/content.expected
2083 993e2a1b 2020-07-23 stsp echo "=======" >> $testroot/content.expected
2084 993e2a1b 2020-07-23 stsp echo "gamma/delta" >> $testroot/content.expected
2085 993e2a1b 2020-07-23 stsp echo '>>>>>>>' >> $testroot/content.expected
2086 993e2a1b 2020-07-23 stsp echo -n "" >> $testroot/content.expected
2087 993e2a1b 2020-07-23 stsp
2088 993e2a1b 2020-07-23 stsp cp $testroot/wt/alpha.link $testroot/content
2089 993e2a1b 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2090 993e2a1b 2020-07-23 stsp ret="$?"
2091 993e2a1b 2020-07-23 stsp if [ "$ret" != "0" ]; then
2092 993e2a1b 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2093 993e2a1b 2020-07-23 stsp test_done "$testroot" "$ret"
2094 993e2a1b 2020-07-23 stsp return 1
2095 993e2a1b 2020-07-23 stsp fi
2096 993e2a1b 2020-07-23 stsp
2097 993e2a1b 2020-07-23 stsp if [ -h $testroot/wt/epsilon.link ]; then
2098 993e2a1b 2020-07-23 stsp echo "epsilon.link is a symlink"
2099 993e2a1b 2020-07-23 stsp test_done "$testroot" "1"
2100 993e2a1b 2020-07-23 stsp return 1
2101 993e2a1b 2020-07-23 stsp fi
2102 993e2a1b 2020-07-23 stsp
2103 993e2a1b 2020-07-23 stsp echo "<<<<<<< merged change: commit $commit_id2" \
2104 283102fc 2020-07-23 stsp > $testroot/content.expected
2105 993e2a1b 2020-07-23 stsp echo "gamma" >> $testroot/content.expected
2106 993e2a1b 2020-07-23 stsp echo "3-way merge base: commit $commit_id1" \
2107 993e2a1b 2020-07-23 stsp >> $testroot/content.expected
2108 993e2a1b 2020-07-23 stsp echo "epsilon" >> $testroot/content.expected
2109 993e2a1b 2020-07-23 stsp echo "=======" >> $testroot/content.expected
2110 993e2a1b 2020-07-23 stsp echo "beta" >> $testroot/content.expected
2111 993e2a1b 2020-07-23 stsp echo '>>>>>>>' >> $testroot/content.expected
2112 993e2a1b 2020-07-23 stsp echo -n "" >> $testroot/content.expected
2113 993e2a1b 2020-07-23 stsp
2114 993e2a1b 2020-07-23 stsp cp $testroot/wt/epsilon.link $testroot/content
2115 993e2a1b 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2116 993e2a1b 2020-07-23 stsp ret="$?"
2117 993e2a1b 2020-07-23 stsp if [ "$ret" != "0" ]; then
2118 993e2a1b 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2119 993e2a1b 2020-07-23 stsp test_done "$testroot" "$ret"
2120 993e2a1b 2020-07-23 stsp return 1
2121 993e2a1b 2020-07-23 stsp fi
2122 993e2a1b 2020-07-23 stsp
2123 993e2a1b 2020-07-23 stsp if [ -h $testroot/wt/passwd.link ]; then
2124 993e2a1b 2020-07-23 stsp echo -n "passwd.link symlink points outside of work tree: " >&2
2125 993e2a1b 2020-07-23 stsp readlink $testroot/wt/passwd.link >&2
2126 993e2a1b 2020-07-23 stsp test_done "$testroot" "1"
2127 993e2a1b 2020-07-23 stsp return 1
2128 993e2a1b 2020-07-23 stsp fi
2129 993e2a1b 2020-07-23 stsp
2130 993e2a1b 2020-07-23 stsp echo -n "/etc/passwd" > $testroot/content.expected
2131 993e2a1b 2020-07-23 stsp cp $testroot/wt/passwd.link $testroot/content
2132 993e2a1b 2020-07-23 stsp
2133 993e2a1b 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2134 993e2a1b 2020-07-23 stsp ret="$?"
2135 993e2a1b 2020-07-23 stsp if [ "$ret" != "0" ]; then
2136 993e2a1b 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2137 993e2a1b 2020-07-23 stsp test_done "$testroot" "$ret"
2138 993e2a1b 2020-07-23 stsp return 1
2139 993e2a1b 2020-07-23 stsp fi
2140 993e2a1b 2020-07-23 stsp
2141 993e2a1b 2020-07-23 stsp if [ -h $testroot/wt/epsilon/beta.link ]; then
2142 993e2a1b 2020-07-23 stsp echo "epsilon/beta.link is a symlink"
2143 993e2a1b 2020-07-23 stsp test_done "$testroot" "1"
2144 993e2a1b 2020-07-23 stsp return 1
2145 993e2a1b 2020-07-23 stsp fi
2146 993e2a1b 2020-07-23 stsp
2147 993e2a1b 2020-07-23 stsp echo "<<<<<<< merged change: commit $commit_id2" \
2148 283102fc 2020-07-23 stsp > $testroot/content.expected
2149 993e2a1b 2020-07-23 stsp echo "../gamma/delta" >> $testroot/content.expected
2150 993e2a1b 2020-07-23 stsp echo "3-way merge base: commit $commit_id1" \
2151 993e2a1b 2020-07-23 stsp >> $testroot/content.expected
2152 993e2a1b 2020-07-23 stsp echo "../beta" >> $testroot/content.expected
2153 993e2a1b 2020-07-23 stsp echo "=======" >> $testroot/content.expected
2154 993e2a1b 2020-07-23 stsp echo "../gamma" >> $testroot/content.expected
2155 993e2a1b 2020-07-23 stsp echo '>>>>>>>' >> $testroot/content.expected
2156 993e2a1b 2020-07-23 stsp echo -n "" >> $testroot/content.expected
2157 993e2a1b 2020-07-23 stsp
2158 993e2a1b 2020-07-23 stsp cp $testroot/wt/epsilon/beta.link $testroot/content
2159 993e2a1b 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2160 993e2a1b 2020-07-23 stsp ret="$?"
2161 993e2a1b 2020-07-23 stsp if [ "$ret" != "0" ]; then
2162 993e2a1b 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2163 993e2a1b 2020-07-23 stsp test_done "$testroot" "$ret"
2164 993e2a1b 2020-07-23 stsp return 1
2165 993e2a1b 2020-07-23 stsp fi
2166 993e2a1b 2020-07-23 stsp
2167 993e2a1b 2020-07-23 stsp if [ -h $testroot/wt/nonexistent.link ]; then
2168 993e2a1b 2020-07-23 stsp echo -n "nonexistent.link still exists on disk: " >&2
2169 993e2a1b 2020-07-23 stsp readlink $testroot/wt/nonexistent.link >&2
2170 993e2a1b 2020-07-23 stsp test_done "$testroot" "1"
2171 993e2a1b 2020-07-23 stsp return 1
2172 993e2a1b 2020-07-23 stsp fi
2173 993e2a1b 2020-07-23 stsp
2174 993e2a1b 2020-07-23 stsp echo "<<<<<<< merged change: commit $commit_id2" \
2175 283102fc 2020-07-23 stsp > $testroot/content.expected
2176 993e2a1b 2020-07-23 stsp echo "(symlink was deleted)" >> $testroot/content.expected
2177 993e2a1b 2020-07-23 stsp echo "=======" >> $testroot/content.expected
2178 993e2a1b 2020-07-23 stsp echo "nonexistent2" >> $testroot/content.expected
2179 993e2a1b 2020-07-23 stsp echo '>>>>>>>' >> $testroot/content.expected
2180 993e2a1b 2020-07-23 stsp echo -n "" >> $testroot/content.expected
2181 993e2a1b 2020-07-23 stsp
2182 993e2a1b 2020-07-23 stsp cp $testroot/wt/nonexistent.link $testroot/content
2183 993e2a1b 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2184 993e2a1b 2020-07-23 stsp ret="$?"
2185 993e2a1b 2020-07-23 stsp if [ "$ret" != "0" ]; then
2186 993e2a1b 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2187 993e2a1b 2020-07-23 stsp test_done "$testroot" "$ret"
2188 993e2a1b 2020-07-23 stsp return 1
2189 993e2a1b 2020-07-23 stsp fi
2190 993e2a1b 2020-07-23 stsp
2191 993e2a1b 2020-07-23 stsp if [ -h $testroot/wt/dotgotfoo.link ]; then
2192 993e2a1b 2020-07-23 stsp echo "dotgotfoo.link is a symlink"
2193 993e2a1b 2020-07-23 stsp test_done "$testroot" "1"
2194 993e2a1b 2020-07-23 stsp return 1
2195 993e2a1b 2020-07-23 stsp fi
2196 993e2a1b 2020-07-23 stsp
2197 3b9f0f87 2020-07-23 stsp echo "<<<<<<< merged change: commit $commit_id2" \
2198 3b9f0f87 2020-07-23 stsp > $testroot/content.expected
2199 3b9f0f87 2020-07-23 stsp echo "this is regular file foo" >> $testroot/content.expected
2200 3b9f0f87 2020-07-23 stsp echo "=======" >> $testroot/content.expected
2201 3b9f0f87 2020-07-23 stsp echo -n ".got/bar" >> $testroot/content.expected
2202 3b9f0f87 2020-07-23 stsp echo '>>>>>>>' >> $testroot/content.expected
2203 3b9f0f87 2020-07-23 stsp echo -n "" >> $testroot/content.expected
2204 3b9f0f87 2020-07-23 stsp
2205 993e2a1b 2020-07-23 stsp cp $testroot/wt/dotgotfoo.link $testroot/content
2206 993e2a1b 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2207 993e2a1b 2020-07-23 stsp ret="$?"
2208 993e2a1b 2020-07-23 stsp if [ "$ret" != "0" ]; then
2209 993e2a1b 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2210 993e2a1b 2020-07-23 stsp test_done "$testroot" "$ret"
2211 993e2a1b 2020-07-23 stsp return 1
2212 993e2a1b 2020-07-23 stsp fi
2213 993e2a1b 2020-07-23 stsp
2214 993e2a1b 2020-07-23 stsp if [ -h $testroot/wt/dotgotbar.link ]; then
2215 993e2a1b 2020-07-23 stsp echo "dotgotbar.link is a symlink"
2216 993e2a1b 2020-07-23 stsp test_done "$testroot" "1"
2217 993e2a1b 2020-07-23 stsp return 1
2218 993e2a1b 2020-07-23 stsp fi
2219 3b9f0f87 2020-07-23 stsp echo "<<<<<<< merged change: commit $commit_id2" \
2220 3b9f0f87 2020-07-23 stsp > $testroot/content.expected
2221 3b9f0f87 2020-07-23 stsp echo -n ".got/bar" >> $testroot/content.expected
2222 3b9f0f87 2020-07-23 stsp echo "=======" >> $testroot/content.expected
2223 3b9f0f87 2020-07-23 stsp echo "this is regular file bar" >> $testroot/content.expected
2224 3b9f0f87 2020-07-23 stsp echo '>>>>>>>' >> $testroot/content.expected
2225 3b9f0f87 2020-07-23 stsp echo -n "" >> $testroot/content.expected
2226 3b9f0f87 2020-07-23 stsp
2227 993e2a1b 2020-07-23 stsp cp $testroot/wt/dotgotbar.link $testroot/content
2228 993e2a1b 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2229 993e2a1b 2020-07-23 stsp ret="$?"
2230 993e2a1b 2020-07-23 stsp if [ "$ret" != "0" ]; then
2231 993e2a1b 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2232 993e2a1b 2020-07-23 stsp test_done "$testroot" "$ret"
2233 993e2a1b 2020-07-23 stsp return 1
2234 993e2a1b 2020-07-23 stsp fi
2235 993e2a1b 2020-07-23 stsp
2236 993e2a1b 2020-07-23 stsp if [ -h $testroot/wt/new.link ]; then
2237 993e2a1b 2020-07-23 stsp echo "new.link is a symlink"
2238 993e2a1b 2020-07-23 stsp test_done "$testroot" "1"
2239 993e2a1b 2020-07-23 stsp return 1
2240 993e2a1b 2020-07-23 stsp fi
2241 993e2a1b 2020-07-23 stsp
2242 993e2a1b 2020-07-23 stsp echo "<<<<<<< merged change: commit $commit_id2" \
2243 283102fc 2020-07-23 stsp > $testroot/content.expected
2244 993e2a1b 2020-07-23 stsp echo "alpha" >> $testroot/content.expected
2245 993e2a1b 2020-07-23 stsp echo "=======" >> $testroot/content.expected
2246 993e2a1b 2020-07-23 stsp echo "beta" >> $testroot/content.expected
2247 993e2a1b 2020-07-23 stsp echo '>>>>>>>' >> $testroot/content.expected
2248 993e2a1b 2020-07-23 stsp echo -n "" >> $testroot/content.expected
2249 993e2a1b 2020-07-23 stsp
2250 993e2a1b 2020-07-23 stsp cp $testroot/wt/new.link $testroot/content
2251 993e2a1b 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
2252 993e2a1b 2020-07-23 stsp ret="$?"
2253 993e2a1b 2020-07-23 stsp if [ "$ret" != "0" ]; then
2254 993e2a1b 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
2255 993e2a1b 2020-07-23 stsp test_done "$testroot" "$ret"
2256 993e2a1b 2020-07-23 stsp return 1
2257 993e2a1b 2020-07-23 stsp fi
2258 993e2a1b 2020-07-23 stsp
2259 993e2a1b 2020-07-23 stsp echo "A dotgotfoo.link" > $testroot/stdout.expected
2260 993e2a1b 2020-07-23 stsp echo "M new.link" >> $testroot/stdout.expected
2261 993e2a1b 2020-07-23 stsp echo "D nonexistent.link" >> $testroot/stdout.expected
2262 993e2a1b 2020-07-23 stsp (cd $testroot/wt && got status > $testroot/stdout)
2263 993e2a1b 2020-07-23 stsp if [ "$ret" != "0" ]; then
2264 993e2a1b 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
2265 993e2a1b 2020-07-23 stsp test_done "$testroot" "$ret"
2266 993e2a1b 2020-07-23 stsp return 1
2267 993e2a1b 2020-07-23 stsp fi
2268 993e2a1b 2020-07-23 stsp
2269 993e2a1b 2020-07-23 stsp test_done "$testroot" "0"
2270 993e2a1b 2020-07-23 stsp
2271 f35fa46a 2020-07-23 stsp }
2272 194cb7cb 2021-01-19 stsp
2273 194cb7cb 2021-01-19 stsp test_update_single_file() {
2274 194cb7cb 2021-01-19 stsp local testroot=`test_init update_single_file 1`
2275 194cb7cb 2021-01-19 stsp
2276 194cb7cb 2021-01-19 stsp echo c1 > $testroot/repo/c
2277 194cb7cb 2021-01-19 stsp (cd $testroot/repo && git add .)
2278 79775c2f 2021-01-19 stsp git_commit $testroot/repo -m "adding file c"
2279 194cb7cb 2021-01-19 stsp local commit_id1=`git_show_head $testroot/repo`
2280 194cb7cb 2021-01-19 stsp
2281 194cb7cb 2021-01-19 stsp echo a > $testroot/repo/a
2282 194cb7cb 2021-01-19 stsp echo b > $testroot/repo/b
2283 194cb7cb 2021-01-19 stsp echo c2 > $testroot/repo/c
2284 194cb7cb 2021-01-19 stsp (cd $testroot/repo && git add .)
2285 79775c2f 2021-01-19 stsp git_commit $testroot/repo -m "add files a and b, change c"
2286 194cb7cb 2021-01-19 stsp local commit_id2=`git_show_head $testroot/repo`
2287 f35fa46a 2020-07-23 stsp
2288 d51387a0 2021-01-19 stsp (cd $testroot/repo && git rm -qf c)
2289 d51387a0 2021-01-19 stsp git_commit $testroot/repo -m "remove file c"
2290 d51387a0 2021-01-19 stsp local commit_id3=`git_show_head $testroot/repo`
2291 d51387a0 2021-01-19 stsp
2292 d51387a0 2021-01-19 stsp got checkout -c $commit_id2 $testroot/repo $testroot/wt > /dev/null
2293 194cb7cb 2021-01-19 stsp ret="$?"
2294 194cb7cb 2021-01-19 stsp if [ "$ret" != "0" ]; then
2295 194cb7cb 2021-01-19 stsp test_done "$testroot" "$ret"
2296 194cb7cb 2021-01-19 stsp return 1
2297 194cb7cb 2021-01-19 stsp fi
2298 194cb7cb 2021-01-19 stsp
2299 194cb7cb 2021-01-19 stsp echo "U c" > $testroot/stdout.expected
2300 79775c2f 2021-01-19 stsp echo "Updated to commit $commit_id1" >> $testroot/stdout.expected
2301 194cb7cb 2021-01-19 stsp
2302 194cb7cb 2021-01-19 stsp (cd $testroot/wt && got update -c $commit_id1 c \
2303 194cb7cb 2021-01-19 stsp > $testroot/stdout)
2304 194cb7cb 2021-01-19 stsp
2305 194cb7cb 2021-01-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2306 194cb7cb 2021-01-19 stsp ret="$?"
2307 194cb7cb 2021-01-19 stsp if [ "$ret" != "0" ]; then
2308 194cb7cb 2021-01-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
2309 194cb7cb 2021-01-19 stsp test_done "$testroot" "$ret"
2310 194cb7cb 2021-01-19 stsp return 1
2311 194cb7cb 2021-01-19 stsp fi
2312 194cb7cb 2021-01-19 stsp
2313 194cb7cb 2021-01-19 stsp echo c1 > $testroot/content.expected
2314 194cb7cb 2021-01-19 stsp cat $testroot/wt/c > $testroot/content
2315 194cb7cb 2021-01-19 stsp
2316 194cb7cb 2021-01-19 stsp cmp -s $testroot/content.expected $testroot/content
2317 194cb7cb 2021-01-19 stsp ret="$?"
2318 194cb7cb 2021-01-19 stsp if [ "$ret" != "0" ]; then
2319 194cb7cb 2021-01-19 stsp diff -u $testroot/content.expected $testroot/content
2320 194cb7cb 2021-01-19 stsp test_done "$testroot" "$ret"
2321 194cb7cb 2021-01-19 stsp return 1
2322 194cb7cb 2021-01-19 stsp fi
2323 194cb7cb 2021-01-19 stsp
2324 194cb7cb 2021-01-19 stsp echo "U c" > $testroot/stdout.expected
2325 79775c2f 2021-01-19 stsp echo "Updated to commit $commit_id2" >> $testroot/stdout.expected
2326 194cb7cb 2021-01-19 stsp
2327 d51387a0 2021-01-19 stsp (cd $testroot/wt && got update -c $commit_id2 c > $testroot/stdout)
2328 194cb7cb 2021-01-19 stsp
2329 194cb7cb 2021-01-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2330 194cb7cb 2021-01-19 stsp ret="$?"
2331 194cb7cb 2021-01-19 stsp if [ "$ret" != "0" ]; then
2332 194cb7cb 2021-01-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
2333 194cb7cb 2021-01-19 stsp test_done "$testroot" "$ret"
2334 194cb7cb 2021-01-19 stsp return 1
2335 194cb7cb 2021-01-19 stsp fi
2336 194cb7cb 2021-01-19 stsp
2337 194cb7cb 2021-01-19 stsp echo c2 > $testroot/content.expected
2338 194cb7cb 2021-01-19 stsp cat $testroot/wt/c > $testroot/content
2339 194cb7cb 2021-01-19 stsp
2340 194cb7cb 2021-01-19 stsp cmp -s $testroot/content.expected $testroot/content
2341 194cb7cb 2021-01-19 stsp ret="$?"
2342 194cb7cb 2021-01-19 stsp if [ "$ret" != "0" ]; then
2343 194cb7cb 2021-01-19 stsp diff -u $testroot/content.expected $testroot/content
2344 d51387a0 2021-01-19 stsp test_done "$testroot" "$ret"
2345 d51387a0 2021-01-19 stsp return 1
2346 194cb7cb 2021-01-19 stsp fi
2347 d51387a0 2021-01-19 stsp
2348 d51387a0 2021-01-19 stsp echo "D c" > $testroot/stdout.expected
2349 d51387a0 2021-01-19 stsp echo "Updated to commit $commit_id3" >> $testroot/stdout.expected
2350 d51387a0 2021-01-19 stsp
2351 d51387a0 2021-01-19 stsp (cd $testroot/wt && got update -c $commit_id3 c \
2352 d51387a0 2021-01-19 stsp > $testroot/stdout 2> $testroot/stderr)
2353 d51387a0 2021-01-19 stsp
2354 d51387a0 2021-01-19 stsp echo "got: /c: no such entry found in tree" > $testroot/stderr.expected
2355 d51387a0 2021-01-19 stsp cmp -s $testroot/stderr.expected $testroot/stderr
2356 d51387a0 2021-01-19 stsp ret="$?"
2357 d51387a0 2021-01-19 stsp if [ "$ret" != "0" ]; then
2358 d51387a0 2021-01-19 stsp diff -u $testroot/stderr.expected $testroot/stderr
2359 d51387a0 2021-01-19 stsp test_done "$testroot" "$ret"
2360 d51387a0 2021-01-19 stsp return 1
2361 d51387a0 2021-01-19 stsp fi
2362 d51387a0 2021-01-19 stsp
2363 d51387a0 2021-01-19 stsp echo -n > $testroot/stdout.expected
2364 d51387a0 2021-01-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2365 d51387a0 2021-01-19 stsp ret="$?"
2366 d51387a0 2021-01-19 stsp if [ "$ret" != "0" ]; then
2367 d51387a0 2021-01-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
2368 d51387a0 2021-01-19 stsp test_done "$testroot" "$ret"
2369 d51387a0 2021-01-19 stsp return 1
2370 d51387a0 2021-01-19 stsp fi
2371 d51387a0 2021-01-19 stsp
2372 d51387a0 2021-01-19 stsp echo "D c" > $testroot/stdout.expected
2373 d51387a0 2021-01-19 stsp echo "Updated to commit $commit_id3" >> $testroot/stdout.expected
2374 d51387a0 2021-01-19 stsp
2375 d51387a0 2021-01-19 stsp (cd $testroot/wt && got update -c $commit_id3 > $testroot/stdout)
2376 d51387a0 2021-01-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
2377 d51387a0 2021-01-19 stsp ret="$?"
2378 d51387a0 2021-01-19 stsp if [ "$ret" != "0" ]; then
2379 d51387a0 2021-01-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
2380 d51387a0 2021-01-19 stsp test_done "$testroot" "$ret"
2381 d51387a0 2021-01-19 stsp return 1
2382 d51387a0 2021-01-19 stsp fi
2383 d51387a0 2021-01-19 stsp
2384 d51387a0 2021-01-19 stsp if [ -e $testroot/wt/c ]; then
2385 d51387a0 2021-01-19 stsp echo "removed file c still exists on disk" >&2
2386 d51387a0 2021-01-19 stsp test_done "$testroot" "1"
2387 d51387a0 2021-01-19 stsp return 1
2388 d51387a0 2021-01-19 stsp fi
2389 d51387a0 2021-01-19 stsp
2390 d51387a0 2021-01-19 stsp test_done "$testroot" "0"
2391 d51387a0 2021-01-19 stsp return 0
2392 194cb7cb 2021-01-19 stsp }
2393 194cb7cb 2021-01-19 stsp
2394 194cb7cb 2021-01-19 stsp
2395 7fb414ae 2020-08-08 stsp test_parseargs "$@"
2396 c84d8c75 2019-01-02 stsp run_test test_update_basic
2397 3b4d3732 2019-01-02 stsp run_test test_update_adds_file
2398 512f0d0e 2019-01-02 stsp run_test test_update_deletes_file
2399 f5c49f82 2019-01-06 stsp run_test test_update_deletes_dir
2400 5cc266ba 2019-01-06 stsp run_test test_update_deletes_dir_with_path_prefix
2401 90285c3b 2019-01-08 stsp run_test test_update_deletes_dir_recursively
2402 4482e97b 2019-01-08 stsp run_test test_update_sibling_dirs_with_common_prefix
2403 50952927 2019-01-12 stsp run_test test_update_dir_with_dot_sibling
2404 46cee7a3 2019-01-12 stsp run_test test_update_moves_files_upwards
2405 bd4792ec 2019-01-13 stsp run_test test_update_moves_files_to_new_dir
2406 4a1ddfc2 2019-01-12 stsp run_test test_update_creates_missing_parent
2407 bd4792ec 2019-01-13 stsp run_test test_update_creates_missing_parent_with_subdir
2408 21908da4 2019-01-13 stsp run_test test_update_file_in_subsubdir
2409 6353ad76 2019-02-08 stsp run_test test_update_merges_file_edits
2410 68ed9ba5 2019-02-10 stsp run_test test_update_keeps_xbit
2411 ba8a0d4d 2019-02-10 stsp run_test test_update_clears_xbit
2412 a378724f 2019-02-10 stsp run_test test_update_restores_missing_file
2413 085d5bcf 2019-03-27 stsp run_test test_update_conflict_wt_add_vs_repo_add
2414 085d5bcf 2019-03-27 stsp run_test test_update_conflict_wt_edit_vs_repo_rm
2415 13d9040b 2019-03-27 stsp run_test test_update_conflict_wt_rm_vs_repo_edit
2416 66b11bf5 2019-03-27 stsp run_test test_update_conflict_wt_rm_vs_repo_rm
2417 c4cdcb68 2019-04-03 stsp run_test test_update_partial
2418 c4cdcb68 2019-04-03 stsp run_test test_update_partial_add
2419 c4cdcb68 2019-04-03 stsp run_test test_update_partial_rm
2420 c4cdcb68 2019-04-03 stsp run_test test_update_partial_dir
2421 d5bea539 2019-05-13 stsp run_test test_update_moved_branch_ref
2422 024e9686 2019-05-14 stsp run_test test_update_to_another_branch
2423 a367ff0f 2019-05-14 stsp run_test test_update_to_commit_on_wrong_branch
2424 c932eeeb 2019-05-22 stsp run_test test_update_bumps_base_commit_id
2425 303e2782 2019-08-09 stsp run_test test_update_tag
2426 523b8417 2019-10-19 stsp run_test test_update_toggles_xbit
2427 5036ab18 2020-04-18 stsp run_test test_update_preserves_conflicted_file
2428 e7303626 2020-05-14 stsp run_test test_update_modified_submodules
2429 e7303626 2020-05-14 stsp run_test test_update_adds_submodule
2430 e7303626 2020-05-14 stsp run_test test_update_conflict_wt_file_vs_repo_submodule
2431 f35fa46a 2020-07-23 stsp run_test test_update_adds_symlink
2432 993e2a1b 2020-07-23 stsp run_test test_update_deletes_symlink
2433 993e2a1b 2020-07-23 stsp run_test test_update_symlink_conflicts
2434 194cb7cb 2021-01-19 stsp run_test test_update_single_file