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)
297 local commit_id1=`git_show_head $testroot/repo`
299 (cd $testroot/wt && got update -c $initial_rev > /dev/null)
301 echo "modified alpha, too" > $testroot/wt/alpha
303 echo "C alpha" > $testroot/stdout.expected
304 echo -n "Updated to refs/heads/master: " >> $testroot/stdout.expected
305 git_show_head $testroot/repo >> $testroot/stdout.expected
306 echo >> $testroot/stdout.expected
307 echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
309 (cd $testroot/wt && got update > $testroot/stdout)
311 cmp -s $testroot/stdout.expected $testroot/stdout
312 ret=$?
313 if [ $ret -ne 0 ]; then
314 diff -u $testroot/stdout.expected $testroot/stdout
315 test_done "$testroot" "$ret"
316 return 1
317 fi
319 (cd $testroot/wt && got commit -m 'commit it' > $testroot/stdout \
320 2> $testroot/stderr)
321 ret=$?
322 if [ $ret -eq 0 ]; then
323 echo "got commit succeeded unexpectedly"
324 test_done "$testroot" "$ret"
325 return 1
326 fi
328 echo "C alpha" > $testroot/stdout.expected
329 echo "got: cannot commit file in conflicted status" \
330 > $testroot/stderr.expected
332 cmp -s $testroot/stdout.expected $testroot/stdout
333 ret=$?
334 if [ $ret -ne 0 ]; then
335 diff -u $testroot/stdout.expected $testroot/stdout
336 test_done "$testroot" "$ret"
337 return 1
338 fi
339 cmp -s $testroot/stderr.expected $testroot/stderr
340 ret=$?
341 if [ $ret -ne 0 ]; then
342 diff -u $testroot/stderr.expected $testroot/stderr
343 test_done "$testroot" "$ret"
344 return 1
345 fi
347 (cd $testroot/wt && got commit -C -m 'commit it' > $testroot/stdout \
348 2> $testroot/stderr)
349 ret=$?
350 if [ $ret -ne 0 ]; then
351 echo "got commit failed unexpectedly"
352 test_done "$testroot" "$ret"
353 return 1
354 fi
356 # make sure the conflicted commit produces a diff
357 local conflict_commit=`git_show_head $testroot/repo`
358 local blob_minus=`got tree -r $testroot/repo -c $commit_id1 -i | \
359 grep 'alpha$' | cut -d' ' -f1`
360 local blob_plus=`got tree -r $testroot/repo -c $conflict_commit -i | \
361 grep 'alpha$' | cut -d' ' -f1`
363 echo -n > $testroot/stderr.expected
364 cmp -s $testroot/stderr.expected $testroot/stderr
365 ret=$?
366 if [ $ret -ne 0 ]; then
367 diff -u $testroot/stderr.expected $testroot/stderr
368 test_done "$testroot" "$ret"
369 return 1
370 fi
372 (cd $testroot/wt && got diff -c master > $testroot/stdout)
374 echo -n > $testroot/stdout.expected
375 cat > $testroot/stdout.expected <<EOF
376 diff $commit_id1 refs/heads/master
377 commit - $commit_id1
378 commit + $conflict_commit
379 blob - $blob_minus
380 blob + $blob_plus
381 --- alpha
382 +++ alpha
383 @@ -1 +1,7 @@
384 +<<<<<<< merged change: commit $commit_id1
385 modified alpha
386 +||||||| 3-way merge base: commit $initial_rev
387 +alpha
388 +=======
389 +modified alpha, too
390 +>>>>>>>
391 EOF
393 cmp -s $testroot/stdout.expected $testroot/stdout
394 ret=$?
395 if [ $ret -ne 0 ]; then
396 diff -u $testroot/stdout.expected $testroot/stdout
397 test_done "$testroot" "$ret"
398 return 1
399 fi
401 (cd $testroot/wt && got status > $testroot/stdout)
403 echo -n > $testroot/stdout.expected
404 cmp -s $testroot/stdout.expected $testroot/stdout
405 ret=$?
406 if [ $ret -ne 0 ]; then
407 diff -u $testroot/stdout.expected $testroot/stdout
408 fi
409 test_done "$testroot" "$ret"
412 test_commit_single_file_multiple() {
413 local testroot=`test_init commit_single_file_multiple`
415 got checkout $testroot/repo $testroot/wt > /dev/null
416 ret=$?
417 if [ $ret -ne 0 ]; then
418 test_done "$testroot" "$ret"
419 return 1
420 fi
422 for i in 1 2 3 4; do
423 echo "modified alpha" >> $testroot/wt/alpha
425 (cd $testroot/wt && \
426 got commit -m "changed alpha" > $testroot/stdout)
428 local head_rev=`git_show_head $testroot/repo`
429 echo "M alpha" > $testroot/stdout.expected
430 echo "Created commit $head_rev" >> $testroot/stdout.expected
432 cmp -s $testroot/stdout.expected $testroot/stdout
433 ret=$?
434 if [ $ret -ne 0 ]; then
435 diff -u $testroot/stdout.expected $testroot/stdout
436 test_done "$testroot" "$ret"
437 return 1
438 fi
439 done
441 test_done "$testroot" "0"
444 test_commit_added_and_modified_in_same_dir() {
445 local testroot=`test_init commit_added_and_modified_in_same_dir`
447 got checkout $testroot/repo $testroot/wt > /dev/null
448 ret=$?
449 if [ $ret -ne 0 ]; then
450 test_done "$testroot" "$ret"
451 return 1
452 fi
454 echo "modified zeta" > $testroot/wt/epsilon/zeta
455 echo "new file" > $testroot/wt/epsilon/new
456 (cd $testroot/wt && got add epsilon/new >/dev/null)
458 (cd $testroot/wt && got commit \
459 -m 'added and modified in same dir' > $testroot/stdout \
460 2> $testroot/stderr)
462 local head_rev=`git_show_head $testroot/repo`
463 echo "A epsilon/new" > $testroot/stdout.expected
464 echo "M epsilon/zeta" >> $testroot/stdout.expected
465 echo "Created commit $head_rev" >> $testroot/stdout.expected
467 cmp -s $testroot/stdout.expected $testroot/stdout
468 ret=$?
469 if [ $ret -ne 0 ]; then
470 diff -u $testroot/stdout.expected $testroot/stdout
471 fi
472 test_done "$testroot" "$ret"
475 test_commit_path_prefix() {
476 local testroot=`test_init commit_path_prefix`
477 local commit1=`git_show_head $testroot/repo`
479 got checkout -p gamma $testroot/repo $testroot/wt > /dev/null
480 ret=$?
481 if [ $ret -ne 0 ]; then
482 test_done "$testroot" "$ret"
483 return 1
484 fi
486 echo "modified delta" > $testroot/wt/delta
488 (cd $testroot/wt && got commit -m 'changed gamma/delta' > $testroot/stdout)
490 local commit2=`git_show_head $testroot/repo`
491 echo "M delta" > $testroot/stdout.expected
492 echo "Created commit $commit2" >> $testroot/stdout.expected
494 cmp -s $testroot/stdout.expected $testroot/stdout
495 ret=$?
496 if [ $ret -ne 0 ]; then
497 diff -u $testroot/stdout.expected $testroot/stdout
498 test_done "$testroot" "$ret"
499 return 1
500 fi
502 echo "diff $commit1 $commit2" > $testroot/stdout.expected
503 echo "commit - $commit1" >> $testroot/stdout.expected
504 echo "commit + $commit2" >> $testroot/stdout.expected
505 echo -n 'blob - ' >> $testroot/stdout.expected
506 got tree -r $testroot/repo -c $commit1 -i gamma | grep 'delta$' \
507 | cut -d' ' -f 1 >> $testroot/stdout.expected
508 echo -n 'blob + ' >> $testroot/stdout.expected
509 got tree -r $testroot/repo -c $commit2 -i gamma | grep 'delta$' | \
510 cut -d' ' -f 1 >> $testroot/stdout.expected
511 echo '--- gamma/delta' >> $testroot/stdout.expected
512 echo '+++ gamma/delta' >> $testroot/stdout.expected
513 echo '@@ -1 +1 @@' >> $testroot/stdout.expected
514 echo '-delta' >> $testroot/stdout.expected
515 echo '+modified delta' >> $testroot/stdout.expected
517 got diff -r $testroot/repo $commit1 $commit2 > $testroot/stdout
518 cmp -s $testroot/stdout.expected $testroot/stdout
519 ret=$?
520 if [ $ret -ne 0 ]; then
521 diff -u $testroot/stdout.expected $testroot/stdout
522 test_done "$testroot" "$ret"
523 return 1
524 fi
526 (cd $testroot/wt && got rm delta > /dev/null)
527 echo new > $testroot/wt/new
528 (cd $testroot/wt && got add new > /dev/null)
530 (cd $testroot/wt && got commit -m 'remove gamma/delta; add gamma/new' \
531 > $testroot/stdout)
533 local commit3=`git_show_head $testroot/repo`
534 echo "A new" > $testroot/stdout.expected
535 echo "D delta" >> $testroot/stdout.expected
536 echo "Created commit $commit3" >> $testroot/stdout.expected
538 cmp -s $testroot/stdout.expected $testroot/stdout
539 ret=$?
540 if [ $ret -ne 0 ]; then
541 diff -u $testroot/stdout.expected $testroot/stdout
542 test_done "$testroot" "$ret"
543 return 1
544 fi
546 echo "diff $commit2 $commit3" > $testroot/stdout.expected
547 echo "commit - $commit2" >> $testroot/stdout.expected
548 echo "commit + $commit3" >> $testroot/stdout.expected
549 echo -n 'blob - ' >> $testroot/stdout.expected
550 got tree -r $testroot/repo -c $commit2 -i gamma | grep 'delta$' \
551 | cut -d' ' -f 1 | sed -e 's/$/ (mode 644)/' \
552 >> $testroot/stdout.expected
553 echo 'blob + /dev/null' >> $testroot/stdout.expected
554 echo '--- gamma/delta' >> $testroot/stdout.expected
555 echo '+++ /dev/null' >> $testroot/stdout.expected
556 echo '@@ -1 +0,0 @@' >> $testroot/stdout.expected
557 echo '-modified delta' >> $testroot/stdout.expected
558 echo 'blob - /dev/null' >> $testroot/stdout.expected
559 echo -n 'blob + ' >> $testroot/stdout.expected
560 got tree -r $testroot/repo -c $commit3 -i gamma | grep 'new$' | \
561 cut -d' ' -f 1 | sed -e 's/$/ (mode 644)/' \
562 >> $testroot/stdout.expected
563 echo '--- /dev/null' >> $testroot/stdout.expected
564 echo '+++ gamma/new' >> $testroot/stdout.expected
565 echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
566 echo '+new' >> $testroot/stdout.expected
568 got diff -r $testroot/repo $commit2 $commit3 > $testroot/stdout
569 cmp -s $testroot/stdout.expected $testroot/stdout
570 ret=$?
571 if [ $ret -ne 0 ]; then
572 diff -u $testroot/stdout.expected $testroot/stdout
573 fi
574 test_done "$testroot" "$ret"
575 return "$ret"
578 test_commit_dir_path() {
579 local testroot=`test_init commit_dir_path`
581 got checkout $testroot/repo $testroot/wt > /dev/null
582 ret=$?
583 if [ $ret -ne 0 ]; then
584 test_done "$testroot" "$ret"
585 return 1
586 fi
588 echo "modified alpha" > $testroot/wt/alpha
589 echo "modified zeta" > $testroot/wt/epsilon/zeta
591 (cd $testroot/wt && got commit -m 'changed zeta' epsilon \
592 > $testroot/stdout)
594 local head_rev=`git_show_head $testroot/repo`
595 echo "M epsilon/zeta" >> $testroot/stdout.expected
596 echo "Created commit $head_rev" >> $testroot/stdout.expected
598 cmp -s $testroot/stdout.expected $testroot/stdout
599 ret=$?
600 if [ $ret -ne 0 ]; then
601 diff -u $testroot/stdout.expected $testroot/stdout
602 test_done "$testroot" "$ret"
603 return 1
604 fi
606 echo "M alpha" > $testroot/stdout.expected
607 (cd $testroot/wt && got status > $testroot/stdout)
608 cmp -s $testroot/stdout.expected $testroot/stdout
609 ret=$?
610 if [ $ret -ne 0 ]; then
611 diff -u $testroot/stdout.expected $testroot/stdout
612 fi
613 test_done "$testroot" "$ret"
616 test_commit_selected_paths() {
617 local testroot=`test_init commit_selected_paths`
619 got checkout $testroot/repo $testroot/wt > /dev/null
620 ret=$?
621 if [ $ret -ne 0 ]; then
622 test_done "$testroot" "$ret"
623 return 1
624 fi
626 echo "modified alpha" > $testroot/wt/alpha
627 echo "modified delta" > $testroot/wt/gamma/delta
628 echo "modified zeta" > $testroot/wt/epsilon/zeta
629 (cd $testroot/wt && got rm beta >/dev/null)
630 echo "new file" > $testroot/wt/new
631 (cd $testroot/wt && got add new >/dev/null)
633 (cd $testroot/wt && got commit -m 'many paths' nonexistent alpha \
634 > $testroot/stdout 2> $testroot/stderr)
635 ret=$?
636 if [ $ret -eq 0 ]; then
637 echo "commit succeeded unexpectedly" >&2
638 test_done "$testroot" "1"
639 return 1
640 fi
641 echo "got: nonexistent: bad path" > $testroot/stderr.expected
643 cmp -s $testroot/stderr.expected $testroot/stderr
644 ret=$?
645 if [ $ret -ne 0 ]; then
646 diff -u $testroot/stderr.expected $testroot/stderr
647 test_done "$testroot" "$ret"
648 return 1
649 fi
651 (cd $testroot/wt && got commit -m 'many paths' \
652 beta new gamma > $testroot/stdout)
654 local head_rev=`git_show_head $testroot/repo`
655 echo "A new" > $testroot/stdout.expected
656 echo "D beta" >> $testroot/stdout.expected
657 echo "M gamma/delta" >> $testroot/stdout.expected
658 echo "Created commit $head_rev" >> $testroot/stdout.expected
660 cmp -s $testroot/stdout.expected $testroot/stdout
661 ret=$?
662 if [ $ret -ne 0 ]; then
663 diff -u $testroot/stdout.expected $testroot/stdout
664 fi
665 test_done "$testroot" "$ret"
668 test_commit_outside_refs_heads() {
669 local testroot=`test_init commit_outside_refs_heads`
671 got ref -r $testroot/repo -c master refs/remotes/origin/master
673 got checkout -b refs/remotes/origin/master \
674 $testroot/repo $testroot/wt > /dev/null
675 ret=$?
676 if [ $ret -ne 0 ]; then
677 test_done "$testroot" "$ret"
678 return 1
679 fi
681 echo "modified alpha" > $testroot/wt/alpha
683 (cd $testroot/wt && got commit -m 'change alpha' \
684 > $testroot/stdout 2> $testroot/stderr)
685 ret=$?
686 if [ $ret -eq 0 ]; then
687 echo "commit succeeded unexpectedly" >&2
688 test_done "$testroot" "1"
689 return 1
690 fi
692 echo -n > $testroot/stdout.expected
693 cmp -s $testroot/stdout.expected $testroot/stdout
694 ret=$?
695 if [ $ret -ne 0 ]; then
696 diff -u $testroot/stdout.expected $testroot/stdout
697 test_done "$testroot" "$ret"
698 return 1
699 fi
701 echo -n "got: will not commit to a branch outside the " \
702 > $testroot/stderr.expected
703 echo '"refs/heads/" reference namespace' \
704 >> $testroot/stderr.expected
705 cmp -s $testroot/stderr.expected $testroot/stderr
706 ret=$?
707 if [ $ret -ne 0 ]; then
708 diff -u $testroot/stderr.expected $testroot/stderr
709 fi
710 test_done "$testroot" "$ret"
713 test_commit_no_email() {
714 local testroot=`test_init commit_no_email`
715 local errmsg=""
717 errmsg="commit author's email address is required for"
718 errmsg="$errmsg compatibility with Git"
720 got checkout $testroot/repo $testroot/wt > /dev/null
721 ret=$?
722 if [ $ret -ne 0 ]; then
723 test_done "$testroot" "$ret"
724 return 1
725 fi
727 echo "modified alpha" > $testroot/wt/alpha
728 (cd $testroot/wt && env GOT_AUTHOR=":flan_hacker:" \
729 got commit -m 'test no email' > $testroot/stdout \
730 2> $testroot/stderr)
732 printf "got: :flan_hacker:: %s\n" "$errmsg" > $testroot/stderr.expected
733 cmp -s $testroot/stderr.expected $testroot/stderr
734 ret=$?
735 if [ $ret -ne 0 ]; then
736 diff -u $testroot/stderr.expected $testroot/stderr
737 test_done "$testroot" "$ret"
738 return 1
739 fi
741 echo -n > $testroot/stdout.expected
742 cmp -s $testroot/stdout.expected $testroot/stdout
743 ret=$?
744 if [ $ret -ne 0 ]; then
745 diff -u $testroot/stdout.expected $testroot/stdout
746 test_done "$testroot" $ret
747 return 1
748 fi
750 # try again with a newline inside the email
751 (cd $testroot/wt \
752 && FS=' ' env GOT_AUTHOR="$(printf "Flan <hack\ner>")" \
753 got commit -m 'test invalid email' > $testroot/stdout \
754 2> $testroot/stderr)
756 printf "got: Flan <hack\ner>: %s\n" "$errmsg" \
757 > $testroot/stderr.expected
758 cmp -s $testroot/stderr.expected $testroot/stderr
759 ret=$?
760 if [ $ret -ne 0 ]; then
761 diff -u $testroot/stderr.expected $testroot/stderr
762 test_done "$testroot" $ret
763 return 1
764 fi
766 echo -n > $testroot/stdout.expected
767 cmp -s $testroot/stdout.expected $testroot/stdout
768 ret=$?
769 if [ $ret -ne 0 ]; then
770 diff -u $testroot/stdout.expected $testroot/stdout
771 test_done "$testroot" $ret
772 return 1
773 fi
775 # try again with a < inside the email
776 (cd $testroot/wt && env GOT_AUTHOR="$(printf "Flan <ha<ker>")" \
777 got commit -m 'test invalid email' > $testroot/stdout \
778 2> $testroot/stderr)
780 printf "got: Flan <ha<ker>: %s\n" "$errmsg" > $testroot/stderr.expected
781 cmp -s $testroot/stderr.expected $testroot/stderr
782 ret=$?
783 if [ $ret -ne 0 ]; then
784 diff -u $testroot/stderr.expected $testroot/stderr
785 test_done "$testroot" $ret
786 return 1
787 fi
789 echo -n > $testroot/stdout.expected
790 cmp -s $testroot/stdout.expected $testroot/stdout
791 ret=$?
792 if [ $ret -ne 0 ]; then
793 diff -u $testroot/stdout.expected $testroot/stdout
794 fi
795 test_done "$testroot" $ret
798 test_commit_tree_entry_sorting() {
799 local testroot=`test_init commit_tree_entry_sorting`
801 got checkout $testroot/repo $testroot/wt > /dev/null
802 ret=$?
803 if [ $ret -ne 0 ]; then
804 test_done "$testroot" "$ret"
805 return 1
806 fi
808 # Git's index gets corrupted when tree entries are written in the
809 # order defined by got_path_cmp() rather than Git's own ordering.
810 # Create a new tree where a directory "got" and a file "got-version"
811 # would sort in the wrong order according to Git's opinion.
812 mkdir $testroot/wt/got
813 touch $testroot/wt/got/foo
814 echo foo > $testroot/wt/got-version
815 echo zzz > $testroot/wt/zzz
816 (cd $testroot/wt && got add got-version got/foo zzz > /dev/null)
818 (cd $testroot/wt && got commit -m 'test' > /dev/null)
820 # Let git-fsck verify the newly written tree to make sure Git is happy
821 (cd $testroot/repo && git fsck --strict \
822 > $testroot/fsck.stdout 2> $testroot/fsck.stderr)
823 ret=$?
824 test_done "$testroot" "$ret"
827 test_commit_cmdline_author() {
828 local testroot=`test_init commit_cmdline_author`
830 got checkout $testroot/repo $testroot/wt > /dev/null
831 ret=$?
832 if [ $ret -ne 0 ]; then
833 test_done "$testroot" $ret
834 return 1
835 fi
837 echo "modified alpha" > $testroot/wt/alpha
839 local author="Foo <foo@example.com>"
840 (cd $testroot/wt && got commit -A "$author" -m 'edit alpha') \
841 > /dev/null
842 ret=$?
843 if [ $ret -ne 0 ]; then
844 test_done "$testroot" $ret
845 return 1
846 fi
848 (cd $testroot/repo && got log -l1 | egrep '^(from|via):') \
849 > $testroot/stdout
850 ret=$?
851 if [ $ret -ne 0 ]; then
852 test_done "$testroot" $ret
853 return 1
854 fi
856 echo "from: $author" > $testroot/stdout.expected
857 echo "via: $GOT_AUTHOR" >> $testroot/stdout.expected
858 cmp -s $testroot/stdout.expected $testroot/stdout
859 ret=$?
860 if [ $ret -ne 0 ]; then
861 diff -u $testroot/stdout.expected $testroot/stdout
862 fi
863 test_done "$testroot" $ret
866 test_commit_gotconfig_author() {
867 local testroot=`test_init commit_gotconfig_author`
869 got checkout $testroot/repo $testroot/wt > /dev/null
870 ret=$?
871 if [ $ret -ne 0 ]; then
872 test_done "$testroot" "$ret"
873 return 1
874 fi
875 echo 'author "Flan Luck <flan_luck@openbsd.org>"' \
876 > $testroot/repo/.git/got.conf
878 echo "modified alpha" > $testroot/wt/alpha
879 (cd $testroot/wt && got commit -m 'test gotconfig author' > /dev/null)
880 ret=$?
881 if [ $ret -ne 0 ]; then
882 test_done "$testroot" "$ret"
883 return 1
884 fi
886 (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
887 ret=$?
888 if [ $ret -ne 0 ]; then
889 test_done "$testroot" "$ret"
890 return 1
891 fi
893 echo "from: Flan Luck <flan_luck@openbsd.org>" \
894 > $testroot/stdout.expected
895 cmp -s $testroot/stdout.expected $testroot/stdout
896 ret=$?
897 if [ $ret -ne 0 ]; then
898 diff -u $testroot/stdout.expected $testroot/stdout
899 fi
900 test_done "$testroot" "$ret"
903 test_commit_gotconfig_worktree_author() {
904 local testroot=`test_init commit_gotconfig_worktree_author`
906 got checkout $testroot/repo $testroot/wt > /dev/null
907 ret=$?
908 if [ $ret -ne 0 ]; then
909 test_done "$testroot" "$ret"
910 return 1
911 fi
912 echo 'author "Flan Luck <flan_luck@openbsd.org>"' \
913 > $testroot/repo/.git/got.conf
914 echo 'author "Flan Squee <flan_squee@openbsd.org>"' \
915 > $testroot/wt/.got/got.conf
917 echo "modified alpha" > $testroot/wt/alpha
918 (cd $testroot/wt && got commit -m 'test gotconfig author' > /dev/null)
919 ret=$?
920 if [ $ret -ne 0 ]; then
921 test_done "$testroot" "$ret"
922 return 1
923 fi
925 (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
926 ret=$?
927 if [ $ret -ne 0 ]; then
928 test_done "$testroot" "$ret"
929 return 1
930 fi
932 echo "from: Flan Squee <flan_squee@openbsd.org>" \
933 > $testroot/stdout.expected
934 cmp -s $testroot/stdout.expected $testroot/stdout
935 ret=$?
936 if [ $ret -ne 0 ]; then
937 diff -u $testroot/stdout.expected $testroot/stdout
938 fi
939 test_done "$testroot" "$ret"
942 test_commit_gitconfig_author() {
943 local testroot=`test_init commit_gitconfig_author`
945 got checkout $testroot/repo $testroot/wt > /dev/null
946 ret=$?
947 if [ $ret -ne 0 ]; then
948 test_done "$testroot" "$ret"
949 return 1
950 fi
952 (cd $testroot/repo && git config user.name 'Flan Luck')
953 (cd $testroot/repo && git config user.email 'flan_luck@openbsd.org')
955 echo "modified alpha" > $testroot/wt/alpha
957 # unset in a subshell to avoid affecting our environment
958 (unset GOT_IGNORE_GITCONFIG && cd $testroot/wt && \
959 got commit -m 'test gitconfig author' > /dev/null)
960 ret=$?
961 if [ $ret -ne 0 ]; then
962 test_done "$testroot" "$ret"
963 return 1
964 fi
966 (cd $testroot/repo && got log -l1 | grep ^from: > $testroot/stdout)
967 ret=$?
968 if [ $ret -ne 0 ]; then
969 test_done "$testroot" "$ret"
970 return 1
971 fi
973 echo "from: Flan Luck <flan_luck@openbsd.org>" \
974 > $testroot/stdout.expected
975 cmp -s $testroot/stdout.expected $testroot/stdout
976 ret=$?
977 if [ $ret -ne 0 ]; then
978 diff -u $testroot/stdout.expected $testroot/stdout
979 fi
980 test_done "$testroot" "$ret"
983 test_commit_xbit_change() {
984 local testroot=`test_init commit_xbit_change`
986 got checkout $testroot/repo $testroot/wt > /dev/null
987 ret=$?
988 if [ $ret -ne 0 ]; then
989 test_done "$testroot" "$ret"
990 return 1
991 fi
993 chmod +x $testroot/wt/alpha
995 echo 'm alpha' > $testroot/stdout.expected
996 (cd $testroot/wt && got status > $testroot/stdout)
998 cmp -s $testroot/stdout.expected $testroot/stdout
999 ret=$?
1000 if [ $ret -ne 0 ]; then
1001 diff -u $testroot/stdout.expected $testroot/stdout
1002 test_done "$testroot" "$ret"
1003 return 1
1006 (cd $testroot/wt && got commit -mx > $testroot/stdout)
1007 ret=$?
1008 if [ $ret -ne 0 ]; then
1009 echo "got commit failed unexpectedly"
1010 test_done "$testroot" "$ret"
1011 return 1
1014 local commit_id=`git_show_head $testroot/repo`
1015 echo 'm alpha' > $testroot/stdout.expected
1016 echo "Created commit $commit_id" >> $testroot/stdout.expected
1017 cmp -s $testroot/stdout.expected $testroot/stdout
1018 ret=$?
1019 if [ $ret -ne 0 ]; then
1020 diff -u $testroot/stdout.expected $testroot/stdout
1021 test_done "$testroot" "$ret"
1022 return 1
1025 (cd $testroot/wt && got status > $testroot/stdout)
1027 echo -n > $testroot/stdout.expected
1028 cmp -s $testroot/stdout.expected $testroot/stdout
1029 ret=$?
1030 if [ $ret -ne 0 ]; then
1031 diff -u $testroot/stdout.expected $testroot/stdout
1032 test_done "$testroot" "$ret"
1033 return 1
1036 chmod -x $testroot/wt/alpha
1038 echo 'm alpha' > $testroot/stdout.expected
1039 (cd $testroot/wt && got status > $testroot/stdout)
1041 cmp -s $testroot/stdout.expected $testroot/stdout
1042 ret=$?
1043 if [ $ret -ne 0 ]; then
1044 diff -u $testroot/stdout.expected $testroot/stdout
1045 test_done "$testroot" "$ret"
1046 return 1
1049 (cd $testroot/wt && got commit -mx > $testroot/stdout)
1050 ret=$?
1051 if [ $ret -ne 0 ]; then
1052 echo "got commit failed unexpectedly"
1053 test_done "$testroot" "$ret"
1054 return 1
1057 local commit_id=`git_show_head $testroot/repo`
1058 echo 'm alpha' > $testroot/stdout.expected
1059 echo "Created commit $commit_id" >> $testroot/stdout.expected
1060 cmp -s $testroot/stdout.expected $testroot/stdout
1061 ret=$?
1062 if [ $ret -ne 0 ]; then
1063 diff -u $testroot/stdout.expected $testroot/stdout
1064 test_done "$testroot" "$ret"
1065 return 1
1068 chmod +x $testroot/wt/alpha
1070 echo 'm alpha' > $testroot/stdout.expected
1071 (cd $testroot/wt && got status > $testroot/stdout)
1073 cmp -s $testroot/stdout.expected $testroot/stdout
1074 ret=$?
1075 if [ $ret -ne 0 ]; then
1076 diff -u $testroot/stdout.expected $testroot/stdout
1078 test_done "$testroot" "$ret"
1081 commit_check_mode() {
1082 local mode="$1"
1083 local expected_mode="$2"
1085 chmod 644 $testroot/wt/alpha
1086 echo a >> $testroot/wt/alpha
1087 chmod $mode $testroot/wt/alpha
1089 (cd $testroot/wt && got commit -mm > $testroot/stdout)
1090 ret=$?
1091 if [ $ret -ne 0 ]; then
1092 echo "got commit failed unexpectedly"
1093 test_done "$testroot" "$ret"
1094 return 1
1097 local commit_id=`git_show_head $testroot/repo`
1098 echo 'M alpha' > $testroot/stdout.expected
1099 echo "Created commit $commit_id" >> $testroot/stdout.expected
1100 cmp -s $testroot/stdout.expected $testroot/stdout
1101 ret=$?
1102 if [ $ret -ne 0 ]; then
1103 diff -u $testroot/stdout.expected $testroot/stdout
1104 test_done "$testroot" "$ret"
1105 return 1
1108 local tree_id=$(got cat -r $testroot/repo $commit_id | \
1109 grep ^tree | cut -d' ' -f2)
1110 local alpha_id=$(got cat -r $testroot/repo $tree_id | \
1111 grep 'alpha$' | cut -d' ' -f1)
1112 echo "$alpha_id $expected_mode alpha" > $testroot/stdout.expected
1113 got cat -r $testroot/repo $tree_id | grep 'alpha$' > $testroot/stdout
1114 cmp -s $testroot/stdout.expected $testroot/stdout
1115 ret=$?
1116 if [ $ret -ne 0 ]; then
1117 diff -u $testroot/stdout.expected $testroot/stdout
1119 return $ret
1122 test_commit_normalizes_filemodes() {
1123 local testroot=`test_init commit_normalizes_filemodes`
1125 got checkout $testroot/repo $testroot/wt > /dev/null
1126 ret=$?
1127 if [ $ret -ne 0 ]; then
1128 test_done "$testroot" "$ret"
1129 return 1
1132 modes="600 400 460 640 440 660 444 666"
1133 for m in $modes; do
1134 commit_check_mode "$m" "0100644"
1135 ret=$?
1136 if [ $ret -ne 0 ]; then
1137 break
1139 done
1140 if [ $ret -ne 0 ]; then
1141 test_done "$testroot" "$ret"
1142 return 1
1144 modes="700 500 570 750 550 770 555 777"
1145 for m in $modes; do
1146 commit_check_mode "$m" "0100755"
1147 ret=$?
1148 if [ $ret -ne 0 ]; then
1149 break
1151 done
1152 if [ $ret -ne 0 ]; then
1153 test_done "$testroot" "$ret"
1154 return 1
1156 test_done "$testroot" "$ret"
1159 test_commit_with_unrelated_submodule() {
1160 local testroot=`test_init commit_with_unrelated_submodule`
1162 make_single_file_repo $testroot/repo2 foo
1164 (cd $testroot/repo && git -c protocol.file.allow=always \
1165 submodule -q add ../repo2)
1166 (cd $testroot/repo && git commit -q -m 'adding submodule')
1168 got checkout $testroot/repo $testroot/wt > /dev/null
1169 ret=$?
1170 if [ $ret -ne 0 ]; then
1171 echo "checkout failed unexpectedly" >&2
1172 test_done "$testroot" "$ret"
1173 return 1
1176 echo "modified alpha" > $testroot/wt/alpha
1178 echo "" > $testroot/stdout.expected
1180 (cd $testroot/wt && got commit -m 'modify alpha' > $testroot/stdout)
1181 ret=$?
1182 if [ $ret -ne 0 ]; then
1183 echo "commit failed unexpectedly" >&2
1184 test_done "$testroot" "$ret"
1185 return 1
1188 local head_rev=`git_show_head $testroot/repo`
1189 echo "M alpha" > $testroot/stdout.expected
1190 echo "Created commit $head_rev" >> $testroot/stdout.expected
1192 cmp -s $testroot/stdout.expected $testroot/stdout
1193 ret=$?
1194 if [ $ret -ne 0 ]; then
1195 diff -u $testroot/stdout.expected $testroot/stdout
1197 test_done "$testroot" "$ret"
1200 check_symlinks() {
1201 local wtpath="$1"
1202 if ! [ -h $wtpath/alpha.link ]; then
1203 echo "alpha.link is not a symlink"
1204 return 1
1207 readlink $wtpath/alpha.link > $testroot/stdout
1208 echo "alpha" > $testroot/stdout.expected
1209 cmp -s $testroot/stdout.expected $testroot/stdout
1210 ret=$?
1211 if [ $ret -ne 0 ]; then
1212 diff -u $testroot/stdout.expected $testroot/stdout
1213 return 1
1216 if ! [ -h $wtpath/epsilon.link ]; then
1217 echo "epsilon.link is not a symlink"
1218 return 1
1221 readlink $wtpath/epsilon.link > $testroot/stdout
1222 echo "epsilon" > $testroot/stdout.expected
1223 cmp -s $testroot/stdout.expected $testroot/stdout
1224 ret=$?
1225 if [ $ret -ne 0 ]; then
1226 diff -u $testroot/stdout.expected $testroot/stdout
1227 return 1
1230 if [ -h $wtpath/passwd.link ]; then
1231 echo -n "passwd.link is a symlink and points outside of work tree: " >&2
1232 readlink $wtpath/passwd.link >&2
1233 return 1
1236 echo -n "/etc/passwd" > $testroot/content.expected
1237 cp $wtpath/passwd.link $testroot/content
1238 ret=$?
1239 if [ $ret -ne 0 ]; then
1240 echo "cp command failed unexpectedly" >&2
1241 return 1
1244 cmp -s $testroot/content.expected $testroot/content
1245 ret=$?
1246 if [ $ret -ne 0 ]; then
1247 diff -u $testroot/content.expected $testroot/content
1248 return 1
1251 readlink $wtpath/epsilon/beta.link > $testroot/stdout
1252 echo "../beta" > $testroot/stdout.expected
1253 cmp -s $testroot/stdout.expected $testroot/stdout
1254 ret=$?
1255 if [ $ret -ne 0 ]; then
1256 diff -u $testroot/stdout.expected $testroot/stdout
1257 return 1
1260 readlink $wtpath/nonexistent.link > $testroot/stdout
1261 echo "nonexistent" > $testroot/stdout.expected
1262 cmp -s $testroot/stdout.expected $testroot/stdout
1263 ret=$?
1264 if [ $ret -ne 0 ]; then
1265 diff -u $testroot/stdout.expected $testroot/stdout
1266 return 1
1269 return 0
1272 test_commit_symlink() {
1273 local testroot=`test_init commit_symlink`
1275 got checkout $testroot/repo $testroot/wt > /dev/null
1276 ret=$?
1277 if [ $ret -ne 0 ]; then
1278 test_done "$testroot" "$ret"
1279 return 1
1282 (cd $testroot/wt && ln -s alpha alpha.link)
1283 (cd $testroot/wt && ln -s epsilon epsilon.link)
1284 (cd $testroot/wt && ln -s /etc/passwd passwd.link)
1285 (cd $testroot/wt && ln -s ../beta epsilon/beta.link)
1286 (cd $testroot/wt && ln -s nonexistent nonexistent.link)
1287 (cd $testroot/wt && got add alpha.link epsilon.link passwd.link \
1288 epsilon/beta.link nonexistent.link > /dev/null)
1290 (cd $testroot/wt && got commit -m 'test commit_symlink' \
1291 > $testroot/stdout 2> $testroot/stderr)
1292 ret=$?
1293 if [ $ret -eq 0 ]; then
1294 echo "got commit succeeded unexpectedly" >&2
1295 test_done "$testroot" "$ret"
1296 return 1
1298 echo -n "got: $testroot/wt/passwd.link: " > $testroot/stderr.expected
1299 echo "symbolic link points outside of paths under version control" \
1300 >> $testroot/stderr.expected
1301 cmp -s $testroot/stderr.expected $testroot/stderr
1302 ret=$?
1303 if [ $ret -ne 0 ]; then
1304 diff -u $testroot/stderr.expected $testroot/stderr
1305 test_done "$testroot" "$ret"
1306 return 1
1309 (cd $testroot/wt && got commit -S -m 'test commit_symlink' \
1310 > $testroot/stdout)
1312 local head_rev=`git_show_head $testroot/repo`
1313 echo "A alpha.link" > $testroot/stdout.expected
1314 echo "A epsilon.link" >> $testroot/stdout.expected
1315 echo "A nonexistent.link" >> $testroot/stdout.expected
1316 echo "A passwd.link" >> $testroot/stdout.expected
1317 echo "A epsilon/beta.link" >> $testroot/stdout.expected
1318 echo "Created commit $head_rev" >> $testroot/stdout.expected
1320 cmp -s $testroot/stdout.expected $testroot/stdout
1321 ret=$?
1322 if [ $ret -ne 0 ]; then
1323 diff -u $testroot/stdout.expected $testroot/stdout
1324 test_done "$testroot" "$ret"
1325 return 1
1328 # verify created in-repository tree
1329 got checkout $testroot/repo $testroot/wt2 > /dev/null
1330 ret=$?
1331 if [ $ret -ne 0 ]; then
1332 test_done "$testroot" "$ret"
1333 return 1
1335 check_symlinks $testroot/wt2
1336 ret=$?
1337 if [ $ret -ne 0 ]; then
1338 test_done "$testroot" "$ret"
1339 return 1
1342 if ! [ -h $testroot/wt/passwd.link ]; then
1343 echo 'passwd.link is not a symlink' >&2
1344 test_done "$testroot" 1
1345 return 1
1348 # 'got update' should reinstall passwd.link as a regular file
1349 (cd $testroot/wt && got update > /dev/null)
1350 check_symlinks $testroot/wt
1351 ret=$?
1352 if [ $ret -ne 0 ]; then
1353 test_done "$testroot" "$ret"
1354 return 1
1357 (cd $testroot/wt && ln -sf beta alpha.link)
1358 (cd $testroot/wt && ln -sfh gamma epsilon.link)
1359 rm $testroot/wt/epsilon/beta.link
1360 echo "this is a regular file" > $testroot/wt/epsilon/beta.link
1361 (cd $testroot/wt && ln -sf .got/bar dotgotbar.link)
1362 (cd $testroot/wt && got add dotgotbar.link > /dev/null)
1363 (cd $testroot/wt && got rm nonexistent.link > /dev/null)
1364 (cd $testroot/wt && ln -sf gamma/delta zeta.link)
1365 (cd $testroot/wt && ln -sf alpha new.link)
1366 (cd $testroot/wt && got add new.link > /dev/null)
1368 (cd $testroot/wt && got commit -m 'test commit_symlink' \
1369 > $testroot/stdout 2> $testroot/stderr)
1370 ret=$?
1371 if [ $ret -eq 0 ]; then
1372 echo "got commit succeeded unexpectedly" >&2
1373 test_done "$testroot" "$ret"
1374 return 1
1376 echo -n "got: $testroot/wt/dotgotbar.link: " > $testroot/stderr.expected
1377 echo "symbolic link points outside of paths under version control" \
1378 >> $testroot/stderr.expected
1379 cmp -s $testroot/stderr.expected $testroot/stderr
1380 ret=$?
1381 if [ $ret -ne 0 ]; then
1382 diff -u $testroot/stderr.expected $testroot/stderr
1383 test_done "$testroot" "$ret"
1384 return 1
1387 (cd $testroot/wt && got commit -S -m 'test commit_symlink' \
1388 > $testroot/stdout)
1390 local head_rev=`git_show_head $testroot/repo`
1391 echo "A dotgotbar.link" > $testroot/stdout.expected
1392 echo "A new.link" >> $testroot/stdout.expected
1393 echo "M alpha.link" >> $testroot/stdout.expected
1394 echo "M epsilon/beta.link" >> $testroot/stdout.expected
1395 echo "M epsilon.link" >> $testroot/stdout.expected
1396 echo "D nonexistent.link" >> $testroot/stdout.expected
1397 echo "Created commit $head_rev" >> $testroot/stdout.expected
1399 cmp -s $testroot/stdout.expected $testroot/stdout
1400 ret=$?
1401 if [ $ret -ne 0 ]; then
1402 diff -u $testroot/stdout.expected $testroot/stdout
1403 test_done "$testroot" "$ret"
1404 return 1
1407 got tree -r $testroot/repo -c $head_rev -R > $testroot/stdout
1408 cat > $testroot/stdout.expected <<EOF
1409 alpha
1410 alpha.link@ -> beta
1411 beta
1412 dotgotbar.link@ -> .got/bar
1413 epsilon/
1414 epsilon/beta.link
1415 epsilon/zeta
1416 epsilon.link@ -> gamma
1417 gamma/
1418 gamma/delta
1419 new.link@ -> alpha
1420 passwd.link@ -> /etc/passwd
1421 EOF
1422 cmp -s $testroot/stdout.expected $testroot/stdout
1423 ret=$?
1424 if [ $ret -ne 0 ]; then
1425 diff -u $testroot/stdout.expected $testroot/stdout
1427 test_done "$testroot" "$ret"
1430 test_commit_fix_bad_symlink() {
1431 local testroot=`test_init commit_fix_bad_symlink`
1433 got checkout $testroot/repo $testroot/wt > /dev/null
1434 ret=$?
1435 if [ $ret -ne 0 ]; then
1436 echo "got checkout failed unexpectedly" >&2
1437 test_done "$testroot" "$ret"
1438 return 1
1441 (cd $testroot/wt && ln -s /etc/passwd passwd.link)
1442 (cd $testroot/wt && got add passwd.link > /dev/null)
1444 (cd $testroot/wt && got commit -S -m 'commit bad symlink' \
1445 > $testroot/stdout)
1447 if ! [ -h $testroot/wt/passwd.link ]; then
1448 echo 'passwd.link is not a symlink' >&2
1449 test_done "$testroot" 1
1450 return 1
1452 (cd $testroot/wt && got update >/dev/null)
1453 if [ -h $testroot/wt/passwd.link ]; then
1454 echo "passwd.link is a symlink but should be a regular file" >&2
1455 test_done "$testroot" "1"
1456 return 1
1459 # create another work tree which will contain the "bad" symlink
1460 got checkout $testroot/repo $testroot/wt2 > /dev/null
1461 ret=$?
1462 if [ $ret -ne 0 ]; then
1463 echo "got checkout failed unexpectedly" >&2
1464 test_done "$testroot" "$ret"
1465 return 1
1468 # change "bad" symlink back into a "good" symlink
1469 (cd $testroot/wt && ln -sfh alpha passwd.link)
1471 (cd $testroot/wt && got commit -m 'fix bad symlink' \
1472 > $testroot/stdout)
1474 local head_rev=`git_show_head $testroot/repo`
1475 echo "M passwd.link" > $testroot/stdout.expected
1476 echo "Created commit $head_rev" >> $testroot/stdout.expected
1478 cmp -s $testroot/stdout.expected $testroot/stdout
1479 ret=$?
1480 if [ $ret -ne 0 ]; then
1481 diff -u $testroot/stdout.expected $testroot/stdout
1482 test_done "$testroot" "$ret"
1483 return 1
1486 if ! [ -h $testroot/wt/passwd.link ]; then
1487 echo 'passwd.link is not a symlink' >&2
1488 test_done "$testroot" 1
1489 return 1
1492 readlink $testroot/wt/passwd.link > $testroot/stdout
1493 echo "alpha" > $testroot/stdout.expected
1494 cmp -s $testroot/stdout.expected $testroot/stdout
1495 ret=$?
1496 if [ $ret -ne 0 ]; then
1497 diff -u $testroot/stdout.expected $testroot/stdout
1498 return 1
1501 # Update the other work tree; the bad symlink should be fixed
1502 (cd $testroot/wt2 && got update > /dev/null)
1503 ret=$?
1504 if [ $ret -ne 0 ]; then
1505 echo "got checkout failed unexpectedly" >&2
1506 test_done "$testroot" "$ret"
1507 return 1
1510 if ! [ -h $testroot/wt2/passwd.link ]; then
1511 echo 'passwd.link is not a symlink' >&2
1512 test_done "$testroot" 1
1513 return 1
1516 readlink $testroot/wt2/passwd.link > $testroot/stdout
1517 echo "alpha" > $testroot/stdout.expected
1518 cmp -s $testroot/stdout.expected $testroot/stdout
1519 ret=$?
1520 if [ $ret -ne 0 ]; then
1521 diff -u $testroot/stdout.expected $testroot/stdout
1522 return 1
1525 test_done "$testroot" "0"
1528 test_commit_prepared_logmsg() {
1529 local testroot=`test_init commit_prepared_logmsg`
1531 got checkout $testroot/repo $testroot/wt > /dev/null
1532 ret=$?
1533 if [ $ret -ne 0 ]; then
1534 test_done "$testroot" "$ret"
1535 return 1
1538 echo "modified alpha" > $testroot/wt/alpha
1539 (cd $testroot/wt && got rm beta >/dev/null)
1540 echo "new file" > $testroot/wt/new
1541 (cd $testroot/wt && got add new >/dev/null)
1543 echo 'test commit_prepared_logmsg' > $testroot/logmsg
1545 cat > $testroot/editor.sh <<EOF
1546 #!/bin/sh
1547 sed -i 's/foo/bar/' "\$1"
1548 EOF
1549 chmod +x $testroot/editor.sh
1551 (cd $testroot/wt && env VISUAL="$testroot/editor.sh" \
1552 got commit -F "$testroot/logmsg" > $testroot/stdout)
1554 local head_rev=`git_show_head $testroot/repo`
1555 echo "A new" > $testroot/stdout.expected
1556 echo "M alpha" >> $testroot/stdout.expected
1557 echo "D beta" >> $testroot/stdout.expected
1558 echo "Created commit $head_rev" >> $testroot/stdout.expected
1560 cmp -s $testroot/stdout.expected $testroot/stdout
1561 ret=$?
1562 if [ $ret -ne 0 ]; then
1563 diff -u $testroot/stdout.expected $testroot/stdout
1564 test_done "$testroot" "$ret"
1565 return 1
1568 local author_time=`git_show_author_time $testroot/repo`
1569 d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
1570 echo "-----------------------------------------------" > $testroot/stdout.expected
1571 echo "commit $head_rev (master)" >> $testroot/stdout.expected
1572 echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
1573 echo "date: $d" >> $testroot/stdout.expected
1574 echo " " >> $testroot/stdout.expected
1575 echo " test commit_prepared_logmsg" >> $testroot/stdout.expected
1576 echo " " >> $testroot/stdout.expected
1578 (cd $testroot/wt && got log -l 1 > $testroot/stdout)
1579 cmp -s $testroot/stdout.expected $testroot/stdout
1580 ret=$?
1581 if [ $ret -ne 0 ]; then
1582 diff -u $testroot/stdout.expected $testroot/stdout
1583 test_done "$testroot" "$ret"
1584 return 1
1587 echo "modified alpha again" > $testroot/wt/alpha
1589 echo 'test commit_prepared_logmsg non-interactive' \
1590 > $testroot/logmsg
1592 (cd $testroot/wt && got commit -N -F "$testroot/logmsg" \
1593 > $testroot/stdout)
1595 local head_rev=`git_show_head $testroot/repo`
1596 echo "M alpha" > $testroot/stdout.expected
1597 echo "Created commit $head_rev" >> $testroot/stdout.expected
1599 cmp -s $testroot/stdout.expected $testroot/stdout
1600 ret=$?
1601 if [ $ret -ne 0 ]; then
1602 diff -u $testroot/stdout.expected $testroot/stdout
1603 test_done "$testroot" "$ret"
1604 return 1
1607 local author_time=`git_show_author_time $testroot/repo`
1608 d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
1609 echo "-----------------------------------------------" \
1610 > $testroot/stdout.expected
1611 echo "commit $head_rev (master)" >> $testroot/stdout.expected
1612 echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
1613 echo "date: $d" >> $testroot/stdout.expected
1614 echo " " >> $testroot/stdout.expected
1615 echo " test commit_prepared_logmsg non-interactive" \
1616 >> $testroot/stdout.expected
1617 echo " " >> $testroot/stdout.expected
1619 (cd $testroot/wt && got log -l 1 > $testroot/stdout)
1620 cmp -s $testroot/stdout.expected $testroot/stdout
1621 ret=$?
1622 if [ $ret -ne 0 ]; then
1623 diff -u $testroot/stdout.expected $testroot/stdout
1625 test_done "$testroot" "$ret"
1628 test_commit_large_file() {
1629 local testroot=`test_init commit_large_file`
1631 got checkout $testroot/repo $testroot/wt > /dev/null
1632 ret=$?
1633 if [ $ret -ne 0 ]; then
1634 test_done "$testroot" "$ret"
1635 return 1
1638 dd status=none if=/dev/zero of=$testroot/wt/new bs=1M count=64
1639 (cd $testroot/wt && got add new >/dev/null)
1641 (cd $testroot/wt && got commit -m 'test commit_large_file' \
1642 > $testroot/stdout)
1644 local head_rev=`git_show_head $testroot/repo`
1645 echo "A new" > $testroot/stdout.expected
1646 echo "Created commit $head_rev" >> $testroot/stdout.expected
1648 cmp -s $testroot/stdout.expected $testroot/stdout
1649 ret=$?
1650 if [ $ret -ne 0 ]; then
1651 diff -u $testroot/stdout.expected $testroot/stdout
1652 test_done "$testroot" "$ret"
1653 return 1
1656 new_id=`get_blob_id $testroot/repo "" new`
1657 got cat -r $testroot/repo $new_id > $testroot/new
1658 ret=$?
1659 if [ $ret -ne 0 ]; then
1660 echo "commit failed unexpectedly" >&2
1661 test_done "$testroot" "1"
1662 return 1
1665 cmp -s $testroot/new $testroot/wt/new
1666 ret=$?
1667 if [ $ret -ne 0 ]; then
1668 diff -u $testroot/new $testroot/wt/new
1670 test_done "$testroot" "$ret"
1675 test_commit_gitignore() {
1676 local testroot=`test_init commit_gitignores`
1678 got checkout $testroot/repo $testroot/wt > /dev/null
1679 ret=$?
1680 if [ $ret -ne 0 ]; then
1681 test_done "$testroot" "$ret"
1682 return 1
1685 mkdir -p $testroot/wt/tree1/foo
1686 mkdir -p $testroot/wt/tree2/foo
1687 echo "tree1/**" > $testroot/wt/.gitignore
1688 echo "tree2/**" >> $testroot/wt/.gitignore
1689 echo -n > $testroot/wt/tree1/bar
1690 echo -n > $testroot/wt/tree1/foo/baz
1691 echo -n > $testroot/wt/tree2/bar
1692 echo -n > $testroot/wt/tree2/foo/baz
1693 echo -n > $testroot/wt/epsilon/zeta1
1694 echo -n > $testroot/wt/epsilon/zeta2
1696 (cd $testroot/wt && got add -I -R tree1 > /dev/null)
1697 (cd $testroot/wt && got add -I tree2/foo/baz > /dev/null)
1698 (cd $testroot/wt && got commit -m "gitignore add" > /dev/null)
1699 (cd $testroot/wt && got log -P -l 1 | egrep '^ .' > $testroot/stdout)
1701 echo ' gitignore add' > $testroot/stdout.expected
1702 echo ' A tree1/bar' >> $testroot/stdout.expected
1703 echo ' A tree1/foo/baz' >> $testroot/stdout.expected
1704 echo ' A tree2/foo/baz' >> $testroot/stdout.expected
1706 cmp -s $testroot/stdout.expected $testroot/stdout
1707 ret=$?
1708 if [ $ret -ne 0 ]; then
1709 diff -u $testroot/stdout.expected $testroot/stdout
1710 test_done "$testroot" "$ret"
1711 return 1
1714 echo touch > $testroot/wt/tree1/bar
1715 echo touch > $testroot/wt/tree1/foo/baz
1716 echo touch > $testroot/wt/epsilon/zeta1
1718 (cd $testroot/wt && got commit -m "gitignore change" > /dev/null)
1719 (cd $testroot/wt && got log -P -l 1 | egrep '^ .' > $testroot/stdout)
1721 echo ' gitignore change' > $testroot/stdout.expected
1722 echo ' M tree1/bar' >> $testroot/stdout.expected
1723 echo ' M tree1/foo/baz' >> $testroot/stdout.expected
1725 cmp -s $testroot/stdout.expected $testroot/stdout
1726 ret=$?
1727 if [ $ret -ne 0 ]; then
1728 diff -u $testroot/stdout.expected $testroot/stdout
1729 test_done "$testroot" "$ret"
1730 return 1
1733 test_done "$testroot" "$ret"
1736 test_commit_bad_author() {
1737 local testroot=`test_init commit_bad_author`
1739 got checkout $testroot/repo $testroot/wt > /dev/null
1740 ret=$?
1741 if [ $ret -ne 0 ]; then
1742 test_done "$testroot" $ret
1743 return 1
1746 echo "modified alpha" > $testroot/wt/alpha
1748 (cd $testroot/wt && got commit \
1749 -A "${GIT_AUTHOR_NAME}<${GIT_AUTHOR_EMAIL}>" -m 'edit alpha') \
1750 > /dev/null 2> $testroot/stderr
1751 ret=$?
1752 if [ $ret -eq 0 ]; then
1753 test_done "$testroot" 1
1754 return 1
1757 echo -n "got: ${GIT_AUTHOR_NAME}<${GIT_AUTHOR_EMAIL}>: " \
1758 > $testroot/stderr.expected
1759 echo -n 'space between author name and email required: ' \
1760 >> $testroot/stderr.expected
1761 echo 'commit author formatting would make Git unhappy' \
1762 >> $testroot/stderr.expected
1763 cmp -s $testroot/stderr.expected $testroot/stderr
1764 ret=$?
1765 if [ $ret -ne 0 ]; then
1766 diff -u $testroot/stderr.expected $testroot/stderr
1767 test_done "$testroot" $ret
1768 return 1
1771 test_done "$testroot" 0
1774 test_commit_logmsg_ref() {
1775 local testroot=`test_init commit_logmsg_ref`
1777 got checkout $testroot/repo $testroot/wt > /dev/null
1778 ret=$?
1779 if [ $ret -ne 0 ]; then
1780 test_done "$testroot" "$ret"
1781 return 1
1784 (cd $testroot/repo && git checkout -q -b newbranch)
1786 local bo_logmsg_prefix="log message of backed-out commit"
1787 local cy_logmsg_prefix="log message of cherrypicked commit"
1788 local branch_rev_logmsg="changes on newbranch to cherrypick"
1789 local branch_rev2_logmsg="modified zeta on newbranch to cherrypick"
1791 echo "modified delta on branch" > $testroot/repo/gamma/delta
1792 echo "modified alpha on branch" > $testroot/repo/alpha
1793 (cd $testroot/repo && git rm -q beta)
1794 echo "new file on branch" > $testroot/repo/epsilon/new
1795 (cd $testroot/repo && git add epsilon/new)
1797 git_commit $testroot/repo -m "$branch_rev_logmsg"
1798 local branch_rev=`git_show_head $testroot/repo`
1800 echo "modified zeta on branch" > $testroot/repo/epsilon/zeta
1802 git_commit $testroot/repo -m "$branch_rev2_logmsg"
1803 local branch_rev2=`git_show_head $testroot/repo`
1805 (cd $testroot/wt && got cherrypick $branch_rev > /dev/null)
1806 (cd $testroot/wt && got cherrypick $branch_rev2 > /dev/null)
1808 cat > $testroot/editor.sh <<EOF
1809 #!/bin/sh
1810 sed -i 's/# l/l/' "\$1"
1811 EOF
1812 chmod +x $testroot/editor.sh
1814 (cd $testroot/wt && 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 # check that multiple cherrypicked log messages populate the editor
1824 local first=`printf '%s\n%s' $branch_rev $branch_rev2 | sort | head -1`
1825 local second=`printf '%s\n%s' $branch_rev $branch_rev2 | sort | tail -1`
1827 if [ $branch_rev == $first ]; then
1828 local first_msg=$branch_rev_logmsg
1829 local second_msg=$branch_rev2_logmsg
1830 else
1831 local first_msg=$branch_rev2_logmsg
1832 local second_msg=$branch_rev_logmsg
1835 echo " $cy_logmsg_prefix $first:" > $testroot/stdout.expected
1836 echo " $first_msg" >> $testroot/stdout.expected
1837 echo " " >> $testroot/stdout.expected
1838 echo " $cy_logmsg_prefix $second:" >> $testroot/stdout.expected
1839 echo " $second_msg" >> $testroot/stdout.expected
1840 echo " " >> $testroot/stdout.expected
1842 (cd $testroot/wt && got log -l2 | \
1843 grep -A2 'log message' | sed '/^--/d' > $testroot/stdout)
1845 cmp -s $testroot/stdout.expected $testroot/stdout
1846 ret=$?
1847 if [ $ret -ne 0 ]; then
1848 diff -u $testroot/stdout.expected $testroot/stdout
1849 test_done "$testroot" "$ret"
1850 return 1
1853 # check that only the relevant log message populates the editor
1854 # when the changes from one of two backout commits are reverted
1855 got checkout $testroot/repo $testroot/wt2 > /dev/null
1856 ret=$?
1857 if [ $ret -ne 0 ]; then
1858 test_done "$testroot" "$ret"
1859 return 1
1862 (cd $testroot/wt2 && got backout $branch_rev > /dev/null)
1863 (cd $testroot/wt2 && got backout $branch_rev2 > /dev/null)
1864 (cd $testroot/wt2 && got revert epsilon/zeta > /dev/null)
1866 (cd $testroot/wt2 && env VISUAL="$testroot/editor.sh" \
1867 got commit > /dev/null)
1868 ret=$?
1869 if [ $ret -ne 0 ]; then
1870 echo "'got commit' failed unexpectedly" >&2
1871 test_done "$testroot" "1"
1872 return 1
1875 echo " $bo_logmsg_prefix $branch_rev:" > $testroot/stdout.expected
1876 echo " $branch_rev_logmsg" >> $testroot/stdout.expected
1877 echo " " >> $testroot/stdout.expected
1879 (cd $testroot/wt2 && got log -l1 | \
1880 grep -A2 'log message' > $testroot/stdout)
1882 cmp -s $testroot/stdout.expected $testroot/stdout
1883 ret=$?
1884 if [ $ret -ne 0 ]; then
1885 diff -u $testroot/stdout.expected $testroot/stdout
1886 test_done "$testroot" "$ret"
1887 return 1
1890 # check that a cherrypicked log message is still
1891 # used when its changes are only partially reverted
1892 branch_rev_logmsg="changes to cherrypick and partially revert"
1894 echo "newline in alpha" >> $testroot/repo/alpha
1895 echo "modified epsilon/zeta on branch" > $testroot/repo/epsilon/zeta
1897 git_commit $testroot/repo -m "$branch_rev_logmsg"
1898 branch_rev=`git_show_head $testroot/repo`
1900 (cd $testroot/wt && got cherrypick $branch_rev > /dev/null)
1901 (cd $testroot/wt && got revert alpha > /dev/null)
1903 (cd $testroot/wt && env VISUAL="$testroot/editor.sh" \
1904 got commit > /dev/null)
1905 ret=$?
1906 if [ $ret -ne 0 ]; then
1907 echo "'got commit' failed unexpectedly" >&2
1908 test_done "$testroot" "1"
1909 return 1
1912 echo " $cy_logmsg_prefix $branch_rev:" > $testroot/stdout.expected
1913 echo " $branch_rev_logmsg" >> $testroot/stdout.expected
1914 echo " " >> $testroot/stdout.expected
1916 (cd $testroot/wt && got log -l1 | \
1917 grep -A2 'log message' > $testroot/stdout)
1919 cmp -s $testroot/stdout.expected $testroot/stdout
1920 ret=$?
1921 if [ $ret -ne 0 ]; then
1922 diff -u $testroot/stdout.expected $testroot/stdout
1923 test_done "$testroot" "$ret"
1924 return 1
1927 # check we don't use and consequently delete the logmsg ref of a
1928 # cherrypicked commit when omitting its changed path from the commit
1929 branch_rev_logmsg="changes to cherrypick but omit from the commit"
1931 echo "changed delta" >> $testroot/repo/gamma/delta
1933 git_commit $testroot/repo -m "$branch_rev_logmsg"
1934 local author_time=`git_show_author_time $testroot/repo`
1935 local d=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
1936 branch_rev=`git_show_head $testroot/repo`
1938 (cd $testroot/wt && got update > /dev/null)
1939 ret=$?
1940 if [ $ret -ne 0 ]; then
1941 echo "got update failed unexpectedly" >&2
1942 test_done "$testroot" "$ret"
1943 return 1
1946 (cd $testroot/wt && got cherrypick $branch_rev > /dev/null)
1948 echo "changed alpha" >> $testroot/wt/alpha
1950 (cd $testroot/wt && got commit -m \
1951 "don't commit cy change to gamma/delta" alpha > /dev/null)
1952 ret=$?
1953 if [ $ret -ne 0 ]; then
1954 echo "'got commit' failed unexpectedly" >&2
1955 test_done "$testroot" "1"
1956 return 1
1959 # confirm logmsg ref was not deleted with got cherrypick -l
1960 echo "-----------------------------------------------" \
1961 > $testroot/stdout.expected
1962 echo "cherrypick $branch_rev (newbranch)" >> $testroot/stdout.expected
1963 echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
1964 echo "date: $d" >> $testroot/stdout.expected
1965 echo " " >> $testroot/stdout.expected
1966 echo " $branch_rev_logmsg" >> $testroot/stdout.expected
1967 echo " " >> $testroot/stdout.expected
1968 echo " M gamma/delta" >> $testroot/stdout.expected
1969 echo >> $testroot/stdout.expected
1971 (cd $testroot/wt && got cherrypick -l > $testroot/stdout)
1973 cmp -s $testroot/stdout.expected $testroot/stdout
1974 ret=$?
1975 if [ $ret -ne 0 ]; then
1976 diff -u $testroot/stdout.expected $testroot/stdout
1977 test_done "$testroot" "$ret"
1978 return 1
1981 # confirm a previously unused logmsg ref is picked up
1982 # when an affected path is actually committed
1983 (cd $testroot/wt && env VISUAL="$testroot/editor.sh" \
1984 got commit > /dev/null)
1985 ret=$?
1986 if [ $ret -ne 0 ]; then
1987 echo "'got commit' failed unexpectedly" >&2
1988 test_done "$testroot" "1"
1989 return 1
1992 echo " $cy_logmsg_prefix $branch_rev:" > $testroot/stdout.expected
1993 echo " $branch_rev_logmsg" >> $testroot/stdout.expected
1994 echo " " >> $testroot/stdout.expected
1996 (cd $testroot/wt && got log -l1 | \
1997 grep -A2 'log message' > $testroot/stdout)
1999 cmp -s $testroot/stdout.expected $testroot/stdout
2000 ret=$?
2001 if [ $ret -ne 0 ]; then
2002 diff -u $testroot/stdout.expected $testroot/stdout
2003 test_done "$testroot" "$ret"
2004 return 1
2007 # make sure we are not littering work trees
2008 # by leaving temp got-logmsg-* files behind
2009 echo -n > $testroot/stdout.expected
2010 (cd $testroot/wt && got status > $testroot/stdout)
2012 cmp -s $testroot/stdout.expected $testroot/stdout
2013 ret=$?
2014 if [ $ret -ne 0 ]; then
2015 echo "$testroot/wt is not clean"
2016 diff -u $testroot/stdout.expected $testroot/stdout
2017 test_done "$testroot" "$ret"
2018 return 1
2021 (cd $testroot/wt2 && got status > $testroot/stdout)
2023 cmp -s $testroot/stdout.expected $testroot/stdout
2024 ret=$?
2025 if [ $ret -ne 0 ]; then
2026 echo "$testroot/repo is not clean"
2027 diff -u $testroot/stdout.expected $testroot/stdout
2029 test_done "$testroot" "$ret"
2032 test_parseargs "$@"
2033 run_test test_commit_basic
2034 run_test test_commit_new_subdir
2035 run_test test_commit_subdir
2036 run_test test_commit_single_file
2037 run_test test_commit_out_of_date
2038 run_test test_commit_added_subdirs
2039 run_test test_commit_deleted_subdirs
2040 run_test test_commit_rejects_conflicted_file
2041 run_test test_commit_single_file_multiple
2042 run_test test_commit_added_and_modified_in_same_dir
2043 run_test test_commit_path_prefix
2044 run_test test_commit_dir_path
2045 run_test test_commit_selected_paths
2046 run_test test_commit_outside_refs_heads
2047 run_test test_commit_no_email
2048 run_test test_commit_tree_entry_sorting
2049 run_test test_commit_cmdline_author
2050 run_test test_commit_gotconfig_author
2051 run_test test_commit_gotconfig_worktree_author
2052 run_test test_commit_gitconfig_author
2053 run_test test_commit_xbit_change
2054 run_test test_commit_normalizes_filemodes
2055 run_test test_commit_with_unrelated_submodule
2056 run_test test_commit_symlink
2057 run_test test_commit_fix_bad_symlink
2058 run_test test_commit_prepared_logmsg
2059 run_test test_commit_large_file
2060 run_test test_commit_gitignore
2061 run_test test_commit_bad_author
2062 run_test test_commit_logmsg_ref