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
306 (cd $testroot/wt && got update > $testroot/stdout)
308 cmp -s $testroot/stdout.expected $testroot/stdout
309 ret="$?"
310 if [ "$ret" != "0" ]; then
311 diff -u $testroot/stdout.expected $testroot/stdout
312 test_done "$testroot" "$ret"
313 return 1
314 fi
316 (cd $testroot/wt && got commit -m 'commit it' > $testroot/stdout \
317 2> $testroot/stderr)
319 echo -n > $testroot/stdout.expected
320 echo "got: cannot commit file in conflicted status" \
321 > $testroot/stderr.expected
323 cmp -s $testroot/stdout.expected $testroot/stdout
324 ret="$?"
325 if [ "$ret" != "0" ]; then
326 diff -u $testroot/stdout.expected $testroot/stdout
327 test_done "$testroot" "$ret"
328 return 1
329 fi
330 cmp -s $testroot/stderr.expected $testroot/stderr
331 ret="$?"
332 if [ "$ret" != "0" ]; then
333 diff -u $testroot/stderr.expected $testroot/stderr
334 fi
335 test_done "$testroot" "$ret"
338 function test_commit_single_file_multiple {
339 local testroot=`test_init commit_single_file_multiple`
341 got checkout $testroot/repo $testroot/wt > /dev/null
342 ret="$?"
343 if [ "$ret" != "0" ]; then
344 test_done "$testroot" "$ret"
345 return 1
346 fi
348 for i in 1 2 3 4; do
349 echo "modified alpha" >> $testroot/wt/alpha
351 (cd $testroot/wt && \
352 got commit -m "changed alpha" > $testroot/stdout)
354 local head_rev=`git_show_head $testroot/repo`
355 echo "M alpha" > $testroot/stdout.expected
356 echo "Created commit $head_rev" >> $testroot/stdout.expected
358 cmp -s $testroot/stdout.expected $testroot/stdout
359 ret="$?"
360 if [ "$ret" != "0" ]; then
361 diff -u $testroot/stdout.expected $testroot/stdout
362 test_done "$testroot" "$ret"
363 return 1
364 fi
365 done
367 test_done "$testroot" "0"
370 function test_commit_added_and_modified_in_same_dir {
371 local testroot=`test_init commit_added_and_modified_in_same_dir`
373 got checkout $testroot/repo $testroot/wt > /dev/null
374 ret="$?"
375 if [ "$ret" != "0" ]; then
376 test_done "$testroot" "$ret"
377 return 1
378 fi
380 echo "modified zeta" > $testroot/wt/epsilon/zeta
381 echo "new file" > $testroot/wt/epsilon/new
382 (cd $testroot/wt && got add epsilon/new >/dev/null)
384 (cd $testroot/wt && got commit \
385 -m 'added and modified in same dir' > $testroot/stdout \
386 2> $testroot/stderr)
388 local head_rev=`git_show_head $testroot/repo`
389 echo "A epsilon/new" > $testroot/stdout.expected
390 echo "M epsilon/zeta" >> $testroot/stdout.expected
391 echo "Created commit $head_rev" >> $testroot/stdout.expected
393 cmp -s $testroot/stdout.expected $testroot/stdout
394 ret="$?"
395 if [ "$ret" != "0" ]; then
396 diff -u $testroot/stdout.expected $testroot/stdout
397 fi
398 test_done "$testroot" "$ret"
401 function test_commit_path_prefix {
402 local testroot=`test_init commit_path_prefix`
403 local commit1=`git_show_head $testroot/repo`
405 got checkout -p gamma $testroot/repo $testroot/wt > /dev/null
406 ret="$?"
407 if [ "$ret" != "0" ]; then
408 test_done "$testroot" "$ret"
409 return 1
410 fi
412 echo "modified delta" > $testroot/wt/delta
414 (cd $testroot/wt && got commit -m 'changed gamma/delta' > $testroot/stdout)
416 local commit2=`git_show_head $testroot/repo`
417 echo "M delta" > $testroot/stdout.expected
418 echo "Created commit $commit2" >> $testroot/stdout.expected
420 cmp -s $testroot/stdout.expected $testroot/stdout
421 ret="$?"
422 if [ "$ret" != "0" ]; then
423 diff -u $testroot/stdout.expected $testroot/stdout
424 test_done "$testroot" "$ret"
425 return 1
426 fi
428 echo "diff $commit1 $commit2" > $testroot/stdout.expected
429 echo -n 'blob - ' >> $testroot/stdout.expected
430 got tree -r $testroot/repo -c $commit1 -i gamma | grep 'delta$' \
431 | cut -d' ' -f 1 >> $testroot/stdout.expected
432 echo -n 'blob + ' >> $testroot/stdout.expected
433 got tree -r $testroot/repo -c $commit2 -i gamma | grep 'delta$' | \
434 cut -d' ' -f 1 >> $testroot/stdout.expected
435 echo '--- gamma/delta' >> $testroot/stdout.expected
436 echo '+++ gamma/delta' >> $testroot/stdout.expected
437 echo '@@ -1 +1 @@' >> $testroot/stdout.expected
438 echo '-delta' >> $testroot/stdout.expected
439 echo '+modified delta' >> $testroot/stdout.expected
441 got diff -r $testroot/repo $commit1 $commit2 > $testroot/stdout
442 cmp -s $testroot/stdout.expected $testroot/stdout
443 ret="$?"
444 if [ "$ret" != "0" ]; then
445 diff -u $testroot/stdout.expected $testroot/stdout
446 fi
447 test_done "$testroot" "$ret"
450 function test_commit_dir_path {
451 local testroot=`test_init commit_dir_path`
453 got checkout $testroot/repo $testroot/wt > /dev/null
454 ret="$?"
455 if [ "$ret" != "0" ]; then
456 test_done "$testroot" "$ret"
457 return 1
458 fi
460 echo "modified alpha" > $testroot/wt/alpha
461 echo "modified zeta" > $testroot/wt/epsilon/zeta
463 (cd $testroot/wt && got commit -m 'changed zeta' epsilon \
464 > $testroot/stdout)
466 local head_rev=`git_show_head $testroot/repo`
467 echo "M epsilon/zeta" >> $testroot/stdout.expected
468 echo "Created commit $head_rev" >> $testroot/stdout.expected
470 cmp -s $testroot/stdout.expected $testroot/stdout
471 ret="$?"
472 if [ "$ret" != "0" ]; then
473 diff -u $testroot/stdout.expected $testroot/stdout
474 test_done "$testroot" "$ret"
475 return 1
476 fi
478 echo "M alpha" > $testroot/stdout.expected
479 (cd $testroot/wt && got status > $testroot/stdout)
480 cmp -s $testroot/stdout.expected $testroot/stdout
481 ret="$?"
482 if [ "$ret" != "0" ]; then
483 diff -u $testroot/stdout.expected $testroot/stdout
484 fi
485 test_done "$testroot" "$ret"
488 function test_commit_selected_paths {
489 local testroot=`test_init commit_selected_paths`
491 got checkout $testroot/repo $testroot/wt > /dev/null
492 ret="$?"
493 if [ "$ret" != "0" ]; then
494 test_done "$testroot" "$ret"
495 return 1
496 fi
498 echo "modified alpha" > $testroot/wt/alpha
499 echo "modified delta" > $testroot/wt/gamma/delta
500 echo "modified zeta" > $testroot/wt/epsilon/zeta
501 (cd $testroot/wt && got rm beta >/dev/null)
502 echo "new file" > $testroot/wt/new
503 (cd $testroot/wt && got add new >/dev/null)
505 (cd $testroot/wt && got commit -m 'many paths' nonexistent alpha \
506 > $testroot/stdout 2> $testroot/stderr)
507 ret="$?"
508 if [ "$ret" == "0" ]; then
509 echo "commit succeeded unexpectedly" >&2
510 test_done "$testroot" "1"
511 return 1
512 fi
513 echo "got: nonexistent: bad path" > $testroot/stderr.expected
515 cmp -s $testroot/stderr.expected $testroot/stderr
516 ret="$?"
517 if [ "$ret" != "0" ]; then
518 diff -u $testroot/stderr.expected $testroot/stderr
519 test_done "$testroot" "$ret"
520 return 1
521 fi
523 (cd $testroot/wt && got commit -m 'many paths' \
524 beta new gamma > $testroot/stdout)
526 local head_rev=`git_show_head $testroot/repo`
527 echo "A new" > $testroot/stdout.expected
528 echo "D beta" >> $testroot/stdout.expected
529 echo "M gamma/delta" >> $testroot/stdout.expected
530 echo "Created commit $head_rev" >> $testroot/stdout.expected
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 function test_commit_outside_refs_heads {
541 local testroot=`test_init commit_outside_refs_heads`
543 got ref -r $testroot/repo -c master refs/remotes/origin/master
545 got checkout -b refs/remotes/origin/master \
546 $testroot/repo $testroot/wt > /dev/null
547 ret="$?"
548 if [ "$ret" != "0" ]; then
549 test_done "$testroot" "$ret"
550 return 1
551 fi
553 echo "modified alpha" > $testroot/wt/alpha
555 (cd $testroot/wt && got commit -m 'change alpha' \
556 > $testroot/stdout 2> $testroot/stderr)
557 ret="$?"
558 if [ "$ret" == "0" ]; then
559 echo "commit succeeded unexpectedly" >&2
560 test_done "$testroot" "1"
561 return 1
562 fi
564 echo -n > $testroot/stdout.expected
565 cmp -s $testroot/stdout.expected $testroot/stdout
566 ret="$?"
567 if [ "$ret" != "0" ]; then
568 diff -u $testroot/stdout.expected $testroot/stdout
569 test_done "$testroot" "$ret"
570 return 1
571 fi
573 echo -n "got: will not commit to a branch outside the " \
574 > $testroot/stderr.expected
575 echo '"refs/heads/" reference namespace' \
576 >> $testroot/stderr.expected
577 cmp -s $testroot/stderr.expected $testroot/stderr
578 ret="$?"
579 if [ "$ret" != "0" ]; then
580 diff -u $testroot/stderr.expected $testroot/stderr
581 fi
582 test_done "$testroot" "$ret"
585 function test_commit_no_email {
586 local testroot=`test_init commit_no_email`
588 got checkout $testroot/repo $testroot/wt > /dev/null
589 ret="$?"
590 if [ "$ret" != "0" ]; then
591 test_done "$testroot" "$ret"
592 return 1
593 fi
595 echo "modified alpha" > $testroot/wt/alpha
596 (cd $testroot/wt && env GOT_AUTHOR=":flan_hacker:" \
597 got commit -m 'test no email' > $testroot/stdout \
598 2> $testroot/stderr)
600 echo -n "got: GOT_AUTHOR environment variable contains no email " \
601 > $testroot/stderr.expected
602 echo -n "address; an email address is required for compatibility "\
603 >> $testroot/stderr.expected
604 echo "with Git" >> $testroot/stderr.expected
605 cmp -s $testroot/stderr.expected $testroot/stderr
606 ret="$?"
607 if [ "$ret" != "0" ]; then
608 diff -u $testroot/stderr.expected $testroot/stderr
609 test_done "$testroot" "$ret"
610 return 1
611 fi
613 echo -n > $testroot/stdout.expected
614 cmp -s $testroot/stdout.expected $testroot/stdout
615 ret="$?"
616 if [ "$ret" != "0" ]; then
617 diff -u $testroot/stdout.expected $testroot/stdout
618 fi
619 test_done "$testroot" "$ret"
622 function test_commit_tree_entry_sorting {
623 local testroot=`test_init commit_tree_entry_sorting`
625 got checkout $testroot/repo $testroot/wt > /dev/null
626 ret="$?"
627 if [ "$ret" != "0" ]; then
628 test_done "$testroot" "$ret"
629 return 1
630 fi
632 # Git's index gets corrupted when tree entries are written in the
633 # order defined by got_path_cmp() rather than Git's own ordering.
634 # Create a new tree where a directory "got" and a file "got-version"
635 # would sort in the wrong order according to Git's opinion.
636 mkdir $testroot/wt/got
637 touch $testroot/wt/got/foo
638 echo foo > $testroot/wt/got-version
639 echo zzz > $testroot/wt/zzz
640 (cd $testroot/wt && got add got-version got/foo zzz > /dev/null)
642 (cd $testroot/wt && got commit -m 'test' > /dev/null)
644 # Let git-fsck verify the newly written tree to make sure Git is happy
645 (cd $testroot/repo && git fsck --strict \
646 > $testroot/fsck.stdout 2> $testroot/fsck.stderr)
647 ret="$?"
648 test_done "$testroot" "$ret"
651 function test_commit_gitconfig_author {
652 local testroot=`test_init commit_gitconfig_author`
654 got checkout $testroot/repo $testroot/wt > /dev/null
655 ret="$?"
656 if [ "$ret" != "0" ]; then
657 test_done "$testroot" "$ret"
658 return 1
659 fi
661 (cd $testroot/repo && git config user.name 'Flan Luck')
662 (cd $testroot/repo && git config user.email 'flan_luck@openbsd.org')
664 echo "modified alpha" > $testroot/wt/alpha
665 (cd $testroot/wt && got commit -m 'test gitconfig author' > /dev/null)
666 ret="$?"
667 if [ "$ret" != "0" ]; then
668 test_done "$testroot" "$ret"
669 return 1
670 fi
672 (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
673 ret="$?"
674 if [ "$ret" != "0" ]; then
675 test_done "$testroot" "$ret"
676 return 1
677 fi
679 echo "from: Flan Luck <flan_luck@openbsd.org>" \
680 > $testroot/stdout.expected
681 cmp -s $testroot/stdout.expected $testroot/stdout
682 ret="$?"
683 if [ "$ret" != "0" ]; then
684 diff -u $testroot/stdout.expected $testroot/stdout
685 fi
686 test_done "$testroot" "$ret"
689 function test_commit_xbit_change {
690 local testroot=`test_init commit_xbit_change`
692 got checkout $testroot/repo $testroot/wt > /dev/null
693 ret="$?"
694 if [ "$ret" != "0" ]; then
695 test_done "$testroot" "$ret"
696 return 1
697 fi
699 chmod +x $testroot/wt/alpha
701 echo 'm alpha' > $testroot/stdout.expected
702 (cd $testroot/wt && got status > $testroot/stdout)
704 cmp -s $testroot/stdout.expected $testroot/stdout
705 ret="$?"
706 if [ "$ret" != "0" ]; then
707 diff -u $testroot/stdout.expected $testroot/stdout
708 test_done "$testroot" "$ret"
709 return 1
710 fi
712 (cd $testroot/wt && got commit -mx > $testroot/stdout)
713 ret="$?"
714 if [ "$ret" != "0" ]; then
715 echo "got commit failed unexpectedly"
716 test_done "$testroot" "$ret"
717 return 1
718 fi
720 local commit_id=`git_show_head $testroot/repo`
721 echo 'm alpha' > $testroot/stdout.expected
722 echo "Created commit $commit_id" >> $testroot/stdout.expected
723 cmp -s $testroot/stdout.expected $testroot/stdout
724 ret="$?"
725 if [ "$ret" != "0" ]; then
726 diff -u $testroot/stdout.expected $testroot/stdout
727 test_done "$testroot" "$ret"
728 return 1
729 fi
731 (cd $testroot/wt && got status > $testroot/stdout)
733 echo -n > $testroot/stdout.expected
734 cmp -s $testroot/stdout.expected $testroot/stdout
735 ret="$?"
736 if [ "$ret" != "0" ]; then
737 diff -u $testroot/stdout.expected $testroot/stdout
738 test_done "$testroot" "$ret"
739 return 1
740 fi
742 chmod -x $testroot/wt/alpha
744 echo 'm alpha' > $testroot/stdout.expected
745 (cd $testroot/wt && got status > $testroot/stdout)
747 cmp -s $testroot/stdout.expected $testroot/stdout
748 ret="$?"
749 if [ "$ret" != "0" ]; then
750 diff -u $testroot/stdout.expected $testroot/stdout
751 test_done "$testroot" "$ret"
752 return 1
753 fi
755 (cd $testroot/wt && got commit -mx > $testroot/stdout)
756 ret="$?"
757 if [ "$ret" != "0" ]; then
758 echo "got commit failed unexpectedly"
759 test_done "$testroot" "$ret"
760 return 1
761 fi
763 local commit_id=`git_show_head $testroot/repo`
764 echo 'm alpha' > $testroot/stdout.expected
765 echo "Created commit $commit_id" >> $testroot/stdout.expected
766 cmp -s $testroot/stdout.expected $testroot/stdout
767 ret="$?"
768 if [ "$ret" != "0" ]; then
769 diff -u $testroot/stdout.expected $testroot/stdout
770 test_done "$testroot" "$ret"
771 return 1
772 fi
774 chmod +x $testroot/wt/alpha
776 echo 'm alpha' > $testroot/stdout.expected
777 (cd $testroot/wt && got status > $testroot/stdout)
779 cmp -s $testroot/stdout.expected $testroot/stdout
780 ret="$?"
781 if [ "$ret" != "0" ]; then
782 diff -u $testroot/stdout.expected $testroot/stdout
783 fi
784 test_done "$testroot" "$ret"
787 run_test test_commit_basic
788 run_test test_commit_new_subdir
789 run_test test_commit_subdir
790 run_test test_commit_single_file
791 run_test test_commit_out_of_date
792 run_test test_commit_added_subdirs
793 run_test test_commit_deleted_subdirs
794 run_test test_commit_rejects_conflicted_file
795 run_test test_commit_single_file_multiple
796 run_test test_commit_added_and_modified_in_same_dir
797 run_test test_commit_path_prefix
798 run_test test_commit_dir_path
799 run_test test_commit_selected_paths
800 run_test test_commit_outside_refs_heads
801 run_test test_commit_no_email
802 run_test test_commit_tree_entry_sorting
803 run_test test_commit_gitconfig_author
804 run_test test_commit_xbit_change