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_rejects_conflicted_file {
242 local testroot=`test_init commit_rejects_conflicted_file`
244 local initial_rev=`git_show_head $testroot/repo`
246 got checkout $testroot/repo $testroot/wt > /dev/null
247 ret="$?"
248 if [ "$ret" != "0" ]; then
249 test_done "$testroot" "$ret"
250 return 1
251 fi
253 echo "modified alpha" > $testroot/wt/alpha
254 (cd $testroot/wt && got commit -m "modified alpha" >/dev/null)
256 (cd $testroot/wt && got update -c $initial_rev > /dev/null)
258 echo "modified alpha, too" > $testroot/wt/alpha
260 echo "C alpha" > $testroot/stdout.expected
261 echo -n "Updated to commit " >> $testroot/stdout.expected
262 git_show_head $testroot/repo >> $testroot/stdout.expected
263 echo >> $testroot/stdout.expected
265 (cd $testroot/wt && got update > $testroot/stdout)
267 cmp -s $testroot/stdout.expected $testroot/stdout
268 ret="$?"
269 if [ "$ret" != "0" ]; then
270 diff -u $testroot/stdout.expected $testroot/stdout
271 test_done "$testroot" "$ret"
272 return 1
273 fi
275 (cd $testroot/wt && got commit -m 'commit it' > $testroot/stdout \
276 2> $testroot/stderr)
278 echo -n > $testroot/stdout.expected
279 echo "got: cannot commit file in conflicted status" \
280 > $testroot/stderr.expected
282 cmp -s $testroot/stdout.expected $testroot/stdout
283 ret="$?"
284 if [ "$ret" != "0" ]; then
285 diff -u $testroot/stdout.expected $testroot/stdout
286 test_done "$testroot" "$ret"
287 return 1
288 fi
289 cmp -s $testroot/stderr.expected $testroot/stderr
290 ret="$?"
291 if [ "$ret" != "0" ]; then
292 diff -u $testroot/stderr.expected $testroot/stderr
293 fi
294 test_done "$testroot" "$ret"
297 function test_commit_single_file_multiple {
298 local testroot=`test_init commit_single_file_multiple`
300 got checkout $testroot/repo $testroot/wt > /dev/null
301 ret="$?"
302 if [ "$ret" != "0" ]; then
303 test_done "$testroot" "$ret"
304 return 1
305 fi
307 for i in 1 2 3 4; do
308 echo "modified alpha" >> $testroot/wt/alpha
310 (cd $testroot/wt && \
311 got commit -m "changed alpha" > $testroot/stdout)
313 local head_rev=`git_show_head $testroot/repo`
314 echo "M alpha" > $testroot/stdout.expected
315 echo "Created commit $head_rev" >> $testroot/stdout.expected
317 cmp -s $testroot/stdout.expected $testroot/stdout
318 ret="$?"
319 if [ "$ret" != "0" ]; then
320 diff -u $testroot/stdout.expected $testroot/stdout
321 test_done "$testroot" "$ret"
322 return 1
323 fi
324 done
326 test_done "$testroot" "0"
329 function test_commit_added_and_modified_in_same_dir {
330 local testroot=`test_init commit_added_and_modified_in_same_dir`
332 got checkout $testroot/repo $testroot/wt > /dev/null
333 ret="$?"
334 if [ "$ret" != "0" ]; then
335 test_done "$testroot" "$ret"
336 return 1
337 fi
339 echo "modified zeta" > $testroot/wt/epsilon/zeta
340 echo "new file" > $testroot/wt/epsilon/new
341 (cd $testroot/wt && got add epsilon/new >/dev/null)
343 (cd $testroot/wt && got commit \
344 -m 'added and modified in same dir' > $testroot/stdout \
345 2> $testroot/stderr)
347 local head_rev=`git_show_head $testroot/repo`
348 echo "A epsilon/new" > $testroot/stdout.expected
349 echo "M epsilon/zeta" >> $testroot/stdout.expected
350 echo "Created commit $head_rev" >> $testroot/stdout.expected
352 cmp -s $testroot/stdout.expected $testroot/stdout
353 ret="$?"
354 if [ "$ret" != "0" ]; then
355 diff -u $testroot/stdout.expected $testroot/stdout
356 fi
357 test_done "$testroot" "$ret"
360 function test_commit_path_prefix {
361 local testroot=`test_init commit_path_prefix`
362 local commit1=`git_show_head $testroot/repo`
364 got checkout -p gamma $testroot/repo $testroot/wt > /dev/null
365 ret="$?"
366 if [ "$ret" != "0" ]; then
367 test_done "$testroot" "$ret"
368 return 1
369 fi
371 echo "modified delta" > $testroot/wt/delta
373 (cd $testroot/wt && got commit -m 'changed gamma/delta' > $testroot/stdout)
375 local commit2=`git_show_head $testroot/repo`
376 echo "M delta" > $testroot/stdout.expected
377 echo "Created commit $commit2" >> $testroot/stdout.expected
379 cmp -s $testroot/stdout.expected $testroot/stdout
380 ret="$?"
381 if [ "$ret" != "0" ]; then
382 diff -u $testroot/stdout.expected $testroot/stdout
383 test_done "$testroot" "$ret"
384 return 1
385 fi
387 echo "diff $commit1 $commit2" > $testroot/stdout.expected
388 echo -n 'blob - ' >> $testroot/stdout.expected
389 got tree -r $testroot/repo -c $commit1 -i gamma | grep 'delta$' \
390 | cut -d' ' -f 1 >> $testroot/stdout.expected
391 echo -n 'blob + ' >> $testroot/stdout.expected
392 got tree -r $testroot/repo -c $commit2 -i gamma | grep 'delta$' | \
393 cut -d' ' -f 1 >> $testroot/stdout.expected
394 echo '--- gamma/delta' >> $testroot/stdout.expected
395 echo '+++ gamma/delta' >> $testroot/stdout.expected
396 echo '@@ -1 +1 @@' >> $testroot/stdout.expected
397 echo '-delta' >> $testroot/stdout.expected
398 echo '+modified delta' >> $testroot/stdout.expected
400 got diff -r $testroot/repo $commit1 $commit2 > $testroot/stdout
401 cmp -s $testroot/stdout.expected $testroot/stdout
402 ret="$?"
403 if [ "$ret" != "0" ]; then
404 diff -u $testroot/stdout.expected $testroot/stdout
405 fi
406 test_done "$testroot" "$ret"
409 function test_commit_dir_path {
410 local testroot=`test_init commit_dir_path`
412 got checkout $testroot/repo $testroot/wt > /dev/null
413 ret="$?"
414 if [ "$ret" != "0" ]; then
415 test_done "$testroot" "$ret"
416 return 1
417 fi
419 echo "modified alpha" > $testroot/wt/alpha
420 echo "modified zeta" > $testroot/wt/epsilon/zeta
422 (cd $testroot/wt && got commit -m 'changed zeta' epsilon \
423 > $testroot/stdout)
425 local head_rev=`git_show_head $testroot/repo`
426 echo "M epsilon/zeta" >> $testroot/stdout.expected
427 echo "Created commit $head_rev" >> $testroot/stdout.expected
429 cmp -s $testroot/stdout.expected $testroot/stdout
430 ret="$?"
431 if [ "$ret" != "0" ]; then
432 diff -u $testroot/stdout.expected $testroot/stdout
433 test_done "$testroot" "$ret"
434 return 1
435 fi
437 echo "M alpha" > $testroot/stdout.expected
438 (cd $testroot/wt && got status > $testroot/stdout)
439 cmp -s $testroot/stdout.expected $testroot/stdout
440 ret="$?"
441 if [ "$ret" != "0" ]; then
442 diff -u $testroot/stdout.expected $testroot/stdout
443 fi
444 test_done "$testroot" "$ret"
447 function test_commit_selected_paths {
448 local testroot=`test_init commit_selected_paths`
450 got checkout $testroot/repo $testroot/wt > /dev/null
451 ret="$?"
452 if [ "$ret" != "0" ]; then
453 test_done "$testroot" "$ret"
454 return 1
455 fi
457 echo "modified alpha" > $testroot/wt/alpha
458 echo "modified delta" > $testroot/wt/gamma/delta
459 echo "modified zeta" > $testroot/wt/epsilon/zeta
460 (cd $testroot/wt && got rm beta >/dev/null)
461 echo "new file" > $testroot/wt/new
462 (cd $testroot/wt && got add new >/dev/null)
464 (cd $testroot/wt && got commit -m 'many paths' nonexistent alpha \
465 > $testroot/stdout 2> $testroot/stderr)
466 ret="$?"
467 if [ "$ret" == "0" ]; then
468 echo "commit succeeded unexpectedly" >&2
469 test_done "$testroot" "1"
470 return 1
471 fi
472 echo "got: nonexistent: bad path" > $testroot/stderr.expected
474 cmp -s $testroot/stderr.expected $testroot/stderr
475 ret="$?"
476 if [ "$ret" != "0" ]; then
477 diff -u $testroot/stderr.expected $testroot/stderr
478 test_done "$testroot" "$ret"
479 return 1
480 fi
482 (cd $testroot/wt && got commit -m 'many paths' \
483 beta new gamma > $testroot/stdout)
485 local head_rev=`git_show_head $testroot/repo`
486 echo "A new" > $testroot/stdout.expected
487 echo "D beta" >> $testroot/stdout.expected
488 echo "M gamma/delta" >> $testroot/stdout.expected
489 echo "Created commit $head_rev" >> $testroot/stdout.expected
491 cmp -s $testroot/stdout.expected $testroot/stdout
492 ret="$?"
493 if [ "$ret" != "0" ]; then
494 diff -u $testroot/stdout.expected $testroot/stdout
495 fi
496 test_done "$testroot" "$ret"
499 function test_commit_outside_refs_heads {
500 local testroot=`test_init commit_outside_refs_heads`
502 got ref -r $testroot/repo refs/remotes/origin/master master
504 got checkout -b refs/remotes/origin/master \
505 $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
514 (cd $testroot/wt && got commit -m 'change alpha' \
515 > $testroot/stdout 2> $testroot/stderr)
516 ret="$?"
517 if [ "$ret" == "0" ]; then
518 echo "commit succeeded unexpectedly" >&2
519 test_done "$testroot" "1"
520 return 1
521 fi
523 echo -n > $testroot/stdout.expected
524 cmp -s $testroot/stdout.expected $testroot/stdout
525 ret="$?"
526 if [ "$ret" != "0" ]; then
527 diff -u $testroot/stdout.expected $testroot/stdout
528 test_done "$testroot" "$ret"
529 return 1
530 fi
532 echo -n "got: will not commit to a branch outside the " \
533 > $testroot/stderr.expected
534 echo '"refs/heads/" reference namespace' \
535 >> $testroot/stderr.expected
536 cmp -s $testroot/stderr.expected $testroot/stderr
537 ret="$?"
538 if [ "$ret" != "0" ]; then
539 diff -u $testroot/stderr.expected $testroot/stderr
540 fi
541 test_done "$testroot" "$ret"
544 function test_commit_no_email {
545 local testroot=`test_init commit_no_email`
547 got checkout $testroot/repo $testroot/wt > /dev/null
548 ret="$?"
549 if [ "$ret" != "0" ]; then
550 test_done "$testroot" "$ret"
551 return 1
552 fi
554 echo "modified alpha" > $testroot/wt/alpha
555 (cd $testroot/wt && env GOT_AUTHOR=":flan_hacker:" \
556 got commit -m 'test no email' > $testroot/stdout \
557 2> $testroot/stderr)
559 echo -n "got: GOT_AUTHOR environment variable contains no email " \
560 > $testroot/stderr.expected
561 echo -n "address; an email address is required for compatibility "\
562 >> $testroot/stderr.expected
563 echo "with Git" >> $testroot/stderr.expected
564 cmp -s $testroot/stderr.expected $testroot/stderr
565 ret="$?"
566 if [ "$ret" != "0" ]; then
567 diff -u $testroot/stderr.expected $testroot/stderr
568 test_done "$testroot" "$ret"
569 return 1
570 fi
572 echo -n > $testroot/stdout.expected
573 cmp -s $testroot/stdout.expected $testroot/stdout
574 ret="$?"
575 if [ "$ret" != "0" ]; then
576 diff -u $testroot/stdout.expected $testroot/stdout
577 fi
578 test_done "$testroot" "$ret"
581 function test_commit_tree_entry_sorting {
582 local testroot=`test_init commit_tree_entry_sorting`
584 got checkout $testroot/repo $testroot/wt > /dev/null
585 ret="$?"
586 if [ "$ret" != "0" ]; then
587 test_done "$testroot" "$ret"
588 return 1
589 fi
591 # Git's index gets corrupted when tree entries are written in the
592 # order defined by got_path_cmp() rather than Git's own ordering.
593 # Create a new tree where a directory "got" and a file "got-version"
594 # would sort in the wrong order according to Git's opinion.
595 mkdir $testroot/wt/got
596 touch $testroot/wt/got/foo
597 echo foo > $testroot/wt/got-version
598 echo zzz > $testroot/wt/zzz
599 (cd $testroot/wt && got add got-version got/foo zzz > /dev/null)
601 (cd $testroot/wt && got commit -m 'test' > /dev/null)
603 # Let git-fsck verify the newly written tree to make sure Git is happy
604 (cd $testroot/repo && git fsck --strict \
605 > $testroot/fsck.stdout 2> $testroot/fsck.stderr)
606 ret="$?"
607 test_done "$testroot" "$ret"
610 function test_commit_gitconfig_author {
611 local testroot=`test_init commit_gitconfig_author`
613 got checkout $testroot/repo $testroot/wt > /dev/null
614 ret="$?"
615 if [ "$ret" != "0" ]; then
616 test_done "$testroot" "$ret"
617 return 1
618 fi
620 (cd $testroot/repo && git config user.name 'Flan Luck')
621 (cd $testroot/repo && git config user.email 'flan_luck@openbsd.org')
623 echo "modified alpha" > $testroot/wt/alpha
624 (cd $testroot/wt && got commit -m 'test gitconfig author' > /dev/null)
625 ret="$?"
626 if [ "$ret" != "0" ]; then
627 test_done "$testroot" "$ret"
628 return 1
629 fi
631 (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
632 ret="$?"
633 if [ "$ret" != "0" ]; then
634 test_done "$testroot" "$ret"
635 return 1
636 fi
638 echo "from: Flan Luck <flan_luck@openbsd.org>" \
639 > $testroot/stdout.expected
640 cmp -s $testroot/stdout.expected $testroot/stdout
641 ret="$?"
642 if [ "$ret" != "0" ]; then
643 diff -u $testroot/stdout.expected $testroot/stdout
644 fi
645 test_done "$testroot" "$ret"
648 function test_commit_xbit_change {
649 local testroot=`test_init commit_xbit_change`
651 got checkout $testroot/repo $testroot/wt > /dev/null
652 ret="$?"
653 if [ "$ret" != "0" ]; then
654 test_done "$testroot" "$ret"
655 return 1
656 fi
658 chmod +x $testroot/wt/alpha
660 echo 'm alpha' > $testroot/stdout.expected
661 (cd $testroot/wt && got status > $testroot/stdout)
663 cmp -s $testroot/stdout.expected $testroot/stdout
664 ret="$?"
665 if [ "$ret" != "0" ]; then
666 diff -u $testroot/stdout.expected $testroot/stdout
667 test_done "$testroot" "$ret"
668 return 1
669 fi
671 (cd $testroot/wt && got commit -mx > $testroot/stdout)
672 ret="$?"
673 if [ "$ret" != "0" ]; then
674 echo "got commit failed unexpectedly"
675 test_done "$testroot" "$ret"
676 return 1
677 fi
679 local commit_id=`git_show_head $testroot/repo`
680 echo 'm alpha' > $testroot/stdout.expected
681 echo "Created commit $commit_id" >> $testroot/stdout.expected
682 cmp -s $testroot/stdout.expected $testroot/stdout
683 ret="$?"
684 if [ "$ret" != "0" ]; then
685 diff -u $testroot/stdout.expected $testroot/stdout
686 test_done "$testroot" "$ret"
687 return 1
688 fi
690 (cd $testroot/wt && got status > $testroot/stdout)
692 echo -n > $testroot/stdout.expected
693 cmp -s $testroot/stdout.expected $testroot/stdout
694 ret="$?"
695 if [ "$ret" != "0" ]; then
696 diff -u $testroot/stdout.expected $testroot/stdout
697 test_done "$testroot" "$ret"
698 return 1
699 fi
701 chmod -x $testroot/wt/alpha
703 echo 'm alpha' > $testroot/stdout.expected
704 (cd $testroot/wt && got status > $testroot/stdout)
706 cmp -s $testroot/stdout.expected $testroot/stdout
707 ret="$?"
708 if [ "$ret" != "0" ]; then
709 diff -u $testroot/stdout.expected $testroot/stdout
710 test_done "$testroot" "$ret"
711 return 1
712 fi
714 (cd $testroot/wt && got commit -mx > $testroot/stdout)
715 ret="$?"
716 if [ "$ret" != "0" ]; then
717 echo "got commit failed unexpectedly"
718 test_done "$testroot" "$ret"
719 return 1
720 fi
722 local commit_id=`git_show_head $testroot/repo`
723 echo 'm alpha' > $testroot/stdout.expected
724 echo "Created commit $commit_id" >> $testroot/stdout.expected
725 cmp -s $testroot/stdout.expected $testroot/stdout
726 ret="$?"
727 if [ "$ret" != "0" ]; then
728 diff -u $testroot/stdout.expected $testroot/stdout
729 test_done "$testroot" "$ret"
730 return 1
731 fi
733 chmod +x $testroot/wt/alpha
735 echo 'm alpha' > $testroot/stdout.expected
736 (cd $testroot/wt && got status > $testroot/stdout)
738 cmp -s $testroot/stdout.expected $testroot/stdout
739 ret="$?"
740 if [ "$ret" != "0" ]; then
741 diff -u $testroot/stdout.expected $testroot/stdout
742 fi
743 test_done "$testroot" "$ret"
746 run_test test_commit_basic
747 run_test test_commit_new_subdir
748 run_test test_commit_subdir
749 run_test test_commit_single_file
750 run_test test_commit_out_of_date
751 run_test test_commit_added_subdirs
752 run_test test_commit_rejects_conflicted_file
753 run_test test_commit_single_file_multiple
754 run_test test_commit_added_and_modified_in_same_dir
755 run_test test_commit_path_prefix
756 run_test test_commit_dir_path
757 run_test test_commit_selected_paths
758 run_test test_commit_outside_refs_heads
759 run_test test_commit_no_email
760 run_test test_commit_tree_entry_sorting
761 run_test test_commit_gitconfig_author
762 run_test test_commit_xbit_change