3 c4296144 2019-05-09 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
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.
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.
17 c4296144 2019-05-09 stsp . ./common.sh
19 c4296144 2019-05-09 stsp function test_commit_basic {
20 c4296144 2019-05-09 stsp local testroot=`test_init commit_basic`
22 c4296144 2019-05-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
24 c4296144 2019-05-09 stsp if [ "$ret" != "0" ]; then
25 c4296144 2019-05-09 stsp test_done "$testroot" "$ret"
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)
34 83a7ae6d 2019-05-10 stsp (cd $testroot/wt && got commit -m 'test commit_basic' > $testroot/stdout)
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
42 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
44 c4296144 2019-05-09 stsp if [ "$ret" != "0" ]; then
45 c4296144 2019-05-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
47 c4296144 2019-05-09 stsp test_done "$testroot" "$ret"
50 baa7dcfa 2019-05-09 stsp function test_commit_new_subdir {
51 baa7dcfa 2019-05-09 stsp local testroot=`test_init commit_new_subdir`
53 baa7dcfa 2019-05-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
55 baa7dcfa 2019-05-09 stsp if [ "$ret" != "0" ]; then
56 baa7dcfa 2019-05-09 stsp test_done "$testroot" "$ret"
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)
66 baa7dcfa 2019-05-09 stsp (cd $testroot/wt && \
67 baa7dcfa 2019-05-09 stsp got commit -m 'test commit_new_subdir' > $testroot/stdout)
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
74 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
76 baa7dcfa 2019-05-09 stsp if [ "$ret" != "0" ]; then
77 baa7dcfa 2019-05-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
79 baa7dcfa 2019-05-09 stsp test_done "$testroot" "$ret"
82 bc70eb79 2019-05-09 stsp function test_commit_subdir {
83 bc70eb79 2019-05-09 stsp local testroot=`test_init commit_subdir`
85 bc70eb79 2019-05-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
87 bc70eb79 2019-05-09 stsp if [ "$ret" != "0" ]; then
88 bc70eb79 2019-05-09 stsp test_done "$testroot" "$ret"
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
95 bc70eb79 2019-05-09 stsp (cd $testroot/wt && \
96 bc70eb79 2019-05-09 stsp got commit -m 'test commit_subdir' epsilon > $testroot/stdout)
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
102 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
104 bc70eb79 2019-05-09 stsp if [ "$ret" != "0" ]; then
105 bc70eb79 2019-05-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
107 bc70eb79 2019-05-09 stsp test_done "$testroot" "$ret"
110 5bbcb68b 2019-05-09 stsp function test_commit_single_file {
111 5bbcb68b 2019-05-09 stsp local testroot=`test_init commit_single_file`
113 5bbcb68b 2019-05-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
115 5bbcb68b 2019-05-09 stsp if [ "$ret" != "0" ]; then
116 5bbcb68b 2019-05-09 stsp test_done "$testroot" "$ret"
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
123 1a36436d 2019-06-10 stsp (cd $testroot/wt && got commit -m 'changed zeta' epsilon/zeta \
124 5bbcb68b 2019-05-09 stsp > $testroot/stdout)
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
130 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
132 5bbcb68b 2019-05-09 stsp if [ "$ret" != "0" ]; then
133 5bbcb68b 2019-05-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
135 5bbcb68b 2019-05-09 stsp test_done "$testroot" "$ret"
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`
142 819f385b 2019-05-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
144 819f385b 2019-05-10 stsp if [ "$ret" != "0" ]; then
145 819f385b 2019-05-10 stsp test_done "$testroot" "$ret"
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"
152 819f385b 2019-05-10 stsp echo "modified alpha" > $testroot/wt/alpha
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)
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
161 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
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"
169 8d301dd9 2019-05-14 stsp cmp -s $testroot/stderr.expected $testroot/stderr
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"
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)
181 f0b75401 2019-08-03 stsp echo "modified alpha" > $testroot/wt/alpha
183 f0b75401 2019-08-03 stsp (cd $testroot/wt && got commit -m 'changed alpha ' > $testroot/stdout)
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"
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
196 f0b75401 2019-08-03 stsp if [ "$ret" != "0" ]; then
197 f0b75401 2019-08-03 stsp diff -u $testroot/stdout.expected $testroot/stdout
199 819f385b 2019-05-10 stsp test_done "$testroot" "$ret"
202 8ba6ba2d 2019-05-14 stsp function test_commit_added_subdirs {
203 8ba6ba2d 2019-05-14 stsp local testroot=`test_init commit_added_subdirs`
205 8ba6ba2d 2019-05-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
207 8ba6ba2d 2019-05-14 stsp if [ "$ret" != "0" ]; then
208 8ba6ba2d 2019-05-14 stsp test_done "$testroot" "$ret"
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
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)
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)
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
233 ba580f68 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
235 ba580f68 2020-03-22 stsp if [ "$ret" != "0" ]; then
236 ba580f68 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
238 ba580f68 2020-03-22 stsp test_done "$testroot" "$ret"
241 ba580f68 2020-03-22 stsp function test_commit_deleted_subdirs {
242 ba580f68 2020-03-22 stsp local testroot=`test_init commit_deleted_subdirs`
244 ba580f68 2020-03-22 stsp got checkout $testroot/repo $testroot/wt > /dev/null
246 ba580f68 2020-03-22 stsp if [ "$ret" != "0" ]; then
247 ba580f68 2020-03-22 stsp test_done "$testroot" "$ret"
251 ba580f68 2020-03-22 stsp (cd $testroot/wt && got rm -R $testroot/wt/{epsilon,gamma} >/dev/null)
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)
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
261 ba580f68 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
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"
269 ba580f68 2020-03-22 stsp got tree -r $testroot/repo > $testroot/stdout
271 ba580f68 2020-03-22 stsp echo "alpha" > $testroot/stdout.expected
272 ba580f68 2020-03-22 stsp echo "beta" >> $testroot/stdout.expected
274 8ba6ba2d 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
276 8ba6ba2d 2019-05-14 stsp if [ "$ret" != "0" ]; then
277 a3df2849 2019-05-20 stsp diff -u $testroot/stdout.expected $testroot/stdout
279 8ba6ba2d 2019-05-14 stsp test_done "$testroot" "$ret"
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`
285 f363d663 2019-05-23 stsp local initial_rev=`git_show_head $testroot/repo`
287 f363d663 2019-05-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
289 f363d663 2019-05-23 stsp if [ "$ret" != "0" ]; then
290 f363d663 2019-05-23 stsp test_done "$testroot" "$ret"
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)
297 f363d663 2019-05-23 stsp (cd $testroot/wt && got update -c $initial_rev > /dev/null)
299 f363d663 2019-05-23 stsp echo "modified alpha, too" > $testroot/wt/alpha
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
307 f363d663 2019-05-23 stsp (cd $testroot/wt && got update > $testroot/stdout)
309 f363d663 2019-05-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
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"
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)
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
324 f363d663 2019-05-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
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"
331 f363d663 2019-05-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
333 f363d663 2019-05-23 stsp if [ "$ret" != "0" ]; then
334 f363d663 2019-05-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
336 f363d663 2019-05-23 stsp test_done "$testroot" "$ret"
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`
342 1a36436d 2019-06-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
344 1a36436d 2019-06-10 stsp if [ "$ret" != "0" ]; then
345 1a36436d 2019-06-10 stsp test_done "$testroot" "$ret"
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
352 1a36436d 2019-06-10 stsp (cd $testroot/wt && \
353 1a36436d 2019-06-10 stsp got commit -m "changed alpha" > $testroot/stdout)
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
359 1a36436d 2019-06-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
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"
368 1a36436d 2019-06-10 stsp test_done "$testroot" "0"
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`
374 4866d084 2019-07-10 stsp got checkout $testroot/repo $testroot/wt > /dev/null
376 4866d084 2019-07-10 stsp if [ "$ret" != "0" ]; then
377 4866d084 2019-07-10 stsp test_done "$testroot" "$ret"
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)
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)
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
394 e0233cea 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
396 e0233cea 2019-07-25 stsp if [ "$ret" != "0" ]; then
397 e0233cea 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
399 e0233cea 2019-07-25 stsp test_done "$testroot" "$ret"
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`
406 e0233cea 2019-07-25 stsp got checkout -p gamma $testroot/repo $testroot/wt > /dev/null
408 e0233cea 2019-07-25 stsp if [ "$ret" != "0" ]; then
409 e0233cea 2019-07-25 stsp test_done "$testroot" "$ret"
413 e0233cea 2019-07-25 stsp echo "modified delta" > $testroot/wt/delta
415 e0233cea 2019-07-25 stsp (cd $testroot/wt && got commit -m 'changed gamma/delta' > $testroot/stdout)
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
421 4866d084 2019-07-10 stsp cmp -s $testroot/stdout.expected $testroot/stdout
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"
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
442 e0233cea 2019-07-25 stsp got diff -r $testroot/repo $commit1 $commit2 > $testroot/stdout
443 e0233cea 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
445 e0233cea 2019-07-25 stsp if [ "$ret" != "0" ]; then
446 e0233cea 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
448 4866d084 2019-07-10 stsp test_done "$testroot" "$ret"
451 90e8619e 2019-07-25 stsp function test_commit_dir_path {
452 90e8619e 2019-07-25 stsp local testroot=`test_init commit_dir_path`
454 90e8619e 2019-07-25 stsp got checkout $testroot/repo $testroot/wt > /dev/null
456 90e8619e 2019-07-25 stsp if [ "$ret" != "0" ]; then
457 90e8619e 2019-07-25 stsp test_done "$testroot" "$ret"
461 90e8619e 2019-07-25 stsp echo "modified alpha" > $testroot/wt/alpha
462 90e8619e 2019-07-25 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
464 90e8619e 2019-07-25 stsp (cd $testroot/wt && got commit -m 'changed zeta' epsilon \
465 90e8619e 2019-07-25 stsp > $testroot/stdout)
467 90e8619e 2019-07-25 stsp local head_rev=`git_show_head $testroot/repo`
468 90e8619e 2019-07-25 stsp echo "M epsilon/zeta" >> $testroot/stdout.expected
469 90e8619e 2019-07-25 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
471 90e8619e 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
473 90e8619e 2019-07-25 stsp if [ "$ret" != "0" ]; then
474 90e8619e 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
475 90e8619e 2019-07-25 stsp test_done "$testroot" "$ret"
479 90e8619e 2019-07-25 stsp echo "M alpha" > $testroot/stdout.expected
480 90e8619e 2019-07-25 stsp (cd $testroot/wt && got status > $testroot/stdout)
481 90e8619e 2019-07-25 stsp cmp -s $testroot/stdout.expected $testroot/stdout
483 90e8619e 2019-07-25 stsp if [ "$ret" != "0" ]; then
484 90e8619e 2019-07-25 stsp diff -u $testroot/stdout.expected $testroot/stdout
486 90e8619e 2019-07-25 stsp test_done "$testroot" "$ret"
489 5c1e53bc 2019-07-28 stsp function test_commit_selected_paths {
490 5c1e53bc 2019-07-28 stsp local testroot=`test_init commit_selected_paths`
492 5c1e53bc 2019-07-28 stsp got checkout $testroot/repo $testroot/wt > /dev/null
494 5c1e53bc 2019-07-28 stsp if [ "$ret" != "0" ]; then
495 5c1e53bc 2019-07-28 stsp test_done "$testroot" "$ret"
499 5c1e53bc 2019-07-28 stsp echo "modified alpha" > $testroot/wt/alpha
500 5c1e53bc 2019-07-28 stsp echo "modified delta" > $testroot/wt/gamma/delta
501 5c1e53bc 2019-07-28 stsp echo "modified zeta" > $testroot/wt/epsilon/zeta
502 5c1e53bc 2019-07-28 stsp (cd $testroot/wt && got rm beta >/dev/null)
503 5c1e53bc 2019-07-28 stsp echo "new file" > $testroot/wt/new
504 5c1e53bc 2019-07-28 stsp (cd $testroot/wt && got add new >/dev/null)
506 5c1e53bc 2019-07-28 stsp (cd $testroot/wt && got commit -m 'many paths' nonexistent alpha \
507 5c1e53bc 2019-07-28 stsp > $testroot/stdout 2> $testroot/stderr)
509 5c1e53bc 2019-07-28 stsp if [ "$ret" == "0" ]; then
510 5c1e53bc 2019-07-28 stsp echo "commit succeeded unexpectedly" >&2
511 5c1e53bc 2019-07-28 stsp test_done "$testroot" "1"
514 5c1e53bc 2019-07-28 stsp echo "got: nonexistent: bad path" > $testroot/stderr.expected
516 5c1e53bc 2019-07-28 stsp cmp -s $testroot/stderr.expected $testroot/stderr
518 5c1e53bc 2019-07-28 stsp if [ "$ret" != "0" ]; then
519 5c1e53bc 2019-07-28 stsp diff -u $testroot/stderr.expected $testroot/stderr
520 5c1e53bc 2019-07-28 stsp test_done "$testroot" "$ret"
524 5c1e53bc 2019-07-28 stsp (cd $testroot/wt && got commit -m 'many paths' \
525 5c1e53bc 2019-07-28 stsp beta new gamma > $testroot/stdout)
527 5c1e53bc 2019-07-28 stsp local head_rev=`git_show_head $testroot/repo`
528 5c1e53bc 2019-07-28 stsp echo "A new" > $testroot/stdout.expected
529 5c1e53bc 2019-07-28 stsp echo "D beta" >> $testroot/stdout.expected
530 5c1e53bc 2019-07-28 stsp echo "M gamma/delta" >> $testroot/stdout.expected
531 5c1e53bc 2019-07-28 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
533 5c1e53bc 2019-07-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
535 5c1e53bc 2019-07-28 stsp if [ "$ret" != "0" ]; then
536 5c1e53bc 2019-07-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
538 5c1e53bc 2019-07-28 stsp test_done "$testroot" "$ret"
541 916f288c 2019-07-30 stsp function test_commit_outside_refs_heads {
542 916f288c 2019-07-30 stsp local testroot=`test_init commit_outside_refs_heads`
544 e31abbf2 2020-03-22 stsp got ref -r $testroot/repo -c master refs/remotes/origin/master
546 916f288c 2019-07-30 stsp got checkout -b refs/remotes/origin/master \
547 916f288c 2019-07-30 stsp $testroot/repo $testroot/wt > /dev/null
549 916f288c 2019-07-30 stsp if [ "$ret" != "0" ]; then
550 916f288c 2019-07-30 stsp test_done "$testroot" "$ret"
554 916f288c 2019-07-30 stsp echo "modified alpha" > $testroot/wt/alpha
556 916f288c 2019-07-30 stsp (cd $testroot/wt && got commit -m 'change alpha' \
557 916f288c 2019-07-30 stsp > $testroot/stdout 2> $testroot/stderr)
559 916f288c 2019-07-30 stsp if [ "$ret" == "0" ]; then
560 916f288c 2019-07-30 stsp echo "commit succeeded unexpectedly" >&2
561 916f288c 2019-07-30 stsp test_done "$testroot" "1"
565 916f288c 2019-07-30 stsp echo -n > $testroot/stdout.expected
566 916f288c 2019-07-30 stsp cmp -s $testroot/stdout.expected $testroot/stdout
568 916f288c 2019-07-30 stsp if [ "$ret" != "0" ]; then
569 916f288c 2019-07-30 stsp diff -u $testroot/stdout.expected $testroot/stdout
570 916f288c 2019-07-30 stsp test_done "$testroot" "$ret"
574 916f288c 2019-07-30 stsp echo -n "got: will not commit to a branch outside the " \
575 916f288c 2019-07-30 stsp > $testroot/stderr.expected
576 916f288c 2019-07-30 stsp echo '"refs/heads/" reference namespace' \
577 916f288c 2019-07-30 stsp >> $testroot/stderr.expected
578 916f288c 2019-07-30 stsp cmp -s $testroot/stderr.expected $testroot/stderr
580 916f288c 2019-07-30 stsp if [ "$ret" != "0" ]; then
581 916f288c 2019-07-30 stsp diff -u $testroot/stderr.expected $testroot/stderr
583 916f288c 2019-07-30 stsp test_done "$testroot" "$ret"
586 84792843 2019-08-09 stsp function test_commit_no_email {
587 84792843 2019-08-09 stsp local testroot=`test_init commit_no_email`
589 84792843 2019-08-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
591 84792843 2019-08-09 stsp if [ "$ret" != "0" ]; then
592 84792843 2019-08-09 stsp test_done "$testroot" "$ret"
596 84792843 2019-08-09 stsp echo "modified alpha" > $testroot/wt/alpha
597 84792843 2019-08-09 stsp (cd $testroot/wt && env GOT_AUTHOR=":flan_hacker:" \
598 84792843 2019-08-09 stsp got commit -m 'test no email' > $testroot/stdout \
599 84792843 2019-08-09 stsp 2> $testroot/stderr)
601 84792843 2019-08-09 stsp echo -n "got: GOT_AUTHOR environment variable contains no email " \
602 84792843 2019-08-09 stsp > $testroot/stderr.expected
603 84792843 2019-08-09 stsp echo -n "address; an email address is required for compatibility "\
604 84792843 2019-08-09 stsp >> $testroot/stderr.expected
605 84792843 2019-08-09 stsp echo "with Git" >> $testroot/stderr.expected
606 84792843 2019-08-09 stsp cmp -s $testroot/stderr.expected $testroot/stderr
608 84792843 2019-08-09 stsp if [ "$ret" != "0" ]; then
609 84792843 2019-08-09 stsp diff -u $testroot/stderr.expected $testroot/stderr
610 84792843 2019-08-09 stsp test_done "$testroot" "$ret"
614 84792843 2019-08-09 stsp echo -n > $testroot/stdout.expected
615 84792843 2019-08-09 stsp cmp -s $testroot/stdout.expected $testroot/stdout
617 84792843 2019-08-09 stsp if [ "$ret" != "0" ]; then
618 84792843 2019-08-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
620 84792843 2019-08-09 stsp test_done "$testroot" "$ret"
623 6af1ccbd 2019-08-16 stsp function test_commit_tree_entry_sorting {
624 6af1ccbd 2019-08-16 stsp local testroot=`test_init commit_tree_entry_sorting`
626 6af1ccbd 2019-08-16 stsp got checkout $testroot/repo $testroot/wt > /dev/null
628 6af1ccbd 2019-08-16 stsp if [ "$ret" != "0" ]; then
629 6af1ccbd 2019-08-16 stsp test_done "$testroot" "$ret"
633 6af1ccbd 2019-08-16 stsp # Git's index gets corrupted when tree entries are written in the
634 6af1ccbd 2019-08-16 stsp # order defined by got_path_cmp() rather than Git's own ordering.
635 6af1ccbd 2019-08-16 stsp # Create a new tree where a directory "got" and a file "got-version"
636 6af1ccbd 2019-08-16 stsp # would sort in the wrong order according to Git's opinion.
637 6af1ccbd 2019-08-16 stsp mkdir $testroot/wt/got
638 6af1ccbd 2019-08-16 stsp touch $testroot/wt/got/foo
639 6af1ccbd 2019-08-16 stsp echo foo > $testroot/wt/got-version
640 6af1ccbd 2019-08-16 stsp echo zzz > $testroot/wt/zzz
641 6af1ccbd 2019-08-16 stsp (cd $testroot/wt && got add got-version got/foo zzz > /dev/null)
643 6af1ccbd 2019-08-16 stsp (cd $testroot/wt && got commit -m 'test' > /dev/null)
645 6af1ccbd 2019-08-16 stsp # Let git-fsck verify the newly written tree to make sure Git is happy
646 6af1ccbd 2019-08-16 stsp (cd $testroot/repo && git fsck --strict \
647 6af1ccbd 2019-08-16 stsp > $testroot/fsck.stdout 2> $testroot/fsck.stderr)
649 6af1ccbd 2019-08-16 stsp test_done "$testroot" "$ret"
652 aba9c984 2019-09-08 stsp function test_commit_gitconfig_author {
653 aba9c984 2019-09-08 stsp local testroot=`test_init commit_gitconfig_author`
655 aba9c984 2019-09-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
657 aba9c984 2019-09-08 stsp if [ "$ret" != "0" ]; then
658 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
662 aba9c984 2019-09-08 stsp (cd $testroot/repo && git config user.name 'Flan Luck')
663 aba9c984 2019-09-08 stsp (cd $testroot/repo && git config user.email 'flan_luck@openbsd.org')
665 aba9c984 2019-09-08 stsp echo "modified alpha" > $testroot/wt/alpha
666 aba9c984 2019-09-08 stsp (cd $testroot/wt && got commit -m 'test gitconfig author' > /dev/null)
668 aba9c984 2019-09-08 stsp if [ "$ret" != "0" ]; then
669 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
673 aba9c984 2019-09-08 stsp (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
675 aba9c984 2019-09-08 stsp if [ "$ret" != "0" ]; then
676 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
680 aba9c984 2019-09-08 stsp echo "from: Flan Luck <flan_luck@openbsd.org>" \
681 aba9c984 2019-09-08 stsp > $testroot/stdout.expected
682 aba9c984 2019-09-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
684 aba9c984 2019-09-08 stsp if [ "$ret" != "0" ]; then
685 aba9c984 2019-09-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
687 aba9c984 2019-09-08 stsp test_done "$testroot" "$ret"
690 1ebedb77 2019-10-19 stsp function test_commit_xbit_change {
691 1ebedb77 2019-10-19 stsp local testroot=`test_init commit_xbit_change`
693 1ebedb77 2019-10-19 stsp got checkout $testroot/repo $testroot/wt > /dev/null
695 1ebedb77 2019-10-19 stsp if [ "$ret" != "0" ]; then
696 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
700 1ebedb77 2019-10-19 stsp chmod +x $testroot/wt/alpha
702 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
703 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
705 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
707 1ebedb77 2019-10-19 stsp if [ "$ret" != "0" ]; then
708 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
709 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
713 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got commit -mx > $testroot/stdout)
715 1ebedb77 2019-10-19 stsp if [ "$ret" != "0" ]; then
716 1ebedb77 2019-10-19 stsp echo "got commit failed unexpectedly"
717 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
721 1ebedb77 2019-10-19 stsp local commit_id=`git_show_head $testroot/repo`
722 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
723 1ebedb77 2019-10-19 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
724 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
726 1ebedb77 2019-10-19 stsp if [ "$ret" != "0" ]; then
727 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
728 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
732 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
734 1ebedb77 2019-10-19 stsp echo -n > $testroot/stdout.expected
735 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
737 1ebedb77 2019-10-19 stsp if [ "$ret" != "0" ]; then
738 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
739 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
743 1ebedb77 2019-10-19 stsp chmod -x $testroot/wt/alpha
745 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
746 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
748 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
750 1ebedb77 2019-10-19 stsp if [ "$ret" != "0" ]; then
751 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
752 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
756 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got commit -mx > $testroot/stdout)
758 1ebedb77 2019-10-19 stsp if [ "$ret" != "0" ]; then
759 1ebedb77 2019-10-19 stsp echo "got commit failed unexpectedly"
760 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
764 1ebedb77 2019-10-19 stsp local commit_id=`git_show_head $testroot/repo`
765 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
766 1ebedb77 2019-10-19 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
767 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
769 1ebedb77 2019-10-19 stsp if [ "$ret" != "0" ]; then
770 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
771 1ebedb77 2019-10-19 stsp test_done "$testroot" "$ret"
775 1ebedb77 2019-10-19 stsp chmod +x $testroot/wt/alpha
777 1ebedb77 2019-10-19 stsp echo 'm alpha' > $testroot/stdout.expected
778 1ebedb77 2019-10-19 stsp (cd $testroot/wt && got status > $testroot/stdout)
780 f7b97ccb 2020-04-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
782 f7b97ccb 2020-04-14 stsp if [ "$ret" != "0" ]; then
783 f7b97ccb 2020-04-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
785 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
788 f7b97ccb 2020-04-14 stsp function commit_check_mode {
789 f7b97ccb 2020-04-14 stsp local mode="$1"
790 f7b97ccb 2020-04-14 stsp local expected_mode="$2"
792 f7b97ccb 2020-04-14 stsp chmod 644 $testroot/wt/alpha
793 f7b97ccb 2020-04-14 stsp echo a >> $testroot/wt/alpha
794 f7b97ccb 2020-04-14 stsp chmod $mode $testroot/wt/alpha
796 f7b97ccb 2020-04-14 stsp (cd $testroot/wt && got commit -mm > $testroot/stdout)
798 f7b97ccb 2020-04-14 stsp if [ "$ret" != "0" ]; then
799 f7b97ccb 2020-04-14 stsp echo "got commit failed unexpectedly"
800 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
804 f7b97ccb 2020-04-14 stsp local commit_id=`git_show_head $testroot/repo`
805 f7b97ccb 2020-04-14 stsp echo 'M alpha' > $testroot/stdout.expected
806 f7b97ccb 2020-04-14 stsp echo "Created commit $commit_id" >> $testroot/stdout.expected
807 f7b97ccb 2020-04-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
809 f7b97ccb 2020-04-14 stsp if [ "$ret" != "0" ]; then
810 f7b97ccb 2020-04-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
811 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
814 f7b97ccb 2020-04-14 stsp local tree_id=$(got cat -r $testroot/repo $commit_id | \
815 f7b97ccb 2020-04-14 stsp grep ^tree | cut -d' ' -f2)
816 f7b97ccb 2020-04-14 stsp local alpha_id=$(got cat -r $testroot/repo $tree_id | \
817 f7b97ccb 2020-04-14 stsp grep 'alpha$' | cut -d' ' -f1)
818 f7b97ccb 2020-04-14 stsp echo "$alpha_id $expected_mode alpha" > $testroot/stdout.expected
819 f7b97ccb 2020-04-14 stsp got cat -r $testroot/repo $tree_id | grep 'alpha$' > $testroot/stdout
820 1ebedb77 2019-10-19 stsp cmp -s $testroot/stdout.expected $testroot/stdout
822 1ebedb77 2019-10-19 stsp if [ "$ret" != "0" ]; then
823 1ebedb77 2019-10-19 stsp diff -u $testroot/stdout.expected $testroot/stdout
825 f7b97ccb 2020-04-14 stsp return $ret
828 f7b97ccb 2020-04-14 stsp function test_commit_normalizes_filemodes {
829 f7b97ccb 2020-04-14 stsp local testroot=`test_init commit_normalizes_filemodes`
831 f7b97ccb 2020-04-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
833 f7b97ccb 2020-04-14 stsp if [ "$ret" != "0" ]; then
834 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
838 f7b97ccb 2020-04-14 stsp modes="600 400 460 640 440 660 444 666"
839 f7b97ccb 2020-04-14 stsp for m in $modes; do
840 f7b97ccb 2020-04-14 stsp commit_check_mode "$m" "0100644"
842 f7b97ccb 2020-04-14 stsp if [ "$ret" != "0" ]; then
846 f7b97ccb 2020-04-14 stsp if [ "$ret" != "0" ]; then
847 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
850 f7b97ccb 2020-04-14 stsp modes="700 500 570 750 550 770 555 777"
851 f7b97ccb 2020-04-14 stsp for m in $modes; do
852 f7b97ccb 2020-04-14 stsp commit_check_mode "$m" "0100755"
854 f7b97ccb 2020-04-14 stsp if [ "$ret" != "0" ]; then
858 f7b97ccb 2020-04-14 stsp if [ "$ret" != "0" ]; then
859 f7b97ccb 2020-04-14 stsp test_done "$testroot" "$ret"
862 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
865 e7303626 2020-05-14 stsp function test_commit_with_unrelated_submodule {
866 e7303626 2020-05-14 stsp local testroot=`test_init commit_with_unrelated_submodule`
868 e7303626 2020-05-14 stsp make_single_file_repo $testroot/repo2 foo
870 e7303626 2020-05-14 stsp (cd $testroot/repo && git submodule -q add ../repo2)
871 e7303626 2020-05-14 stsp (cd $testroot/repo && git commit -q -m 'adding submodule')
873 e7303626 2020-05-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
875 e7303626 2020-05-14 stsp if [ "$ret" != "0" ]; then
876 7aadece8 2020-05-17 stsp echo "checkout failed unexpectedly" >&2
877 e7303626 2020-05-14 stsp test_done "$testroot" "$ret"
881 e7303626 2020-05-14 stsp echo "modified alpha" > $testroot/wt/alpha
883 7aadece8 2020-05-17 stsp echo "" > $testroot/stdout.expected
885 74ad335c 2020-06-23 stsp (cd $testroot/wt && got commit -m 'modify alpha' > $testroot/stdout)
887 7aadece8 2020-05-17 stsp if [ "$ret" != "0" ]; then
888 7aadece8 2020-05-17 stsp echo "commit failed unexpectedly" >&2
889 7aadece8 2020-05-17 stsp test_done "$testroot" "$ret"
893 7aadece8 2020-05-17 stsp local head_rev=`git_show_head $testroot/repo`
894 7aadece8 2020-05-17 stsp echo "M alpha" > $testroot/stdout.expected
895 7aadece8 2020-05-17 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
897 3d9a4ec4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
899 3d9a4ec4 2020-07-23 stsp if [ "$ret" != "0" ]; then
900 3d9a4ec4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
902 3d9a4ec4 2020-07-23 stsp test_done "$testroot" "$ret"
905 bd6aa359 2020-07-23 stsp function check_symlinks {
906 bd6aa359 2020-07-23 stsp local wtpath="$1"
907 bd6aa359 2020-07-23 stsp if ! [ -h $wtpath/alpha.link ]; then
908 bd6aa359 2020-07-23 stsp echo "alpha.link is not a symlink"
912 bd6aa359 2020-07-23 stsp readlink $wtpath/alpha.link > $testroot/stdout
913 bd6aa359 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
914 bd6aa359 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
916 3d9a4ec4 2020-07-23 stsp if [ "$ret" != "0" ]; then
917 bd6aa359 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
921 bd6aa359 2020-07-23 stsp if ! [ -h $wtpath/epsilon.link ]; then
922 bd6aa359 2020-07-23 stsp echo "epsilon.link is not a symlink"
926 bd6aa359 2020-07-23 stsp readlink $wtpath/epsilon.link > $testroot/stdout
927 bd6aa359 2020-07-23 stsp echo "epsilon" > $testroot/stdout.expected
928 3d9a4ec4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
930 3d9a4ec4 2020-07-23 stsp if [ "$ret" != "0" ]; then
931 3d9a4ec4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
935 bd6aa359 2020-07-23 stsp if [ -h $wtpath/passwd.link ]; then
936 bd6aa359 2020-07-23 stsp echo -n "passwd.link is a symlink and points outside of work tree: " >&2
937 bd6aa359 2020-07-23 stsp readlink $wtpath/passwd.link >&2
941 bd6aa359 2020-07-23 stsp echo -n "/etc/passwd" > $testroot/content.expected
942 bd6aa359 2020-07-23 stsp cp $wtpath/passwd.link $testroot/content
944 3d9a4ec4 2020-07-23 stsp if [ "$ret" != "0" ]; then
945 bd6aa359 2020-07-23 stsp echo "cp command failed unexpectedly" >&2
949 bd6aa359 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
951 bd6aa359 2020-07-23 stsp if [ "$ret" != "0" ]; then
952 bd6aa359 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
956 bd6aa359 2020-07-23 stsp readlink $wtpath/epsilon/beta.link > $testroot/stdout
957 bd6aa359 2020-07-23 stsp echo "../beta" > $testroot/stdout.expected
958 3d9a4ec4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
960 3d9a4ec4 2020-07-23 stsp if [ "$ret" != "0" ]; then
961 3d9a4ec4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
965 bd6aa359 2020-07-23 stsp readlink $wtpath/nonexistent.link > $testroot/stdout
966 bd6aa359 2020-07-23 stsp echo "nonexistent" > $testroot/stdout.expected
967 7aadece8 2020-05-17 stsp cmp -s $testroot/stdout.expected $testroot/stdout
969 e7303626 2020-05-14 stsp if [ "$ret" != "0" ]; then
970 7aadece8 2020-05-17 stsp diff -u $testroot/stdout.expected $testroot/stdout
977 bd6aa359 2020-07-23 stsp function test_commit_symlink {
978 bd6aa359 2020-07-23 stsp local testroot=`test_init commit_symlink`
980 bd6aa359 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
982 3d9a4ec4 2020-07-23 stsp if [ "$ret" != "0" ]; then
983 3d9a4ec4 2020-07-23 stsp test_done "$testroot" "$ret"
987 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s alpha alpha.link)
988 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s epsilon epsilon.link)
989 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s /etc/passwd passwd.link)
990 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s ../beta epsilon/beta.link)
991 bd6aa359 2020-07-23 stsp (cd $testroot/wt && ln -s nonexistent nonexistent.link)
992 bd6aa359 2020-07-23 stsp (cd $testroot/wt && got add alpha.link epsilon.link passwd.link \
993 bd6aa359 2020-07-23 stsp epsilon/beta.link nonexistent.link > /dev/null)
995 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -m 'test commit_symlink' \
996 35213c7c 2020-07-23 stsp > $testroot/stdout 2> $testroot/stderr)
998 35213c7c 2020-07-23 stsp if [ "$ret" == "0" ]; then
999 35213c7c 2020-07-23 stsp echo "got commit succeeded unexpectedly" >&2
1000 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
1003 35213c7c 2020-07-23 stsp echo -n "got: $testroot/wt/passwd.link: " > $testroot/stderr.expected
1004 35213c7c 2020-07-23 stsp echo "symbolic link points outside of paths under version control" \
1005 35213c7c 2020-07-23 stsp >> $testroot/stderr.expected
1006 35213c7c 2020-07-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1008 35213c7c 2020-07-23 stsp if [ "$ret" != "0" ]; then
1009 35213c7c 2020-07-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
1010 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
1014 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -S -m 'test commit_symlink' \
1015 35213c7c 2020-07-23 stsp > $testroot/stdout)
1017 bd6aa359 2020-07-23 stsp local head_rev=`git_show_head $testroot/repo`
1018 bd6aa359 2020-07-23 stsp echo "A alpha.link" > $testroot/stdout.expected
1019 bd6aa359 2020-07-23 stsp echo "A epsilon.link" >> $testroot/stdout.expected
1020 bd6aa359 2020-07-23 stsp echo "A nonexistent.link" >> $testroot/stdout.expected
1021 bd6aa359 2020-07-23 stsp echo "A passwd.link" >> $testroot/stdout.expected
1022 bd6aa359 2020-07-23 stsp echo "A epsilon/beta.link" >> $testroot/stdout.expected
1023 bd6aa359 2020-07-23 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1025 3d9a4ec4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1027 3d9a4ec4 2020-07-23 stsp if [ "$ret" != "0" ]; then
1028 3d9a4ec4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1029 3d9a4ec4 2020-07-23 stsp test_done "$testroot" "$ret"
1033 bd6aa359 2020-07-23 stsp # verify created in-repository tree
1034 bd6aa359 2020-07-23 stsp got checkout $testroot/repo $testroot/wt2 > /dev/null
1036 3d9a4ec4 2020-07-23 stsp if [ "$ret" != "0" ]; then
1037 bd6aa359 2020-07-23 stsp test_done "$testroot" "$ret"
1040 bd6aa359 2020-07-23 stsp check_symlinks $testroot/wt2
1042 bd6aa359 2020-07-23 stsp if [ "$ret" != "0" ]; then
1043 bd6aa359 2020-07-23 stsp test_done "$testroot" "$ret"
1047 75f0a0fb 2020-07-23 stsp if ! [ -h $testroot/wt/passwd.link ]; then
1048 75f0a0fb 2020-07-23 stsp echo 'passwd.link is not a symlink' >&2
1049 75f0a0fb 2020-07-23 stsp test_done "$testroot" 1
1053 75f0a0fb 2020-07-23 stsp # 'got update' should reinstall passwd.link as a regular file
1054 75f0a0fb 2020-07-23 stsp (cd $testroot/wt && got update > /dev/null)
1055 bd6aa359 2020-07-23 stsp check_symlinks $testroot/wt
1057 5a1fbc73 2020-07-23 stsp if [ "$ret" != "0" ]; then
1058 5a1fbc73 2020-07-23 stsp test_done "$testroot" "$ret"
1062 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sf beta alpha.link)
1063 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sfh gamma epsilon.link)
1064 88fb31d4 2020-07-23 stsp rm $testroot/wt/epsilon/beta.link
1065 88fb31d4 2020-07-23 stsp echo "this is a regular file" > $testroot/wt/epsilon/beta.link
1066 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sf .got/bar dotgotbar.link)
1067 35213c7c 2020-07-23 stsp (cd $testroot/wt && got add dotgotbar.link > /dev/null)
1068 88fb31d4 2020-07-23 stsp (cd $testroot/wt && got rm nonexistent.link > /dev/null)
1069 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sf gamma/delta zeta.link)
1070 88fb31d4 2020-07-23 stsp (cd $testroot/wt && ln -sf alpha new.link)
1071 88fb31d4 2020-07-23 stsp (cd $testroot/wt && got add new.link > /dev/null)
1073 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -m 'test commit_symlink' \
1074 35213c7c 2020-07-23 stsp > $testroot/stdout 2> $testroot/stderr)
1076 35213c7c 2020-07-23 stsp if [ "$ret" == "0" ]; then
1077 35213c7c 2020-07-23 stsp echo "got commit succeeded unexpectedly" >&2
1078 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
1081 35213c7c 2020-07-23 stsp echo -n "got: $testroot/wt/dotgotbar.link: " > $testroot/stderr.expected
1082 35213c7c 2020-07-23 stsp echo "symbolic link points outside of paths under version control" \
1083 35213c7c 2020-07-23 stsp >> $testroot/stderr.expected
1084 35213c7c 2020-07-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1086 35213c7c 2020-07-23 stsp if [ "$ret" != "0" ]; then
1087 35213c7c 2020-07-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
1088 35213c7c 2020-07-23 stsp test_done "$testroot" "$ret"
1092 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -S -m 'test commit_symlink' \
1093 35213c7c 2020-07-23 stsp > $testroot/stdout)
1095 88fb31d4 2020-07-23 stsp local head_rev=`git_show_head $testroot/repo`
1096 35213c7c 2020-07-23 stsp echo "A dotgotbar.link" > $testroot/stdout.expected
1097 35213c7c 2020-07-23 stsp echo "A new.link" >> $testroot/stdout.expected
1098 88fb31d4 2020-07-23 stsp echo "M alpha.link" >> $testroot/stdout.expected
1099 88fb31d4 2020-07-23 stsp echo "M epsilon/beta.link" >> $testroot/stdout.expected
1100 88fb31d4 2020-07-23 stsp echo "M epsilon.link" >> $testroot/stdout.expected
1101 88fb31d4 2020-07-23 stsp echo "D nonexistent.link" >> $testroot/stdout.expected
1102 88fb31d4 2020-07-23 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1104 88fb31d4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1106 88fb31d4 2020-07-23 stsp if [ "$ret" != "0" ]; then
1107 88fb31d4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1108 88fb31d4 2020-07-23 stsp test_done "$testroot" "$ret"
1112 88fb31d4 2020-07-23 stsp got tree -r $testroot/repo -c $head_rev -R > $testroot/stdout
1113 88fb31d4 2020-07-23 stsp cat > $testroot/stdout.expected <<EOF
1115 88fb31d4 2020-07-23 stsp alpha.link@ -> beta
1117 35213c7c 2020-07-23 stsp dotgotbar.link@ -> .got/bar
1119 88fb31d4 2020-07-23 stsp epsilon/beta.link
1120 88fb31d4 2020-07-23 stsp epsilon/zeta
1121 88fb31d4 2020-07-23 stsp epsilon.link@ -> gamma
1123 88fb31d4 2020-07-23 stsp gamma/delta
1124 88fb31d4 2020-07-23 stsp new.link@ -> alpha
1125 88fb31d4 2020-07-23 stsp passwd.link@ -> /etc/passwd
1127 88fb31d4 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1129 88fb31d4 2020-07-23 stsp if [ "$ret" != "0" ]; then
1130 88fb31d4 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1132 88fb31d4 2020-07-23 stsp test_done "$testroot" "$ret"
1135 5a1fbc73 2020-07-23 stsp function test_commit_fix_bad_symlink {
1136 5a1fbc73 2020-07-23 stsp local testroot=`test_init commit_fix_bad_symlink`
1138 5a1fbc73 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1140 5a1fbc73 2020-07-23 stsp if [ "$ret" != "0" ]; then
1141 5a1fbc73 2020-07-23 stsp echo "got checkout failed unexpectedly" >&2
1142 5a1fbc73 2020-07-23 stsp test_done "$testroot" "$ret"
1146 5a1fbc73 2020-07-23 stsp (cd $testroot/wt && ln -s /etc/passwd passwd.link)
1147 5a1fbc73 2020-07-23 stsp (cd $testroot/wt && got add passwd.link > /dev/null)
1149 35213c7c 2020-07-23 stsp (cd $testroot/wt && got commit -S -m 'commit bad symlink' \
1150 35213c7c 2020-07-23 stsp > $testroot/stdout)
1152 75f0a0fb 2020-07-23 stsp if ! [ -h $testroot/wt/passwd.link ]; then
1153 75f0a0fb 2020-07-23 stsp echo 'passwd.link is not a symlink' >&2
1154 75f0a0fb 2020-07-23 stsp test_done "$testroot" 1
1157 75f0a0fb 2020-07-23 stsp (cd $testroot/wt && got update >/dev/null)
1158 5a1fbc73 2020-07-23 stsp if [ -h $testroot/wt/passwd.link ]; then
1159 5a1fbc73 2020-07-23 stsp echo "passwd.link is a symlink but should be a regular file" >&2
1160 5a1fbc73 2020-07-23 stsp test_done "$testroot" "1"
1164 5a1fbc73 2020-07-23 stsp # create another work tree which will contain the "bad" symlink
1165 5a1fbc73 2020-07-23 stsp got checkout $testroot/repo $testroot/wt2 > /dev/null
1167 5a1fbc73 2020-07-23 stsp if [ "$ret" != "0" ]; then
1168 5a1fbc73 2020-07-23 stsp echo "got checkout failed unexpectedly" >&2
1169 5a1fbc73 2020-07-23 stsp test_done "$testroot" "$ret"
1173 5a1fbc73 2020-07-23 stsp # change "bad" symlink back into a "good" symlink
1174 5a1fbc73 2020-07-23 stsp (cd $testroot/wt && ln -sfh alpha passwd.link)
1176 5a1fbc73 2020-07-23 stsp (cd $testroot/wt && got commit -m 'fix bad symlink' \
1177 5a1fbc73 2020-07-23 stsp > $testroot/stdout)
1179 5a1fbc73 2020-07-23 stsp local head_rev=`git_show_head $testroot/repo`
1180 5a1fbc73 2020-07-23 stsp echo "M passwd.link" > $testroot/stdout.expected
1181 5a1fbc73 2020-07-23 stsp echo "Created commit $head_rev" >> $testroot/stdout.expected
1183 5a1fbc73 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1185 bd6aa359 2020-07-23 stsp if [ "$ret" != "0" ]; then
1186 5a1fbc73 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1187 bd6aa359 2020-07-23 stsp test_done "$testroot" "$ret"
1191 5a1fbc73 2020-07-23 stsp if ! [ -h $testroot/wt/passwd.link ]; then
1192 5a1fbc73 2020-07-23 stsp echo 'passwd.link is not a symlink' >&2
1193 5a1fbc73 2020-07-23 stsp test_done "$testroot" 1
1197 5a1fbc73 2020-07-23 stsp readlink $testroot/wt/passwd.link > $testroot/stdout
1198 5a1fbc73 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
1199 5a1fbc73 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1201 5a1fbc73 2020-07-23 stsp if [ "$ret" != "0" ]; then
1202 5a1fbc73 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1206 5a1fbc73 2020-07-23 stsp # Update the other work tree; the bad symlink should be fixed
1207 5a1fbc73 2020-07-23 stsp (cd $testroot/wt2 && got update > /dev/null)
1209 5a1fbc73 2020-07-23 stsp if [ "$ret" != "0" ]; then
1210 5a1fbc73 2020-07-23 stsp echo "got checkout failed unexpectedly" >&2
1211 5a1fbc73 2020-07-23 stsp test_done "$testroot" "$ret"
1215 5a1fbc73 2020-07-23 stsp if ! [ -h $testroot/wt2/passwd.link ]; then
1216 5a1fbc73 2020-07-23 stsp echo 'passwd.link is not a symlink' >&2
1217 5a1fbc73 2020-07-23 stsp test_done "$testroot" 1
1221 5a1fbc73 2020-07-23 stsp readlink $testroot/wt2/passwd.link > $testroot/stdout
1222 5a1fbc73 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
1223 5a1fbc73 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1225 5a1fbc73 2020-07-23 stsp if [ "$ret" != "0" ]; then
1226 5a1fbc73 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
1230 bd6aa359 2020-07-23 stsp test_done "$testroot" "0"
1233 c4296144 2019-05-09 stsp run_test test_commit_basic
1234 83a7ae6d 2019-05-10 stsp run_test test_commit_new_subdir
1235 83a7ae6d 2019-05-10 stsp run_test test_commit_subdir
1236 83a7ae6d 2019-05-10 stsp run_test test_commit_single_file
1237 83a7ae6d 2019-05-10 stsp run_test test_commit_out_of_date
1238 8ba6ba2d 2019-05-14 stsp run_test test_commit_added_subdirs
1239 ba580f68 2020-03-22 stsp run_test test_commit_deleted_subdirs
1240 f363d663 2019-05-23 stsp run_test test_commit_rejects_conflicted_file
1241 1a36436d 2019-06-10 stsp run_test test_commit_single_file_multiple
1242 4866d084 2019-07-10 stsp run_test test_commit_added_and_modified_in_same_dir
1243 e0233cea 2019-07-25 stsp run_test test_commit_path_prefix
1244 90e8619e 2019-07-25 stsp run_test test_commit_dir_path
1245 5c1e53bc 2019-07-28 stsp run_test test_commit_selected_paths
1246 916f288c 2019-07-30 stsp run_test test_commit_outside_refs_heads
1247 84792843 2019-08-09 stsp run_test test_commit_no_email
1248 6af1ccbd 2019-08-16 stsp run_test test_commit_tree_entry_sorting
1249 aba9c984 2019-09-08 stsp run_test test_commit_gitconfig_author
1250 1ebedb77 2019-10-19 stsp run_test test_commit_xbit_change
1251 f7b97ccb 2020-04-14 stsp run_test test_commit_normalizes_filemodes
1252 e7303626 2020-05-14 stsp run_test test_commit_with_unrelated_submodule
1253 3d9a4ec4 2020-07-23 stsp run_test test_commit_symlink
1254 5a1fbc73 2020-07-23 stsp run_test test_commit_fix_bad_symlink