Blame


1 c4296144 2019-05-09 stsp #!/bin/sh
2 c4296144 2019-05-09 stsp #
3 c4296144 2019-05-09 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
4 c4296144 2019-05-09 stsp #
5 c4296144 2019-05-09 stsp # Permission to use, copy, modify, and distribute this software for any
6 c4296144 2019-05-09 stsp # purpose with or without fee is hereby granted, provided that the above
7 c4296144 2019-05-09 stsp # copyright notice and this permission notice appear in all copies.
8 c4296144 2019-05-09 stsp #
9 c4296144 2019-05-09 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 c4296144 2019-05-09 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 c4296144 2019-05-09 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 c4296144 2019-05-09 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 c4296144 2019-05-09 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 c4296144 2019-05-09 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 c4296144 2019-05-09 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 c4296144 2019-05-09 stsp
17 c4296144 2019-05-09 stsp . ./common.sh
18 c4296144 2019-05-09 stsp
19 c4296144 2019-05-09 stsp function test_commit_basic {
20 c4296144 2019-05-09 stsp local testroot=`test_init commit_basic`
21 c4296144 2019-05-09 stsp
22 c4296144 2019-05-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
23 c4296144 2019-05-09 stsp ret="$?"
24 c4296144 2019-05-09 stsp if [ "$ret" != "0" ]; then
25 c4296144 2019-05-09 stsp test_done "$testroot" "$ret"
26 c4296144 2019-05-09 stsp return 1
27 c4296144 2019-05-09 stsp fi
28 c4296144 2019-05-09 stsp
29 c4296144 2019-05-09 stsp echo "modified alpha" > $testroot/wt/alpha
30 c4296144 2019-05-09 stsp (cd $testroot/wt && got rm beta >/dev/null)
31 c4296144 2019-05-09 stsp echo "new file" > $testroot/wt/new
32 c4296144 2019-05-09 stsp (cd $testroot/wt && got add new >/dev/null)
33 c4296144 2019-05-09 stsp
34 83a7ae6d 2019-05-10 stsp (cd $testroot/wt && got commit -m 'test commit_basic' > $testroot/stdout)
35 c4296144 2019-05-09 stsp
36 c4296144 2019-05-09 stsp local head_rev=`git_show_head $testroot/repo`
37 afa376bf 2019-05-09 stsp echo "A new" > $testroot/stdout.expected
38 afa376bf 2019-05-09 stsp echo "M alpha" >> $testroot/stdout.expected
39 afa376bf 2019-05-09 stsp echo "D beta" >> $testroot/stdout.expected
40 a7648d7a 2019-06-02 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
41 c4296144 2019-05-09 stsp
42 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
43 c4296144 2019-05-09 stsp ret="$?"
44 c4296144 2019-05-09 stsp if [ "$ret" != "0" ]; then
45 c4296144 2019-05-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
46 c4296144 2019-05-09 stsp fi
47 c4296144 2019-05-09 stsp test_done "$testroot" "$ret"
48 c4296144 2019-05-09 stsp }
49 c4296144 2019-05-09 stsp
50 baa7dcfa 2019-05-09 stsp function test_commit_new_subdir {
51 baa7dcfa 2019-05-09 stsp local testroot=`test_init commit_new_subdir`
52 baa7dcfa 2019-05-09 stsp
53 baa7dcfa 2019-05-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
54 baa7dcfa 2019-05-09 stsp ret="$?"
55 baa7dcfa 2019-05-09 stsp if [ "$ret" != "0" ]; then
56 baa7dcfa 2019-05-09 stsp test_done "$testroot" "$ret"
57 baa7dcfa 2019-05-09 stsp return 1
58 baa7dcfa 2019-05-09 stsp fi
59 baa7dcfa 2019-05-09 stsp
60 baa7dcfa 2019-05-09 stsp mkdir -p $testroot/wt/d
61 baa7dcfa 2019-05-09 stsp echo "new file" > $testroot/wt/d/new
62 baa7dcfa 2019-05-09 stsp echo "another new file" > $testroot/wt/d/new2
63 baa7dcfa 2019-05-09 stsp (cd $testroot/wt && got add d/new >/dev/null)
64 baa7dcfa 2019-05-09 stsp (cd $testroot/wt && got add d/new2 >/dev/null)
65 baa7dcfa 2019-05-09 stsp
66 baa7dcfa 2019-05-09 stsp (cd $testroot/wt && \
67 baa7dcfa 2019-05-09 stsp got commit -m 'test commit_new_subdir' > $testroot/stdout)
68 baa7dcfa 2019-05-09 stsp
69 baa7dcfa 2019-05-09 stsp local head_rev=`git_show_head $testroot/repo`
70 baa7dcfa 2019-05-09 stsp echo "A d/new" > $testroot/stdout.expected
71 baa7dcfa 2019-05-09 stsp echo "A d/new2" >> $testroot/stdout.expected
72 a7648d7a 2019-06-02 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
73 baa7dcfa 2019-05-09 stsp
74 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
75 baa7dcfa 2019-05-09 stsp ret="$?"
76 baa7dcfa 2019-05-09 stsp if [ "$ret" != "0" ]; then
77 baa7dcfa 2019-05-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
78 baa7dcfa 2019-05-09 stsp fi
79 baa7dcfa 2019-05-09 stsp test_done "$testroot" "$ret"
80 baa7dcfa 2019-05-09 stsp }
81 baa7dcfa 2019-05-09 stsp
82 bc70eb79 2019-05-09 stsp function test_commit_subdir {
83 bc70eb79 2019-05-09 stsp local testroot=`test_init commit_subdir`
84 bc70eb79 2019-05-09 stsp
85 bc70eb79 2019-05-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
86 bc70eb79 2019-05-09 stsp ret="$?"
87 bc70eb79 2019-05-09 stsp if [ "$ret" != "0" ]; then
88 bc70eb79 2019-05-09 stsp test_done "$testroot" "$ret"
89 bc70eb79 2019-05-09 stsp return 1
90 bc70eb79 2019-05-09 stsp fi
91 bc70eb79 2019-05-09 stsp
92 bc70eb79 2019-05-09 stsp echo "modified alpha" > $testroot/wt/alpha
93 bc70eb79 2019-05-09 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
94 bc70eb79 2019-05-09 stsp
95 bc70eb79 2019-05-09 stsp (cd $testroot/wt && \
96 bc70eb79 2019-05-09 stsp got commit -m 'test commit_subdir' epsilon > $testroot/stdout)
97 bc70eb79 2019-05-09 stsp
98 bc70eb79 2019-05-09 stsp local head_rev=`git_show_head $testroot/repo`
99 bc70eb79 2019-05-09 stsp echo "M epsilon/zeta" >> $testroot/stdout.expected
100 a7648d7a 2019-06-02 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
101 bc70eb79 2019-05-09 stsp
102 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
103 bc70eb79 2019-05-09 stsp ret="$?"
104 bc70eb79 2019-05-09 stsp if [ "$ret" != "0" ]; then
105 bc70eb79 2019-05-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
106 bc70eb79 2019-05-09 stsp fi
107 bc70eb79 2019-05-09 stsp test_done "$testroot" "$ret"
108 bc70eb79 2019-05-09 stsp }
109 bc70eb79 2019-05-09 stsp
110 5bbcb68b 2019-05-09 stsp function test_commit_single_file {
111 5bbcb68b 2019-05-09 stsp local testroot=`test_init commit_single_file`
112 5bbcb68b 2019-05-09 stsp
113 5bbcb68b 2019-05-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
114 5bbcb68b 2019-05-09 stsp ret="$?"
115 5bbcb68b 2019-05-09 stsp if [ "$ret" != "0" ]; then
116 5bbcb68b 2019-05-09 stsp test_done "$testroot" "$ret"
117 5bbcb68b 2019-05-09 stsp return 1
118 5bbcb68b 2019-05-09 stsp fi
119 5bbcb68b 2019-05-09 stsp
120 5bbcb68b 2019-05-09 stsp echo "modified alpha" > $testroot/wt/alpha
121 5bbcb68b 2019-05-09 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
122 5bbcb68b 2019-05-09 stsp
123 1a36436d 2019-06-10 stsp (cd $testroot/wt && got commit -m 'changed zeta' epsilon/zeta \
124 5bbcb68b 2019-05-09 stsp > $testroot/stdout)
125 5bbcb68b 2019-05-09 stsp
126 5bbcb68b 2019-05-09 stsp local head_rev=`git_show_head $testroot/repo`
127 5bbcb68b 2019-05-09 stsp echo "M epsilon/zeta" >> $testroot/stdout.expected
128 a7648d7a 2019-06-02 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
129 5bbcb68b 2019-05-09 stsp
130 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
131 5bbcb68b 2019-05-09 stsp ret="$?"
132 5bbcb68b 2019-05-09 stsp if [ "$ret" != "0" ]; then
133 5bbcb68b 2019-05-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
134 5bbcb68b 2019-05-09 stsp fi
135 5bbcb68b 2019-05-09 stsp test_done "$testroot" "$ret"
136 5bbcb68b 2019-05-09 stsp }
137 5bbcb68b 2019-05-09 stsp
138 819f385b 2019-05-10 stsp function test_commit_out_of_date {
139 819f385b 2019-05-10 stsp local testroot=`test_init commit_out_of_date`
140 f0b75401 2019-08-03 stsp local first_commit=`git_show_head $testroot/repo`
141 819f385b 2019-05-10 stsp
142 819f385b 2019-05-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
143 819f385b 2019-05-10 stsp ret="$?"
144 819f385b 2019-05-10 stsp if [ "$ret" != "0" ]; then
145 819f385b 2019-05-10 stsp test_done "$testroot" "$ret"
146 819f385b 2019-05-10 stsp return 1
147 819f385b 2019-05-10 stsp fi
148 819f385b 2019-05-10 stsp
149 819f385b 2019-05-10 stsp echo "modified alpha" > $testroot/repo/alpha
150 819f385b 2019-05-10 stsp git_commit $testroot/repo -m "modified alpha"
151 819f385b 2019-05-10 stsp
152 819f385b 2019-05-10 stsp echo "modified alpha" > $testroot/wt/alpha
153 819f385b 2019-05-10 stsp
154 819f385b 2019-05-10 stsp (cd $testroot/wt && got commit -m 'test commit_out_of_date' \
155 819f385b 2019-05-10 stsp > $testroot/stdout 2> $testroot/stderr)
156 819f385b 2019-05-10 stsp
157 819f385b 2019-05-10 stsp echo -n > $testroot/stdout.expected
158 819f385b 2019-05-10 stsp echo "got: work tree must be updated before these" \
159 819f385b 2019-05-10 stsp "changes can be committed" > $testroot/stderr.expected
160 819f385b 2019-05-10 stsp
161 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
162 819f385b 2019-05-10 stsp ret="$?"
163 819f385b 2019-05-10 stsp if [ "$ret" != "0" ]; then
164 819f385b 2019-05-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
165 819f385b 2019-05-10 stsp test_done "$testroot" "$ret"
166 819f385b 2019-05-10 stsp return 1
167 819f385b 2019-05-10 stsp fi
168 819f385b 2019-05-10 stsp
169 8d301dd9 2019-05-14 stsp cmp -s $testroot/stderr.expected $testroot/stderr
170 819f385b 2019-05-10 stsp ret="$?"
171 819f385b 2019-05-10 stsp if [ "$ret" != "0" ]; then
172 819f385b 2019-05-10 stsp diff -u $testroot/stderr.expected $testroot/stderr
173 f0b75401 2019-08-03 stsp test_done "$testroot" "$ret"
174 f0b75401 2019-08-03 stsp return 1
175 819f385b 2019-05-10 stsp fi
176 f0b75401 2019-08-03 stsp
177 f0b75401 2019-08-03 stsp echo "alpha" > $testroot/repo/alpha
178 f0b75401 2019-08-03 stsp git_commit $testroot/repo -m "reset alpha contents"
179 f0b75401 2019-08-03 stsp (cd $testroot/wt && got update -c $first_commit > /dev/null)
180 f0b75401 2019-08-03 stsp
181 f0b75401 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
182 f0b75401 2019-08-03 stsp
183 f0b75401 2019-08-03 stsp (cd $testroot/wt && got commit -m 'changed alpha ' > $testroot/stdout)
184 f0b75401 2019-08-03 stsp ret="$?"
185 f0b75401 2019-08-03 stsp if [ "$ret" != "0" ]; then
186 f0b75401 2019-08-03 stsp echo "commit failed unexpectedly" >&2
187 f0b75401 2019-08-03 stsp test_done "$testroot" "1"
188 f0b75401 2019-08-03 stsp return 1
189 f0b75401 2019-08-03 stsp fi
190 f0b75401 2019-08-03 stsp
191 f0b75401 2019-08-03 stsp local head_rev=`git_show_head $testroot/repo`
192 f0b75401 2019-08-03 stsp echo "M alpha" > $testroot/stdout.expected
193 f0b75401 2019-08-03 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
194 f0b75401 2019-08-03 stsp cmp -s $testroot/stdout.expected $testroot/stdout
195 f0b75401 2019-08-03 stsp ret="$?"
196 f0b75401 2019-08-03 stsp if [ "$ret" != "0" ]; then
197 f0b75401 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
198 f0b75401 2019-08-03 stsp fi
199 819f385b 2019-05-10 stsp test_done "$testroot" "$ret"
200 819f385b 2019-05-10 stsp }
201 819f385b 2019-05-10 stsp
202 8ba6ba2d 2019-05-14 stsp function test_commit_added_subdirs {
203 8ba6ba2d 2019-05-14 stsp local testroot=`test_init commit_added_subdirs`
204 8ba6ba2d 2019-05-14 stsp
205 8ba6ba2d 2019-05-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
206 8ba6ba2d 2019-05-14 stsp ret="$?"
207 8ba6ba2d 2019-05-14 stsp if [ "$ret" != "0" ]; then
208 8ba6ba2d 2019-05-14 stsp test_done "$testroot" "$ret"
209 8ba6ba2d 2019-05-14 stsp return 1
210 8ba6ba2d 2019-05-14 stsp fi
211 8ba6ba2d 2019-05-14 stsp
212 8ba6ba2d 2019-05-14 stsp mkdir -p $testroot/wt/d
213 8ba6ba2d 2019-05-14 stsp echo "new file" > $testroot/wt/d/new
214 8ba6ba2d 2019-05-14 stsp echo "new file 2" > $testroot/wt/d/new2
215 8ba6ba2d 2019-05-14 stsp mkdir -p $testroot/wt/d/f
216 8ba6ba2d 2019-05-14 stsp echo "new file 3" > $testroot/wt/d/f/new3
217 8ba6ba2d 2019-05-14 stsp mkdir -p $testroot/wt/d/f/g
218 8ba6ba2d 2019-05-14 stsp echo "new file 4" > $testroot/wt/d/f/g/new4
219 8ba6ba2d 2019-05-14 stsp
220 8ba6ba2d 2019-05-14 stsp (cd $testroot/wt && got add $testroot/wt/*/new* \
221 8ba6ba2d 2019-05-14 stsp $testroot/wt/*/*/new* $testroot/wt/*/*/*/new* > /dev/null)
222 8ba6ba2d 2019-05-14 stsp
223 8ba6ba2d 2019-05-14 stsp (cd $testroot/wt && got commit -m 'test commit_added_subdirs' \
224 8ba6ba2d 2019-05-14 stsp > $testroot/stdout 2> $testroot/stderr)
225 8ba6ba2d 2019-05-14 stsp
226 8ba6ba2d 2019-05-14 stsp local head_rev=`git_show_head $testroot/repo`
227 a3df2849 2019-05-20 stsp echo "A d/f/g/new4" > $testroot/stdout.expected
228 a3df2849 2019-05-20 stsp echo "A d/f/new3" >> $testroot/stdout.expected
229 8ba6ba2d 2019-05-14 stsp echo "A d/new" >> $testroot/stdout.expected
230 8ba6ba2d 2019-05-14 stsp echo "A d/new2" >> $testroot/stdout.expected
231 ba580f68 2020-03-22 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
232 ba580f68 2020-03-22 stsp
233 ba580f68 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
234 ba580f68 2020-03-22 stsp ret="$?"
235 ba580f68 2020-03-22 stsp if [ "$ret" != "0" ]; then
236 ba580f68 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
237 ba580f68 2020-03-22 stsp fi
238 ba580f68 2020-03-22 stsp test_done "$testroot" "$ret"
239 ba580f68 2020-03-22 stsp }
240 ba580f68 2020-03-22 stsp
241 ba580f68 2020-03-22 stsp function test_commit_deleted_subdirs {
242 ba580f68 2020-03-22 stsp local testroot=`test_init commit_deleted_subdirs`
243 ba580f68 2020-03-22 stsp
244 ba580f68 2020-03-22 stsp got checkout $testroot/repo $testroot/wt > /dev/null
245 ba580f68 2020-03-22 stsp ret="$?"
246 ba580f68 2020-03-22 stsp if [ "$ret" != "0" ]; then
247 ba580f68 2020-03-22 stsp test_done "$testroot" "$ret"
248 ba580f68 2020-03-22 stsp return 1
249 ba580f68 2020-03-22 stsp fi
250 ba580f68 2020-03-22 stsp
251 ba580f68 2020-03-22 stsp (cd $testroot/wt && got rm -R $testroot/wt/{epsilon,gamma} >/dev/null)
252 ba580f68 2020-03-22 stsp
253 ba580f68 2020-03-22 stsp (cd $testroot/wt && got commit -m 'test commit_deleted_subdirs' \
254 ba580f68 2020-03-22 stsp > $testroot/stdout 2> $testroot/stderr)
255 ba580f68 2020-03-22 stsp
256 ba580f68 2020-03-22 stsp local head_rev=`git_show_head $testroot/repo`
257 ba580f68 2020-03-22 stsp echo "D epsilon/zeta" > $testroot/stdout.expected
258 ba580f68 2020-03-22 stsp echo "D gamma/delta" >> $testroot/stdout.expected
259 a7648d7a 2019-06-02 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
260 ba580f68 2020-03-22 stsp
261 ba580f68 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
262 ba580f68 2020-03-22 stsp ret="$?"
263 ba580f68 2020-03-22 stsp if [ "$ret" != "0" ]; then
264 ba580f68 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
265 ba580f68 2020-03-22 stsp test_done "$testroot" "$ret"
266 ba580f68 2020-03-22 stsp return 1
267 ba580f68 2020-03-22 stsp fi
268 8ba6ba2d 2019-05-14 stsp
269 ba580f68 2020-03-22 stsp got tree -r $testroot/repo > $testroot/stdout
270 ba580f68 2020-03-22 stsp
271 ba580f68 2020-03-22 stsp echo "alpha" > $testroot/stdout.expected
272 ba580f68 2020-03-22 stsp echo "beta" >> $testroot/stdout.expected
273 ba580f68 2020-03-22 stsp
274 8ba6ba2d 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
275 8ba6ba2d 2019-05-14 stsp ret="$?"
276 8ba6ba2d 2019-05-14 stsp if [ "$ret" != "0" ]; then
277 a3df2849 2019-05-20 stsp diff -u $testroot/stdout.expected $testroot/stdout
278 8ba6ba2d 2019-05-14 stsp fi
279 8ba6ba2d 2019-05-14 stsp test_done "$testroot" "$ret"
280 8ba6ba2d 2019-05-14 stsp }
281 8ba6ba2d 2019-05-14 stsp
282 f363d663 2019-05-23 stsp function test_commit_rejects_conflicted_file {
283 461aee03 2019-06-29 stsp local testroot=`test_init commit_rejects_conflicted_file`
284 f363d663 2019-05-23 stsp
285 f363d663 2019-05-23 stsp local initial_rev=`git_show_head $testroot/repo`
286 f363d663 2019-05-23 stsp
287 f363d663 2019-05-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
288 f363d663 2019-05-23 stsp ret="$?"
289 f363d663 2019-05-23 stsp if [ "$ret" != "0" ]; then
290 f363d663 2019-05-23 stsp test_done "$testroot" "$ret"
291 f363d663 2019-05-23 stsp return 1
292 f363d663 2019-05-23 stsp fi
293 f363d663 2019-05-23 stsp
294 f363d663 2019-05-23 stsp echo "modified alpha" > $testroot/wt/alpha
295 f363d663 2019-05-23 stsp (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
296 f363d663 2019-05-23 stsp
297 f363d663 2019-05-23 stsp (cd $testroot/wt && got update -c $initial_rev > /dev/null)
298 f363d663 2019-05-23 stsp
299 f363d663 2019-05-23 stsp echo "modified alpha, too" > $testroot/wt/alpha
300 f363d663 2019-05-23 stsp
301 f363d663 2019-05-23 stsp echo "C alpha" > $testroot/stdout.expected
302 f363d663 2019-05-23 stsp echo -n "Updated to commit " >> $testroot/stdout.expected
303 f363d663 2019-05-23 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
304 f363d663 2019-05-23 stsp echo >> $testroot/stdout.expected
305 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
306 f363d663 2019-05-23 stsp
307 f363d663 2019-05-23 stsp (cd $testroot/wt && got update > $testroot/stdout)
308 f363d663 2019-05-23 stsp
309 f363d663 2019-05-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
310 f363d663 2019-05-23 stsp ret="$?"
311 f363d663 2019-05-23 stsp if [ "$ret" != "0" ]; then
312 f363d663 2019-05-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
313 f363d663 2019-05-23 stsp test_done "$testroot" "$ret"
314 f363d663 2019-05-23 stsp return 1
315 f363d663 2019-05-23 stsp fi
316 f363d663 2019-05-23 stsp
317 f363d663 2019-05-23 stsp (cd $testroot/wt && got commit -m 'commit it' > $testroot/stdout \
318 f363d663 2019-05-23 stsp 2> $testroot/stderr)
319 f363d663 2019-05-23 stsp
320 f363d663 2019-05-23 stsp echo -n > $testroot/stdout.expected
321 f363d663 2019-05-23 stsp echo "got: cannot commit file in conflicted status" \
322 f363d663 2019-05-23 stsp > $testroot/stderr.expected
323 f363d663 2019-05-23 stsp
324 f363d663 2019-05-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
325 f363d663 2019-05-23 stsp ret="$?"
326 f363d663 2019-05-23 stsp if [ "$ret" != "0" ]; then
327 f363d663 2019-05-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
328 f363d663 2019-05-23 stsp test_done "$testroot" "$ret"
329 f363d663 2019-05-23 stsp return 1
330 f363d663 2019-05-23 stsp fi
331 f363d663 2019-05-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
332 f363d663 2019-05-23 stsp ret="$?"
333 f363d663 2019-05-23 stsp if [ "$ret" != "0" ]; then
334 f363d663 2019-05-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
335 f363d663 2019-05-23 stsp fi
336 f363d663 2019-05-23 stsp test_done "$testroot" "$ret"
337 f363d663 2019-05-23 stsp }
338 1a36436d 2019-06-10 stsp
339 1a36436d 2019-06-10 stsp function test_commit_single_file_multiple {
340 1a36436d 2019-06-10 stsp local testroot=`test_init commit_single_file_multiple`
341 f363d663 2019-05-23 stsp
342 1a36436d 2019-06-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
343 1a36436d 2019-06-10 stsp ret="$?"
344 1a36436d 2019-06-10 stsp if [ "$ret" != "0" ]; then
345 1a36436d 2019-06-10 stsp test_done "$testroot" "$ret"
346 1a36436d 2019-06-10 stsp return 1
347 1a36436d 2019-06-10 stsp fi
348 1a36436d 2019-06-10 stsp
349 1a36436d 2019-06-10 stsp for i in 1 2 3 4; do
350 1a36436d 2019-06-10 stsp echo "modified alpha" >> $testroot/wt/alpha
351 1a36436d 2019-06-10 stsp
352 1a36436d 2019-06-10 stsp (cd $testroot/wt && \
353 1a36436d 2019-06-10 stsp got commit -m "changed alpha" > $testroot/stdout)
354 1a36436d 2019-06-10 stsp
355 1a36436d 2019-06-10 stsp local head_rev=`git_show_head $testroot/repo`
356 1a36436d 2019-06-10 stsp echo "M alpha" > $testroot/stdout.expected
357 1a36436d 2019-06-10 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
358 1a36436d 2019-06-10 stsp
359 1a36436d 2019-06-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
360 1a36436d 2019-06-10 stsp ret="$?"
361 1a36436d 2019-06-10 stsp if [ "$ret" != "0" ]; then
362 1a36436d 2019-06-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
363 1a36436d 2019-06-10 stsp test_done "$testroot" "$ret"
364 1a36436d 2019-06-10 stsp return 1
365 1a36436d 2019-06-10 stsp fi
366 1a36436d 2019-06-10 stsp done
367 1a36436d 2019-06-10 stsp
368 1a36436d 2019-06-10 stsp test_done "$testroot" "0"
369 1a36436d 2019-06-10 stsp }
370 4866d084 2019-07-10 stsp
371 4866d084 2019-07-10 stsp function test_commit_added_and_modified_in_same_dir {
372 4866d084 2019-07-10 stsp local testroot=`test_init commit_added_and_modified_in_same_dir`
373 1a36436d 2019-06-10 stsp
374 4866d084 2019-07-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
375 4866d084 2019-07-10 stsp ret="$?"
376 4866d084 2019-07-10 stsp if [ "$ret" != "0" ]; then
377 4866d084 2019-07-10 stsp test_done "$testroot" "$ret"
378 4866d084 2019-07-10 stsp return 1
379 4866d084 2019-07-10 stsp fi
380 4866d084 2019-07-10 stsp
381 4866d084 2019-07-10 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
382 4866d084 2019-07-10 stsp echo "new file" > $testroot/wt/epsilon/new
383 4866d084 2019-07-10 stsp (cd $testroot/wt && got add epsilon/new >/dev/null)
384 4866d084 2019-07-10 stsp
385 4866d084 2019-07-10 stsp (cd $testroot/wt && got commit \
386 4866d084 2019-07-10 stsp -m 'added and modified in same dir' > $testroot/stdout \
387 4866d084 2019-07-10 stsp 2> $testroot/stderr)
388 4866d084 2019-07-10 stsp
389 4866d084 2019-07-10 stsp local head_rev=`git_show_head $testroot/repo`
390 4866d084 2019-07-10 stsp echo "A epsilon/new" > $testroot/stdout.expected
391 4866d084 2019-07-10 stsp echo "M epsilon/zeta" >> $testroot/stdout.expected
392 4866d084 2019-07-10 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
393 e0233cea 2019-07-25 stsp
394 e0233cea 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
395 e0233cea 2019-07-25 stsp ret="$?"
396 e0233cea 2019-07-25 stsp if [ "$ret" != "0" ]; then
397 e0233cea 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
398 e0233cea 2019-07-25 stsp fi
399 e0233cea 2019-07-25 stsp test_done "$testroot" "$ret"
400 e0233cea 2019-07-25 stsp }
401 e0233cea 2019-07-25 stsp
402 e0233cea 2019-07-25 stsp function test_commit_path_prefix {
403 e0233cea 2019-07-25 stsp local testroot=`test_init commit_path_prefix`
404 e0233cea 2019-07-25 stsp local commit1=`git_show_head $testroot/repo`
405 e0233cea 2019-07-25 stsp
406 e0233cea 2019-07-25 stsp got checkout -p gamma $testroot/repo $testroot/wt > /dev/null
407 e0233cea 2019-07-25 stsp ret="$?"
408 e0233cea 2019-07-25 stsp if [ "$ret" != "0" ]; then
409 e0233cea 2019-07-25 stsp test_done "$testroot" "$ret"
410 e0233cea 2019-07-25 stsp return 1
411 e0233cea 2019-07-25 stsp fi
412 e0233cea 2019-07-25 stsp
413 e0233cea 2019-07-25 stsp echo "modified delta" > $testroot/wt/delta
414 e0233cea 2019-07-25 stsp
415 e0233cea 2019-07-25 stsp (cd $testroot/wt && got commit -m 'changed gamma/delta' > $testroot/stdout)
416 e0233cea 2019-07-25 stsp
417 e0233cea 2019-07-25 stsp local commit2=`git_show_head $testroot/repo`
418 e0233cea 2019-07-25 stsp echo "M delta" > $testroot/stdout.expected
419 e0233cea 2019-07-25 stsp echo "Created commit $commit2" >> $testroot/stdout.expected
420 4866d084 2019-07-10 stsp
421 4866d084 2019-07-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
422 4866d084 2019-07-10 stsp ret="$?"
423 4866d084 2019-07-10 stsp if [ "$ret" != "0" ]; then
424 2b496619 2019-07-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
425 e0233cea 2019-07-25 stsp test_done "$testroot" "$ret"
426 e0233cea 2019-07-25 stsp return 1
427 4866d084 2019-07-10 stsp fi
428 e0233cea 2019-07-25 stsp
429 e0233cea 2019-07-25 stsp echo "diff $commit1 $commit2" > $testroot/stdout.expected
430 e0233cea 2019-07-25 stsp echo -n 'blob - ' >> $testroot/stdout.expected
431 e0233cea 2019-07-25 stsp got tree -r $testroot/repo -c $commit1 -i gamma | grep 'delta$' \
432 e0233cea 2019-07-25 stsp | cut -d' ' -f 1 >> $testroot/stdout.expected
433 e0233cea 2019-07-25 stsp echo -n 'blob + ' >> $testroot/stdout.expected
434 e0233cea 2019-07-25 stsp got tree -r $testroot/repo -c $commit2 -i gamma | grep 'delta$' | \
435 e0233cea 2019-07-25 stsp cut -d' ' -f 1 >> $testroot/stdout.expected
436 e0233cea 2019-07-25 stsp echo '--- gamma/delta' >> $testroot/stdout.expected
437 e0233cea 2019-07-25 stsp echo '+++ gamma/delta' >> $testroot/stdout.expected
438 e0233cea 2019-07-25 stsp echo '@@ -1 +1 @@' >> $testroot/stdout.expected
439 e0233cea 2019-07-25 stsp echo '-delta' >> $testroot/stdout.expected
440 e0233cea 2019-07-25 stsp echo '+modified delta' >> $testroot/stdout.expected
441 e0233cea 2019-07-25 stsp
442 e0233cea 2019-07-25 stsp got diff -r $testroot/repo $commit1 $commit2 > $testroot/stdout
443 f2b0a8b0 2020-07-31 stsp cmp -s $testroot/stdout.expected $testroot/stdout
444 f2b0a8b0 2020-07-31 stsp ret="$?"
445 f2b0a8b0 2020-07-31 stsp if [ "$ret" != "0" ]; then
446 f2b0a8b0 2020-07-31 stsp diff -u $testroot/stdout.expected $testroot/stdout
447 f2b0a8b0 2020-07-31 stsp test_done "$testroot" "$ret"
448 f2b0a8b0 2020-07-31 stsp return 1
449 f2b0a8b0 2020-07-31 stsp fi
450 f2b0a8b0 2020-07-31 stsp
451 f2b0a8b0 2020-07-31 stsp (cd $testroot/wt && got rm delta > /dev/null)
452 f2b0a8b0 2020-07-31 stsp echo new > $testroot/wt/new
453 f2b0a8b0 2020-07-31 stsp (cd $testroot/wt && got add new > /dev/null)
454 f2b0a8b0 2020-07-31 stsp
455 f2b0a8b0 2020-07-31 stsp (cd $testroot/wt && got commit -m 'remove gamma/delta; add gamma/new' \
456 f2b0a8b0 2020-07-31 stsp > $testroot/stdout)
457 f2b0a8b0 2020-07-31 stsp
458 f2b0a8b0 2020-07-31 stsp local commit3=`git_show_head $testroot/repo`
459 f2b0a8b0 2020-07-31 stsp echo "A new" > $testroot/stdout.expected
460 f2b0a8b0 2020-07-31 stsp echo "D delta" >> $testroot/stdout.expected
461 f2b0a8b0 2020-07-31 stsp echo "Created commit $commit3" >> $testroot/stdout.expected
462 f2b0a8b0 2020-07-31 stsp
463 f2b0a8b0 2020-07-31 stsp cmp -s $testroot/stdout.expected $testroot/stdout
464 f2b0a8b0 2020-07-31 stsp ret="$?"
465 f2b0a8b0 2020-07-31 stsp if [ "$ret" != "0" ]; then
466 f2b0a8b0 2020-07-31 stsp diff -u $testroot/stdout.expected $testroot/stdout
467 f2b0a8b0 2020-07-31 stsp test_done "$testroot" "$ret"
468 f2b0a8b0 2020-07-31 stsp return 1
469 f2b0a8b0 2020-07-31 stsp fi
470 f2b0a8b0 2020-07-31 stsp
471 f2b0a8b0 2020-07-31 stsp echo "diff $commit2 $commit3" > $testroot/stdout.expected
472 f2b0a8b0 2020-07-31 stsp echo -n 'blob - ' >> $testroot/stdout.expected
473 f2b0a8b0 2020-07-31 stsp got tree -r $testroot/repo -c $commit2 -i gamma | grep 'delta$' \
474 f2b0a8b0 2020-07-31 stsp | cut -d' ' -f 1 | sed -e 's/$/ (mode 644)/' \
475 f2b0a8b0 2020-07-31 stsp >> $testroot/stdout.expected
476 f2b0a8b0 2020-07-31 stsp echo 'blob + /dev/null' >> $testroot/stdout.expected
477 f2b0a8b0 2020-07-31 stsp echo '--- gamma/delta' >> $testroot/stdout.expected
478 f2b0a8b0 2020-07-31 stsp echo '+++ /dev/null' >> $testroot/stdout.expected
479 f2b0a8b0 2020-07-31 stsp echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
480 f2b0a8b0 2020-07-31 stsp echo '-modified delta' >> $testroot/stdout.expected
481 f2b0a8b0 2020-07-31 stsp echo 'blob - /dev/null' >> $testroot/stdout.expected
482 f2b0a8b0 2020-07-31 stsp echo -n 'blob + ' >> $testroot/stdout.expected
483 f2b0a8b0 2020-07-31 stsp got tree -r $testroot/repo -c $commit3 -i gamma | grep 'new$' | \
484 f2b0a8b0 2020-07-31 stsp cut -d' ' -f 1 | sed -e 's/$/ (mode 644)/' \
485 f2b0a8b0 2020-07-31 stsp >> $testroot/stdout.expected
486 f2b0a8b0 2020-07-31 stsp echo '--- /dev/null' >> $testroot/stdout.expected
487 f2b0a8b0 2020-07-31 stsp echo '+++ gamma/new' >> $testroot/stdout.expected
488 f2b0a8b0 2020-07-31 stsp echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
489 f2b0a8b0 2020-07-31 stsp echo '+new' >> $testroot/stdout.expected
490 f2b0a8b0 2020-07-31 stsp
491 f2b0a8b0 2020-07-31 stsp got diff -r $testroot/repo $commit2 $commit3 > $testroot/stdout
492 e0233cea 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
493 e0233cea 2019-07-25 stsp ret="$?"
494 e0233cea 2019-07-25 stsp if [ "$ret" != "0" ]; then
495 e0233cea 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
496 e0233cea 2019-07-25 stsp fi
497 4866d084 2019-07-10 stsp test_done "$testroot" "$ret"
498 f2b0a8b0 2020-07-31 stsp return "$ret"
499 4866d084 2019-07-10 stsp }
500 90e8619e 2019-07-25 stsp
501 90e8619e 2019-07-25 stsp function test_commit_dir_path {
502 90e8619e 2019-07-25 stsp local testroot=`test_init commit_dir_path`
503 4866d084 2019-07-10 stsp
504 90e8619e 2019-07-25 stsp got checkout $testroot/repo $testroot/wt > /dev/null
505 90e8619e 2019-07-25 stsp ret="$?"
506 90e8619e 2019-07-25 stsp if [ "$ret" != "0" ]; then
507 90e8619e 2019-07-25 stsp test_done "$testroot" "$ret"
508 90e8619e 2019-07-25 stsp return 1
509 90e8619e 2019-07-25 stsp fi
510 90e8619e 2019-07-25 stsp
511 90e8619e 2019-07-25 stsp echo "modified alpha" > $testroot/wt/alpha
512 90e8619e 2019-07-25 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
513 90e8619e 2019-07-25 stsp
514 90e8619e 2019-07-25 stsp (cd $testroot/wt && got commit -m 'changed zeta' epsilon \
515 90e8619e 2019-07-25 stsp > $testroot/stdout)
516 90e8619e 2019-07-25 stsp
517 90e8619e 2019-07-25 stsp local head_rev=`git_show_head $testroot/repo`
518 90e8619e 2019-07-25 stsp echo "M epsilon/zeta" >> $testroot/stdout.expected
519 90e8619e 2019-07-25 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
520 90e8619e 2019-07-25 stsp
521 90e8619e 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
522 90e8619e 2019-07-25 stsp ret="$?"
523 90e8619e 2019-07-25 stsp if [ "$ret" != "0" ]; then
524 90e8619e 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
525 90e8619e 2019-07-25 stsp test_done "$testroot" "$ret"
526 90e8619e 2019-07-25 stsp return 1
527 90e8619e 2019-07-25 stsp fi
528 90e8619e 2019-07-25 stsp
529 90e8619e 2019-07-25 stsp echo "M alpha" > $testroot/stdout.expected
530 90e8619e 2019-07-25 stsp (cd $testroot/wt && got status > $testroot/stdout)
531 90e8619e 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
532 90e8619e 2019-07-25 stsp ret="$?"
533 90e8619e 2019-07-25 stsp if [ "$ret" != "0" ]; then
534 90e8619e 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
535 90e8619e 2019-07-25 stsp fi
536 90e8619e 2019-07-25 stsp test_done "$testroot" "$ret"
537 90e8619e 2019-07-25 stsp }
538 5c1e53bc 2019-07-28 stsp
539 5c1e53bc 2019-07-28 stsp function test_commit_selected_paths {
540 5c1e53bc 2019-07-28 stsp local testroot=`test_init commit_selected_paths`
541 5c1e53bc 2019-07-28 stsp
542 5c1e53bc 2019-07-28 stsp got checkout $testroot/repo $testroot/wt > /dev/null
543 5c1e53bc 2019-07-28 stsp ret="$?"
544 5c1e53bc 2019-07-28 stsp if [ "$ret" != "0" ]; then
545 5c1e53bc 2019-07-28 stsp test_done "$testroot" "$ret"
546 5c1e53bc 2019-07-28 stsp return 1
547 5c1e53bc 2019-07-28 stsp fi
548 5c1e53bc 2019-07-28 stsp
549 5c1e53bc 2019-07-28 stsp echo "modified alpha" > $testroot/wt/alpha
550 5c1e53bc 2019-07-28 stsp echo "modified delta" > $testroot/wt/gamma/delta
551 5c1e53bc 2019-07-28 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
552 5c1e53bc 2019-07-28 stsp (cd $testroot/wt && got rm beta >/dev/null)
553 5c1e53bc 2019-07-28 stsp echo "new file" > $testroot/wt/new
554 5c1e53bc 2019-07-28 stsp (cd $testroot/wt && got add new >/dev/null)
555 90e8619e 2019-07-25 stsp
556 5c1e53bc 2019-07-28 stsp (cd $testroot/wt && got commit -m 'many paths' nonexistent alpha \
557 5c1e53bc 2019-07-28 stsp > $testroot/stdout 2> $testroot/stderr)
558 5c1e53bc 2019-07-28 stsp ret="$?"
559 5c1e53bc 2019-07-28 stsp if [ "$ret" == "0" ]; then
560 5c1e53bc 2019-07-28 stsp echo "commit succeeded unexpectedly" >&2
561 5c1e53bc 2019-07-28 stsp test_done "$testroot" "1"
562 5c1e53bc 2019-07-28 stsp return 1
563 5c1e53bc 2019-07-28 stsp fi
564 5c1e53bc 2019-07-28 stsp echo "got: nonexistent: bad path" > $testroot/stderr.expected
565 5c1e53bc 2019-07-28 stsp
566 5c1e53bc 2019-07-28 stsp cmp -s $testroot/stderr.expected $testroot/stderr
567 5c1e53bc 2019-07-28 stsp ret="$?"
568 5c1e53bc 2019-07-28 stsp if [ "$ret" != "0" ]; then
569 5c1e53bc 2019-07-28 stsp diff -u $testroot/stderr.expected $testroot/stderr
570 5c1e53bc 2019-07-28 stsp test_done "$testroot" "$ret"
571 5c1e53bc 2019-07-28 stsp return 1
572 5c1e53bc 2019-07-28 stsp fi
573 5c1e53bc 2019-07-28 stsp
574 5c1e53bc 2019-07-28 stsp (cd $testroot/wt && got commit -m 'many paths' \
575 5c1e53bc 2019-07-28 stsp beta new gamma > $testroot/stdout)
576 5c1e53bc 2019-07-28 stsp
577 5c1e53bc 2019-07-28 stsp local head_rev=`git_show_head $testroot/repo`
578 5c1e53bc 2019-07-28 stsp echo "A new" > $testroot/stdout.expected
579 5c1e53bc 2019-07-28 stsp echo "D beta" >> $testroot/stdout.expected
580 5c1e53bc 2019-07-28 stsp echo "M gamma/delta" >> $testroot/stdout.expected
581 5c1e53bc 2019-07-28 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
582 5c1e53bc 2019-07-28 stsp
583 5c1e53bc 2019-07-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
584 5c1e53bc 2019-07-28 stsp ret="$?"
585 5c1e53bc 2019-07-28 stsp if [ "$ret" != "0" ]; then
586 5c1e53bc 2019-07-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
587 5c1e53bc 2019-07-28 stsp fi
588 5c1e53bc 2019-07-28 stsp test_done "$testroot" "$ret"
589 5c1e53bc 2019-07-28 stsp }
590 5c1e53bc 2019-07-28 stsp
591 916f288c 2019-07-30 stsp function test_commit_outside_refs_heads {
592 916f288c 2019-07-30 stsp local testroot=`test_init commit_outside_refs_heads`
593 916f288c 2019-07-30 stsp
594 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c master refs/remotes/origin/master
595 916f288c 2019-07-30 stsp
596 916f288c 2019-07-30 stsp got checkout -b refs/remotes/origin/master \
597 916f288c 2019-07-30 stsp $testroot/repo $testroot/wt > /dev/null
598 916f288c 2019-07-30 stsp ret="$?"
599 916f288c 2019-07-30 stsp if [ "$ret" != "0" ]; then
600 916f288c 2019-07-30 stsp test_done "$testroot" "$ret"
601 916f288c 2019-07-30 stsp return 1
602 916f288c 2019-07-30 stsp fi
603 916f288c 2019-07-30 stsp
604 916f288c 2019-07-30 stsp echo "modified alpha" > $testroot/wt/alpha
605 916f288c 2019-07-30 stsp
606 916f288c 2019-07-30 stsp (cd $testroot/wt && got commit -m 'change alpha' \
607 916f288c 2019-07-30 stsp > $testroot/stdout 2> $testroot/stderr)
608 916f288c 2019-07-30 stsp ret="$?"
609 916f288c 2019-07-30 stsp if [ "$ret" == "0" ]; then
610 916f288c 2019-07-30 stsp echo "commit succeeded unexpectedly" >&2
611 916f288c 2019-07-30 stsp test_done "$testroot" "1"
612 916f288c 2019-07-30 stsp return 1
613 916f288c 2019-07-30 stsp fi
614 916f288c 2019-07-30 stsp
615 916f288c 2019-07-30 stsp echo -n > $testroot/stdout.expected
616 916f288c 2019-07-30 stsp cmp -s $testroot/stdout.expected $testroot/stdout
617 916f288c 2019-07-30 stsp ret="$?"
618 916f288c 2019-07-30 stsp if [ "$ret" != "0" ]; then
619 916f288c 2019-07-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
620 916f288c 2019-07-30 stsp test_done "$testroot" "$ret"
621 916f288c 2019-07-30 stsp return 1
622 916f288c 2019-07-30 stsp fi
623 916f288c 2019-07-30 stsp
624 916f288c 2019-07-30 stsp echo -n "got: will not commit to a branch outside the " \
625 916f288c 2019-07-30 stsp > $testroot/stderr.expected
626 916f288c 2019-07-30 stsp echo '"refs/heads/" reference namespace' \
627 916f288c 2019-07-30 stsp >> $testroot/stderr.expected
628 916f288c 2019-07-30 stsp cmp -s $testroot/stderr.expected $testroot/stderr
629 916f288c 2019-07-30 stsp ret="$?"
630 916f288c 2019-07-30 stsp if [ "$ret" != "0" ]; then
631 916f288c 2019-07-30 stsp diff -u $testroot/stderr.expected $testroot/stderr
632 916f288c 2019-07-30 stsp fi
633 916f288c 2019-07-30 stsp test_done "$testroot" "$ret"
634 916f288c 2019-07-30 stsp }
635 916f288c 2019-07-30 stsp
636 84792843 2019-08-09 stsp function test_commit_no_email {
637 84792843 2019-08-09 stsp local testroot=`test_init commit_no_email`
638 916f288c 2019-07-30 stsp
639 84792843 2019-08-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
640 84792843 2019-08-09 stsp ret="$?"
641 84792843 2019-08-09 stsp if [ "$ret" != "0" ]; then
642 84792843 2019-08-09 stsp test_done "$testroot" "$ret"
643 84792843 2019-08-09 stsp return 1
644 84792843 2019-08-09 stsp fi
645 84792843 2019-08-09 stsp
646 84792843 2019-08-09 stsp echo "modified alpha" > $testroot/wt/alpha
647 84792843 2019-08-09 stsp (cd $testroot/wt && env GOT_AUTHOR=":flan_hacker:" \
648 84792843 2019-08-09 stsp got commit -m 'test no email' > $testroot/stdout \
649 84792843 2019-08-09 stsp 2> $testroot/stderr)
650 84792843 2019-08-09 stsp
651 84792843 2019-08-09 stsp echo -n "got: GOT_AUTHOR environment variable contains no email " \
652 84792843 2019-08-09 stsp > $testroot/stderr.expected
653 84792843 2019-08-09 stsp echo -n "address; an email address is required for compatibility "\
654 84792843 2019-08-09 stsp >> $testroot/stderr.expected
655 84792843 2019-08-09 stsp echo "with Git" >> $testroot/stderr.expected
656 84792843 2019-08-09 stsp cmp -s $testroot/stderr.expected $testroot/stderr
657 84792843 2019-08-09 stsp ret="$?"
658 84792843 2019-08-09 stsp if [ "$ret" != "0" ]; then
659 84792843 2019-08-09 stsp diff -u $testroot/stderr.expected $testroot/stderr
660 84792843 2019-08-09 stsp test_done "$testroot" "$ret"
661 84792843 2019-08-09 stsp return 1
662 84792843 2019-08-09 stsp fi
663 84792843 2019-08-09 stsp
664 84792843 2019-08-09 stsp echo -n > $testroot/stdout.expected
665 84792843 2019-08-09 stsp cmp -s $testroot/stdout.expected $testroot/stdout
666 84792843 2019-08-09 stsp ret="$?"
667 84792843 2019-08-09 stsp if [ "$ret" != "0" ]; then
668 84792843 2019-08-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
669 84792843 2019-08-09 stsp fi
670 84792843 2019-08-09 stsp test_done "$testroot" "$ret"
671 84792843 2019-08-09 stsp }
672 6af1ccbd 2019-08-16 stsp
673 6af1ccbd 2019-08-16 stsp function test_commit_tree_entry_sorting {
674 6af1ccbd 2019-08-16 stsp local testroot=`test_init commit_tree_entry_sorting`
675 6af1ccbd 2019-08-16 stsp
676 6af1ccbd 2019-08-16 stsp got checkout $testroot/repo $testroot/wt > /dev/null
677 6af1ccbd 2019-08-16 stsp ret="$?"
678 6af1ccbd 2019-08-16 stsp if [ "$ret" != "0" ]; then
679 6af1ccbd 2019-08-16 stsp test_done "$testroot" "$ret"
680 6af1ccbd 2019-08-16 stsp return 1
681 6af1ccbd 2019-08-16 stsp fi
682 6af1ccbd 2019-08-16 stsp
683 6af1ccbd 2019-08-16 stsp # Git's index gets corrupted when tree entries are written in the
684 6af1ccbd 2019-08-16 stsp # order defined by got_path_cmp() rather than Git's own ordering.
685 6af1ccbd 2019-08-16 stsp # Create a new tree where a directory "got" and a file "got-version"
686 6af1ccbd 2019-08-16 stsp # would sort in the wrong order according to Git's opinion.
687 6af1ccbd 2019-08-16 stsp mkdir $testroot/wt/got
688 6af1ccbd 2019-08-16 stsp touch $testroot/wt/got/foo
689 6af1ccbd 2019-08-16 stsp echo foo > $testroot/wt/got-version
690 6af1ccbd 2019-08-16 stsp echo zzz > $testroot/wt/zzz
691 6af1ccbd 2019-08-16 stsp (cd $testroot/wt && got add got-version got/foo zzz > /dev/null)
692 84792843 2019-08-09 stsp
693 6af1ccbd 2019-08-16 stsp (cd $testroot/wt && got commit -m 'test' > /dev/null)
694 84792843 2019-08-09 stsp
695 6af1ccbd 2019-08-16 stsp # Let git-fsck verify the newly written tree to make sure Git is happy
696 6af1ccbd 2019-08-16 stsp (cd $testroot/repo && git fsck --strict \
697 6af1ccbd 2019-08-16 stsp > $testroot/fsck.stdout 2> $testroot/fsck.stderr)
698 6af1ccbd 2019-08-16 stsp ret="$?"
699 6af1ccbd 2019-08-16 stsp test_done "$testroot" "$ret"
700 6af1ccbd 2019-08-16 stsp }
701 aba9c984 2019-09-08 stsp
702 aba9c984 2019-09-08 stsp function test_commit_gitconfig_author {
703 aba9c984 2019-09-08 stsp local testroot=`test_init commit_gitconfig_author`
704 84792843 2019-08-09 stsp
705 aba9c984 2019-09-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
706 aba9c984 2019-09-08 stsp ret="$?"
707 aba9c984 2019-09-08 stsp if [ "$ret" != "0" ]; then
708 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
709 aba9c984 2019-09-08 stsp return 1
710 aba9c984 2019-09-08 stsp fi
711 aba9c984 2019-09-08 stsp
712 aba9c984 2019-09-08 stsp (cd $testroot/repo && git config user.name 'Flan Luck')
713 aba9c984 2019-09-08 stsp (cd $testroot/repo && git config user.email 'flan_luck@openbsd.org')
714 aba9c984 2019-09-08 stsp
715 aba9c984 2019-09-08 stsp echo "modified alpha" > $testroot/wt/alpha
716 aba9c984 2019-09-08 stsp (cd $testroot/wt && got commit -m 'test gitconfig author' > /dev/null)
717 aba9c984 2019-09-08 stsp ret="$?"
718 aba9c984 2019-09-08 stsp if [ "$ret" != "0" ]; then
719 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
720 aba9c984 2019-09-08 stsp return 1
721 aba9c984 2019-09-08 stsp fi
722 aba9c984 2019-09-08 stsp
723 aba9c984 2019-09-08 stsp (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
724 aba9c984 2019-09-08 stsp ret="$?"
725 aba9c984 2019-09-08 stsp if [ "$ret" != "0" ]; then
726 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
727 aba9c984 2019-09-08 stsp return 1
728 aba9c984 2019-09-08 stsp fi
729 aba9c984 2019-09-08 stsp
730 aba9c984 2019-09-08 stsp echo "from: Flan Luck <flan_luck@openbsd.org>" \
731 aba9c984 2019-09-08 stsp > $testroot/stdout.expected
732 aba9c984 2019-09-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
733 aba9c984 2019-09-08 stsp ret="$?"
734 aba9c984 2019-09-08 stsp if [ "$ret" != "0" ]; then
735 aba9c984 2019-09-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
736 aba9c984 2019-09-08 stsp fi
737 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
738 aba9c984 2019-09-08 stsp }
739 1ebedb77 2019-10-19 stsp
740 1ebedb77 2019-10-19 stsp function test_commit_xbit_change {
741 1ebedb77 2019-10-19 stsp local testroot=`test_init commit_xbit_change`
742 1ebedb77 2019-10-19 stsp
743 1ebedb77 2019-10-19 stsp got checkout $testroot/repo $testroot/wt > /dev/null
744 1ebedb77 2019-10-19 stsp ret="$?"
745 1ebedb77 2019-10-19 stsp if [ "$ret" != "0" ]; then
746 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
747 1ebedb77 2019-10-19 stsp return 1
748 1ebedb77 2019-10-19 stsp fi
749 1ebedb77 2019-10-19 stsp
750 1ebedb77 2019-10-19 stsp chmod +x $testroot/wt/alpha
751 1ebedb77 2019-10-19 stsp
752 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
753 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
754 aba9c984 2019-09-08 stsp
755 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
756 1ebedb77 2019-10-19 stsp ret="$?"
757 1ebedb77 2019-10-19 stsp if [ "$ret" != "0" ]; then
758 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
759 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
760 1ebedb77 2019-10-19 stsp return 1
761 1ebedb77 2019-10-19 stsp fi
762 1ebedb77 2019-10-19 stsp
763 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got commit -mx > $testroot/stdout)
764 1ebedb77 2019-10-19 stsp ret="$?"
765 1ebedb77 2019-10-19 stsp if [ "$ret" != "0" ]; then
766 1ebedb77 2019-10-19 stsp echo "got commit failed unexpectedly"
767 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
768 1ebedb77 2019-10-19 stsp return 1
769 1ebedb77 2019-10-19 stsp fi
770 1ebedb77 2019-10-19 stsp
771 1ebedb77 2019-10-19 stsp local commit_id=`git_show_head $testroot/repo`
772 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
773 1ebedb77 2019-10-19 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
774 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
775 1ebedb77 2019-10-19 stsp ret="$?"
776 1ebedb77 2019-10-19 stsp if [ "$ret" != "0" ]; then
777 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
778 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
779 1ebedb77 2019-10-19 stsp return 1
780 1ebedb77 2019-10-19 stsp fi
781 1ebedb77 2019-10-19 stsp
782 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
783 1ebedb77 2019-10-19 stsp
784 1ebedb77 2019-10-19 stsp echo -n > $testroot/stdout.expected
785 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
786 1ebedb77 2019-10-19 stsp ret="$?"
787 1ebedb77 2019-10-19 stsp if [ "$ret" != "0" ]; then
788 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
789 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
790 1ebedb77 2019-10-19 stsp return 1
791 1ebedb77 2019-10-19 stsp fi
792 1ebedb77 2019-10-19 stsp
793 1ebedb77 2019-10-19 stsp chmod -x $testroot/wt/alpha
794 1ebedb77 2019-10-19 stsp
795 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
796 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
797 1ebedb77 2019-10-19 stsp
798 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
799 1ebedb77 2019-10-19 stsp ret="$?"
800 1ebedb77 2019-10-19 stsp if [ "$ret" != "0" ]; then
801 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
802 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
803 1ebedb77 2019-10-19 stsp return 1
804 1ebedb77 2019-10-19 stsp fi
805 1ebedb77 2019-10-19 stsp
806 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got commit -mx > $testroot/stdout)
807 1ebedb77 2019-10-19 stsp ret="$?"
808 1ebedb77 2019-10-19 stsp if [ "$ret" != "0" ]; then
809 1ebedb77 2019-10-19 stsp echo "got commit failed unexpectedly"
810 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
811 1ebedb77 2019-10-19 stsp return 1
812 1ebedb77 2019-10-19 stsp fi
813 1ebedb77 2019-10-19 stsp
814 1ebedb77 2019-10-19 stsp local commit_id=`git_show_head $testroot/repo`
815 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
816 1ebedb77 2019-10-19 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
817 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
818 1ebedb77 2019-10-19 stsp ret="$?"
819 1ebedb77 2019-10-19 stsp if [ "$ret" != "0" ]; then
820 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
821 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
822 1ebedb77 2019-10-19 stsp return 1
823 1ebedb77 2019-10-19 stsp fi
824 1ebedb77 2019-10-19 stsp
825 1ebedb77 2019-10-19 stsp chmod +x $testroot/wt/alpha
826 1ebedb77 2019-10-19 stsp
827 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
828 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
829 f7b97ccb 2020-04-14 stsp
830 f7b97ccb 2020-04-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
831 f7b97ccb 2020-04-14 stsp ret="$?"
832 f7b97ccb 2020-04-14 stsp if [ "$ret" != "0" ]; then
833 f7b97ccb 2020-04-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
834 f7b97ccb 2020-04-14 stsp fi
835 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
836 f7b97ccb 2020-04-14 stsp }
837 f7b97ccb 2020-04-14 stsp
838 f7b97ccb 2020-04-14 stsp function commit_check_mode {
839 f7b97ccb 2020-04-14 stsp local mode="$1"
840 f7b97ccb 2020-04-14 stsp local expected_mode="$2"
841 f7b97ccb 2020-04-14 stsp
842 f7b97ccb 2020-04-14 stsp chmod 644 $testroot/wt/alpha
843 f7b97ccb 2020-04-14 stsp echo a >> $testroot/wt/alpha
844 f7b97ccb 2020-04-14 stsp chmod $mode $testroot/wt/alpha
845 f7b97ccb 2020-04-14 stsp
846 f7b97ccb 2020-04-14 stsp (cd $testroot/wt && got commit -mm > $testroot/stdout)
847 f7b97ccb 2020-04-14 stsp ret="$?"
848 f7b97ccb 2020-04-14 stsp if [ "$ret" != "0" ]; then
849 f7b97ccb 2020-04-14 stsp echo "got commit failed unexpectedly"
850 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
851 f7b97ccb 2020-04-14 stsp return 1
852 f7b97ccb 2020-04-14 stsp fi
853 1ebedb77 2019-10-19 stsp
854 f7b97ccb 2020-04-14 stsp local commit_id=`git_show_head $testroot/repo`
855 f7b97ccb 2020-04-14 stsp echo 'M alpha' > $testroot/stdout.expected
856 f7b97ccb 2020-04-14 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
857 f7b97ccb 2020-04-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
858 f7b97ccb 2020-04-14 stsp ret="$?"
859 f7b97ccb 2020-04-14 stsp if [ "$ret" != "0" ]; then
860 f7b97ccb 2020-04-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
861 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
862 f7b97ccb 2020-04-14 stsp fi
863 f7b97ccb 2020-04-14 stsp
864 f7b97ccb 2020-04-14 stsp local tree_id=$(got cat -r $testroot/repo $commit_id | \
865 f7b97ccb 2020-04-14 stsp grep ^tree | cut -d' ' -f2)
866 f7b97ccb 2020-04-14 stsp local alpha_id=$(got cat -r $testroot/repo $tree_id | \
867 f7b97ccb 2020-04-14 stsp grep 'alpha$' | cut -d' ' -f1)
868 f7b97ccb 2020-04-14 stsp echo "$alpha_id $expected_mode alpha" > $testroot/stdout.expected
869 f7b97ccb 2020-04-14 stsp got cat -r $testroot/repo $tree_id | grep 'alpha$' > $testroot/stdout
870 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
871 1ebedb77 2019-10-19 stsp ret="$?"
872 1ebedb77 2019-10-19 stsp if [ "$ret" != "0" ]; then
873 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
874 1ebedb77 2019-10-19 stsp fi
875 f7b97ccb 2020-04-14 stsp return $ret
876 f7b97ccb 2020-04-14 stsp }
877 f7b97ccb 2020-04-14 stsp
878 f7b97ccb 2020-04-14 stsp function test_commit_normalizes_filemodes {
879 f7b97ccb 2020-04-14 stsp local testroot=`test_init commit_normalizes_filemodes`
880 f7b97ccb 2020-04-14 stsp
881 f7b97ccb 2020-04-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
882 f7b97ccb 2020-04-14 stsp ret="$?"
883 f7b97ccb 2020-04-14 stsp if [ "$ret" != "0" ]; then
884 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
885 f7b97ccb 2020-04-14 stsp return 1
886 f7b97ccb 2020-04-14 stsp fi
887 f7b97ccb 2020-04-14 stsp
888 f7b97ccb 2020-04-14 stsp modes="600 400 460 640 440 660 444 666"
889 f7b97ccb 2020-04-14 stsp for m in $modes; do
890 f7b97ccb 2020-04-14 stsp commit_check_mode "$m" "0100644"
891 cb35d58a 2020-04-14 stsp ret="$?"
892 f7b97ccb 2020-04-14 stsp if [ "$ret" != "0" ]; then
893 f7b97ccb 2020-04-14 stsp break
894 f7b97ccb 2020-04-14 stsp fi
895 f7b97ccb 2020-04-14 stsp done
896 f7b97ccb 2020-04-14 stsp if [ "$ret" != "0" ]; then
897 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
898 f7b97ccb 2020-04-14 stsp return 1
899 f7b97ccb 2020-04-14 stsp fi
900 f7b97ccb 2020-04-14 stsp modes="700 500 570 750 550 770 555 777"
901 f7b97ccb 2020-04-14 stsp for m in $modes; do
902 f7b97ccb 2020-04-14 stsp commit_check_mode "$m" "0100755"
903 cb35d58a 2020-04-14 stsp ret="$?"
904 f7b97ccb 2020-04-14 stsp if [ "$ret" != "0" ]; then
905 f7b97ccb 2020-04-14 stsp break
906 f7b97ccb 2020-04-14 stsp fi
907 f7b97ccb 2020-04-14 stsp done
908 f7b97ccb 2020-04-14 stsp if [ "$ret" != "0" ]; then
909 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
910 e7303626 2020-05-14 stsp return 1
911 e7303626 2020-05-14 stsp fi
912 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
913 e7303626 2020-05-14 stsp }
914 e7303626 2020-05-14 stsp
915 e7303626 2020-05-14 stsp function test_commit_with_unrelated_submodule {
916 e7303626 2020-05-14 stsp local testroot=`test_init commit_with_unrelated_submodule`
917 e7303626 2020-05-14 stsp
918 e7303626 2020-05-14 stsp make_single_file_repo $testroot/repo2 foo
919 e7303626 2020-05-14 stsp
920 e7303626 2020-05-14 stsp (cd $testroot/repo && git submodule -q add ../repo2)
921 e7303626 2020-05-14 stsp (cd $testroot/repo && git commit -q -m 'adding submodule')
922 e7303626 2020-05-14 stsp
923 e7303626 2020-05-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
924 e7303626 2020-05-14 stsp ret="$?"
925 e7303626 2020-05-14 stsp if [ "$ret" != "0" ]; then
926 7aadece8 2020-05-17 stsp echo "checkout failed unexpectedly" >&2
927 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
928 e7303626 2020-05-14 stsp return 1
929 e7303626 2020-05-14 stsp fi
930 e7303626 2020-05-14 stsp
931 e7303626 2020-05-14 stsp echo "modified alpha" > $testroot/wt/alpha
932 e7303626 2020-05-14 stsp
933 7aadece8 2020-05-17 stsp echo "" > $testroot/stdout.expected
934 7aadece8 2020-05-17 stsp
935 74ad335c 2020-06-23 stsp (cd $testroot/wt && got commit -m 'modify alpha' > $testroot/stdout)
936 e7303626 2020-05-14 stsp ret="$?"
937 7aadece8 2020-05-17 stsp if [ "$ret" != "0" ]; then
938 7aadece8 2020-05-17 stsp echo "commit failed unexpectedly" >&2
939 7aadece8 2020-05-17 stsp test_done "$testroot" "$ret"
940 f7b97ccb 2020-04-14 stsp return 1
941 f7b97ccb 2020-04-14 stsp fi
942 e7303626 2020-05-14 stsp
943 7aadece8 2020-05-17 stsp local head_rev=`git_show_head $testroot/repo`
944 7aadece8 2020-05-17 stsp echo "M alpha" > $testroot/stdout.expected
945 7aadece8 2020-05-17 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
946 3d9a4ec4 2020-07-23 stsp
947 3d9a4ec4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
948 3d9a4ec4 2020-07-23 stsp ret="$?"
949 3d9a4ec4 2020-07-23 stsp if [ "$ret" != "0" ]; then
950 3d9a4ec4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
951 3d9a4ec4 2020-07-23 stsp fi
952 3d9a4ec4 2020-07-23 stsp test_done "$testroot" "$ret"
953 3d9a4ec4 2020-07-23 stsp }
954 3d9a4ec4 2020-07-23 stsp
955 bd6aa359 2020-07-23 stsp function check_symlinks {
956 bd6aa359 2020-07-23 stsp local wtpath="$1"
957 bd6aa359 2020-07-23 stsp if ! [ -h $wtpath/alpha.link ]; then
958 bd6aa359 2020-07-23 stsp echo "alpha.link is not a symlink"
959 bd6aa359 2020-07-23 stsp return 1
960 bd6aa359 2020-07-23 stsp fi
961 3d9a4ec4 2020-07-23 stsp
962 bd6aa359 2020-07-23 stsp readlink $wtpath/alpha.link > $testroot/stdout
963 bd6aa359 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
964 bd6aa359 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
965 3d9a4ec4 2020-07-23 stsp ret="$?"
966 3d9a4ec4 2020-07-23 stsp if [ "$ret" != "0" ]; then
967 bd6aa359 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
968 3d9a4ec4 2020-07-23 stsp return 1
969 3d9a4ec4 2020-07-23 stsp fi
970 3d9a4ec4 2020-07-23 stsp
971 bd6aa359 2020-07-23 stsp if ! [ -h $wtpath/epsilon.link ]; then
972 bd6aa359 2020-07-23 stsp echo "epsilon.link is not a symlink"
973 bd6aa359 2020-07-23 stsp return 1
974 bd6aa359 2020-07-23 stsp fi
975 3d9a4ec4 2020-07-23 stsp
976 bd6aa359 2020-07-23 stsp readlink $wtpath/epsilon.link > $testroot/stdout
977 bd6aa359 2020-07-23 stsp echo "epsilon" > $testroot/stdout.expected
978 3d9a4ec4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
979 3d9a4ec4 2020-07-23 stsp ret="$?"
980 3d9a4ec4 2020-07-23 stsp if [ "$ret" != "0" ]; then
981 3d9a4ec4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
982 3d9a4ec4 2020-07-23 stsp return 1
983 3d9a4ec4 2020-07-23 stsp fi
984 3d9a4ec4 2020-07-23 stsp
985 bd6aa359 2020-07-23 stsp if [ -h $wtpath/passwd.link ]; then
986 bd6aa359 2020-07-23 stsp echo -n "passwd.link is a symlink and points outside of work tree: " >&2
987 bd6aa359 2020-07-23 stsp readlink $wtpath/passwd.link >&2
988 bd6aa359 2020-07-23 stsp return 1
989 bd6aa359 2020-07-23 stsp fi
990 bd6aa359 2020-07-23 stsp
991 bd6aa359 2020-07-23 stsp echo -n "/etc/passwd" > $testroot/content.expected
992 bd6aa359 2020-07-23 stsp cp $wtpath/passwd.link $testroot/content
993 3d9a4ec4 2020-07-23 stsp ret="$?"
994 3d9a4ec4 2020-07-23 stsp if [ "$ret" != "0" ]; then
995 bd6aa359 2020-07-23 stsp echo "cp command failed unexpectedly" >&2
996 3d9a4ec4 2020-07-23 stsp return 1
997 3d9a4ec4 2020-07-23 stsp fi
998 3d9a4ec4 2020-07-23 stsp
999 bd6aa359 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
1000 bd6aa359 2020-07-23 stsp ret="$?"
1001 bd6aa359 2020-07-23 stsp if [ "$ret" != "0" ]; then
1002 bd6aa359 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
1003 3d9a4ec4 2020-07-23 stsp return 1
1004 3d9a4ec4 2020-07-23 stsp fi
1005 3d9a4ec4 2020-07-23 stsp
1006 bd6aa359 2020-07-23 stsp readlink $wtpath/epsilon/beta.link > $testroot/stdout
1007 bd6aa359 2020-07-23 stsp echo "../beta" > $testroot/stdout.expected
1008 3d9a4ec4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1009 3d9a4ec4 2020-07-23 stsp ret="$?"
1010 3d9a4ec4 2020-07-23 stsp if [ "$ret" != "0" ]; then
1011 3d9a4ec4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1012 3d9a4ec4 2020-07-23 stsp return 1
1013 3d9a4ec4 2020-07-23 stsp fi
1014 7aadece8 2020-05-17 stsp
1015 bd6aa359 2020-07-23 stsp readlink $wtpath/nonexistent.link > $testroot/stdout
1016 bd6aa359 2020-07-23 stsp echo "nonexistent" > $testroot/stdout.expected
1017 7aadece8 2020-05-17 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1018 e7303626 2020-05-14 stsp ret="$?"
1019 e7303626 2020-05-14 stsp if [ "$ret" != "0" ]; then
1020 7aadece8 2020-05-17 stsp diff -u $testroot/stdout.expected $testroot/stdout
1021 3d9a4ec4 2020-07-23 stsp return 1
1022 e7303626 2020-05-14 stsp fi
1023 3d9a4ec4 2020-07-23 stsp
1024 bd6aa359 2020-07-23 stsp return 0
1025 bd6aa359 2020-07-23 stsp }
1026 3d9a4ec4 2020-07-23 stsp
1027 bd6aa359 2020-07-23 stsp function test_commit_symlink {
1028 bd6aa359 2020-07-23 stsp local testroot=`test_init commit_symlink`
1029 3d9a4ec4 2020-07-23 stsp
1030 bd6aa359 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1031 3d9a4ec4 2020-07-23 stsp ret="$?"
1032 3d9a4ec4 2020-07-23 stsp if [ "$ret" != "0" ]; then
1033 3d9a4ec4 2020-07-23 stsp test_done "$testroot" "$ret"
1034 3d9a4ec4 2020-07-23 stsp return 1
1035 3d9a4ec4 2020-07-23 stsp fi
1036 3d9a4ec4 2020-07-23 stsp
1037 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s alpha alpha.link)
1038 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s epsilon epsilon.link)
1039 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s /etc/passwd passwd.link)
1040 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s ../beta epsilon/beta.link)
1041 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s nonexistent nonexistent.link)
1042 bd6aa359 2020-07-23 stsp (cd $testroot/wt && got add alpha.link epsilon.link passwd.link \
1043 bd6aa359 2020-07-23 stsp epsilon/beta.link nonexistent.link > /dev/null)
1044 bd6aa359 2020-07-23 stsp
1045 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -m 'test commit_symlink' \
1046 35213c7c 2020-07-23 stsp > $testroot/stdout 2> $testroot/stderr)
1047 35213c7c 2020-07-23 stsp ret="$?"
1048 35213c7c 2020-07-23 stsp if [ "$ret" == "0" ]; then
1049 35213c7c 2020-07-23 stsp echo "got commit succeeded unexpectedly" >&2
1050 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
1051 35213c7c 2020-07-23 stsp return 1
1052 35213c7c 2020-07-23 stsp fi
1053 35213c7c 2020-07-23 stsp echo -n "got: $testroot/wt/passwd.link: " > $testroot/stderr.expected
1054 35213c7c 2020-07-23 stsp echo "symbolic link points outside of paths under version control" \
1055 35213c7c 2020-07-23 stsp >> $testroot/stderr.expected
1056 35213c7c 2020-07-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1057 35213c7c 2020-07-23 stsp ret="$?"
1058 35213c7c 2020-07-23 stsp if [ "$ret" != "0" ]; then
1059 35213c7c 2020-07-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
1060 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
1061 35213c7c 2020-07-23 stsp return 1
1062 35213c7c 2020-07-23 stsp fi
1063 bd6aa359 2020-07-23 stsp
1064 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -S -m 'test commit_symlink' \
1065 35213c7c 2020-07-23 stsp > $testroot/stdout)
1066 35213c7c 2020-07-23 stsp
1067 bd6aa359 2020-07-23 stsp local head_rev=`git_show_head $testroot/repo`
1068 bd6aa359 2020-07-23 stsp echo "A alpha.link" > $testroot/stdout.expected
1069 bd6aa359 2020-07-23 stsp echo "A epsilon.link" >> $testroot/stdout.expected
1070 bd6aa359 2020-07-23 stsp echo "A nonexistent.link" >> $testroot/stdout.expected
1071 bd6aa359 2020-07-23 stsp echo "A passwd.link" >> $testroot/stdout.expected
1072 bd6aa359 2020-07-23 stsp echo "A epsilon/beta.link" >> $testroot/stdout.expected
1073 bd6aa359 2020-07-23 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1074 bd6aa359 2020-07-23 stsp
1075 3d9a4ec4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1076 3d9a4ec4 2020-07-23 stsp ret="$?"
1077 3d9a4ec4 2020-07-23 stsp if [ "$ret" != "0" ]; then
1078 3d9a4ec4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1079 3d9a4ec4 2020-07-23 stsp test_done "$testroot" "$ret"
1080 3d9a4ec4 2020-07-23 stsp return 1
1081 3d9a4ec4 2020-07-23 stsp fi
1082 3d9a4ec4 2020-07-23 stsp
1083 bd6aa359 2020-07-23 stsp # verify created in-repository tree
1084 bd6aa359 2020-07-23 stsp got checkout $testroot/repo $testroot/wt2 > /dev/null
1085 3d9a4ec4 2020-07-23 stsp ret="$?"
1086 3d9a4ec4 2020-07-23 stsp if [ "$ret" != "0" ]; then
1087 bd6aa359 2020-07-23 stsp test_done "$testroot" "$ret"
1088 bd6aa359 2020-07-23 stsp return 1
1089 3d9a4ec4 2020-07-23 stsp fi
1090 bd6aa359 2020-07-23 stsp check_symlinks $testroot/wt2
1091 bd6aa359 2020-07-23 stsp ret="$?"
1092 bd6aa359 2020-07-23 stsp if [ "$ret" != "0" ]; then
1093 bd6aa359 2020-07-23 stsp test_done "$testroot" "$ret"
1094 bd6aa359 2020-07-23 stsp return 1
1095 bd6aa359 2020-07-23 stsp fi
1096 bd6aa359 2020-07-23 stsp
1097 75f0a0fb 2020-07-23 stsp if ! [ -h $testroot/wt/passwd.link ]; then
1098 75f0a0fb 2020-07-23 stsp echo 'passwd.link is not a symlink' >&2
1099 75f0a0fb 2020-07-23 stsp test_done "$testroot" 1
1100 75f0a0fb 2020-07-23 stsp return 1
1101 75f0a0fb 2020-07-23 stsp fi
1102 75f0a0fb 2020-07-23 stsp
1103 75f0a0fb 2020-07-23 stsp # 'got update' should reinstall passwd.link as a regular file
1104 75f0a0fb 2020-07-23 stsp (cd $testroot/wt && got update > /dev/null)
1105 bd6aa359 2020-07-23 stsp check_symlinks $testroot/wt
1106 5a1fbc73 2020-07-23 stsp ret="$?"
1107 5a1fbc73 2020-07-23 stsp if [ "$ret" != "0" ]; then
1108 5a1fbc73 2020-07-23 stsp test_done "$testroot" "$ret"
1109 5a1fbc73 2020-07-23 stsp return 1
1110 5a1fbc73 2020-07-23 stsp fi
1111 88fb31d4 2020-07-23 stsp
1112 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sf beta alpha.link)
1113 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sfh gamma epsilon.link)
1114 88fb31d4 2020-07-23 stsp rm $testroot/wt/epsilon/beta.link
1115 88fb31d4 2020-07-23 stsp echo "this is a regular file" > $testroot/wt/epsilon/beta.link
1116 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sf .got/bar dotgotbar.link)
1117 35213c7c 2020-07-23 stsp (cd $testroot/wt && got add dotgotbar.link > /dev/null)
1118 88fb31d4 2020-07-23 stsp (cd $testroot/wt && got rm nonexistent.link > /dev/null)
1119 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sf gamma/delta zeta.link)
1120 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sf alpha new.link)
1121 88fb31d4 2020-07-23 stsp (cd $testroot/wt && got add new.link > /dev/null)
1122 88fb31d4 2020-07-23 stsp
1123 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -m 'test commit_symlink' \
1124 35213c7c 2020-07-23 stsp > $testroot/stdout 2> $testroot/stderr)
1125 35213c7c 2020-07-23 stsp ret="$?"
1126 35213c7c 2020-07-23 stsp if [ "$ret" == "0" ]; then
1127 35213c7c 2020-07-23 stsp echo "got commit succeeded unexpectedly" >&2
1128 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
1129 35213c7c 2020-07-23 stsp return 1
1130 35213c7c 2020-07-23 stsp fi
1131 35213c7c 2020-07-23 stsp echo -n "got: $testroot/wt/dotgotbar.link: " > $testroot/stderr.expected
1132 35213c7c 2020-07-23 stsp echo "symbolic link points outside of paths under version control" \
1133 35213c7c 2020-07-23 stsp >> $testroot/stderr.expected
1134 35213c7c 2020-07-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1135 35213c7c 2020-07-23 stsp ret="$?"
1136 35213c7c 2020-07-23 stsp if [ "$ret" != "0" ]; then
1137 35213c7c 2020-07-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
1138 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
1139 35213c7c 2020-07-23 stsp return 1
1140 35213c7c 2020-07-23 stsp fi
1141 88fb31d4 2020-07-23 stsp
1142 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -S -m 'test commit_symlink' \
1143 35213c7c 2020-07-23 stsp > $testroot/stdout)
1144 35213c7c 2020-07-23 stsp
1145 88fb31d4 2020-07-23 stsp local head_rev=`git_show_head $testroot/repo`
1146 35213c7c 2020-07-23 stsp echo "A dotgotbar.link" > $testroot/stdout.expected
1147 35213c7c 2020-07-23 stsp echo "A new.link" >> $testroot/stdout.expected
1148 88fb31d4 2020-07-23 stsp echo "M alpha.link" >> $testroot/stdout.expected
1149 88fb31d4 2020-07-23 stsp echo "M epsilon/beta.link" >> $testroot/stdout.expected
1150 88fb31d4 2020-07-23 stsp echo "M epsilon.link" >> $testroot/stdout.expected
1151 88fb31d4 2020-07-23 stsp echo "D nonexistent.link" >> $testroot/stdout.expected
1152 88fb31d4 2020-07-23 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1153 88fb31d4 2020-07-23 stsp
1154 88fb31d4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1155 88fb31d4 2020-07-23 stsp ret="$?"
1156 88fb31d4 2020-07-23 stsp if [ "$ret" != "0" ]; then
1157 88fb31d4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1158 88fb31d4 2020-07-23 stsp test_done "$testroot" "$ret"
1159 88fb31d4 2020-07-23 stsp return 1
1160 88fb31d4 2020-07-23 stsp fi
1161 88fb31d4 2020-07-23 stsp
1162 88fb31d4 2020-07-23 stsp got tree -r $testroot/repo -c $head_rev -R > $testroot/stdout
1163 88fb31d4 2020-07-23 stsp cat > $testroot/stdout.expected <<EOF
1164 88fb31d4 2020-07-23 stsp alpha
1165 88fb31d4 2020-07-23 stsp alpha.link@ -> beta
1166 88fb31d4 2020-07-23 stsp beta
1167 35213c7c 2020-07-23 stsp dotgotbar.link@ -> .got/bar
1168 88fb31d4 2020-07-23 stsp epsilon/
1169 88fb31d4 2020-07-23 stsp epsilon/beta.link
1170 88fb31d4 2020-07-23 stsp epsilon/zeta
1171 88fb31d4 2020-07-23 stsp epsilon.link@ -> gamma
1172 88fb31d4 2020-07-23 stsp gamma/
1173 88fb31d4 2020-07-23 stsp gamma/delta
1174 88fb31d4 2020-07-23 stsp new.link@ -> alpha
1175 88fb31d4 2020-07-23 stsp passwd.link@ -> /etc/passwd
1176 88fb31d4 2020-07-23 stsp EOF
1177 88fb31d4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1178 88fb31d4 2020-07-23 stsp ret="$?"
1179 88fb31d4 2020-07-23 stsp if [ "$ret" != "0" ]; then
1180 88fb31d4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1181 88fb31d4 2020-07-23 stsp fi
1182 88fb31d4 2020-07-23 stsp test_done "$testroot" "$ret"
1183 5a1fbc73 2020-07-23 stsp }
1184 5a1fbc73 2020-07-23 stsp
1185 5a1fbc73 2020-07-23 stsp function test_commit_fix_bad_symlink {
1186 5a1fbc73 2020-07-23 stsp local testroot=`test_init commit_fix_bad_symlink`
1187 5a1fbc73 2020-07-23 stsp
1188 5a1fbc73 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1189 5a1fbc73 2020-07-23 stsp ret="$?"
1190 5a1fbc73 2020-07-23 stsp if [ "$ret" != "0" ]; then
1191 5a1fbc73 2020-07-23 stsp echo "got checkout failed unexpectedly" >&2
1192 5a1fbc73 2020-07-23 stsp test_done "$testroot" "$ret"
1193 5a1fbc73 2020-07-23 stsp return 1
1194 5a1fbc73 2020-07-23 stsp fi
1195 5a1fbc73 2020-07-23 stsp
1196 5a1fbc73 2020-07-23 stsp (cd $testroot/wt && ln -s /etc/passwd passwd.link)
1197 5a1fbc73 2020-07-23 stsp (cd $testroot/wt && got add passwd.link > /dev/null)
1198 5a1fbc73 2020-07-23 stsp
1199 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -S -m 'commit bad symlink' \
1200 35213c7c 2020-07-23 stsp > $testroot/stdout)
1201 5a1fbc73 2020-07-23 stsp
1202 75f0a0fb 2020-07-23 stsp if ! [ -h $testroot/wt/passwd.link ]; then
1203 75f0a0fb 2020-07-23 stsp echo 'passwd.link is not a symlink' >&2
1204 75f0a0fb 2020-07-23 stsp test_done "$testroot" 1
1205 75f0a0fb 2020-07-23 stsp return 1
1206 75f0a0fb 2020-07-23 stsp fi
1207 75f0a0fb 2020-07-23 stsp (cd $testroot/wt && got update >/dev/null)
1208 5a1fbc73 2020-07-23 stsp if [ -h $testroot/wt/passwd.link ]; then
1209 5a1fbc73 2020-07-23 stsp echo "passwd.link is a symlink but should be a regular file" >&2
1210 5a1fbc73 2020-07-23 stsp test_done "$testroot" "1"
1211 5a1fbc73 2020-07-23 stsp return 1
1212 5a1fbc73 2020-07-23 stsp fi
1213 5a1fbc73 2020-07-23 stsp
1214 5a1fbc73 2020-07-23 stsp # create another work tree which will contain the "bad" symlink
1215 5a1fbc73 2020-07-23 stsp got checkout $testroot/repo $testroot/wt2 > /dev/null
1216 5a1fbc73 2020-07-23 stsp ret="$?"
1217 5a1fbc73 2020-07-23 stsp if [ "$ret" != "0" ]; then
1218 5a1fbc73 2020-07-23 stsp echo "got checkout failed unexpectedly" >&2
1219 5a1fbc73 2020-07-23 stsp test_done "$testroot" "$ret"
1220 5a1fbc73 2020-07-23 stsp return 1
1221 5a1fbc73 2020-07-23 stsp fi
1222 5a1fbc73 2020-07-23 stsp
1223 5a1fbc73 2020-07-23 stsp # change "bad" symlink back into a "good" symlink
1224 5a1fbc73 2020-07-23 stsp (cd $testroot/wt && ln -sfh alpha passwd.link)
1225 5a1fbc73 2020-07-23 stsp
1226 5a1fbc73 2020-07-23 stsp (cd $testroot/wt && got commit -m 'fix bad symlink' \
1227 5a1fbc73 2020-07-23 stsp > $testroot/stdout)
1228 5a1fbc73 2020-07-23 stsp
1229 5a1fbc73 2020-07-23 stsp local head_rev=`git_show_head $testroot/repo`
1230 5a1fbc73 2020-07-23 stsp echo "M passwd.link" > $testroot/stdout.expected
1231 5a1fbc73 2020-07-23 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1232 5a1fbc73 2020-07-23 stsp
1233 5a1fbc73 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1234 bd6aa359 2020-07-23 stsp ret="$?"
1235 bd6aa359 2020-07-23 stsp if [ "$ret" != "0" ]; then
1236 5a1fbc73 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1237 bd6aa359 2020-07-23 stsp test_done "$testroot" "$ret"
1238 bd6aa359 2020-07-23 stsp return 1
1239 bd6aa359 2020-07-23 stsp fi
1240 5a1fbc73 2020-07-23 stsp
1241 5a1fbc73 2020-07-23 stsp if ! [ -h $testroot/wt/passwd.link ]; then
1242 5a1fbc73 2020-07-23 stsp echo 'passwd.link is not a symlink' >&2
1243 5a1fbc73 2020-07-23 stsp test_done "$testroot" 1
1244 5a1fbc73 2020-07-23 stsp return 1
1245 5a1fbc73 2020-07-23 stsp fi
1246 5a1fbc73 2020-07-23 stsp
1247 5a1fbc73 2020-07-23 stsp readlink $testroot/wt/passwd.link > $testroot/stdout
1248 5a1fbc73 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
1249 5a1fbc73 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1250 5a1fbc73 2020-07-23 stsp ret="$?"
1251 5a1fbc73 2020-07-23 stsp if [ "$ret" != "0" ]; then
1252 5a1fbc73 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1253 5a1fbc73 2020-07-23 stsp return 1
1254 5a1fbc73 2020-07-23 stsp fi
1255 5a1fbc73 2020-07-23 stsp
1256 5a1fbc73 2020-07-23 stsp # Update the other work tree; the bad symlink should be fixed
1257 5a1fbc73 2020-07-23 stsp (cd $testroot/wt2 && got update > /dev/null)
1258 5a1fbc73 2020-07-23 stsp ret="$?"
1259 5a1fbc73 2020-07-23 stsp if [ "$ret" != "0" ]; then
1260 5a1fbc73 2020-07-23 stsp echo "got checkout failed unexpectedly" >&2
1261 5a1fbc73 2020-07-23 stsp test_done "$testroot" "$ret"
1262 5a1fbc73 2020-07-23 stsp return 1
1263 5a1fbc73 2020-07-23 stsp fi
1264 5a1fbc73 2020-07-23 stsp
1265 5a1fbc73 2020-07-23 stsp if ! [ -h $testroot/wt2/passwd.link ]; then
1266 5a1fbc73 2020-07-23 stsp echo 'passwd.link is not a symlink' >&2
1267 5a1fbc73 2020-07-23 stsp test_done "$testroot" 1
1268 5a1fbc73 2020-07-23 stsp return 1
1269 5a1fbc73 2020-07-23 stsp fi
1270 5a1fbc73 2020-07-23 stsp
1271 5a1fbc73 2020-07-23 stsp readlink $testroot/wt2/passwd.link > $testroot/stdout
1272 5a1fbc73 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
1273 5a1fbc73 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1274 5a1fbc73 2020-07-23 stsp ret="$?"
1275 5a1fbc73 2020-07-23 stsp if [ "$ret" != "0" ]; then
1276 5a1fbc73 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1277 5a1fbc73 2020-07-23 stsp return 1
1278 5a1fbc73 2020-07-23 stsp fi
1279 5a1fbc73 2020-07-23 stsp
1280 bd6aa359 2020-07-23 stsp test_done "$testroot" "0"
1281 1ebedb77 2019-10-19 stsp }
1282 1ebedb77 2019-10-19 stsp
1283 c4296144 2019-05-09 stsp run_test test_commit_basic
1284 83a7ae6d 2019-05-10 stsp run_test test_commit_new_subdir
1285 83a7ae6d 2019-05-10 stsp run_test test_commit_subdir
1286 83a7ae6d 2019-05-10 stsp run_test test_commit_single_file
1287 83a7ae6d 2019-05-10 stsp run_test test_commit_out_of_date
1288 8ba6ba2d 2019-05-14 stsp run_test test_commit_added_subdirs
1289 ba580f68 2020-03-22 stsp run_test test_commit_deleted_subdirs
1290 f363d663 2019-05-23 stsp run_test test_commit_rejects_conflicted_file
1291 1a36436d 2019-06-10 stsp run_test test_commit_single_file_multiple
1292 4866d084 2019-07-10 stsp run_test test_commit_added_and_modified_in_same_dir
1293 e0233cea 2019-07-25 stsp run_test test_commit_path_prefix
1294 90e8619e 2019-07-25 stsp run_test test_commit_dir_path
1295 5c1e53bc 2019-07-28 stsp run_test test_commit_selected_paths
1296 916f288c 2019-07-30 stsp run_test test_commit_outside_refs_heads
1297 84792843 2019-08-09 stsp run_test test_commit_no_email
1298 6af1ccbd 2019-08-16 stsp run_test test_commit_tree_entry_sorting
1299 aba9c984 2019-09-08 stsp run_test test_commit_gitconfig_author
1300 1ebedb77 2019-10-19 stsp run_test test_commit_xbit_change
1301 f7b97ccb 2020-04-14 stsp run_test test_commit_normalizes_filemodes
1302 e7303626 2020-05-14 stsp run_test test_commit_with_unrelated_submodule
1303 3d9a4ec4 2020-07-23 stsp run_test test_commit_symlink
1304 5a1fbc73 2020-07-23 stsp run_test test_commit_fix_bad_symlink