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 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 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 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 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 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 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 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 && \
252 got rm -R $testroot/wt/epsilon $testroot/wt/gamma >/dev/null)
254 (cd $testroot/wt && got commit -m 'test commit_deleted_subdirs' \
255 > $testroot/stdout 2> $testroot/stderr)
257 local head_rev=`git_show_head $testroot/repo`
258 echo "D epsilon/zeta" > $testroot/stdout.expected
259 echo "D gamma/delta" >> $testroot/stdout.expected
260 echo "Created commit $head_rev" >> $testroot/stdout.expected
262 cmp -s $testroot/stdout.expected $testroot/stdout
263 ret="$?"
264 if [ "$ret" != "0" ]; then
265 diff -u $testroot/stdout.expected $testroot/stdout
266 test_done "$testroot" "$ret"
267 return 1
268 fi
270 got tree -r $testroot/repo > $testroot/stdout
272 echo "alpha" > $testroot/stdout.expected
273 echo "beta" >> $testroot/stdout.expected
275 cmp -s $testroot/stdout.expected $testroot/stdout
276 ret="$?"
277 if [ "$ret" != "0" ]; then
278 diff -u $testroot/stdout.expected $testroot/stdout
279 fi
280 test_done "$testroot" "$ret"
283 test_commit_rejects_conflicted_file() {
284 local testroot=`test_init commit_rejects_conflicted_file`
286 local initial_rev=`git_show_head $testroot/repo`
288 got checkout $testroot/repo $testroot/wt > /dev/null
289 ret="$?"
290 if [ "$ret" != "0" ]; then
291 test_done "$testroot" "$ret"
292 return 1
293 fi
295 echo "modified alpha" > $testroot/wt/alpha
296 (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
298 (cd $testroot/wt && got update -c $initial_rev > /dev/null)
300 echo "modified alpha, too" > $testroot/wt/alpha
302 echo "C alpha" > $testroot/stdout.expected
303 echo -n "Updated to commit " >> $testroot/stdout.expected
304 git_show_head $testroot/repo >> $testroot/stdout.expected
305 echo >> $testroot/stdout.expected
306 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
308 (cd $testroot/wt && got update > $testroot/stdout)
310 cmp -s $testroot/stdout.expected $testroot/stdout
311 ret="$?"
312 if [ "$ret" != "0" ]; then
313 diff -u $testroot/stdout.expected $testroot/stdout
314 test_done "$testroot" "$ret"
315 return 1
316 fi
318 (cd $testroot/wt && got commit -m 'commit it' > $testroot/stdout \
319 2> $testroot/stderr)
321 echo -n > $testroot/stdout.expected
322 echo "got: cannot commit file in conflicted status" \
323 > $testroot/stderr.expected
325 cmp -s $testroot/stdout.expected $testroot/stdout
326 ret="$?"
327 if [ "$ret" != "0" ]; then
328 diff -u $testroot/stdout.expected $testroot/stdout
329 test_done "$testroot" "$ret"
330 return 1
331 fi
332 cmp -s $testroot/stderr.expected $testroot/stderr
333 ret="$?"
334 if [ "$ret" != "0" ]; then
335 diff -u $testroot/stderr.expected $testroot/stderr
336 fi
337 test_done "$testroot" "$ret"
340 test_commit_single_file_multiple() {
341 local testroot=`test_init commit_single_file_multiple`
343 got checkout $testroot/repo $testroot/wt > /dev/null
344 ret="$?"
345 if [ "$ret" != "0" ]; then
346 test_done "$testroot" "$ret"
347 return 1
348 fi
350 for i in 1 2 3 4; do
351 echo "modified alpha" >> $testroot/wt/alpha
353 (cd $testroot/wt && \
354 got commit -m "changed alpha" > $testroot/stdout)
356 local head_rev=`git_show_head $testroot/repo`
357 echo "M alpha" > $testroot/stdout.expected
358 echo "Created commit $head_rev" >> $testroot/stdout.expected
360 cmp -s $testroot/stdout.expected $testroot/stdout
361 ret="$?"
362 if [ "$ret" != "0" ]; then
363 diff -u $testroot/stdout.expected $testroot/stdout
364 test_done "$testroot" "$ret"
365 return 1
366 fi
367 done
369 test_done "$testroot" "0"
372 test_commit_added_and_modified_in_same_dir() {
373 local testroot=`test_init commit_added_and_modified_in_same_dir`
375 got checkout $testroot/repo $testroot/wt > /dev/null
376 ret="$?"
377 if [ "$ret" != "0" ]; then
378 test_done "$testroot" "$ret"
379 return 1
380 fi
382 echo "modified zeta" > $testroot/wt/epsilon/zeta
383 echo "new file" > $testroot/wt/epsilon/new
384 (cd $testroot/wt && got add epsilon/new >/dev/null)
386 (cd $testroot/wt && got commit \
387 -m 'added and modified in same dir' > $testroot/stdout \
388 2> $testroot/stderr)
390 local head_rev=`git_show_head $testroot/repo`
391 echo "A epsilon/new" > $testroot/stdout.expected
392 echo "M epsilon/zeta" >> $testroot/stdout.expected
393 echo "Created commit $head_rev" >> $testroot/stdout.expected
395 cmp -s $testroot/stdout.expected $testroot/stdout
396 ret="$?"
397 if [ "$ret" != "0" ]; then
398 diff -u $testroot/stdout.expected $testroot/stdout
399 fi
400 test_done "$testroot" "$ret"
403 test_commit_path_prefix() {
404 local testroot=`test_init commit_path_prefix`
405 local commit1=`git_show_head $testroot/repo`
407 got checkout -p gamma $testroot/repo $testroot/wt > /dev/null
408 ret="$?"
409 if [ "$ret" != "0" ]; then
410 test_done "$testroot" "$ret"
411 return 1
412 fi
414 echo "modified delta" > $testroot/wt/delta
416 (cd $testroot/wt && got commit -m 'changed gamma/delta' > $testroot/stdout)
418 local commit2=`git_show_head $testroot/repo`
419 echo "M delta" > $testroot/stdout.expected
420 echo "Created commit $commit2" >> $testroot/stdout.expected
422 cmp -s $testroot/stdout.expected $testroot/stdout
423 ret="$?"
424 if [ "$ret" != "0" ]; then
425 diff -u $testroot/stdout.expected $testroot/stdout
426 test_done "$testroot" "$ret"
427 return 1
428 fi
430 echo "diff $commit1 $commit2" > $testroot/stdout.expected
431 echo -n 'blob - ' >> $testroot/stdout.expected
432 got tree -r $testroot/repo -c $commit1 -i gamma | grep 'delta$' \
433 | cut -d' ' -f 1 >> $testroot/stdout.expected
434 echo -n 'blob + ' >> $testroot/stdout.expected
435 got tree -r $testroot/repo -c $commit2 -i gamma | grep 'delta$' | \
436 cut -d' ' -f 1 >> $testroot/stdout.expected
437 echo '--- gamma/delta' >> $testroot/stdout.expected
438 echo '+++ gamma/delta' >> $testroot/stdout.expected
439 echo '@@ -1 +1 @@' >> $testroot/stdout.expected
440 echo '-delta' >> $testroot/stdout.expected
441 echo '+modified delta' >> $testroot/stdout.expected
443 got diff -r $testroot/repo $commit1 $commit2 > $testroot/stdout
444 cmp -s $testroot/stdout.expected $testroot/stdout
445 ret="$?"
446 if [ "$ret" != "0" ]; then
447 diff -u $testroot/stdout.expected $testroot/stdout
448 test_done "$testroot" "$ret"
449 return 1
450 fi
452 (cd $testroot/wt && got rm delta > /dev/null)
453 echo new > $testroot/wt/new
454 (cd $testroot/wt && got add new > /dev/null)
456 (cd $testroot/wt && got commit -m 'remove gamma/delta; add gamma/new' \
457 > $testroot/stdout)
459 local commit3=`git_show_head $testroot/repo`
460 echo "A new" > $testroot/stdout.expected
461 echo "D delta" >> $testroot/stdout.expected
462 echo "Created commit $commit3" >> $testroot/stdout.expected
464 cmp -s $testroot/stdout.expected $testroot/stdout
465 ret="$?"
466 if [ "$ret" != "0" ]; then
467 diff -u $testroot/stdout.expected $testroot/stdout
468 test_done "$testroot" "$ret"
469 return 1
470 fi
472 echo "diff $commit2 $commit3" > $testroot/stdout.expected
473 echo -n 'blob - ' >> $testroot/stdout.expected
474 got tree -r $testroot/repo -c $commit2 -i gamma | grep 'delta$' \
475 | cut -d' ' -f 1 | sed -e 's/$/ (mode 644)/' \
476 >> $testroot/stdout.expected
477 echo 'blob + /dev/null' >> $testroot/stdout.expected
478 echo '--- gamma/delta' >> $testroot/stdout.expected
479 echo '+++ /dev/null' >> $testroot/stdout.expected
480 echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
481 echo '-modified delta' >> $testroot/stdout.expected
482 echo 'blob - /dev/null' >> $testroot/stdout.expected
483 echo -n 'blob + ' >> $testroot/stdout.expected
484 got tree -r $testroot/repo -c $commit3 -i gamma | grep 'new$' | \
485 cut -d' ' -f 1 | sed -e 's/$/ (mode 644)/' \
486 >> $testroot/stdout.expected
487 echo '--- /dev/null' >> $testroot/stdout.expected
488 echo '+++ gamma/new' >> $testroot/stdout.expected
489 echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
490 echo '+new' >> $testroot/stdout.expected
492 got diff -r $testroot/repo $commit2 $commit3 > $testroot/stdout
493 cmp -s $testroot/stdout.expected $testroot/stdout
494 ret="$?"
495 if [ "$ret" != "0" ]; then
496 diff -u $testroot/stdout.expected $testroot/stdout
497 fi
498 test_done "$testroot" "$ret"
499 return "$ret"
502 test_commit_dir_path() {
503 local testroot=`test_init commit_dir_path`
505 got checkout $testroot/repo $testroot/wt > /dev/null
506 ret="$?"
507 if [ "$ret" != "0" ]; then
508 test_done "$testroot" "$ret"
509 return 1
510 fi
512 echo "modified alpha" > $testroot/wt/alpha
513 echo "modified zeta" > $testroot/wt/epsilon/zeta
515 (cd $testroot/wt && got commit -m 'changed zeta' epsilon \
516 > $testroot/stdout)
518 local head_rev=`git_show_head $testroot/repo`
519 echo "M epsilon/zeta" >> $testroot/stdout.expected
520 echo "Created commit $head_rev" >> $testroot/stdout.expected
522 cmp -s $testroot/stdout.expected $testroot/stdout
523 ret="$?"
524 if [ "$ret" != "0" ]; then
525 diff -u $testroot/stdout.expected $testroot/stdout
526 test_done "$testroot" "$ret"
527 return 1
528 fi
530 echo "M alpha" > $testroot/stdout.expected
531 (cd $testroot/wt && got status > $testroot/stdout)
532 cmp -s $testroot/stdout.expected $testroot/stdout
533 ret="$?"
534 if [ "$ret" != "0" ]; then
535 diff -u $testroot/stdout.expected $testroot/stdout
536 fi
537 test_done "$testroot" "$ret"
540 test_commit_selected_paths() {
541 local testroot=`test_init commit_selected_paths`
543 got checkout $testroot/repo $testroot/wt > /dev/null
544 ret="$?"
545 if [ "$ret" != "0" ]; then
546 test_done "$testroot" "$ret"
547 return 1
548 fi
550 echo "modified alpha" > $testroot/wt/alpha
551 echo "modified delta" > $testroot/wt/gamma/delta
552 echo "modified zeta" > $testroot/wt/epsilon/zeta
553 (cd $testroot/wt && got rm beta >/dev/null)
554 echo "new file" > $testroot/wt/new
555 (cd $testroot/wt && got add new >/dev/null)
557 (cd $testroot/wt && got commit -m 'many paths' nonexistent alpha \
558 > $testroot/stdout 2> $testroot/stderr)
559 ret="$?"
560 if [ "$ret" == "0" ]; then
561 echo "commit succeeded unexpectedly" >&2
562 test_done "$testroot" "1"
563 return 1
564 fi
565 echo "got: nonexistent: bad path" > $testroot/stderr.expected
567 cmp -s $testroot/stderr.expected $testroot/stderr
568 ret="$?"
569 if [ "$ret" != "0" ]; then
570 diff -u $testroot/stderr.expected $testroot/stderr
571 test_done "$testroot" "$ret"
572 return 1
573 fi
575 (cd $testroot/wt && got commit -m 'many paths' \
576 beta new gamma > $testroot/stdout)
578 local head_rev=`git_show_head $testroot/repo`
579 echo "A new" > $testroot/stdout.expected
580 echo "D beta" >> $testroot/stdout.expected
581 echo "M gamma/delta" >> $testroot/stdout.expected
582 echo "Created commit $head_rev" >> $testroot/stdout.expected
584 cmp -s $testroot/stdout.expected $testroot/stdout
585 ret="$?"
586 if [ "$ret" != "0" ]; then
587 diff -u $testroot/stdout.expected $testroot/stdout
588 fi
589 test_done "$testroot" "$ret"
592 test_commit_outside_refs_heads() {
593 local testroot=`test_init commit_outside_refs_heads`
595 got ref -r $testroot/repo -c master refs/remotes/origin/master
597 got checkout -b refs/remotes/origin/master \
598 $testroot/repo $testroot/wt > /dev/null
599 ret="$?"
600 if [ "$ret" != "0" ]; then
601 test_done "$testroot" "$ret"
602 return 1
603 fi
605 echo "modified alpha" > $testroot/wt/alpha
607 (cd $testroot/wt && got commit -m 'change alpha' \
608 > $testroot/stdout 2> $testroot/stderr)
609 ret="$?"
610 if [ "$ret" == "0" ]; then
611 echo "commit succeeded unexpectedly" >&2
612 test_done "$testroot" "1"
613 return 1
614 fi
616 echo -n > $testroot/stdout.expected
617 cmp -s $testroot/stdout.expected $testroot/stdout
618 ret="$?"
619 if [ "$ret" != "0" ]; then
620 diff -u $testroot/stdout.expected $testroot/stdout
621 test_done "$testroot" "$ret"
622 return 1
623 fi
625 echo -n "got: will not commit to a branch outside the " \
626 > $testroot/stderr.expected
627 echo '"refs/heads/" reference namespace' \
628 >> $testroot/stderr.expected
629 cmp -s $testroot/stderr.expected $testroot/stderr
630 ret="$?"
631 if [ "$ret" != "0" ]; then
632 diff -u $testroot/stderr.expected $testroot/stderr
633 fi
634 test_done "$testroot" "$ret"
637 test_commit_no_email() {
638 local testroot=`test_init commit_no_email`
640 got checkout $testroot/repo $testroot/wt > /dev/null
641 ret="$?"
642 if [ "$ret" != "0" ]; then
643 test_done "$testroot" "$ret"
644 return 1
645 fi
647 echo "modified alpha" > $testroot/wt/alpha
648 (cd $testroot/wt && env GOT_AUTHOR=":flan_hacker:" \
649 got commit -m 'test no email' > $testroot/stdout \
650 2> $testroot/stderr)
652 echo -n "got: GOT_AUTHOR environment variable contains no email " \
653 > $testroot/stderr.expected
654 echo -n "address; an email address is required for compatibility "\
655 >> $testroot/stderr.expected
656 echo "with Git" >> $testroot/stderr.expected
657 cmp -s $testroot/stderr.expected $testroot/stderr
658 ret="$?"
659 if [ "$ret" != "0" ]; then
660 diff -u $testroot/stderr.expected $testroot/stderr
661 test_done "$testroot" "$ret"
662 return 1
663 fi
665 echo -n > $testroot/stdout.expected
666 cmp -s $testroot/stdout.expected $testroot/stdout
667 ret="$?"
668 if [ "$ret" != "0" ]; then
669 diff -u $testroot/stdout.expected $testroot/stdout
670 fi
671 test_done "$testroot" "$ret"
674 test_commit_tree_entry_sorting() {
675 local testroot=`test_init commit_tree_entry_sorting`
677 got checkout $testroot/repo $testroot/wt > /dev/null
678 ret="$?"
679 if [ "$ret" != "0" ]; then
680 test_done "$testroot" "$ret"
681 return 1
682 fi
684 # Git's index gets corrupted when tree entries are written in the
685 # order defined by got_path_cmp() rather than Git's own ordering.
686 # Create a new tree where a directory "got" and a file "got-version"
687 # would sort in the wrong order according to Git's opinion.
688 mkdir $testroot/wt/got
689 touch $testroot/wt/got/foo
690 echo foo > $testroot/wt/got-version
691 echo zzz > $testroot/wt/zzz
692 (cd $testroot/wt && got add got-version got/foo zzz > /dev/null)
694 (cd $testroot/wt && got commit -m 'test' > /dev/null)
696 # Let git-fsck verify the newly written tree to make sure Git is happy
697 (cd $testroot/repo && git fsck --strict \
698 > $testroot/fsck.stdout 2> $testroot/fsck.stderr)
699 ret="$?"
700 test_done "$testroot" "$ret"
703 test_commit_gotconfig_author() {
704 local testroot=`test_init commit_gotconfig_author`
706 got checkout $testroot/repo $testroot/wt > /dev/null
707 ret="$?"
708 if [ "$ret" != "0" ]; then
709 test_done "$testroot" "$ret"
710 return 1
711 fi
712 echo 'author "Flan Luck <flan_luck@openbsd.org>"' \
713 > $testroot/repo/.git/got.conf
715 echo "modified alpha" > $testroot/wt/alpha
716 (cd $testroot/wt && got commit -m 'test gotconfig author' > /dev/null)
717 ret="$?"
718 if [ "$ret" != "0" ]; then
719 test_done "$testroot" "$ret"
720 return 1
721 fi
723 (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
724 ret="$?"
725 if [ "$ret" != "0" ]; then
726 test_done "$testroot" "$ret"
727 return 1
728 fi
730 echo "from: Flan Luck <flan_luck@openbsd.org>" \
731 > $testroot/stdout.expected
732 cmp -s $testroot/stdout.expected $testroot/stdout
733 ret="$?"
734 if [ "$ret" != "0" ]; then
735 diff -u $testroot/stdout.expected $testroot/stdout
736 fi
737 test_done "$testroot" "$ret"
740 test_commit_gotconfig_worktree_author() {
741 local testroot=`test_init commit_gotconfig_worktree_author`
743 got checkout $testroot/repo $testroot/wt > /dev/null
744 ret="$?"
745 if [ "$ret" != "0" ]; then
746 test_done "$testroot" "$ret"
747 return 1
748 fi
749 echo 'author "Flan Luck <flan_luck@openbsd.org>"' \
750 > $testroot/repo/.git/got.conf
751 echo 'author "Flan Squee <flan_squee@openbsd.org>"' \
752 > $testroot/wt/.got/got.conf
754 echo "modified alpha" > $testroot/wt/alpha
755 (cd $testroot/wt && got commit -m 'test gotconfig author' > /dev/null)
756 ret="$?"
757 if [ "$ret" != "0" ]; then
758 test_done "$testroot" "$ret"
759 return 1
760 fi
762 (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
763 ret="$?"
764 if [ "$ret" != "0" ]; then
765 test_done "$testroot" "$ret"
766 return 1
767 fi
769 echo "from: Flan Squee <flan_squee@openbsd.org>" \
770 > $testroot/stdout.expected
771 cmp -s $testroot/stdout.expected $testroot/stdout
772 ret="$?"
773 if [ "$ret" != "0" ]; then
774 diff -u $testroot/stdout.expected $testroot/stdout
775 fi
776 test_done "$testroot" "$ret"
779 test_commit_gitconfig_author() {
780 local testroot=`test_init commit_gitconfig_author`
782 got checkout $testroot/repo $testroot/wt > /dev/null
783 ret="$?"
784 if [ "$ret" != "0" ]; then
785 test_done "$testroot" "$ret"
786 return 1
787 fi
789 (cd $testroot/repo && git config user.name 'Flan Luck')
790 (cd $testroot/repo && git config user.email 'flan_luck@openbsd.org')
792 echo "modified alpha" > $testroot/wt/alpha
793 (cd $testroot/wt && got commit -m 'test gitconfig author' > /dev/null)
794 ret="$?"
795 if [ "$ret" != "0" ]; then
796 test_done "$testroot" "$ret"
797 return 1
798 fi
800 (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
801 ret="$?"
802 if [ "$ret" != "0" ]; then
803 test_done "$testroot" "$ret"
804 return 1
805 fi
807 echo "from: Flan Luck <flan_luck@openbsd.org>" \
808 > $testroot/stdout.expected
809 cmp -s $testroot/stdout.expected $testroot/stdout
810 ret="$?"
811 if [ "$ret" != "0" ]; then
812 diff -u $testroot/stdout.expected $testroot/stdout
813 fi
814 test_done "$testroot" "$ret"
817 test_commit_xbit_change() {
818 local testroot=`test_init commit_xbit_change`
820 got checkout $testroot/repo $testroot/wt > /dev/null
821 ret="$?"
822 if [ "$ret" != "0" ]; then
823 test_done "$testroot" "$ret"
824 return 1
825 fi
827 chmod +x $testroot/wt/alpha
829 echo 'm alpha' > $testroot/stdout.expected
830 (cd $testroot/wt && got status > $testroot/stdout)
832 cmp -s $testroot/stdout.expected $testroot/stdout
833 ret="$?"
834 if [ "$ret" != "0" ]; then
835 diff -u $testroot/stdout.expected $testroot/stdout
836 test_done "$testroot" "$ret"
837 return 1
838 fi
840 (cd $testroot/wt && got commit -mx > $testroot/stdout)
841 ret="$?"
842 if [ "$ret" != "0" ]; then
843 echo "got commit failed unexpectedly"
844 test_done "$testroot" "$ret"
845 return 1
846 fi
848 local commit_id=`git_show_head $testroot/repo`
849 echo 'm alpha' > $testroot/stdout.expected
850 echo "Created commit $commit_id" >> $testroot/stdout.expected
851 cmp -s $testroot/stdout.expected $testroot/stdout
852 ret="$?"
853 if [ "$ret" != "0" ]; then
854 diff -u $testroot/stdout.expected $testroot/stdout
855 test_done "$testroot" "$ret"
856 return 1
857 fi
859 (cd $testroot/wt && got status > $testroot/stdout)
861 echo -n > $testroot/stdout.expected
862 cmp -s $testroot/stdout.expected $testroot/stdout
863 ret="$?"
864 if [ "$ret" != "0" ]; then
865 diff -u $testroot/stdout.expected $testroot/stdout
866 test_done "$testroot" "$ret"
867 return 1
868 fi
870 chmod -x $testroot/wt/alpha
872 echo 'm alpha' > $testroot/stdout.expected
873 (cd $testroot/wt && got status > $testroot/stdout)
875 cmp -s $testroot/stdout.expected $testroot/stdout
876 ret="$?"
877 if [ "$ret" != "0" ]; then
878 diff -u $testroot/stdout.expected $testroot/stdout
879 test_done "$testroot" "$ret"
880 return 1
881 fi
883 (cd $testroot/wt && got commit -mx > $testroot/stdout)
884 ret="$?"
885 if [ "$ret" != "0" ]; then
886 echo "got commit failed unexpectedly"
887 test_done "$testroot" "$ret"
888 return 1
889 fi
891 local commit_id=`git_show_head $testroot/repo`
892 echo 'm alpha' > $testroot/stdout.expected
893 echo "Created commit $commit_id" >> $testroot/stdout.expected
894 cmp -s $testroot/stdout.expected $testroot/stdout
895 ret="$?"
896 if [ "$ret" != "0" ]; then
897 diff -u $testroot/stdout.expected $testroot/stdout
898 test_done "$testroot" "$ret"
899 return 1
900 fi
902 chmod +x $testroot/wt/alpha
904 echo 'm alpha' > $testroot/stdout.expected
905 (cd $testroot/wt && got status > $testroot/stdout)
907 cmp -s $testroot/stdout.expected $testroot/stdout
908 ret="$?"
909 if [ "$ret" != "0" ]; then
910 diff -u $testroot/stdout.expected $testroot/stdout
911 fi
912 test_done "$testroot" "$ret"
915 commit_check_mode() {
916 local mode="$1"
917 local expected_mode="$2"
919 chmod 644 $testroot/wt/alpha
920 echo a >> $testroot/wt/alpha
921 chmod $mode $testroot/wt/alpha
923 (cd $testroot/wt && got commit -mm > $testroot/stdout)
924 ret="$?"
925 if [ "$ret" != "0" ]; then
926 echo "got commit failed unexpectedly"
927 test_done "$testroot" "$ret"
928 return 1
929 fi
931 local commit_id=`git_show_head $testroot/repo`
932 echo 'M alpha' > $testroot/stdout.expected
933 echo "Created commit $commit_id" >> $testroot/stdout.expected
934 cmp -s $testroot/stdout.expected $testroot/stdout
935 ret="$?"
936 if [ "$ret" != "0" ]; then
937 diff -u $testroot/stdout.expected $testroot/stdout
938 test_done "$testroot" "$ret"
939 fi
941 local tree_id=$(got cat -r $testroot/repo $commit_id | \
942 grep ^tree | cut -d' ' -f2)
943 local alpha_id=$(got cat -r $testroot/repo $tree_id | \
944 grep 'alpha$' | cut -d' ' -f1)
945 echo "$alpha_id $expected_mode alpha" > $testroot/stdout.expected
946 got cat -r $testroot/repo $tree_id | grep 'alpha$' > $testroot/stdout
947 cmp -s $testroot/stdout.expected $testroot/stdout
948 ret="$?"
949 if [ "$ret" != "0" ]; then
950 diff -u $testroot/stdout.expected $testroot/stdout
951 fi
952 return $ret
955 test_commit_normalizes_filemodes() {
956 local testroot=`test_init commit_normalizes_filemodes`
958 got checkout $testroot/repo $testroot/wt > /dev/null
959 ret="$?"
960 if [ "$ret" != "0" ]; then
961 test_done "$testroot" "$ret"
962 return 1
963 fi
965 modes="600 400 460 640 440 660 444 666"
966 for m in $modes; do
967 commit_check_mode "$m" "0100644"
968 ret="$?"
969 if [ "$ret" != "0" ]; then
970 break
971 fi
972 done
973 if [ "$ret" != "0" ]; then
974 test_done "$testroot" "$ret"
975 return 1
976 fi
977 modes="700 500 570 750 550 770 555 777"
978 for m in $modes; do
979 commit_check_mode "$m" "0100755"
980 ret="$?"
981 if [ "$ret" != "0" ]; then
982 break
983 fi
984 done
985 if [ "$ret" != "0" ]; then
986 test_done "$testroot" "$ret"
987 return 1
988 fi
989 test_done "$testroot" "$ret"
992 test_commit_with_unrelated_submodule() {
993 local testroot=`test_init commit_with_unrelated_submodule`
995 make_single_file_repo $testroot/repo2 foo
997 (cd $testroot/repo && git submodule -q add ../repo2)
998 (cd $testroot/repo && git commit -q -m 'adding submodule')
1000 got checkout $testroot/repo $testroot/wt > /dev/null
1001 ret="$?"
1002 if [ "$ret" != "0" ]; then
1003 echo "checkout failed unexpectedly" >&2
1004 test_done "$testroot" "$ret"
1005 return 1
1008 echo "modified alpha" > $testroot/wt/alpha
1010 echo "" > $testroot/stdout.expected
1012 (cd $testroot/wt && got commit -m 'modify alpha' > $testroot/stdout)
1013 ret="$?"
1014 if [ "$ret" != "0" ]; then
1015 echo "commit failed unexpectedly" >&2
1016 test_done "$testroot" "$ret"
1017 return 1
1020 local head_rev=`git_show_head $testroot/repo`
1021 echo "M alpha" > $testroot/stdout.expected
1022 echo "Created commit $head_rev" >> $testroot/stdout.expected
1024 cmp -s $testroot/stdout.expected $testroot/stdout
1025 ret="$?"
1026 if [ "$ret" != "0" ]; then
1027 diff -u $testroot/stdout.expected $testroot/stdout
1029 test_done "$testroot" "$ret"
1032 check_symlinks() {
1033 local wtpath="$1"
1034 if ! [ -h $wtpath/alpha.link ]; then
1035 echo "alpha.link is not a symlink"
1036 return 1
1039 readlink $wtpath/alpha.link > $testroot/stdout
1040 echo "alpha" > $testroot/stdout.expected
1041 cmp -s $testroot/stdout.expected $testroot/stdout
1042 ret="$?"
1043 if [ "$ret" != "0" ]; then
1044 diff -u $testroot/stdout.expected $testroot/stdout
1045 return 1
1048 if ! [ -h $wtpath/epsilon.link ]; then
1049 echo "epsilon.link is not a symlink"
1050 return 1
1053 readlink $wtpath/epsilon.link > $testroot/stdout
1054 echo "epsilon" > $testroot/stdout.expected
1055 cmp -s $testroot/stdout.expected $testroot/stdout
1056 ret="$?"
1057 if [ "$ret" != "0" ]; then
1058 diff -u $testroot/stdout.expected $testroot/stdout
1059 return 1
1062 if [ -h $wtpath/passwd.link ]; then
1063 echo -n "passwd.link is a symlink and points outside of work tree: " >&2
1064 readlink $wtpath/passwd.link >&2
1065 return 1
1068 echo -n "/etc/passwd" > $testroot/content.expected
1069 cp $wtpath/passwd.link $testroot/content
1070 ret="$?"
1071 if [ "$ret" != "0" ]; then
1072 echo "cp command failed unexpectedly" >&2
1073 return 1
1076 cmp -s $testroot/content.expected $testroot/content
1077 ret="$?"
1078 if [ "$ret" != "0" ]; then
1079 diff -u $testroot/content.expected $testroot/content
1080 return 1
1083 readlink $wtpath/epsilon/beta.link > $testroot/stdout
1084 echo "../beta" > $testroot/stdout.expected
1085 cmp -s $testroot/stdout.expected $testroot/stdout
1086 ret="$?"
1087 if [ "$ret" != "0" ]; then
1088 diff -u $testroot/stdout.expected $testroot/stdout
1089 return 1
1092 readlink $wtpath/nonexistent.link > $testroot/stdout
1093 echo "nonexistent" > $testroot/stdout.expected
1094 cmp -s $testroot/stdout.expected $testroot/stdout
1095 ret="$?"
1096 if [ "$ret" != "0" ]; then
1097 diff -u $testroot/stdout.expected $testroot/stdout
1098 return 1
1101 return 0
1104 test_commit_symlink() {
1105 local testroot=`test_init commit_symlink`
1107 got checkout $testroot/repo $testroot/wt > /dev/null
1108 ret="$?"
1109 if [ "$ret" != "0" ]; then
1110 test_done "$testroot" "$ret"
1111 return 1
1114 (cd $testroot/wt && ln -s alpha alpha.link)
1115 (cd $testroot/wt && ln -s epsilon epsilon.link)
1116 (cd $testroot/wt && ln -s /etc/passwd passwd.link)
1117 (cd $testroot/wt && ln -s ../beta epsilon/beta.link)
1118 (cd $testroot/wt && ln -s nonexistent nonexistent.link)
1119 (cd $testroot/wt && got add alpha.link epsilon.link passwd.link \
1120 epsilon/beta.link nonexistent.link > /dev/null)
1122 (cd $testroot/wt && got commit -m 'test commit_symlink' \
1123 > $testroot/stdout 2> $testroot/stderr)
1124 ret="$?"
1125 if [ "$ret" == "0" ]; then
1126 echo "got commit succeeded unexpectedly" >&2
1127 test_done "$testroot" "$ret"
1128 return 1
1130 echo -n "got: $testroot/wt/passwd.link: " > $testroot/stderr.expected
1131 echo "symbolic link points outside of paths under version control" \
1132 >> $testroot/stderr.expected
1133 cmp -s $testroot/stderr.expected $testroot/stderr
1134 ret="$?"
1135 if [ "$ret" != "0" ]; then
1136 diff -u $testroot/stderr.expected $testroot/stderr
1137 test_done "$testroot" "$ret"
1138 return 1
1141 (cd $testroot/wt && got commit -S -m 'test commit_symlink' \
1142 > $testroot/stdout)
1144 local head_rev=`git_show_head $testroot/repo`
1145 echo "A alpha.link" > $testroot/stdout.expected
1146 echo "A epsilon.link" >> $testroot/stdout.expected
1147 echo "A nonexistent.link" >> $testroot/stdout.expected
1148 echo "A passwd.link" >> $testroot/stdout.expected
1149 echo "A epsilon/beta.link" >> $testroot/stdout.expected
1150 echo "Created commit $head_rev" >> $testroot/stdout.expected
1152 cmp -s $testroot/stdout.expected $testroot/stdout
1153 ret="$?"
1154 if [ "$ret" != "0" ]; then
1155 diff -u $testroot/stdout.expected $testroot/stdout
1156 test_done "$testroot" "$ret"
1157 return 1
1160 # verify created in-repository tree
1161 got checkout $testroot/repo $testroot/wt2 > /dev/null
1162 ret="$?"
1163 if [ "$ret" != "0" ]; then
1164 test_done "$testroot" "$ret"
1165 return 1
1167 check_symlinks $testroot/wt2
1168 ret="$?"
1169 if [ "$ret" != "0" ]; then
1170 test_done "$testroot" "$ret"
1171 return 1
1174 if ! [ -h $testroot/wt/passwd.link ]; then
1175 echo 'passwd.link is not a symlink' >&2
1176 test_done "$testroot" 1
1177 return 1
1180 # 'got update' should reinstall passwd.link as a regular file
1181 (cd $testroot/wt && got update > /dev/null)
1182 check_symlinks $testroot/wt
1183 ret="$?"
1184 if [ "$ret" != "0" ]; then
1185 test_done "$testroot" "$ret"
1186 return 1
1189 (cd $testroot/wt && ln -sf beta alpha.link)
1190 (cd $testroot/wt && ln -sfh gamma epsilon.link)
1191 rm $testroot/wt/epsilon/beta.link
1192 echo "this is a regular file" > $testroot/wt/epsilon/beta.link
1193 (cd $testroot/wt && ln -sf .got/bar dotgotbar.link)
1194 (cd $testroot/wt && got add dotgotbar.link > /dev/null)
1195 (cd $testroot/wt && got rm nonexistent.link > /dev/null)
1196 (cd $testroot/wt && ln -sf gamma/delta zeta.link)
1197 (cd $testroot/wt && ln -sf alpha new.link)
1198 (cd $testroot/wt && got add new.link > /dev/null)
1200 (cd $testroot/wt && got commit -m 'test commit_symlink' \
1201 > $testroot/stdout 2> $testroot/stderr)
1202 ret="$?"
1203 if [ "$ret" == "0" ]; then
1204 echo "got commit succeeded unexpectedly" >&2
1205 test_done "$testroot" "$ret"
1206 return 1
1208 echo -n "got: $testroot/wt/dotgotbar.link: " > $testroot/stderr.expected
1209 echo "symbolic link points outside of paths under version control" \
1210 >> $testroot/stderr.expected
1211 cmp -s $testroot/stderr.expected $testroot/stderr
1212 ret="$?"
1213 if [ "$ret" != "0" ]; then
1214 diff -u $testroot/stderr.expected $testroot/stderr
1215 test_done "$testroot" "$ret"
1216 return 1
1219 (cd $testroot/wt && got commit -S -m 'test commit_symlink' \
1220 > $testroot/stdout)
1222 local head_rev=`git_show_head $testroot/repo`
1223 echo "A dotgotbar.link" > $testroot/stdout.expected
1224 echo "A new.link" >> $testroot/stdout.expected
1225 echo "M alpha.link" >> $testroot/stdout.expected
1226 echo "M epsilon/beta.link" >> $testroot/stdout.expected
1227 echo "M epsilon.link" >> $testroot/stdout.expected
1228 echo "D nonexistent.link" >> $testroot/stdout.expected
1229 echo "Created commit $head_rev" >> $testroot/stdout.expected
1231 cmp -s $testroot/stdout.expected $testroot/stdout
1232 ret="$?"
1233 if [ "$ret" != "0" ]; then
1234 diff -u $testroot/stdout.expected $testroot/stdout
1235 test_done "$testroot" "$ret"
1236 return 1
1239 got tree -r $testroot/repo -c $head_rev -R > $testroot/stdout
1240 cat > $testroot/stdout.expected <<EOF
1241 alpha
1242 alpha.link@ -> beta
1243 beta
1244 dotgotbar.link@ -> .got/bar
1245 epsilon/
1246 epsilon/beta.link
1247 epsilon/zeta
1248 epsilon.link@ -> gamma
1249 gamma/
1250 gamma/delta
1251 new.link@ -> alpha
1252 passwd.link@ -> /etc/passwd
1253 EOF
1254 cmp -s $testroot/stdout.expected $testroot/stdout
1255 ret="$?"
1256 if [ "$ret" != "0" ]; then
1257 diff -u $testroot/stdout.expected $testroot/stdout
1259 test_done "$testroot" "$ret"
1262 test_commit_fix_bad_symlink() {
1263 local testroot=`test_init commit_fix_bad_symlink`
1265 got checkout $testroot/repo $testroot/wt > /dev/null
1266 ret="$?"
1267 if [ "$ret" != "0" ]; then
1268 echo "got checkout failed unexpectedly" >&2
1269 test_done "$testroot" "$ret"
1270 return 1
1273 (cd $testroot/wt && ln -s /etc/passwd passwd.link)
1274 (cd $testroot/wt && got add passwd.link > /dev/null)
1276 (cd $testroot/wt && got commit -S -m 'commit bad symlink' \
1277 > $testroot/stdout)
1279 if ! [ -h $testroot/wt/passwd.link ]; then
1280 echo 'passwd.link is not a symlink' >&2
1281 test_done "$testroot" 1
1282 return 1
1284 (cd $testroot/wt && got update >/dev/null)
1285 if [ -h $testroot/wt/passwd.link ]; then
1286 echo "passwd.link is a symlink but should be a regular file" >&2
1287 test_done "$testroot" "1"
1288 return 1
1291 # create another work tree which will contain the "bad" symlink
1292 got checkout $testroot/repo $testroot/wt2 > /dev/null
1293 ret="$?"
1294 if [ "$ret" != "0" ]; then
1295 echo "got checkout failed unexpectedly" >&2
1296 test_done "$testroot" "$ret"
1297 return 1
1300 # change "bad" symlink back into a "good" symlink
1301 (cd $testroot/wt && ln -sfh alpha passwd.link)
1303 (cd $testroot/wt && got commit -m 'fix bad symlink' \
1304 > $testroot/stdout)
1306 local head_rev=`git_show_head $testroot/repo`
1307 echo "M passwd.link" > $testroot/stdout.expected
1308 echo "Created commit $head_rev" >> $testroot/stdout.expected
1310 cmp -s $testroot/stdout.expected $testroot/stdout
1311 ret="$?"
1312 if [ "$ret" != "0" ]; then
1313 diff -u $testroot/stdout.expected $testroot/stdout
1314 test_done "$testroot" "$ret"
1315 return 1
1318 if ! [ -h $testroot/wt/passwd.link ]; then
1319 echo 'passwd.link is not a symlink' >&2
1320 test_done "$testroot" 1
1321 return 1
1324 readlink $testroot/wt/passwd.link > $testroot/stdout
1325 echo "alpha" > $testroot/stdout.expected
1326 cmp -s $testroot/stdout.expected $testroot/stdout
1327 ret="$?"
1328 if [ "$ret" != "0" ]; then
1329 diff -u $testroot/stdout.expected $testroot/stdout
1330 return 1
1333 # Update the other work tree; the bad symlink should be fixed
1334 (cd $testroot/wt2 && got update > /dev/null)
1335 ret="$?"
1336 if [ "$ret" != "0" ]; then
1337 echo "got checkout failed unexpectedly" >&2
1338 test_done "$testroot" "$ret"
1339 return 1
1342 if ! [ -h $testroot/wt2/passwd.link ]; then
1343 echo 'passwd.link is not a symlink' >&2
1344 test_done "$testroot" 1
1345 return 1
1348 readlink $testroot/wt2/passwd.link > $testroot/stdout
1349 echo "alpha" > $testroot/stdout.expected
1350 cmp -s $testroot/stdout.expected $testroot/stdout
1351 ret="$?"
1352 if [ "$ret" != "0" ]; then
1353 diff -u $testroot/stdout.expected $testroot/stdout
1354 return 1
1357 test_done "$testroot" "0"
1360 test_parseargs "$@"
1361 run_test test_commit_basic
1362 run_test test_commit_new_subdir
1363 run_test test_commit_subdir
1364 run_test test_commit_single_file
1365 run_test test_commit_out_of_date
1366 run_test test_commit_added_subdirs
1367 run_test test_commit_deleted_subdirs
1368 run_test test_commit_rejects_conflicted_file
1369 run_test test_commit_single_file_multiple
1370 run_test test_commit_added_and_modified_in_same_dir
1371 run_test test_commit_path_prefix
1372 run_test test_commit_dir_path
1373 run_test test_commit_selected_paths
1374 run_test test_commit_outside_refs_heads
1375 run_test test_commit_no_email
1376 run_test test_commit_tree_entry_sorting
1377 run_test test_commit_gotconfig_author
1378 run_test test_commit_gotconfig_worktree_author
1379 run_test test_commit_gitconfig_author
1380 run_test test_commit_xbit_change
1381 run_test test_commit_normalizes_filemodes
1382 run_test test_commit_with_unrelated_submodule
1383 run_test test_commit_symlink
1384 run_test test_commit_fix_bad_symlink