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 -ne 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 -ne 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 -ne 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 -ne 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 -ne 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 -ne 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 -ne 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 -ne 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 -ne 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 -ne 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 -ne 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 -ne 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 -ne 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 -ne 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 -ne 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 -ne 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 -ne 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 -ne 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 -ne 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 refs/heads/master: " >> $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 -ne 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 -ne 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 -ne 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 -ne 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 -ne 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 -ne 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 -ne 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 -ne 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 -ne 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 "commit - $commit1" >> $testroot/stdout.expected
432 echo "commit + $commit2" >> $testroot/stdout.expected
433 echo -n 'blob - ' >> $testroot/stdout.expected
434 got tree -r $testroot/repo -c $commit1 -i gamma | grep 'delta$' \
435 | cut -d' ' -f 1 >> $testroot/stdout.expected
436 echo -n 'blob + ' >> $testroot/stdout.expected
437 got tree -r $testroot/repo -c $commit2 -i gamma | grep 'delta$' | \
438 cut -d' ' -f 1 >> $testroot/stdout.expected
439 echo '--- gamma/delta' >> $testroot/stdout.expected
440 echo '+++ gamma/delta' >> $testroot/stdout.expected
441 echo '@@ -1 +1 @@' >> $testroot/stdout.expected
442 echo '-delta' >> $testroot/stdout.expected
443 echo '+modified delta' >> $testroot/stdout.expected
445 got diff -r $testroot/repo $commit1 $commit2 > $testroot/stdout
446 cmp -s $testroot/stdout.expected $testroot/stdout
447 ret=$?
448 if [ $ret -ne 0 ]; then
449 diff -u $testroot/stdout.expected $testroot/stdout
450 test_done "$testroot" "$ret"
451 return 1
452 fi
454 (cd $testroot/wt && got rm delta > /dev/null)
455 echo new > $testroot/wt/new
456 (cd $testroot/wt && got add new > /dev/null)
458 (cd $testroot/wt && got commit -m 'remove gamma/delta; add gamma/new' \
459 > $testroot/stdout)
461 local commit3=`git_show_head $testroot/repo`
462 echo "A new" > $testroot/stdout.expected
463 echo "D delta" >> $testroot/stdout.expected
464 echo "Created commit $commit3" >> $testroot/stdout.expected
466 cmp -s $testroot/stdout.expected $testroot/stdout
467 ret=$?
468 if [ $ret -ne 0 ]; then
469 diff -u $testroot/stdout.expected $testroot/stdout
470 test_done "$testroot" "$ret"
471 return 1
472 fi
474 echo "diff $commit2 $commit3" > $testroot/stdout.expected
475 echo "commit - $commit2" >> $testroot/stdout.expected
476 echo "commit + $commit3" >> $testroot/stdout.expected
477 echo -n 'blob - ' >> $testroot/stdout.expected
478 got tree -r $testroot/repo -c $commit2 -i gamma | grep 'delta$' \
479 | cut -d' ' -f 1 | sed -e 's/$/ (mode 644)/' \
480 >> $testroot/stdout.expected
481 echo 'blob + /dev/null' >> $testroot/stdout.expected
482 echo '--- gamma/delta' >> $testroot/stdout.expected
483 echo '+++ /dev/null' >> $testroot/stdout.expected
484 echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
485 echo '-modified delta' >> $testroot/stdout.expected
486 echo 'blob - /dev/null' >> $testroot/stdout.expected
487 echo -n 'blob + ' >> $testroot/stdout.expected
488 got tree -r $testroot/repo -c $commit3 -i gamma | grep 'new$' | \
489 cut -d' ' -f 1 | sed -e 's/$/ (mode 644)/' \
490 >> $testroot/stdout.expected
491 echo '--- /dev/null' >> $testroot/stdout.expected
492 echo '+++ gamma/new' >> $testroot/stdout.expected
493 echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
494 echo '+new' >> $testroot/stdout.expected
496 got diff -r $testroot/repo $commit2 $commit3 > $testroot/stdout
497 cmp -s $testroot/stdout.expected $testroot/stdout
498 ret=$?
499 if [ $ret -ne 0 ]; then
500 diff -u $testroot/stdout.expected $testroot/stdout
501 fi
502 test_done "$testroot" "$ret"
503 return "$ret"
506 test_commit_dir_path() {
507 local testroot=`test_init commit_dir_path`
509 got checkout $testroot/repo $testroot/wt > /dev/null
510 ret=$?
511 if [ $ret -ne 0 ]; then
512 test_done "$testroot" "$ret"
513 return 1
514 fi
516 echo "modified alpha" > $testroot/wt/alpha
517 echo "modified zeta" > $testroot/wt/epsilon/zeta
519 (cd $testroot/wt && got commit -m 'changed zeta' epsilon \
520 > $testroot/stdout)
522 local head_rev=`git_show_head $testroot/repo`
523 echo "M epsilon/zeta" >> $testroot/stdout.expected
524 echo "Created commit $head_rev" >> $testroot/stdout.expected
526 cmp -s $testroot/stdout.expected $testroot/stdout
527 ret=$?
528 if [ $ret -ne 0 ]; then
529 diff -u $testroot/stdout.expected $testroot/stdout
530 test_done "$testroot" "$ret"
531 return 1
532 fi
534 echo "M alpha" > $testroot/stdout.expected
535 (cd $testroot/wt && got status > $testroot/stdout)
536 cmp -s $testroot/stdout.expected $testroot/stdout
537 ret=$?
538 if [ $ret -ne 0 ]; then
539 diff -u $testroot/stdout.expected $testroot/stdout
540 fi
541 test_done "$testroot" "$ret"
544 test_commit_selected_paths() {
545 local testroot=`test_init commit_selected_paths`
547 got checkout $testroot/repo $testroot/wt > /dev/null
548 ret=$?
549 if [ $ret -ne 0 ]; then
550 test_done "$testroot" "$ret"
551 return 1
552 fi
554 echo "modified alpha" > $testroot/wt/alpha
555 echo "modified delta" > $testroot/wt/gamma/delta
556 echo "modified zeta" > $testroot/wt/epsilon/zeta
557 (cd $testroot/wt && got rm beta >/dev/null)
558 echo "new file" > $testroot/wt/new
559 (cd $testroot/wt && got add new >/dev/null)
561 (cd $testroot/wt && got commit -m 'many paths' nonexistent alpha \
562 > $testroot/stdout 2> $testroot/stderr)
563 ret=$?
564 if [ $ret -eq 0 ]; then
565 echo "commit succeeded unexpectedly" >&2
566 test_done "$testroot" "1"
567 return 1
568 fi
569 echo "got: nonexistent: bad path" > $testroot/stderr.expected
571 cmp -s $testroot/stderr.expected $testroot/stderr
572 ret=$?
573 if [ $ret -ne 0 ]; then
574 diff -u $testroot/stderr.expected $testroot/stderr
575 test_done "$testroot" "$ret"
576 return 1
577 fi
579 (cd $testroot/wt && got commit -m 'many paths' \
580 beta new gamma > $testroot/stdout)
582 local head_rev=`git_show_head $testroot/repo`
583 echo "A new" > $testroot/stdout.expected
584 echo "D beta" >> $testroot/stdout.expected
585 echo "M gamma/delta" >> $testroot/stdout.expected
586 echo "Created commit $head_rev" >> $testroot/stdout.expected
588 cmp -s $testroot/stdout.expected $testroot/stdout
589 ret=$?
590 if [ $ret -ne 0 ]; then
591 diff -u $testroot/stdout.expected $testroot/stdout
592 fi
593 test_done "$testroot" "$ret"
596 test_commit_outside_refs_heads() {
597 local testroot=`test_init commit_outside_refs_heads`
599 got ref -r $testroot/repo -c master refs/remotes/origin/master
601 got checkout -b refs/remotes/origin/master \
602 $testroot/repo $testroot/wt > /dev/null
603 ret=$?
604 if [ $ret -ne 0 ]; then
605 test_done "$testroot" "$ret"
606 return 1
607 fi
609 echo "modified alpha" > $testroot/wt/alpha
611 (cd $testroot/wt && got commit -m 'change alpha' \
612 > $testroot/stdout 2> $testroot/stderr)
613 ret=$?
614 if [ $ret -eq 0 ]; then
615 echo "commit succeeded unexpectedly" >&2
616 test_done "$testroot" "1"
617 return 1
618 fi
620 echo -n > $testroot/stdout.expected
621 cmp -s $testroot/stdout.expected $testroot/stdout
622 ret=$?
623 if [ $ret -ne 0 ]; then
624 diff -u $testroot/stdout.expected $testroot/stdout
625 test_done "$testroot" "$ret"
626 return 1
627 fi
629 echo -n "got: will not commit to a branch outside the " \
630 > $testroot/stderr.expected
631 echo '"refs/heads/" reference namespace' \
632 >> $testroot/stderr.expected
633 cmp -s $testroot/stderr.expected $testroot/stderr
634 ret=$?
635 if [ $ret -ne 0 ]; then
636 diff -u $testroot/stderr.expected $testroot/stderr
637 fi
638 test_done "$testroot" "$ret"
641 test_commit_no_email() {
642 local testroot=`test_init commit_no_email`
643 local errmsg=""
645 errmsg="commit author's email address is required for"
646 errmsg="$errmsg compatibility with Git"
648 got checkout $testroot/repo $testroot/wt > /dev/null
649 ret=$?
650 if [ $ret -ne 0 ]; then
651 test_done "$testroot" "$ret"
652 return 1
653 fi
655 echo "modified alpha" > $testroot/wt/alpha
656 (cd $testroot/wt && env GOT_AUTHOR=":flan_hacker:" \
657 got commit -m 'test no email' > $testroot/stdout \
658 2> $testroot/stderr)
660 printf "got: :flan_hacker:: %s\n" "$errmsg" > $testroot/stderr.expected
661 cmp -s $testroot/stderr.expected $testroot/stderr
662 ret=$?
663 if [ $ret -ne 0 ]; then
664 diff -u $testroot/stderr.expected $testroot/stderr
665 test_done "$testroot" "$ret"
666 return 1
667 fi
669 echo -n > $testroot/stdout.expected
670 cmp -s $testroot/stdout.expected $testroot/stdout
671 ret=$?
672 if [ $ret -ne 0 ]; then
673 diff -u $testroot/stdout.expected $testroot/stdout
674 test_done "$testroot" $ret
675 return 1
676 fi
678 # try again with a newline inside the email
679 (cd $testroot/wt \
680 && FS=' ' env GOT_AUTHOR="$(printf "Flan <hack\ner>")" \
681 got commit -m 'test invalid email' > $testroot/stdout \
682 2> $testroot/stderr)
684 printf "got: Flan <hack\ner>: %s\n" "$errmsg" \
685 > $testroot/stderr.expected
686 cmp -s $testroot/stderr.expected $testroot/stderr
687 ret=$?
688 if [ $ret -ne 0 ]; then
689 diff -u $testroot/stderr.expected $testroot/stderr
690 test_done "$testroot" $ret
691 return 1
692 fi
694 echo -n > $testroot/stdout.expected
695 cmp -s $testroot/stdout.expected $testroot/stdout
696 ret=$?
697 if [ $ret -ne 0 ]; then
698 diff -u $testroot/stdout.expected $testroot/stdout
699 test_done "$testroot" $ret
700 return 1
701 fi
703 # try again with a < inside the email
704 (cd $testroot/wt && env GOT_AUTHOR="$(printf "Flan <ha<ker>")" \
705 got commit -m 'test invalid email' > $testroot/stdout \
706 2> $testroot/stderr)
708 printf "got: Flan <ha<ker>: %s\n" "$errmsg" > $testroot/stderr.expected
709 cmp -s $testroot/stderr.expected $testroot/stderr
710 ret=$?
711 if [ $ret -ne 0 ]; then
712 diff -u $testroot/stderr.expected $testroot/stderr
713 test_done "$testroot" $ret
714 return 1
715 fi
717 echo -n > $testroot/stdout.expected
718 cmp -s $testroot/stdout.expected $testroot/stdout
719 ret=$?
720 if [ $ret -ne 0 ]; then
721 diff -u $testroot/stdout.expected $testroot/stdout
722 fi
723 test_done "$testroot" $ret
726 test_commit_tree_entry_sorting() {
727 local testroot=`test_init commit_tree_entry_sorting`
729 got checkout $testroot/repo $testroot/wt > /dev/null
730 ret=$?
731 if [ $ret -ne 0 ]; then
732 test_done "$testroot" "$ret"
733 return 1
734 fi
736 # Git's index gets corrupted when tree entries are written in the
737 # order defined by got_path_cmp() rather than Git's own ordering.
738 # Create a new tree where a directory "got" and a file "got-version"
739 # would sort in the wrong order according to Git's opinion.
740 mkdir $testroot/wt/got
741 touch $testroot/wt/got/foo
742 echo foo > $testroot/wt/got-version
743 echo zzz > $testroot/wt/zzz
744 (cd $testroot/wt && got add got-version got/foo zzz > /dev/null)
746 (cd $testroot/wt && got commit -m 'test' > /dev/null)
748 # Let git-fsck verify the newly written tree to make sure Git is happy
749 (cd $testroot/repo && git fsck --strict \
750 > $testroot/fsck.stdout 2> $testroot/fsck.stderr)
751 ret=$?
752 test_done "$testroot" "$ret"
755 test_commit_cmdline_author() {
756 local testroot=`test_init commit_cmdline_author`
758 got checkout $testroot/repo $testroot/wt > /dev/null
759 ret=$?
760 if [ $ret -ne 0 ]; then
761 test_done "$testroot" $ret
762 return 1
763 fi
765 echo "modified alpha" > $testroot/wt/alpha
767 # first try with a -A equals to $GOT_AUTHOR
768 (cd $testroot/wt && got commit -A "$GOT_AUTHOR" -m 'edit alpha') \
769 > /dev/null 2> $testroot/stderr
770 ret=$?
771 if [ $ret -eq 0 ]; then
772 test_done "$testroot" 1
773 return 1
774 fi
776 echo 'got: specified author is equal to the default one' \
777 > $testroot/stderr.expected
778 cmp -s $testroot/stderr.expected $testroot/stderr
779 ret=$?
780 if [ $ret -ne 0 ]; then
781 diff -u $testroot/stderr.expected $testroot/stderr
782 test_done "$testroot" $ret
783 return 1
784 fi
786 # try again with a different author
787 local author="Foo <foo@example.com>"
788 (cd $testroot/wt && got commit -A "$author" -m 'edit alpha') \
789 > /dev/null
790 ret=$?
791 if [ $ret -ne 0 ]; then
792 test_done "$testroot" $ret
793 return 1
794 fi
796 (cd $testroot/repo && got log -l1 | egrep '^(from|via):') \
797 > $testroot/stdout
798 ret=$?
799 if [ $ret -ne 0 ]; then
800 test_done "$testroot" $ret
801 return 1
802 fi
804 echo "from: $author" > $testroot/stdout.expected
805 echo "via: $GOT_AUTHOR" >> $testroot/stdout.expected
806 cmp -s $testroot/stdout.expected $testroot/stdout
807 ret=$?
808 if [ $ret -ne 0 ]; then
809 diff -u $testroot/stdout.expected $testroot/stdout
810 fi
811 test_done "$testroot" $ret
814 test_commit_gotconfig_author() {
815 local testroot=`test_init commit_gotconfig_author`
817 got checkout $testroot/repo $testroot/wt > /dev/null
818 ret=$?
819 if [ $ret -ne 0 ]; then
820 test_done "$testroot" "$ret"
821 return 1
822 fi
823 echo 'author "Flan Luck <flan_luck@openbsd.org>"' \
824 > $testroot/repo/.git/got.conf
826 echo "modified alpha" > $testroot/wt/alpha
827 (cd $testroot/wt && got commit -m 'test gotconfig author' > /dev/null)
828 ret=$?
829 if [ $ret -ne 0 ]; then
830 test_done "$testroot" "$ret"
831 return 1
832 fi
834 (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
835 ret=$?
836 if [ $ret -ne 0 ]; then
837 test_done "$testroot" "$ret"
838 return 1
839 fi
841 echo "from: Flan Luck <flan_luck@openbsd.org>" \
842 > $testroot/stdout.expected
843 cmp -s $testroot/stdout.expected $testroot/stdout
844 ret=$?
845 if [ $ret -ne 0 ]; then
846 diff -u $testroot/stdout.expected $testroot/stdout
847 fi
848 test_done "$testroot" "$ret"
851 test_commit_gotconfig_worktree_author() {
852 local testroot=`test_init commit_gotconfig_worktree_author`
854 got checkout $testroot/repo $testroot/wt > /dev/null
855 ret=$?
856 if [ $ret -ne 0 ]; then
857 test_done "$testroot" "$ret"
858 return 1
859 fi
860 echo 'author "Flan Luck <flan_luck@openbsd.org>"' \
861 > $testroot/repo/.git/got.conf
862 echo 'author "Flan Squee <flan_squee@openbsd.org>"' \
863 > $testroot/wt/.got/got.conf
865 echo "modified alpha" > $testroot/wt/alpha
866 (cd $testroot/wt && got commit -m 'test gotconfig author' > /dev/null)
867 ret=$?
868 if [ $ret -ne 0 ]; then
869 test_done "$testroot" "$ret"
870 return 1
871 fi
873 (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
874 ret=$?
875 if [ $ret -ne 0 ]; then
876 test_done "$testroot" "$ret"
877 return 1
878 fi
880 echo "from: Flan Squee <flan_squee@openbsd.org>" \
881 > $testroot/stdout.expected
882 cmp -s $testroot/stdout.expected $testroot/stdout
883 ret=$?
884 if [ $ret -ne 0 ]; then
885 diff -u $testroot/stdout.expected $testroot/stdout
886 fi
887 test_done "$testroot" "$ret"
890 test_commit_gitconfig_author() {
891 local testroot=`test_init commit_gitconfig_author`
893 got checkout $testroot/repo $testroot/wt > /dev/null
894 ret=$?
895 if [ $ret -ne 0 ]; then
896 test_done "$testroot" "$ret"
897 return 1
898 fi
900 (cd $testroot/repo && git config user.name 'Flan Luck')
901 (cd $testroot/repo && git config user.email 'flan_luck@openbsd.org')
903 echo "modified alpha" > $testroot/wt/alpha
905 # unset in a subshell to avoid affecting our environment
906 (unset GOT_IGNORE_GITCONFIG && cd $testroot/wt && \
907 got commit -m 'test gitconfig author' > /dev/null)
908 ret=$?
909 if [ $ret -ne 0 ]; then
910 test_done "$testroot" "$ret"
911 return 1
912 fi
914 (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
915 ret=$?
916 if [ $ret -ne 0 ]; then
917 test_done "$testroot" "$ret"
918 return 1
919 fi
921 echo "from: Flan Luck <flan_luck@openbsd.org>" \
922 > $testroot/stdout.expected
923 cmp -s $testroot/stdout.expected $testroot/stdout
924 ret=$?
925 if [ $ret -ne 0 ]; then
926 diff -u $testroot/stdout.expected $testroot/stdout
927 fi
928 test_done "$testroot" "$ret"
931 test_commit_xbit_change() {
932 local testroot=`test_init commit_xbit_change`
934 got checkout $testroot/repo $testroot/wt > /dev/null
935 ret=$?
936 if [ $ret -ne 0 ]; then
937 test_done "$testroot" "$ret"
938 return 1
939 fi
941 chmod +x $testroot/wt/alpha
943 echo 'm alpha' > $testroot/stdout.expected
944 (cd $testroot/wt && got status > $testroot/stdout)
946 cmp -s $testroot/stdout.expected $testroot/stdout
947 ret=$?
948 if [ $ret -ne 0 ]; then
949 diff -u $testroot/stdout.expected $testroot/stdout
950 test_done "$testroot" "$ret"
951 return 1
952 fi
954 (cd $testroot/wt && got commit -mx > $testroot/stdout)
955 ret=$?
956 if [ $ret -ne 0 ]; then
957 echo "got commit failed unexpectedly"
958 test_done "$testroot" "$ret"
959 return 1
960 fi
962 local commit_id=`git_show_head $testroot/repo`
963 echo 'm alpha' > $testroot/stdout.expected
964 echo "Created commit $commit_id" >> $testroot/stdout.expected
965 cmp -s $testroot/stdout.expected $testroot/stdout
966 ret=$?
967 if [ $ret -ne 0 ]; then
968 diff -u $testroot/stdout.expected $testroot/stdout
969 test_done "$testroot" "$ret"
970 return 1
971 fi
973 (cd $testroot/wt && got status > $testroot/stdout)
975 echo -n > $testroot/stdout.expected
976 cmp -s $testroot/stdout.expected $testroot/stdout
977 ret=$?
978 if [ $ret -ne 0 ]; then
979 diff -u $testroot/stdout.expected $testroot/stdout
980 test_done "$testroot" "$ret"
981 return 1
982 fi
984 chmod -x $testroot/wt/alpha
986 echo 'm alpha' > $testroot/stdout.expected
987 (cd $testroot/wt && got status > $testroot/stdout)
989 cmp -s $testroot/stdout.expected $testroot/stdout
990 ret=$?
991 if [ $ret -ne 0 ]; then
992 diff -u $testroot/stdout.expected $testroot/stdout
993 test_done "$testroot" "$ret"
994 return 1
995 fi
997 (cd $testroot/wt && got commit -mx > $testroot/stdout)
998 ret=$?
999 if [ $ret -ne 0 ]; then
1000 echo "got commit failed unexpectedly"
1001 test_done "$testroot" "$ret"
1002 return 1
1005 local commit_id=`git_show_head $testroot/repo`
1006 echo 'm alpha' > $testroot/stdout.expected
1007 echo "Created commit $commit_id" >> $testroot/stdout.expected
1008 cmp -s $testroot/stdout.expected $testroot/stdout
1009 ret=$?
1010 if [ $ret -ne 0 ]; then
1011 diff -u $testroot/stdout.expected $testroot/stdout
1012 test_done "$testroot" "$ret"
1013 return 1
1016 chmod +x $testroot/wt/alpha
1018 echo 'm alpha' > $testroot/stdout.expected
1019 (cd $testroot/wt && got status > $testroot/stdout)
1021 cmp -s $testroot/stdout.expected $testroot/stdout
1022 ret=$?
1023 if [ $ret -ne 0 ]; then
1024 diff -u $testroot/stdout.expected $testroot/stdout
1026 test_done "$testroot" "$ret"
1029 commit_check_mode() {
1030 local mode="$1"
1031 local expected_mode="$2"
1033 chmod 644 $testroot/wt/alpha
1034 echo a >> $testroot/wt/alpha
1035 chmod $mode $testroot/wt/alpha
1037 (cd $testroot/wt && got commit -mm > $testroot/stdout)
1038 ret=$?
1039 if [ $ret -ne 0 ]; then
1040 echo "got commit failed unexpectedly"
1041 test_done "$testroot" "$ret"
1042 return 1
1045 local commit_id=`git_show_head $testroot/repo`
1046 echo 'M alpha' > $testroot/stdout.expected
1047 echo "Created commit $commit_id" >> $testroot/stdout.expected
1048 cmp -s $testroot/stdout.expected $testroot/stdout
1049 ret=$?
1050 if [ $ret -ne 0 ]; then
1051 diff -u $testroot/stdout.expected $testroot/stdout
1052 test_done "$testroot" "$ret"
1053 return 1
1056 local tree_id=$(got cat -r $testroot/repo $commit_id | \
1057 grep ^tree | cut -d' ' -f2)
1058 local alpha_id=$(got cat -r $testroot/repo $tree_id | \
1059 grep 'alpha$' | cut -d' ' -f1)
1060 echo "$alpha_id $expected_mode alpha" > $testroot/stdout.expected
1061 got cat -r $testroot/repo $tree_id | grep 'alpha$' > $testroot/stdout
1062 cmp -s $testroot/stdout.expected $testroot/stdout
1063 ret=$?
1064 if [ $ret -ne 0 ]; then
1065 diff -u $testroot/stdout.expected $testroot/stdout
1067 return $ret
1070 test_commit_normalizes_filemodes() {
1071 local testroot=`test_init commit_normalizes_filemodes`
1073 got checkout $testroot/repo $testroot/wt > /dev/null
1074 ret=$?
1075 if [ $ret -ne 0 ]; then
1076 test_done "$testroot" "$ret"
1077 return 1
1080 modes="600 400 460 640 440 660 444 666"
1081 for m in $modes; do
1082 commit_check_mode "$m" "0100644"
1083 ret=$?
1084 if [ $ret -ne 0 ]; then
1085 break
1087 done
1088 if [ $ret -ne 0 ]; then
1089 test_done "$testroot" "$ret"
1090 return 1
1092 modes="700 500 570 750 550 770 555 777"
1093 for m in $modes; do
1094 commit_check_mode "$m" "0100755"
1095 ret=$?
1096 if [ $ret -ne 0 ]; then
1097 break
1099 done
1100 if [ $ret -ne 0 ]; then
1101 test_done "$testroot" "$ret"
1102 return 1
1104 test_done "$testroot" "$ret"
1107 test_commit_with_unrelated_submodule() {
1108 local testroot=`test_init commit_with_unrelated_submodule`
1110 make_single_file_repo $testroot/repo2 foo
1112 (cd $testroot/repo && git -c protocol.file.allow=always \
1113 submodule -q add ../repo2)
1114 (cd $testroot/repo && git commit -q -m 'adding submodule')
1116 got checkout $testroot/repo $testroot/wt > /dev/null
1117 ret=$?
1118 if [ $ret -ne 0 ]; then
1119 echo "checkout failed unexpectedly" >&2
1120 test_done "$testroot" "$ret"
1121 return 1
1124 echo "modified alpha" > $testroot/wt/alpha
1126 echo "" > $testroot/stdout.expected
1128 (cd $testroot/wt && got commit -m 'modify alpha' > $testroot/stdout)
1129 ret=$?
1130 if [ $ret -ne 0 ]; then
1131 echo "commit failed unexpectedly" >&2
1132 test_done "$testroot" "$ret"
1133 return 1
1136 local head_rev=`git_show_head $testroot/repo`
1137 echo "M alpha" > $testroot/stdout.expected
1138 echo "Created commit $head_rev" >> $testroot/stdout.expected
1140 cmp -s $testroot/stdout.expected $testroot/stdout
1141 ret=$?
1142 if [ $ret -ne 0 ]; then
1143 diff -u $testroot/stdout.expected $testroot/stdout
1145 test_done "$testroot" "$ret"
1148 check_symlinks() {
1149 local wtpath="$1"
1150 if ! [ -h $wtpath/alpha.link ]; then
1151 echo "alpha.link is not a symlink"
1152 return 1
1155 readlink $wtpath/alpha.link > $testroot/stdout
1156 echo "alpha" > $testroot/stdout.expected
1157 cmp -s $testroot/stdout.expected $testroot/stdout
1158 ret=$?
1159 if [ $ret -ne 0 ]; then
1160 diff -u $testroot/stdout.expected $testroot/stdout
1161 return 1
1164 if ! [ -h $wtpath/epsilon.link ]; then
1165 echo "epsilon.link is not a symlink"
1166 return 1
1169 readlink $wtpath/epsilon.link > $testroot/stdout
1170 echo "epsilon" > $testroot/stdout.expected
1171 cmp -s $testroot/stdout.expected $testroot/stdout
1172 ret=$?
1173 if [ $ret -ne 0 ]; then
1174 diff -u $testroot/stdout.expected $testroot/stdout
1175 return 1
1178 if [ -h $wtpath/passwd.link ]; then
1179 echo -n "passwd.link is a symlink and points outside of work tree: " >&2
1180 readlink $wtpath/passwd.link >&2
1181 return 1
1184 echo -n "/etc/passwd" > $testroot/content.expected
1185 cp $wtpath/passwd.link $testroot/content
1186 ret=$?
1187 if [ $ret -ne 0 ]; then
1188 echo "cp command failed unexpectedly" >&2
1189 return 1
1192 cmp -s $testroot/content.expected $testroot/content
1193 ret=$?
1194 if [ $ret -ne 0 ]; then
1195 diff -u $testroot/content.expected $testroot/content
1196 return 1
1199 readlink $wtpath/epsilon/beta.link > $testroot/stdout
1200 echo "../beta" > $testroot/stdout.expected
1201 cmp -s $testroot/stdout.expected $testroot/stdout
1202 ret=$?
1203 if [ $ret -ne 0 ]; then
1204 diff -u $testroot/stdout.expected $testroot/stdout
1205 return 1
1208 readlink $wtpath/nonexistent.link > $testroot/stdout
1209 echo "nonexistent" > $testroot/stdout.expected
1210 cmp -s $testroot/stdout.expected $testroot/stdout
1211 ret=$?
1212 if [ $ret -ne 0 ]; then
1213 diff -u $testroot/stdout.expected $testroot/stdout
1214 return 1
1217 return 0
1220 test_commit_symlink() {
1221 local testroot=`test_init commit_symlink`
1223 got checkout $testroot/repo $testroot/wt > /dev/null
1224 ret=$?
1225 if [ $ret -ne 0 ]; then
1226 test_done "$testroot" "$ret"
1227 return 1
1230 (cd $testroot/wt && ln -s alpha alpha.link)
1231 (cd $testroot/wt && ln -s epsilon epsilon.link)
1232 (cd $testroot/wt && ln -s /etc/passwd passwd.link)
1233 (cd $testroot/wt && ln -s ../beta epsilon/beta.link)
1234 (cd $testroot/wt && ln -s nonexistent nonexistent.link)
1235 (cd $testroot/wt && got add alpha.link epsilon.link passwd.link \
1236 epsilon/beta.link nonexistent.link > /dev/null)
1238 (cd $testroot/wt && got commit -m 'test commit_symlink' \
1239 > $testroot/stdout 2> $testroot/stderr)
1240 ret=$?
1241 if [ $ret -eq 0 ]; then
1242 echo "got commit succeeded unexpectedly" >&2
1243 test_done "$testroot" "$ret"
1244 return 1
1246 echo -n "got: $testroot/wt/passwd.link: " > $testroot/stderr.expected
1247 echo "symbolic link points outside of paths under version control" \
1248 >> $testroot/stderr.expected
1249 cmp -s $testroot/stderr.expected $testroot/stderr
1250 ret=$?
1251 if [ $ret -ne 0 ]; then
1252 diff -u $testroot/stderr.expected $testroot/stderr
1253 test_done "$testroot" "$ret"
1254 return 1
1257 (cd $testroot/wt && got commit -S -m 'test commit_symlink' \
1258 > $testroot/stdout)
1260 local head_rev=`git_show_head $testroot/repo`
1261 echo "A alpha.link" > $testroot/stdout.expected
1262 echo "A epsilon.link" >> $testroot/stdout.expected
1263 echo "A nonexistent.link" >> $testroot/stdout.expected
1264 echo "A passwd.link" >> $testroot/stdout.expected
1265 echo "A epsilon/beta.link" >> $testroot/stdout.expected
1266 echo "Created commit $head_rev" >> $testroot/stdout.expected
1268 cmp -s $testroot/stdout.expected $testroot/stdout
1269 ret=$?
1270 if [ $ret -ne 0 ]; then
1271 diff -u $testroot/stdout.expected $testroot/stdout
1272 test_done "$testroot" "$ret"
1273 return 1
1276 # verify created in-repository tree
1277 got checkout $testroot/repo $testroot/wt2 > /dev/null
1278 ret=$?
1279 if [ $ret -ne 0 ]; then
1280 test_done "$testroot" "$ret"
1281 return 1
1283 check_symlinks $testroot/wt2
1284 ret=$?
1285 if [ $ret -ne 0 ]; then
1286 test_done "$testroot" "$ret"
1287 return 1
1290 if ! [ -h $testroot/wt/passwd.link ]; then
1291 echo 'passwd.link is not a symlink' >&2
1292 test_done "$testroot" 1
1293 return 1
1296 # 'got update' should reinstall passwd.link as a regular file
1297 (cd $testroot/wt && got update > /dev/null)
1298 check_symlinks $testroot/wt
1299 ret=$?
1300 if [ $ret -ne 0 ]; then
1301 test_done "$testroot" "$ret"
1302 return 1
1305 (cd $testroot/wt && ln -sf beta alpha.link)
1306 (cd $testroot/wt && ln -sfh gamma epsilon.link)
1307 rm $testroot/wt/epsilon/beta.link
1308 echo "this is a regular file" > $testroot/wt/epsilon/beta.link
1309 (cd $testroot/wt && ln -sf .got/bar dotgotbar.link)
1310 (cd $testroot/wt && got add dotgotbar.link > /dev/null)
1311 (cd $testroot/wt && got rm nonexistent.link > /dev/null)
1312 (cd $testroot/wt && ln -sf gamma/delta zeta.link)
1313 (cd $testroot/wt && ln -sf alpha new.link)
1314 (cd $testroot/wt && got add new.link > /dev/null)
1316 (cd $testroot/wt && got commit -m 'test commit_symlink' \
1317 > $testroot/stdout 2> $testroot/stderr)
1318 ret=$?
1319 if [ $ret -eq 0 ]; then
1320 echo "got commit succeeded unexpectedly" >&2
1321 test_done "$testroot" "$ret"
1322 return 1
1324 echo -n "got: $testroot/wt/dotgotbar.link: " > $testroot/stderr.expected
1325 echo "symbolic link points outside of paths under version control" \
1326 >> $testroot/stderr.expected
1327 cmp -s $testroot/stderr.expected $testroot/stderr
1328 ret=$?
1329 if [ $ret -ne 0 ]; then
1330 diff -u $testroot/stderr.expected $testroot/stderr
1331 test_done "$testroot" "$ret"
1332 return 1
1335 (cd $testroot/wt && got commit -S -m 'test commit_symlink' \
1336 > $testroot/stdout)
1338 local head_rev=`git_show_head $testroot/repo`
1339 echo "A dotgotbar.link" > $testroot/stdout.expected
1340 echo "A new.link" >> $testroot/stdout.expected
1341 echo "M alpha.link" >> $testroot/stdout.expected
1342 echo "M epsilon/beta.link" >> $testroot/stdout.expected
1343 echo "M epsilon.link" >> $testroot/stdout.expected
1344 echo "D nonexistent.link" >> $testroot/stdout.expected
1345 echo "Created commit $head_rev" >> $testroot/stdout.expected
1347 cmp -s $testroot/stdout.expected $testroot/stdout
1348 ret=$?
1349 if [ $ret -ne 0 ]; then
1350 diff -u $testroot/stdout.expected $testroot/stdout
1351 test_done "$testroot" "$ret"
1352 return 1
1355 got tree -r $testroot/repo -c $head_rev -R > $testroot/stdout
1356 cat > $testroot/stdout.expected <<EOF
1357 alpha
1358 alpha.link@ -> beta
1359 beta
1360 dotgotbar.link@ -> .got/bar
1361 epsilon/
1362 epsilon/beta.link
1363 epsilon/zeta
1364 epsilon.link@ -> gamma
1365 gamma/
1366 gamma/delta
1367 new.link@ -> alpha
1368 passwd.link@ -> /etc/passwd
1369 EOF
1370 cmp -s $testroot/stdout.expected $testroot/stdout
1371 ret=$?
1372 if [ $ret -ne 0 ]; then
1373 diff -u $testroot/stdout.expected $testroot/stdout
1375 test_done "$testroot" "$ret"
1378 test_commit_fix_bad_symlink() {
1379 local testroot=`test_init commit_fix_bad_symlink`
1381 got checkout $testroot/repo $testroot/wt > /dev/null
1382 ret=$?
1383 if [ $ret -ne 0 ]; then
1384 echo "got checkout failed unexpectedly" >&2
1385 test_done "$testroot" "$ret"
1386 return 1
1389 (cd $testroot/wt && ln -s /etc/passwd passwd.link)
1390 (cd $testroot/wt && got add passwd.link > /dev/null)
1392 (cd $testroot/wt && got commit -S -m 'commit bad symlink' \
1393 > $testroot/stdout)
1395 if ! [ -h $testroot/wt/passwd.link ]; then
1396 echo 'passwd.link is not a symlink' >&2
1397 test_done "$testroot" 1
1398 return 1
1400 (cd $testroot/wt && got update >/dev/null)
1401 if [ -h $testroot/wt/passwd.link ]; then
1402 echo "passwd.link is a symlink but should be a regular file" >&2
1403 test_done "$testroot" "1"
1404 return 1
1407 # create another work tree which will contain the "bad" symlink
1408 got checkout $testroot/repo $testroot/wt2 > /dev/null
1409 ret=$?
1410 if [ $ret -ne 0 ]; then
1411 echo "got checkout failed unexpectedly" >&2
1412 test_done "$testroot" "$ret"
1413 return 1
1416 # change "bad" symlink back into a "good" symlink
1417 (cd $testroot/wt && ln -sfh alpha passwd.link)
1419 (cd $testroot/wt && got commit -m 'fix bad symlink' \
1420 > $testroot/stdout)
1422 local head_rev=`git_show_head $testroot/repo`
1423 echo "M passwd.link" > $testroot/stdout.expected
1424 echo "Created commit $head_rev" >> $testroot/stdout.expected
1426 cmp -s $testroot/stdout.expected $testroot/stdout
1427 ret=$?
1428 if [ $ret -ne 0 ]; then
1429 diff -u $testroot/stdout.expected $testroot/stdout
1430 test_done "$testroot" "$ret"
1431 return 1
1434 if ! [ -h $testroot/wt/passwd.link ]; then
1435 echo 'passwd.link is not a symlink' >&2
1436 test_done "$testroot" 1
1437 return 1
1440 readlink $testroot/wt/passwd.link > $testroot/stdout
1441 echo "alpha" > $testroot/stdout.expected
1442 cmp -s $testroot/stdout.expected $testroot/stdout
1443 ret=$?
1444 if [ $ret -ne 0 ]; then
1445 diff -u $testroot/stdout.expected $testroot/stdout
1446 return 1
1449 # Update the other work tree; the bad symlink should be fixed
1450 (cd $testroot/wt2 && got update > /dev/null)
1451 ret=$?
1452 if [ $ret -ne 0 ]; then
1453 echo "got checkout failed unexpectedly" >&2
1454 test_done "$testroot" "$ret"
1455 return 1
1458 if ! [ -h $testroot/wt2/passwd.link ]; then
1459 echo 'passwd.link is not a symlink' >&2
1460 test_done "$testroot" 1
1461 return 1
1464 readlink $testroot/wt2/passwd.link > $testroot/stdout
1465 echo "alpha" > $testroot/stdout.expected
1466 cmp -s $testroot/stdout.expected $testroot/stdout
1467 ret=$?
1468 if [ $ret -ne 0 ]; then
1469 diff -u $testroot/stdout.expected $testroot/stdout
1470 return 1
1473 test_done "$testroot" "0"
1476 test_commit_prepared_logmsg() {
1477 local testroot=`test_init commit_prepared_logmsg`
1479 got checkout $testroot/repo $testroot/wt > /dev/null
1480 ret=$?
1481 if [ $ret -ne 0 ]; then
1482 test_done "$testroot" "$ret"
1483 return 1
1486 echo "modified alpha" > $testroot/wt/alpha
1487 (cd $testroot/wt && got rm beta >/dev/null)
1488 echo "new file" > $testroot/wt/new
1489 (cd $testroot/wt && got add new >/dev/null)
1491 echo 'test commit_prepared_logmsg' > $testroot/logmsg
1493 cat > $testroot/editor.sh <<EOF
1494 #!/bin/sh
1495 sed -i 's/foo/bar/' "\$1"
1496 EOF
1497 chmod +x $testroot/editor.sh
1499 (cd $testroot/wt && env VISUAL="$testroot/editor.sh" \
1500 got commit -F "$testroot/logmsg" > $testroot/stdout)
1502 local head_rev=`git_show_head $testroot/repo`
1503 echo "A new" > $testroot/stdout.expected
1504 echo "M alpha" >> $testroot/stdout.expected
1505 echo "D beta" >> $testroot/stdout.expected
1506 echo "Created commit $head_rev" >> $testroot/stdout.expected
1508 cmp -s $testroot/stdout.expected $testroot/stdout
1509 ret=$?
1510 if [ $ret -ne 0 ]; then
1511 diff -u $testroot/stdout.expected $testroot/stdout
1512 test_done "$testroot" "$ret"
1513 return 1
1516 local author_time=`git_show_author_time $testroot/repo`
1517 d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
1518 echo "-----------------------------------------------" > $testroot/stdout.expected
1519 echo "commit $head_rev (master)" >> $testroot/stdout.expected
1520 echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
1521 echo "date: $d" >> $testroot/stdout.expected
1522 echo " " >> $testroot/stdout.expected
1523 echo " test commit_prepared_logmsg" >> $testroot/stdout.expected
1524 echo " " >> $testroot/stdout.expected
1526 (cd $testroot/wt && got log -l 1 > $testroot/stdout)
1527 cmp -s $testroot/stdout.expected $testroot/stdout
1528 ret=$?
1529 if [ $ret -ne 0 ]; then
1530 diff -u $testroot/stdout.expected $testroot/stdout
1531 test_done "$testroot" "$ret"
1532 return 1
1535 echo "modified alpha again" > $testroot/wt/alpha
1537 echo 'test commit_prepared_logmsg non-interactive' \
1538 > $testroot/logmsg
1540 (cd $testroot/wt && got commit -N -F "$testroot/logmsg" \
1541 > $testroot/stdout)
1543 local head_rev=`git_show_head $testroot/repo`
1544 echo "M alpha" > $testroot/stdout.expected
1545 echo "Created commit $head_rev" >> $testroot/stdout.expected
1547 cmp -s $testroot/stdout.expected $testroot/stdout
1548 ret=$?
1549 if [ $ret -ne 0 ]; then
1550 diff -u $testroot/stdout.expected $testroot/stdout
1551 test_done "$testroot" "$ret"
1552 return 1
1555 local author_time=`git_show_author_time $testroot/repo`
1556 d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
1557 echo "-----------------------------------------------" \
1558 > $testroot/stdout.expected
1559 echo "commit $head_rev (master)" >> $testroot/stdout.expected
1560 echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
1561 echo "date: $d" >> $testroot/stdout.expected
1562 echo " " >> $testroot/stdout.expected
1563 echo " test commit_prepared_logmsg non-interactive" \
1564 >> $testroot/stdout.expected
1565 echo " " >> $testroot/stdout.expected
1567 (cd $testroot/wt && got log -l 1 > $testroot/stdout)
1568 cmp -s $testroot/stdout.expected $testroot/stdout
1569 ret=$?
1570 if [ $ret -ne 0 ]; then
1571 diff -u $testroot/stdout.expected $testroot/stdout
1573 test_done "$testroot" "$ret"
1576 test_commit_large_file() {
1577 local testroot=`test_init commit_large_file`
1579 got checkout $testroot/repo $testroot/wt > /dev/null
1580 ret=$?
1581 if [ $ret -ne 0 ]; then
1582 test_done "$testroot" "$ret"
1583 return 1
1586 dd status=none if=/dev/zero of=$testroot/wt/new bs=1M count=64
1587 (cd $testroot/wt && got add new >/dev/null)
1589 (cd $testroot/wt && got commit -m 'test commit_large_file' \
1590 > $testroot/stdout)
1592 local head_rev=`git_show_head $testroot/repo`
1593 echo "A new" > $testroot/stdout.expected
1594 echo "Created commit $head_rev" >> $testroot/stdout.expected
1596 cmp -s $testroot/stdout.expected $testroot/stdout
1597 ret=$?
1598 if [ $ret -ne 0 ]; then
1599 diff -u $testroot/stdout.expected $testroot/stdout
1600 test_done "$testroot" "$ret"
1601 return 1
1604 new_id=`get_blob_id $testroot/repo "" new`
1605 got cat -r $testroot/repo $new_id > $testroot/new
1606 ret=$?
1607 if [ $ret -ne 0 ]; then
1608 echo "commit failed unexpectedly" >&2
1609 test_done "$testroot" "1"
1610 return 1
1613 cmp -s $testroot/new $testroot/wt/new
1614 ret=$?
1615 if [ $ret -ne 0 ]; then
1616 diff -u $testroot/new $testroot/wt/new
1618 test_done "$testroot" "$ret"
1623 test_commit_gitignore() {
1624 local testroot=`test_init commit_gitignores`
1626 got checkout $testroot/repo $testroot/wt > /dev/null
1627 ret=$?
1628 if [ $ret -ne 0 ]; then
1629 test_done "$testroot" "$ret"
1630 return 1
1633 mkdir -p $testroot/wt/tree1/foo
1634 mkdir -p $testroot/wt/tree2/foo
1635 echo "tree1/**" > $testroot/wt/.gitignore
1636 echo "tree2/**" >> $testroot/wt/.gitignore
1637 echo -n > $testroot/wt/tree1/bar
1638 echo -n > $testroot/wt/tree1/foo/baz
1639 echo -n > $testroot/wt/tree2/bar
1640 echo -n > $testroot/wt/tree2/foo/baz
1641 echo -n > $testroot/wt/epsilon/zeta1
1642 echo -n > $testroot/wt/epsilon/zeta2
1644 (cd $testroot/wt && got add -I -R tree1 > /dev/null)
1645 (cd $testroot/wt && got add -I tree2/foo/baz > /dev/null)
1646 (cd $testroot/wt && got commit -m "gitignore add" > /dev/null)
1647 (cd $testroot/wt && got log -P -l 1 | egrep '^ .' > $testroot/stdout)
1649 echo ' gitignore add' > $testroot/stdout.expected
1650 echo ' A tree1/bar' >> $testroot/stdout.expected
1651 echo ' A tree1/foo/baz' >> $testroot/stdout.expected
1652 echo ' A tree2/foo/baz' >> $testroot/stdout.expected
1654 cmp -s $testroot/stdout.expected $testroot/stdout
1655 ret=$?
1656 if [ $ret -ne 0 ]; then
1657 diff -u $testroot/stdout.expected $testroot/stdout
1658 test_done "$testroot" "$ret"
1659 return 1
1662 echo touch > $testroot/wt/tree1/bar
1663 echo touch > $testroot/wt/tree1/foo/baz
1664 echo touch > $testroot/wt/epsilon/zeta1
1666 (cd $testroot/wt && got commit -m "gitignore change" > /dev/null)
1667 (cd $testroot/wt && got log -P -l 1 | egrep '^ .' > $testroot/stdout)
1669 echo ' gitignore change' > $testroot/stdout.expected
1670 echo ' M tree1/bar' >> $testroot/stdout.expected
1671 echo ' M tree1/foo/baz' >> $testroot/stdout.expected
1673 cmp -s $testroot/stdout.expected $testroot/stdout
1674 ret=$?
1675 if [ $ret -ne 0 ]; then
1676 diff -u $testroot/stdout.expected $testroot/stdout
1677 test_done "$testroot" "$ret"
1678 return 1
1681 test_done "$testroot" "$ret"
1684 test_commit_bad_author() {
1685 local testroot=`test_init commit_bad_author`
1687 got checkout $testroot/repo $testroot/wt > /dev/null
1688 ret=$?
1689 if [ $ret -ne 0 ]; then
1690 test_done "$testroot" $ret
1691 return 1
1694 echo "modified alpha" > $testroot/wt/alpha
1696 (cd $testroot/wt && got commit \
1697 -A "${GIT_AUTHOR_NAME}<${GIT_AUTHOR_EMAIL}>" -m 'edit alpha') \
1698 > /dev/null 2> $testroot/stderr
1699 ret=$?
1700 if [ $ret -eq 0 ]; then
1701 test_done "$testroot" 1
1702 return 1
1705 echo -n "got: ${GIT_AUTHOR_NAME}<${GIT_AUTHOR_EMAIL}>: " \
1706 > $testroot/stderr.expected
1707 echo -n 'space between author name and email required: ' \
1708 >> $testroot/stderr.expected
1709 echo 'commit author formatting would make Git unhappy' \
1710 >> $testroot/stderr.expected
1711 cmp -s $testroot/stderr.expected $testroot/stderr
1712 ret=$?
1713 if [ $ret -ne 0 ]; then
1714 diff -u $testroot/stderr.expected $testroot/stderr
1715 test_done "$testroot" $ret
1716 return 1
1719 test_done "$testroot" 0
1722 test_commit_logmsg_ref() {
1723 local testroot=`test_init commit_logmsg_ref`
1725 got checkout $testroot/repo $testroot/wt > /dev/null
1726 ret=$?
1727 if [ $ret -ne 0 ]; then
1728 test_done "$testroot" "$ret"
1729 return 1
1732 (cd $testroot/repo && git checkout -q -b newbranch)
1734 local bo_logmsg_prefix="log message of backed-out commit"
1735 local cy_logmsg_prefix="log message of cherrypicked commit"
1736 local branch_rev_logmsg="changes on newbranch to cherrypick"
1737 local branch_rev2_logmsg="modified zeta on newbranch to cherrypick"
1739 echo "modified delta on branch" > $testroot/repo/gamma/delta
1740 echo "modified alpha on branch" > $testroot/repo/alpha
1741 (cd $testroot/repo && git rm -q beta)
1742 echo "new file on branch" > $testroot/repo/epsilon/new
1743 (cd $testroot/repo && git add epsilon/new)
1745 git_commit $testroot/repo -m "$branch_rev_logmsg"
1746 local branch_rev=`git_show_head $testroot/repo`
1748 echo "modified zeta on branch" > $testroot/repo/epsilon/zeta
1750 git_commit $testroot/repo -m "$branch_rev2_logmsg"
1751 local branch_rev2=`git_show_head $testroot/repo`
1753 (cd $testroot/wt && got cherrypick $branch_rev > /dev/null)
1754 (cd $testroot/wt && got cherrypick $branch_rev2 > /dev/null)
1756 cat > $testroot/editor.sh <<EOF
1757 #!/bin/sh
1758 sed -i 's/# l/l/' "\$1"
1759 EOF
1760 chmod +x $testroot/editor.sh
1762 (cd $testroot/wt && env VISUAL="$testroot/editor.sh" \
1763 got commit > /dev/null)
1764 ret=$?
1765 if [ $ret -ne 0 ]; then
1766 echo "'got commit' failed unexpectedly" >&2
1767 test_done "$testroot" "1"
1768 return 1
1771 # check that multiple cherrypicked log messages populate the editor
1772 local first=`printf '%s\n%s' $branch_rev $branch_rev2 | sort | head -1`
1773 local second=`printf '%s\n%s' $branch_rev $branch_rev2 | sort | tail -1`
1775 if [ $branch_rev == $first ]; then
1776 local first_msg=$branch_rev_logmsg
1777 local second_msg=$branch_rev2_logmsg
1778 else
1779 local first_msg=$branch_rev2_logmsg
1780 local second_msg=$branch_rev_logmsg
1783 echo " $cy_logmsg_prefix $first:" > $testroot/stdout.expected
1784 echo " $first_msg" >> $testroot/stdout.expected
1785 echo " " >> $testroot/stdout.expected
1786 echo " $cy_logmsg_prefix $second:" >> $testroot/stdout.expected
1787 echo " $second_msg" >> $testroot/stdout.expected
1788 echo " " >> $testroot/stdout.expected
1790 (cd $testroot/wt && got log -l2 | \
1791 grep -A2 'log message' | sed '/^--/d' > $testroot/stdout)
1793 cmp -s $testroot/stdout.expected $testroot/stdout
1794 ret=$?
1795 if [ $ret -ne 0 ]; then
1796 diff -u $testroot/stdout.expected $testroot/stdout
1797 test_done "$testroot" "$ret"
1798 return 1
1801 # check that only the relevant log message populates the editor
1802 # when the changes from one of two backout commits are reverted
1803 got checkout $testroot/repo $testroot/wt2 > /dev/null
1804 ret=$?
1805 if [ $ret -ne 0 ]; then
1806 test_done "$testroot" "$ret"
1807 return 1
1810 (cd $testroot/wt2 && got backout $branch_rev > /dev/null)
1811 (cd $testroot/wt2 && got backout $branch_rev2 > /dev/null)
1812 (cd $testroot/wt2 && got revert epsilon/zeta > /dev/null)
1814 (cd $testroot/wt2 && env VISUAL="$testroot/editor.sh" \
1815 got commit > /dev/null)
1816 ret=$?
1817 if [ $ret -ne 0 ]; then
1818 echo "'got commit' failed unexpectedly" >&2
1819 test_done "$testroot" "1"
1820 return 1
1823 echo " $bo_logmsg_prefix $branch_rev:" > $testroot/stdout.expected
1824 echo " $branch_rev_logmsg" >> $testroot/stdout.expected
1825 echo " " >> $testroot/stdout.expected
1827 (cd $testroot/wt2 && got log -l1 | \
1828 grep -A2 'log message' > $testroot/stdout)
1830 cmp -s $testroot/stdout.expected $testroot/stdout
1831 ret=$?
1832 if [ $ret -ne 0 ]; then
1833 diff -u $testroot/stdout.expected $testroot/stdout
1834 test_done "$testroot" "$ret"
1835 return 1
1838 # check that a cherrypicked log message is still
1839 # used when its changes are only partially reverted
1840 branch_rev_logmsg="changes to cherrypick and partially revert"
1842 echo "newline in alpha" >> $testroot/repo/alpha
1843 echo "modified epsilon/zeta on branch" > $testroot/repo/epsilon/zeta
1845 git_commit $testroot/repo -m "$branch_rev_logmsg"
1846 branch_rev=`git_show_head $testroot/repo`
1848 (cd $testroot/wt && got cherrypick $branch_rev > /dev/null)
1849 (cd $testroot/wt && got revert alpha > /dev/null)
1851 (cd $testroot/wt && env VISUAL="$testroot/editor.sh" \
1852 got commit > /dev/null)
1853 ret=$?
1854 if [ $ret -ne 0 ]; then
1855 echo "'got commit' failed unexpectedly" >&2
1856 test_done "$testroot" "1"
1857 return 1
1860 echo " $cy_logmsg_prefix $branch_rev:" > $testroot/stdout.expected
1861 echo " $branch_rev_logmsg" >> $testroot/stdout.expected
1862 echo " " >> $testroot/stdout.expected
1864 (cd $testroot/wt && got log -l1 | \
1865 grep -A2 'log message' > $testroot/stdout)
1867 cmp -s $testroot/stdout.expected $testroot/stdout
1868 ret=$?
1869 if [ $ret -ne 0 ]; then
1870 diff -u $testroot/stdout.expected $testroot/stdout
1871 test_done "$testroot" "$ret"
1872 return 1
1875 # check we don't use and consequently delete the logmsg ref of a
1876 # cherrypicked commit when omitting its changed path from the commit
1877 branch_rev_logmsg="changes to cherrypick but omit from the commit"
1879 echo "changed delta" >> $testroot/repo/gamma/delta
1881 git_commit $testroot/repo -m "$branch_rev_logmsg"
1882 local author_time=`git_show_author_time $testroot/repo`
1883 local d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
1884 branch_rev=`git_show_head $testroot/repo`
1886 (cd $testroot/wt && got update > /dev/null)
1887 ret=$?
1888 if [ $ret -ne 0 ]; then
1889 echo "got update failed unexpectedly" >&2
1890 test_done "$testroot" "$ret"
1891 return 1
1894 (cd $testroot/wt && got cherrypick $branch_rev > /dev/null)
1896 echo "changed alpha" >> $testroot/wt/alpha
1898 (cd $testroot/wt && got commit -m \
1899 "don't commit cy change to gamma/delta" alpha > /dev/null)
1900 ret=$?
1901 if [ $ret -ne 0 ]; then
1902 echo "'got commit' failed unexpectedly" >&2
1903 test_done "$testroot" "1"
1904 return 1
1907 # confirm logmsg ref was not deleted with got cherrypick -l
1908 echo "-----------------------------------------------" \
1909 > $testroot/stdout.expected
1910 echo "cherrypick $branch_rev (newbranch)" >> $testroot/stdout.expected
1911 echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
1912 echo "date: $d" >> $testroot/stdout.expected
1913 echo " " >> $testroot/stdout.expected
1914 echo " $branch_rev_logmsg" >> $testroot/stdout.expected
1915 echo " " >> $testroot/stdout.expected
1916 echo " M gamma/delta" >> $testroot/stdout.expected
1917 echo >> $testroot/stdout.expected
1919 (cd $testroot/wt && got cherrypick -l > $testroot/stdout)
1921 cmp -s $testroot/stdout.expected $testroot/stdout
1922 ret=$?
1923 if [ $ret -ne 0 ]; then
1924 diff -u $testroot/stdout.expected $testroot/stdout
1925 test_done "$testroot" "$ret"
1926 return 1
1929 # confirm a previously unused logmsg ref is picked up
1930 # when an affected path is actually committed
1931 (cd $testroot/wt && env VISUAL="$testroot/editor.sh" \
1932 got commit > /dev/null)
1933 ret=$?
1934 if [ $ret -ne 0 ]; then
1935 echo "'got commit' failed unexpectedly" >&2
1936 test_done "$testroot" "1"
1937 return 1
1940 echo " $cy_logmsg_prefix $branch_rev:" > $testroot/stdout.expected
1941 echo " $branch_rev_logmsg" >> $testroot/stdout.expected
1942 echo " " >> $testroot/stdout.expected
1944 (cd $testroot/wt && got log -l1 | \
1945 grep -A2 'log message' > $testroot/stdout)
1947 cmp -s $testroot/stdout.expected $testroot/stdout
1948 ret=$?
1949 if [ $ret -ne 0 ]; then
1950 diff -u $testroot/stdout.expected $testroot/stdout
1951 test_done "$testroot" "$ret"
1952 return 1
1955 # make sure we are not littering work trees
1956 # by leaving temp got-logmsg-* files behind
1957 echo -n > $testroot/stdout.expected
1958 (cd $testroot/wt && got status > $testroot/stdout)
1960 cmp -s $testroot/stdout.expected $testroot/stdout
1961 ret=$?
1962 if [ $ret -ne 0 ]; then
1963 echo "$testroot/wt is not clean"
1964 diff -u $testroot/stdout.expected $testroot/stdout
1965 test_done "$testroot" "$ret"
1966 return 1
1969 (cd $testroot/wt2 && got status > $testroot/stdout)
1971 cmp -s $testroot/stdout.expected $testroot/stdout
1972 ret=$?
1973 if [ $ret -ne 0 ]; then
1974 echo "$testroot/repo is not clean"
1975 diff -u $testroot/stdout.expected $testroot/stdout
1977 test_done "$testroot" "$ret"
1980 test_parseargs "$@"
1981 run_test test_commit_basic
1982 run_test test_commit_new_subdir
1983 run_test test_commit_subdir
1984 run_test test_commit_single_file
1985 run_test test_commit_out_of_date
1986 run_test test_commit_added_subdirs
1987 run_test test_commit_deleted_subdirs
1988 run_test test_commit_rejects_conflicted_file
1989 run_test test_commit_single_file_multiple
1990 run_test test_commit_added_and_modified_in_same_dir
1991 run_test test_commit_path_prefix
1992 run_test test_commit_dir_path
1993 run_test test_commit_selected_paths
1994 run_test test_commit_outside_refs_heads
1995 run_test test_commit_no_email
1996 run_test test_commit_tree_entry_sorting
1997 run_test test_commit_cmdline_author
1998 run_test test_commit_gotconfig_author
1999 run_test test_commit_gotconfig_worktree_author
2000 run_test test_commit_gitconfig_author
2001 run_test test_commit_xbit_change
2002 run_test test_commit_normalizes_filemodes
2003 run_test test_commit_with_unrelated_submodule
2004 run_test test_commit_symlink
2005 run_test test_commit_fix_bad_symlink
2006 run_test test_commit_prepared_logmsg
2007 run_test test_commit_large_file
2008 run_test test_commit_gitignore
2009 run_test test_commit_bad_author
2010 run_test test_commit_logmsg_ref