Blob


1 #!/bin/sh
2 #
3 # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
4 #
5 # Permission to use, copy, modify, and distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
8 #
9 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 . ./common.sh
19 function test_commit_basic {
20 local testroot=`test_init commit_basic`
22 got checkout $testroot/repo $testroot/wt > /dev/null
23 ret="$?"
24 if [ "$ret" != "0" ]; then
25 test_done "$testroot" "$ret"
26 return 1
27 fi
29 echo "modified alpha" > $testroot/wt/alpha
30 (cd $testroot/wt && got rm beta >/dev/null)
31 echo "new file" > $testroot/wt/new
32 (cd $testroot/wt && got add new >/dev/null)
34 (cd $testroot/wt && got commit -m 'test commit_basic' > $testroot/stdout)
36 local head_rev=`git_show_head $testroot/repo`
37 echo "A new" > $testroot/stdout.expected
38 echo "M alpha" >> $testroot/stdout.expected
39 echo "D beta" >> $testroot/stdout.expected
40 echo "Created commit $head_rev" >> $testroot/stdout.expected
42 cmp -s $testroot/stdout.expected $testroot/stdout
43 ret="$?"
44 if [ "$ret" != "0" ]; then
45 diff -u $testroot/stdout.expected $testroot/stdout
46 fi
47 test_done "$testroot" "$ret"
48 }
50 function test_commit_new_subdir {
51 local testroot=`test_init commit_new_subdir`
53 got checkout $testroot/repo $testroot/wt > /dev/null
54 ret="$?"
55 if [ "$ret" != "0" ]; then
56 test_done "$testroot" "$ret"
57 return 1
58 fi
60 mkdir -p $testroot/wt/d
61 echo "new file" > $testroot/wt/d/new
62 echo "another new file" > $testroot/wt/d/new2
63 (cd $testroot/wt && got add d/new >/dev/null)
64 (cd $testroot/wt && got add d/new2 >/dev/null)
66 (cd $testroot/wt && \
67 got commit -m 'test commit_new_subdir' > $testroot/stdout)
69 local head_rev=`git_show_head $testroot/repo`
70 echo "A d/new" > $testroot/stdout.expected
71 echo "A d/new2" >> $testroot/stdout.expected
72 echo "Created commit $head_rev" >> $testroot/stdout.expected
74 cmp -s $testroot/stdout.expected $testroot/stdout
75 ret="$?"
76 if [ "$ret" != "0" ]; then
77 diff -u $testroot/stdout.expected $testroot/stdout
78 fi
79 test_done "$testroot" "$ret"
80 }
82 function test_commit_subdir {
83 local testroot=`test_init commit_subdir`
85 got checkout $testroot/repo $testroot/wt > /dev/null
86 ret="$?"
87 if [ "$ret" != "0" ]; then
88 test_done "$testroot" "$ret"
89 return 1
90 fi
92 echo "modified alpha" > $testroot/wt/alpha
93 echo "modified zeta" > $testroot/wt/epsilon/zeta
95 (cd $testroot/wt && \
96 got commit -m 'test commit_subdir' epsilon > $testroot/stdout)
98 local head_rev=`git_show_head $testroot/repo`
99 echo "M epsilon/zeta" >> $testroot/stdout.expected
100 echo "Created commit $head_rev" >> $testroot/stdout.expected
102 cmp -s $testroot/stdout.expected $testroot/stdout
103 ret="$?"
104 if [ "$ret" != "0" ]; then
105 diff -u $testroot/stdout.expected $testroot/stdout
106 fi
107 test_done "$testroot" "$ret"
110 function test_commit_single_file {
111 local testroot=`test_init commit_single_file`
113 got checkout $testroot/repo $testroot/wt > /dev/null
114 ret="$?"
115 if [ "$ret" != "0" ]; then
116 test_done "$testroot" "$ret"
117 return 1
118 fi
120 echo "modified alpha" > $testroot/wt/alpha
121 echo "modified zeta" > $testroot/wt/epsilon/zeta
123 (cd $testroot/wt && got commit -m 'changed zeta' epsilon/zeta \
124 > $testroot/stdout)
126 local head_rev=`git_show_head $testroot/repo`
127 echo "M epsilon/zeta" >> $testroot/stdout.expected
128 echo "Created commit $head_rev" >> $testroot/stdout.expected
130 cmp -s $testroot/stdout.expected $testroot/stdout
131 ret="$?"
132 if [ "$ret" != "0" ]; then
133 diff -u $testroot/stdout.expected $testroot/stdout
134 fi
135 test_done "$testroot" "$ret"
138 function test_commit_out_of_date {
139 local testroot=`test_init commit_out_of_date`
140 local first_commit=`git_show_head $testroot/repo`
142 got checkout $testroot/repo $testroot/wt > /dev/null
143 ret="$?"
144 if [ "$ret" != "0" ]; then
145 test_done "$testroot" "$ret"
146 return 1
147 fi
149 echo "modified alpha" > $testroot/repo/alpha
150 git_commit $testroot/repo -m "modified alpha"
152 echo "modified alpha" > $testroot/wt/alpha
154 (cd $testroot/wt && got commit -m 'test commit_out_of_date' \
155 > $testroot/stdout 2> $testroot/stderr)
157 echo -n > $testroot/stdout.expected
158 echo "got: work tree must be updated before these" \
159 "changes can be committed" > $testroot/stderr.expected
161 cmp -s $testroot/stdout.expected $testroot/stdout
162 ret="$?"
163 if [ "$ret" != "0" ]; then
164 diff -u $testroot/stdout.expected $testroot/stdout
165 test_done "$testroot" "$ret"
166 return 1
167 fi
169 cmp -s $testroot/stderr.expected $testroot/stderr
170 ret="$?"
171 if [ "$ret" != "0" ]; then
172 diff -u $testroot/stderr.expected $testroot/stderr
173 test_done "$testroot" "$ret"
174 return 1
175 fi
177 echo "alpha" > $testroot/repo/alpha
178 git_commit $testroot/repo -m "reset alpha contents"
179 (cd $testroot/wt && got update -c $first_commit > /dev/null)
181 echo "modified alpha" > $testroot/wt/alpha
183 (cd $testroot/wt && got commit -m 'changed alpha ' > $testroot/stdout)
184 ret="$?"
185 if [ "$ret" != "0" ]; then
186 echo "commit failed unexpectedly" >&2
187 test_done "$testroot" "1"
188 return 1
189 fi
191 local head_rev=`git_show_head $testroot/repo`
192 echo "M alpha" > $testroot/stdout.expected
193 echo "Created commit $head_rev" >> $testroot/stdout.expected
194 cmp -s $testroot/stdout.expected $testroot/stdout
195 ret="$?"
196 if [ "$ret" != "0" ]; then
197 diff -u $testroot/stdout.expected $testroot/stdout
198 fi
199 test_done "$testroot" "$ret"
202 function test_commit_added_subdirs {
203 local testroot=`test_init commit_added_subdirs`
205 got checkout $testroot/repo $testroot/wt > /dev/null
206 ret="$?"
207 if [ "$ret" != "0" ]; then
208 test_done "$testroot" "$ret"
209 return 1
210 fi
212 mkdir -p $testroot/wt/d
213 echo "new file" > $testroot/wt/d/new
214 echo "new file 2" > $testroot/wt/d/new2
215 mkdir -p $testroot/wt/d/f
216 echo "new file 3" > $testroot/wt/d/f/new3
217 mkdir -p $testroot/wt/d/f/g
218 echo "new file 4" > $testroot/wt/d/f/g/new4
220 (cd $testroot/wt && got add $testroot/wt/*/new* \
221 $testroot/wt/*/*/new* $testroot/wt/*/*/*/new* > /dev/null)
223 (cd $testroot/wt && got commit -m 'test commit_added_subdirs' \
224 > $testroot/stdout 2> $testroot/stderr)
226 local head_rev=`git_show_head $testroot/repo`
227 echo "A d/f/g/new4" > $testroot/stdout.expected
228 echo "A d/f/new3" >> $testroot/stdout.expected
229 echo "A d/new" >> $testroot/stdout.expected
230 echo "A d/new2" >> $testroot/stdout.expected
231 echo "Created commit $head_rev" >> $testroot/stdout.expected
233 cmp -s $testroot/stdout.expected $testroot/stdout
234 ret="$?"
235 if [ "$ret" != "0" ]; then
236 diff -u $testroot/stdout.expected $testroot/stdout
237 fi
238 test_done "$testroot" "$ret"
241 function test_commit_deleted_subdirs {
242 local testroot=`test_init commit_deleted_subdirs`
244 got checkout $testroot/repo $testroot/wt > /dev/null
245 ret="$?"
246 if [ "$ret" != "0" ]; then
247 test_done "$testroot" "$ret"
248 return 1
249 fi
251 (cd $testroot/wt && got rm -R $testroot/wt/{epsilon,gamma} >/dev/null)
253 (cd $testroot/wt && got commit -m 'test commit_deleted_subdirs' \
254 > $testroot/stdout 2> $testroot/stderr)
256 local head_rev=`git_show_head $testroot/repo`
257 echo "D epsilon/zeta" > $testroot/stdout.expected
258 echo "D gamma/delta" >> $testroot/stdout.expected
259 echo "Created commit $head_rev" >> $testroot/stdout.expected
261 cmp -s $testroot/stdout.expected $testroot/stdout
262 ret="$?"
263 if [ "$ret" != "0" ]; then
264 diff -u $testroot/stdout.expected $testroot/stdout
265 test_done "$testroot" "$ret"
266 return 1
267 fi
269 got tree -r $testroot/repo > $testroot/stdout
271 echo "alpha" > $testroot/stdout.expected
272 echo "beta" >> $testroot/stdout.expected
274 cmp -s $testroot/stdout.expected $testroot/stdout
275 ret="$?"
276 if [ "$ret" != "0" ]; then
277 diff -u $testroot/stdout.expected $testroot/stdout
278 fi
279 test_done "$testroot" "$ret"
282 function test_commit_rejects_conflicted_file {
283 local testroot=`test_init commit_rejects_conflicted_file`
285 local initial_rev=`git_show_head $testroot/repo`
287 got checkout $testroot/repo $testroot/wt > /dev/null
288 ret="$?"
289 if [ "$ret" != "0" ]; then
290 test_done "$testroot" "$ret"
291 return 1
292 fi
294 echo "modified alpha" > $testroot/wt/alpha
295 (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
297 (cd $testroot/wt && got update -c $initial_rev > /dev/null)
299 echo "modified alpha, too" > $testroot/wt/alpha
301 echo "C alpha" > $testroot/stdout.expected
302 echo -n "Updated to commit " >> $testroot/stdout.expected
303 git_show_head $testroot/repo >> $testroot/stdout.expected
304 echo >> $testroot/stdout.expected
305 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
307 (cd $testroot/wt && got update > $testroot/stdout)
309 cmp -s $testroot/stdout.expected $testroot/stdout
310 ret="$?"
311 if [ "$ret" != "0" ]; then
312 diff -u $testroot/stdout.expected $testroot/stdout
313 test_done "$testroot" "$ret"
314 return 1
315 fi
317 (cd $testroot/wt && got commit -m 'commit it' > $testroot/stdout \
318 2> $testroot/stderr)
320 echo -n > $testroot/stdout.expected
321 echo "got: cannot commit file in conflicted status" \
322 > $testroot/stderr.expected
324 cmp -s $testroot/stdout.expected $testroot/stdout
325 ret="$?"
326 if [ "$ret" != "0" ]; then
327 diff -u $testroot/stdout.expected $testroot/stdout
328 test_done "$testroot" "$ret"
329 return 1
330 fi
331 cmp -s $testroot/stderr.expected $testroot/stderr
332 ret="$?"
333 if [ "$ret" != "0" ]; then
334 diff -u $testroot/stderr.expected $testroot/stderr
335 fi
336 test_done "$testroot" "$ret"
339 function test_commit_single_file_multiple {
340 local testroot=`test_init commit_single_file_multiple`
342 got checkout $testroot/repo $testroot/wt > /dev/null
343 ret="$?"
344 if [ "$ret" != "0" ]; then
345 test_done "$testroot" "$ret"
346 return 1
347 fi
349 for i in 1 2 3 4; do
350 echo "modified alpha" >> $testroot/wt/alpha
352 (cd $testroot/wt && \
353 got commit -m "changed alpha" > $testroot/stdout)
355 local head_rev=`git_show_head $testroot/repo`
356 echo "M alpha" > $testroot/stdout.expected
357 echo "Created commit $head_rev" >> $testroot/stdout.expected
359 cmp -s $testroot/stdout.expected $testroot/stdout
360 ret="$?"
361 if [ "$ret" != "0" ]; then
362 diff -u $testroot/stdout.expected $testroot/stdout
363 test_done "$testroot" "$ret"
364 return 1
365 fi
366 done
368 test_done "$testroot" "0"
371 function test_commit_added_and_modified_in_same_dir {
372 local testroot=`test_init commit_added_and_modified_in_same_dir`
374 got checkout $testroot/repo $testroot/wt > /dev/null
375 ret="$?"
376 if [ "$ret" != "0" ]; then
377 test_done "$testroot" "$ret"
378 return 1
379 fi
381 echo "modified zeta" > $testroot/wt/epsilon/zeta
382 echo "new file" > $testroot/wt/epsilon/new
383 (cd $testroot/wt && got add epsilon/new >/dev/null)
385 (cd $testroot/wt && got commit \
386 -m 'added and modified in same dir' > $testroot/stdout \
387 2> $testroot/stderr)
389 local head_rev=`git_show_head $testroot/repo`
390 echo "A epsilon/new" > $testroot/stdout.expected
391 echo "M epsilon/zeta" >> $testroot/stdout.expected
392 echo "Created commit $head_rev" >> $testroot/stdout.expected
394 cmp -s $testroot/stdout.expected $testroot/stdout
395 ret="$?"
396 if [ "$ret" != "0" ]; then
397 diff -u $testroot/stdout.expected $testroot/stdout
398 fi
399 test_done "$testroot" "$ret"
402 function test_commit_path_prefix {
403 local testroot=`test_init commit_path_prefix`
404 local commit1=`git_show_head $testroot/repo`
406 got checkout -p gamma $testroot/repo $testroot/wt > /dev/null
407 ret="$?"
408 if [ "$ret" != "0" ]; then
409 test_done "$testroot" "$ret"
410 return 1
411 fi
413 echo "modified delta" > $testroot/wt/delta
415 (cd $testroot/wt && got commit -m 'changed gamma/delta' > $testroot/stdout)
417 local commit2=`git_show_head $testroot/repo`
418 echo "M delta" > $testroot/stdout.expected
419 echo "Created commit $commit2" >> $testroot/stdout.expected
421 cmp -s $testroot/stdout.expected $testroot/stdout
422 ret="$?"
423 if [ "$ret" != "0" ]; then
424 diff -u $testroot/stdout.expected $testroot/stdout
425 test_done "$testroot" "$ret"
426 return 1
427 fi
429 echo "diff $commit1 $commit2" > $testroot/stdout.expected
430 echo -n 'blob - ' >> $testroot/stdout.expected
431 got tree -r $testroot/repo -c $commit1 -i gamma | grep 'delta$' \
432 | cut -d' ' -f 1 >> $testroot/stdout.expected
433 echo -n 'blob + ' >> $testroot/stdout.expected
434 got tree -r $testroot/repo -c $commit2 -i gamma | grep 'delta$' | \
435 cut -d' ' -f 1 >> $testroot/stdout.expected
436 echo '--- gamma/delta' >> $testroot/stdout.expected
437 echo '+++ gamma/delta' >> $testroot/stdout.expected
438 echo '@@ -1 +1 @@' >> $testroot/stdout.expected
439 echo '-delta' >> $testroot/stdout.expected
440 echo '+modified delta' >> $testroot/stdout.expected
442 got diff -r $testroot/repo $commit1 $commit2 > $testroot/stdout
443 cmp -s $testroot/stdout.expected $testroot/stdout
444 ret="$?"
445 if [ "$ret" != "0" ]; then
446 diff -u $testroot/stdout.expected $testroot/stdout
447 test_done "$testroot" "$ret"
448 return 1
449 fi
451 (cd $testroot/wt && got rm delta > /dev/null)
452 echo new > $testroot/wt/new
453 (cd $testroot/wt && got add new > /dev/null)
455 (cd $testroot/wt && got commit -m 'remove gamma/delta; add gamma/new' \
456 > $testroot/stdout)
458 local commit3=`git_show_head $testroot/repo`
459 echo "A new" > $testroot/stdout.expected
460 echo "D delta" >> $testroot/stdout.expected
461 echo "Created commit $commit3" >> $testroot/stdout.expected
463 cmp -s $testroot/stdout.expected $testroot/stdout
464 ret="$?"
465 if [ "$ret" != "0" ]; then
466 diff -u $testroot/stdout.expected $testroot/stdout
467 test_done "$testroot" "$ret"
468 return 1
469 fi
471 echo "diff $commit2 $commit3" > $testroot/stdout.expected
472 echo -n 'blob - ' >> $testroot/stdout.expected
473 got tree -r $testroot/repo -c $commit2 -i gamma | grep 'delta$' \
474 | cut -d' ' -f 1 | sed -e 's/$/ (mode 644)/' \
475 >> $testroot/stdout.expected
476 echo 'blob + /dev/null' >> $testroot/stdout.expected
477 echo '--- gamma/delta' >> $testroot/stdout.expected
478 echo '+++ /dev/null' >> $testroot/stdout.expected
479 echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
480 echo '-modified delta' >> $testroot/stdout.expected
481 echo 'blob - /dev/null' >> $testroot/stdout.expected
482 echo -n 'blob + ' >> $testroot/stdout.expected
483 got tree -r $testroot/repo -c $commit3 -i gamma | grep 'new$' | \
484 cut -d' ' -f 1 | sed -e 's/$/ (mode 644)/' \
485 >> $testroot/stdout.expected
486 echo '--- /dev/null' >> $testroot/stdout.expected
487 echo '+++ gamma/new' >> $testroot/stdout.expected
488 echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
489 echo '+new' >> $testroot/stdout.expected
491 got diff -r $testroot/repo $commit2 $commit3 > $testroot/stdout
492 cmp -s $testroot/stdout.expected $testroot/stdout
493 ret="$?"
494 if [ "$ret" != "0" ]; then
495 diff -u $testroot/stdout.expected $testroot/stdout
496 fi
497 test_done "$testroot" "$ret"
498 return "$ret"
501 function test_commit_dir_path {
502 local testroot=`test_init commit_dir_path`
504 got checkout $testroot/repo $testroot/wt > /dev/null
505 ret="$?"
506 if [ "$ret" != "0" ]; then
507 test_done "$testroot" "$ret"
508 return 1
509 fi
511 echo "modified alpha" > $testroot/wt/alpha
512 echo "modified zeta" > $testroot/wt/epsilon/zeta
514 (cd $testroot/wt && got commit -m 'changed zeta' epsilon \
515 > $testroot/stdout)
517 local head_rev=`git_show_head $testroot/repo`
518 echo "M epsilon/zeta" >> $testroot/stdout.expected
519 echo "Created commit $head_rev" >> $testroot/stdout.expected
521 cmp -s $testroot/stdout.expected $testroot/stdout
522 ret="$?"
523 if [ "$ret" != "0" ]; then
524 diff -u $testroot/stdout.expected $testroot/stdout
525 test_done "$testroot" "$ret"
526 return 1
527 fi
529 echo "M alpha" > $testroot/stdout.expected
530 (cd $testroot/wt && got status > $testroot/stdout)
531 cmp -s $testroot/stdout.expected $testroot/stdout
532 ret="$?"
533 if [ "$ret" != "0" ]; then
534 diff -u $testroot/stdout.expected $testroot/stdout
535 fi
536 test_done "$testroot" "$ret"
539 function test_commit_selected_paths {
540 local testroot=`test_init commit_selected_paths`
542 got checkout $testroot/repo $testroot/wt > /dev/null
543 ret="$?"
544 if [ "$ret" != "0" ]; then
545 test_done "$testroot" "$ret"
546 return 1
547 fi
549 echo "modified alpha" > $testroot/wt/alpha
550 echo "modified delta" > $testroot/wt/gamma/delta
551 echo "modified zeta" > $testroot/wt/epsilon/zeta
552 (cd $testroot/wt && got rm beta >/dev/null)
553 echo "new file" > $testroot/wt/new
554 (cd $testroot/wt && got add new >/dev/null)
556 (cd $testroot/wt && got commit -m 'many paths' nonexistent alpha \
557 > $testroot/stdout 2> $testroot/stderr)
558 ret="$?"
559 if [ "$ret" == "0" ]; then
560 echo "commit succeeded unexpectedly" >&2
561 test_done "$testroot" "1"
562 return 1
563 fi
564 echo "got: nonexistent: bad path" > $testroot/stderr.expected
566 cmp -s $testroot/stderr.expected $testroot/stderr
567 ret="$?"
568 if [ "$ret" != "0" ]; then
569 diff -u $testroot/stderr.expected $testroot/stderr
570 test_done "$testroot" "$ret"
571 return 1
572 fi
574 (cd $testroot/wt && got commit -m 'many paths' \
575 beta new gamma > $testroot/stdout)
577 local head_rev=`git_show_head $testroot/repo`
578 echo "A new" > $testroot/stdout.expected
579 echo "D beta" >> $testroot/stdout.expected
580 echo "M gamma/delta" >> $testroot/stdout.expected
581 echo "Created commit $head_rev" >> $testroot/stdout.expected
583 cmp -s $testroot/stdout.expected $testroot/stdout
584 ret="$?"
585 if [ "$ret" != "0" ]; then
586 diff -u $testroot/stdout.expected $testroot/stdout
587 fi
588 test_done "$testroot" "$ret"
591 function test_commit_outside_refs_heads {
592 local testroot=`test_init commit_outside_refs_heads`
594 got ref -r $testroot/repo -c master refs/remotes/origin/master
596 got checkout -b refs/remotes/origin/master \
597 $testroot/repo $testroot/wt > /dev/null
598 ret="$?"
599 if [ "$ret" != "0" ]; then
600 test_done "$testroot" "$ret"
601 return 1
602 fi
604 echo "modified alpha" > $testroot/wt/alpha
606 (cd $testroot/wt && got commit -m 'change alpha' \
607 > $testroot/stdout 2> $testroot/stderr)
608 ret="$?"
609 if [ "$ret" == "0" ]; then
610 echo "commit succeeded unexpectedly" >&2
611 test_done "$testroot" "1"
612 return 1
613 fi
615 echo -n > $testroot/stdout.expected
616 cmp -s $testroot/stdout.expected $testroot/stdout
617 ret="$?"
618 if [ "$ret" != "0" ]; then
619 diff -u $testroot/stdout.expected $testroot/stdout
620 test_done "$testroot" "$ret"
621 return 1
622 fi
624 echo -n "got: will not commit to a branch outside the " \
625 > $testroot/stderr.expected
626 echo '"refs/heads/" reference namespace' \
627 >> $testroot/stderr.expected
628 cmp -s $testroot/stderr.expected $testroot/stderr
629 ret="$?"
630 if [ "$ret" != "0" ]; then
631 diff -u $testroot/stderr.expected $testroot/stderr
632 fi
633 test_done "$testroot" "$ret"
636 function test_commit_no_email {
637 local testroot=`test_init commit_no_email`
639 got checkout $testroot/repo $testroot/wt > /dev/null
640 ret="$?"
641 if [ "$ret" != "0" ]; then
642 test_done "$testroot" "$ret"
643 return 1
644 fi
646 echo "modified alpha" > $testroot/wt/alpha
647 (cd $testroot/wt && env GOT_AUTHOR=":flan_hacker:" \
648 got commit -m 'test no email' > $testroot/stdout \
649 2> $testroot/stderr)
651 echo -n "got: GOT_AUTHOR environment variable contains no email " \
652 > $testroot/stderr.expected
653 echo -n "address; an email address is required for compatibility "\
654 >> $testroot/stderr.expected
655 echo "with Git" >> $testroot/stderr.expected
656 cmp -s $testroot/stderr.expected $testroot/stderr
657 ret="$?"
658 if [ "$ret" != "0" ]; then
659 diff -u $testroot/stderr.expected $testroot/stderr
660 test_done "$testroot" "$ret"
661 return 1
662 fi
664 echo -n > $testroot/stdout.expected
665 cmp -s $testroot/stdout.expected $testroot/stdout
666 ret="$?"
667 if [ "$ret" != "0" ]; then
668 diff -u $testroot/stdout.expected $testroot/stdout
669 fi
670 test_done "$testroot" "$ret"
673 function test_commit_tree_entry_sorting {
674 local testroot=`test_init commit_tree_entry_sorting`
676 got checkout $testroot/repo $testroot/wt > /dev/null
677 ret="$?"
678 if [ "$ret" != "0" ]; then
679 test_done "$testroot" "$ret"
680 return 1
681 fi
683 # Git's index gets corrupted when tree entries are written in the
684 # order defined by got_path_cmp() rather than Git's own ordering.
685 # Create a new tree where a directory "got" and a file "got-version"
686 # would sort in the wrong order according to Git's opinion.
687 mkdir $testroot/wt/got
688 touch $testroot/wt/got/foo
689 echo foo > $testroot/wt/got-version
690 echo zzz > $testroot/wt/zzz
691 (cd $testroot/wt && got add got-version got/foo zzz > /dev/null)
693 (cd $testroot/wt && got commit -m 'test' > /dev/null)
695 # Let git-fsck verify the newly written tree to make sure Git is happy
696 (cd $testroot/repo && git fsck --strict \
697 > $testroot/fsck.stdout 2> $testroot/fsck.stderr)
698 ret="$?"
699 test_done "$testroot" "$ret"
702 function test_commit_gotconfig_author {
703 local testroot=`test_init commit_gotconfig_author`
705 got checkout $testroot/repo $testroot/wt > /dev/null
706 ret="$?"
707 if [ "$ret" != "0" ]; then
708 test_done "$testroot" "$ret"
709 return 1
710 fi
711 echo 'author "Flan Luck <flan_luck@openbsd.org>"' \
712 > $testroot/repo/.git/got.conf
714 echo "modified alpha" > $testroot/wt/alpha
715 (cd $testroot/wt && got commit -m 'test gotconfig author' > /dev/null)
716 ret="$?"
717 if [ "$ret" != "0" ]; then
718 test_done "$testroot" "$ret"
719 return 1
720 fi
722 (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
723 ret="$?"
724 if [ "$ret" != "0" ]; then
725 test_done "$testroot" "$ret"
726 return 1
727 fi
729 echo "from: Flan Luck <flan_luck@openbsd.org>" \
730 > $testroot/stdout.expected
731 cmp -s $testroot/stdout.expected $testroot/stdout
732 ret="$?"
733 if [ "$ret" != "0" ]; then
734 diff -u $testroot/stdout.expected $testroot/stdout
735 fi
736 test_done "$testroot" "$ret"
739 function test_commit_gotconfig_worktree_author {
740 local testroot=`test_init commit_gotconfig_worktree_author`
742 got checkout $testroot/repo $testroot/wt > /dev/null
743 ret="$?"
744 if [ "$ret" != "0" ]; then
745 test_done "$testroot" "$ret"
746 return 1
747 fi
748 echo 'author "Flan Luck <flan_luck@openbsd.org>"' \
749 > $testroot/repo/.git/got.conf
750 echo 'author "Flan Squee <flan_squee@openbsd.org>"' \
751 > $testroot/wt/.got/got.conf
753 echo "modified alpha" > $testroot/wt/alpha
754 (cd $testroot/wt && got commit -m 'test gotconfig author' > /dev/null)
755 ret="$?"
756 if [ "$ret" != "0" ]; then
757 test_done "$testroot" "$ret"
758 return 1
759 fi
761 (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
762 ret="$?"
763 if [ "$ret" != "0" ]; then
764 test_done "$testroot" "$ret"
765 return 1
766 fi
768 echo "from: Flan Squee <flan_squee@openbsd.org>" \
769 > $testroot/stdout.expected
770 cmp -s $testroot/stdout.expected $testroot/stdout
771 ret="$?"
772 if [ "$ret" != "0" ]; then
773 diff -u $testroot/stdout.expected $testroot/stdout
774 fi
775 test_done "$testroot" "$ret"
778 function test_commit_gitconfig_author {
779 local testroot=`test_init commit_gitconfig_author`
781 got checkout $testroot/repo $testroot/wt > /dev/null
782 ret="$?"
783 if [ "$ret" != "0" ]; then
784 test_done "$testroot" "$ret"
785 return 1
786 fi
788 (cd $testroot/repo && git config user.name 'Flan Luck')
789 (cd $testroot/repo && git config user.email 'flan_luck@openbsd.org')
791 echo "modified alpha" > $testroot/wt/alpha
792 (cd $testroot/wt && got commit -m 'test gitconfig author' > /dev/null)
793 ret="$?"
794 if [ "$ret" != "0" ]; then
795 test_done "$testroot" "$ret"
796 return 1
797 fi
799 (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
800 ret="$?"
801 if [ "$ret" != "0" ]; then
802 test_done "$testroot" "$ret"
803 return 1
804 fi
806 echo "from: Flan Luck <flan_luck@openbsd.org>" \
807 > $testroot/stdout.expected
808 cmp -s $testroot/stdout.expected $testroot/stdout
809 ret="$?"
810 if [ "$ret" != "0" ]; then
811 diff -u $testroot/stdout.expected $testroot/stdout
812 fi
813 test_done "$testroot" "$ret"
816 function test_commit_xbit_change {
817 local testroot=`test_init commit_xbit_change`
819 got checkout $testroot/repo $testroot/wt > /dev/null
820 ret="$?"
821 if [ "$ret" != "0" ]; then
822 test_done "$testroot" "$ret"
823 return 1
824 fi
826 chmod +x $testroot/wt/alpha
828 echo 'm alpha' > $testroot/stdout.expected
829 (cd $testroot/wt && got status > $testroot/stdout)
831 cmp -s $testroot/stdout.expected $testroot/stdout
832 ret="$?"
833 if [ "$ret" != "0" ]; then
834 diff -u $testroot/stdout.expected $testroot/stdout
835 test_done "$testroot" "$ret"
836 return 1
837 fi
839 (cd $testroot/wt && got commit -mx > $testroot/stdout)
840 ret="$?"
841 if [ "$ret" != "0" ]; then
842 echo "got commit failed unexpectedly"
843 test_done "$testroot" "$ret"
844 return 1
845 fi
847 local commit_id=`git_show_head $testroot/repo`
848 echo 'm alpha' > $testroot/stdout.expected
849 echo "Created commit $commit_id" >> $testroot/stdout.expected
850 cmp -s $testroot/stdout.expected $testroot/stdout
851 ret="$?"
852 if [ "$ret" != "0" ]; then
853 diff -u $testroot/stdout.expected $testroot/stdout
854 test_done "$testroot" "$ret"
855 return 1
856 fi
858 (cd $testroot/wt && got status > $testroot/stdout)
860 echo -n > $testroot/stdout.expected
861 cmp -s $testroot/stdout.expected $testroot/stdout
862 ret="$?"
863 if [ "$ret" != "0" ]; then
864 diff -u $testroot/stdout.expected $testroot/stdout
865 test_done "$testroot" "$ret"
866 return 1
867 fi
869 chmod -x $testroot/wt/alpha
871 echo 'm alpha' > $testroot/stdout.expected
872 (cd $testroot/wt && got status > $testroot/stdout)
874 cmp -s $testroot/stdout.expected $testroot/stdout
875 ret="$?"
876 if [ "$ret" != "0" ]; then
877 diff -u $testroot/stdout.expected $testroot/stdout
878 test_done "$testroot" "$ret"
879 return 1
880 fi
882 (cd $testroot/wt && got commit -mx > $testroot/stdout)
883 ret="$?"
884 if [ "$ret" != "0" ]; then
885 echo "got commit failed unexpectedly"
886 test_done "$testroot" "$ret"
887 return 1
888 fi
890 local commit_id=`git_show_head $testroot/repo`
891 echo 'm alpha' > $testroot/stdout.expected
892 echo "Created commit $commit_id" >> $testroot/stdout.expected
893 cmp -s $testroot/stdout.expected $testroot/stdout
894 ret="$?"
895 if [ "$ret" != "0" ]; then
896 diff -u $testroot/stdout.expected $testroot/stdout
897 test_done "$testroot" "$ret"
898 return 1
899 fi
901 chmod +x $testroot/wt/alpha
903 echo 'm alpha' > $testroot/stdout.expected
904 (cd $testroot/wt && got status > $testroot/stdout)
906 cmp -s $testroot/stdout.expected $testroot/stdout
907 ret="$?"
908 if [ "$ret" != "0" ]; then
909 diff -u $testroot/stdout.expected $testroot/stdout
910 fi
911 test_done "$testroot" "$ret"
914 function commit_check_mode {
915 local mode="$1"
916 local expected_mode="$2"
918 chmod 644 $testroot/wt/alpha
919 echo a >> $testroot/wt/alpha
920 chmod $mode $testroot/wt/alpha
922 (cd $testroot/wt && got commit -mm > $testroot/stdout)
923 ret="$?"
924 if [ "$ret" != "0" ]; then
925 echo "got commit failed unexpectedly"
926 test_done "$testroot" "$ret"
927 return 1
928 fi
930 local commit_id=`git_show_head $testroot/repo`
931 echo 'M alpha' > $testroot/stdout.expected
932 echo "Created commit $commit_id" >> $testroot/stdout.expected
933 cmp -s $testroot/stdout.expected $testroot/stdout
934 ret="$?"
935 if [ "$ret" != "0" ]; then
936 diff -u $testroot/stdout.expected $testroot/stdout
937 test_done "$testroot" "$ret"
938 fi
940 local tree_id=$(got cat -r $testroot/repo $commit_id | \
941 grep ^tree | cut -d' ' -f2)
942 local alpha_id=$(got cat -r $testroot/repo $tree_id | \
943 grep 'alpha$' | cut -d' ' -f1)
944 echo "$alpha_id $expected_mode alpha" > $testroot/stdout.expected
945 got cat -r $testroot/repo $tree_id | grep 'alpha$' > $testroot/stdout
946 cmp -s $testroot/stdout.expected $testroot/stdout
947 ret="$?"
948 if [ "$ret" != "0" ]; then
949 diff -u $testroot/stdout.expected $testroot/stdout
950 fi
951 return $ret
954 function test_commit_normalizes_filemodes {
955 local testroot=`test_init commit_normalizes_filemodes`
957 got checkout $testroot/repo $testroot/wt > /dev/null
958 ret="$?"
959 if [ "$ret" != "0" ]; then
960 test_done "$testroot" "$ret"
961 return 1
962 fi
964 modes="600 400 460 640 440 660 444 666"
965 for m in $modes; do
966 commit_check_mode "$m" "0100644"
967 ret="$?"
968 if [ "$ret" != "0" ]; then
969 break
970 fi
971 done
972 if [ "$ret" != "0" ]; then
973 test_done "$testroot" "$ret"
974 return 1
975 fi
976 modes="700 500 570 750 550 770 555 777"
977 for m in $modes; do
978 commit_check_mode "$m" "0100755"
979 ret="$?"
980 if [ "$ret" != "0" ]; then
981 break
982 fi
983 done
984 if [ "$ret" != "0" ]; then
985 test_done "$testroot" "$ret"
986 return 1
987 fi
988 test_done "$testroot" "$ret"
991 function test_commit_with_unrelated_submodule {
992 local testroot=`test_init commit_with_unrelated_submodule`
994 make_single_file_repo $testroot/repo2 foo
996 (cd $testroot/repo && git submodule -q add ../repo2)
997 (cd $testroot/repo && git commit -q -m 'adding submodule')
999 got checkout $testroot/repo $testroot/wt > /dev/null
1000 ret="$?"
1001 if [ "$ret" != "0" ]; then
1002 echo "checkout failed unexpectedly" >&2
1003 test_done "$testroot" "$ret"
1004 return 1
1007 echo "modified alpha" > $testroot/wt/alpha
1009 echo "" > $testroot/stdout.expected
1011 (cd $testroot/wt && got commit -m 'modify alpha' > $testroot/stdout)
1012 ret="$?"
1013 if [ "$ret" != "0" ]; then
1014 echo "commit failed unexpectedly" >&2
1015 test_done "$testroot" "$ret"
1016 return 1
1019 local head_rev=`git_show_head $testroot/repo`
1020 echo "M alpha" > $testroot/stdout.expected
1021 echo "Created commit $head_rev" >> $testroot/stdout.expected
1023 cmp -s $testroot/stdout.expected $testroot/stdout
1024 ret="$?"
1025 if [ "$ret" != "0" ]; then
1026 diff -u $testroot/stdout.expected $testroot/stdout
1028 test_done "$testroot" "$ret"
1031 function check_symlinks {
1032 local wtpath="$1"
1033 if ! [ -h $wtpath/alpha.link ]; then
1034 echo "alpha.link is not a symlink"
1035 return 1
1038 readlink $wtpath/alpha.link > $testroot/stdout
1039 echo "alpha" > $testroot/stdout.expected
1040 cmp -s $testroot/stdout.expected $testroot/stdout
1041 ret="$?"
1042 if [ "$ret" != "0" ]; then
1043 diff -u $testroot/stdout.expected $testroot/stdout
1044 return 1
1047 if ! [ -h $wtpath/epsilon.link ]; then
1048 echo "epsilon.link is not a symlink"
1049 return 1
1052 readlink $wtpath/epsilon.link > $testroot/stdout
1053 echo "epsilon" > $testroot/stdout.expected
1054 cmp -s $testroot/stdout.expected $testroot/stdout
1055 ret="$?"
1056 if [ "$ret" != "0" ]; then
1057 diff -u $testroot/stdout.expected $testroot/stdout
1058 return 1
1061 if [ -h $wtpath/passwd.link ]; then
1062 echo -n "passwd.link is a symlink and points outside of work tree: " >&2
1063 readlink $wtpath/passwd.link >&2
1064 return 1
1067 echo -n "/etc/passwd" > $testroot/content.expected
1068 cp $wtpath/passwd.link $testroot/content
1069 ret="$?"
1070 if [ "$ret" != "0" ]; then
1071 echo "cp command failed unexpectedly" >&2
1072 return 1
1075 cmp -s $testroot/content.expected $testroot/content
1076 ret="$?"
1077 if [ "$ret" != "0" ]; then
1078 diff -u $testroot/content.expected $testroot/content
1079 return 1
1082 readlink $wtpath/epsilon/beta.link > $testroot/stdout
1083 echo "../beta" > $testroot/stdout.expected
1084 cmp -s $testroot/stdout.expected $testroot/stdout
1085 ret="$?"
1086 if [ "$ret" != "0" ]; then
1087 diff -u $testroot/stdout.expected $testroot/stdout
1088 return 1
1091 readlink $wtpath/nonexistent.link > $testroot/stdout
1092 echo "nonexistent" > $testroot/stdout.expected
1093 cmp -s $testroot/stdout.expected $testroot/stdout
1094 ret="$?"
1095 if [ "$ret" != "0" ]; then
1096 diff -u $testroot/stdout.expected $testroot/stdout
1097 return 1
1100 return 0
1103 function test_commit_symlink {
1104 local testroot=`test_init commit_symlink`
1106 got checkout $testroot/repo $testroot/wt > /dev/null
1107 ret="$?"
1108 if [ "$ret" != "0" ]; then
1109 test_done "$testroot" "$ret"
1110 return 1
1113 (cd $testroot/wt && ln -s alpha alpha.link)
1114 (cd $testroot/wt && ln -s epsilon epsilon.link)
1115 (cd $testroot/wt && ln -s /etc/passwd passwd.link)
1116 (cd $testroot/wt && ln -s ../beta epsilon/beta.link)
1117 (cd $testroot/wt && ln -s nonexistent nonexistent.link)
1118 (cd $testroot/wt && got add alpha.link epsilon.link passwd.link \
1119 epsilon/beta.link nonexistent.link > /dev/null)
1121 (cd $testroot/wt && got commit -m 'test commit_symlink' \
1122 > $testroot/stdout 2> $testroot/stderr)
1123 ret="$?"
1124 if [ "$ret" == "0" ]; then
1125 echo "got commit succeeded unexpectedly" >&2
1126 test_done "$testroot" "$ret"
1127 return 1
1129 echo -n "got: $testroot/wt/passwd.link: " > $testroot/stderr.expected
1130 echo "symbolic link points outside of paths under version control" \
1131 >> $testroot/stderr.expected
1132 cmp -s $testroot/stderr.expected $testroot/stderr
1133 ret="$?"
1134 if [ "$ret" != "0" ]; then
1135 diff -u $testroot/stderr.expected $testroot/stderr
1136 test_done "$testroot" "$ret"
1137 return 1
1140 (cd $testroot/wt && got commit -S -m 'test commit_symlink' \
1141 > $testroot/stdout)
1143 local head_rev=`git_show_head $testroot/repo`
1144 echo "A alpha.link" > $testroot/stdout.expected
1145 echo "A epsilon.link" >> $testroot/stdout.expected
1146 echo "A nonexistent.link" >> $testroot/stdout.expected
1147 echo "A passwd.link" >> $testroot/stdout.expected
1148 echo "A epsilon/beta.link" >> $testroot/stdout.expected
1149 echo "Created commit $head_rev" >> $testroot/stdout.expected
1151 cmp -s $testroot/stdout.expected $testroot/stdout
1152 ret="$?"
1153 if [ "$ret" != "0" ]; then
1154 diff -u $testroot/stdout.expected $testroot/stdout
1155 test_done "$testroot" "$ret"
1156 return 1
1159 # verify created in-repository tree
1160 got checkout $testroot/repo $testroot/wt2 > /dev/null
1161 ret="$?"
1162 if [ "$ret" != "0" ]; then
1163 test_done "$testroot" "$ret"
1164 return 1
1166 check_symlinks $testroot/wt2
1167 ret="$?"
1168 if [ "$ret" != "0" ]; then
1169 test_done "$testroot" "$ret"
1170 return 1
1173 if ! [ -h $testroot/wt/passwd.link ]; then
1174 echo 'passwd.link is not a symlink' >&2
1175 test_done "$testroot" 1
1176 return 1
1179 # 'got update' should reinstall passwd.link as a regular file
1180 (cd $testroot/wt && got update > /dev/null)
1181 check_symlinks $testroot/wt
1182 ret="$?"
1183 if [ "$ret" != "0" ]; then
1184 test_done "$testroot" "$ret"
1185 return 1
1188 (cd $testroot/wt && ln -sf beta alpha.link)
1189 (cd $testroot/wt && ln -sfh gamma epsilon.link)
1190 rm $testroot/wt/epsilon/beta.link
1191 echo "this is a regular file" > $testroot/wt/epsilon/beta.link
1192 (cd $testroot/wt && ln -sf .got/bar dotgotbar.link)
1193 (cd $testroot/wt && got add dotgotbar.link > /dev/null)
1194 (cd $testroot/wt && got rm nonexistent.link > /dev/null)
1195 (cd $testroot/wt && ln -sf gamma/delta zeta.link)
1196 (cd $testroot/wt && ln -sf alpha new.link)
1197 (cd $testroot/wt && got add new.link > /dev/null)
1199 (cd $testroot/wt && got commit -m 'test commit_symlink' \
1200 > $testroot/stdout 2> $testroot/stderr)
1201 ret="$?"
1202 if [ "$ret" == "0" ]; then
1203 echo "got commit succeeded unexpectedly" >&2
1204 test_done "$testroot" "$ret"
1205 return 1
1207 echo -n "got: $testroot/wt/dotgotbar.link: " > $testroot/stderr.expected
1208 echo "symbolic link points outside of paths under version control" \
1209 >> $testroot/stderr.expected
1210 cmp -s $testroot/stderr.expected $testroot/stderr
1211 ret="$?"
1212 if [ "$ret" != "0" ]; then
1213 diff -u $testroot/stderr.expected $testroot/stderr
1214 test_done "$testroot" "$ret"
1215 return 1
1218 (cd $testroot/wt && got commit -S -m 'test commit_symlink' \
1219 > $testroot/stdout)
1221 local head_rev=`git_show_head $testroot/repo`
1222 echo "A dotgotbar.link" > $testroot/stdout.expected
1223 echo "A new.link" >> $testroot/stdout.expected
1224 echo "M alpha.link" >> $testroot/stdout.expected
1225 echo "M epsilon/beta.link" >> $testroot/stdout.expected
1226 echo "M epsilon.link" >> $testroot/stdout.expected
1227 echo "D nonexistent.link" >> $testroot/stdout.expected
1228 echo "Created commit $head_rev" >> $testroot/stdout.expected
1230 cmp -s $testroot/stdout.expected $testroot/stdout
1231 ret="$?"
1232 if [ "$ret" != "0" ]; then
1233 diff -u $testroot/stdout.expected $testroot/stdout
1234 test_done "$testroot" "$ret"
1235 return 1
1238 got tree -r $testroot/repo -c $head_rev -R > $testroot/stdout
1239 cat > $testroot/stdout.expected <<EOF
1240 alpha
1241 alpha.link@ -> beta
1242 beta
1243 dotgotbar.link@ -> .got/bar
1244 epsilon/
1245 epsilon/beta.link
1246 epsilon/zeta
1247 epsilon.link@ -> gamma
1248 gamma/
1249 gamma/delta
1250 new.link@ -> alpha
1251 passwd.link@ -> /etc/passwd
1252 EOF
1253 cmp -s $testroot/stdout.expected $testroot/stdout
1254 ret="$?"
1255 if [ "$ret" != "0" ]; then
1256 diff -u $testroot/stdout.expected $testroot/stdout
1258 test_done "$testroot" "$ret"
1261 function test_commit_fix_bad_symlink {
1262 local testroot=`test_init commit_fix_bad_symlink`
1264 got checkout $testroot/repo $testroot/wt > /dev/null
1265 ret="$?"
1266 if [ "$ret" != "0" ]; then
1267 echo "got checkout failed unexpectedly" >&2
1268 test_done "$testroot" "$ret"
1269 return 1
1272 (cd $testroot/wt && ln -s /etc/passwd passwd.link)
1273 (cd $testroot/wt && got add passwd.link > /dev/null)
1275 (cd $testroot/wt && got commit -S -m 'commit bad symlink' \
1276 > $testroot/stdout)
1278 if ! [ -h $testroot/wt/passwd.link ]; then
1279 echo 'passwd.link is not a symlink' >&2
1280 test_done "$testroot" 1
1281 return 1
1283 (cd $testroot/wt && got update >/dev/null)
1284 if [ -h $testroot/wt/passwd.link ]; then
1285 echo "passwd.link is a symlink but should be a regular file" >&2
1286 test_done "$testroot" "1"
1287 return 1
1290 # create another work tree which will contain the "bad" symlink
1291 got checkout $testroot/repo $testroot/wt2 > /dev/null
1292 ret="$?"
1293 if [ "$ret" != "0" ]; then
1294 echo "got checkout failed unexpectedly" >&2
1295 test_done "$testroot" "$ret"
1296 return 1
1299 # change "bad" symlink back into a "good" symlink
1300 (cd $testroot/wt && ln -sfh alpha passwd.link)
1302 (cd $testroot/wt && got commit -m 'fix bad symlink' \
1303 > $testroot/stdout)
1305 local head_rev=`git_show_head $testroot/repo`
1306 echo "M passwd.link" > $testroot/stdout.expected
1307 echo "Created commit $head_rev" >> $testroot/stdout.expected
1309 cmp -s $testroot/stdout.expected $testroot/stdout
1310 ret="$?"
1311 if [ "$ret" != "0" ]; then
1312 diff -u $testroot/stdout.expected $testroot/stdout
1313 test_done "$testroot" "$ret"
1314 return 1
1317 if ! [ -h $testroot/wt/passwd.link ]; then
1318 echo 'passwd.link is not a symlink' >&2
1319 test_done "$testroot" 1
1320 return 1
1323 readlink $testroot/wt/passwd.link > $testroot/stdout
1324 echo "alpha" > $testroot/stdout.expected
1325 cmp -s $testroot/stdout.expected $testroot/stdout
1326 ret="$?"
1327 if [ "$ret" != "0" ]; then
1328 diff -u $testroot/stdout.expected $testroot/stdout
1329 return 1
1332 # Update the other work tree; the bad symlink should be fixed
1333 (cd $testroot/wt2 && got update > /dev/null)
1334 ret="$?"
1335 if [ "$ret" != "0" ]; then
1336 echo "got checkout failed unexpectedly" >&2
1337 test_done "$testroot" "$ret"
1338 return 1
1341 if ! [ -h $testroot/wt2/passwd.link ]; then
1342 echo 'passwd.link is not a symlink' >&2
1343 test_done "$testroot" 1
1344 return 1
1347 readlink $testroot/wt2/passwd.link > $testroot/stdout
1348 echo "alpha" > $testroot/stdout.expected
1349 cmp -s $testroot/stdout.expected $testroot/stdout
1350 ret="$?"
1351 if [ "$ret" != "0" ]; then
1352 diff -u $testroot/stdout.expected $testroot/stdout
1353 return 1
1356 test_done "$testroot" "0"
1359 test_parseargs "$@"
1360 run_test test_commit_basic
1361 run_test test_commit_new_subdir
1362 run_test test_commit_subdir
1363 run_test test_commit_single_file
1364 run_test test_commit_out_of_date
1365 run_test test_commit_added_subdirs
1366 run_test test_commit_deleted_subdirs
1367 run_test test_commit_rejects_conflicted_file
1368 run_test test_commit_single_file_multiple
1369 run_test test_commit_added_and_modified_in_same_dir
1370 run_test test_commit_path_prefix
1371 run_test test_commit_dir_path
1372 run_test test_commit_selected_paths
1373 run_test test_commit_outside_refs_heads
1374 run_test test_commit_no_email
1375 run_test test_commit_tree_entry_sorting
1376 run_test test_commit_gotconfig_author
1377 run_test test_commit_gotconfig_worktree_author
1378 run_test test_commit_gitconfig_author
1379 run_test test_commit_xbit_change
1380 run_test test_commit_normalizes_filemodes
1381 run_test test_commit_with_unrelated_submodule
1382 run_test test_commit_symlink
1383 run_test test_commit_fix_bad_symlink