3 # Copyright (c) 2019, 2020 Stefan Sperling <stsp@openbsd.org>
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.
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.
19 function test_log_in_repo {
20 local testroot=`test_init log_in_repo`
21 local head_rev=`git_show_head $testroot/repo`
23 echo "commit $head_rev (master)" > $testroot/stdout.expected
25 for p in "" "." alpha epsilon epsilon/zeta; do
26 (cd $testroot/repo && got log $p | \
27 grep ^commit > $testroot/stdout)
28 cmp -s $testroot/stdout.expected $testroot/stdout
30 if [ "$ret" != "0" ]; then
31 diff -u $testroot/stdout.expected $testroot/stdout
32 test_done "$testroot" "$ret"
37 for p in "" "." zeta; do
38 (cd $testroot/repo/epsilon && got log $p | \
39 grep ^commit > $testroot/stdout)
40 cmp -s $testroot/stdout.expected $testroot/stdout
42 if [ "$ret" != "0" ]; then
43 diff -u $testroot/stdout.expected $testroot/stdout
44 test_done "$testroot" "$ret"
49 test_done "$testroot" "0"
52 function test_log_in_bare_repo {
53 local testroot=`test_init log_in_bare_repo`
54 local head_rev=`git_show_head $testroot/repo`
56 echo "commit $head_rev (master)" > $testroot/stdout.expected
58 for p in "" "." alpha epsilon epsilon/zeta; do
59 (cd $testroot/repo/.git && got log $p | \
60 grep ^commit > $testroot/stdout)
61 cmp -s $testroot/stdout.expected $testroot/stdout
63 if [ "$ret" != "0" ]; then
64 diff -u $testroot/stdout.expected $testroot/stdout
65 test_done "$testroot" "$ret"
70 test_done "$testroot" "0"
73 function test_log_in_worktree {
74 local testroot=`test_init log_in_worktree 1`
76 make_test_tree $testroot/repo
77 mkdir -p $testroot/repo/epsilon/d
78 echo foo > $testroot/repo/epsilon/d/foo
79 (cd $testroot/repo && git add .)
80 git_commit $testroot/repo -m "adding the test tree"
81 local head_commit=`git_show_head $testroot/repo`
83 got checkout $testroot/repo $testroot/wt > /dev/null
85 if [ "$ret" != "0" ]; then
86 test_done "$testroot" "$ret"
90 echo "commit $head_commit (master)" > $testroot/stdout.expected
92 for p in "" "." alpha epsilon; do
93 (cd $testroot/wt && got log $p | \
94 grep ^commit > $testroot/stdout)
95 cmp -s $testroot/stdout.expected $testroot/stdout
97 if [ "$ret" != "0" ]; then
98 diff -u $testroot/stdout.expected $testroot/stdout
99 test_done "$testroot" "$ret"
104 for p in "" "." zeta; do
105 (cd $testroot/wt/epsilon && got log $p | \
106 grep ^commit > $testroot/stdout)
107 cmp -s $testroot/stdout.expected $testroot/stdout
109 if [ "$ret" != "0" ]; then
110 diff -u $testroot/stdout.expected $testroot/stdout
111 test_done "$testroot" "$ret"
116 for p in "" "." foo; do
117 (cd $testroot/wt/epsilon && got log d/$p | \
118 grep ^commit > $testroot/stdout)
119 cmp -s $testroot/stdout.expected $testroot/stdout
121 if [ "$ret" != "0" ]; then
122 diff -u $testroot/stdout.expected $testroot/stdout
123 test_done "$testroot" "$ret"
128 test_done "$testroot" "0"
131 function test_log_in_worktree_with_path_prefix {
132 local testroot=`test_init log_in_prefixed_worktree`
133 local head_rev=`git_show_head $testroot/repo`
135 echo "modified zeta" > $testroot/repo/epsilon/zeta
136 git_commit $testroot/repo -m "modified zeta"
137 local zeta_rev=`git_show_head $testroot/repo`
139 echo "modified delta" > $testroot/repo/gamma/delta
140 git_commit $testroot/repo -m "modified delta"
142 got checkout -p epsilon $testroot/repo $testroot/wt > /dev/null
144 if [ "$ret" != "0" ]; then
145 test_done "$testroot" "$ret"
149 echo "commit $zeta_rev" > $testroot/stdout.expected
150 echo "commit $head_rev" >> $testroot/stdout.expected
152 for p in "" "." zeta; do
153 (cd $testroot/wt && got log $p | \
154 grep ^commit > $testroot/stdout)
155 cmp -s $testroot/stdout.expected $testroot/stdout
157 if [ "$ret" != "0" ]; then
158 diff -u $testroot/stdout.expected $testroot/stdout
159 test_done "$testroot" "$ret"
164 test_done "$testroot" "0"
167 function test_log_tag {
168 local testroot=`test_init log_tag`
169 local commit_id=`git_show_head $testroot/repo`
173 got checkout $testroot/repo $testroot/wt > /dev/null
175 if [ "$ret" != "0" ]; then
176 test_done "$testroot" "$ret"
180 (cd $testroot/repo && git tag -a -m "test" $tag)
182 echo "commit $commit_id (master, tags/$tag)" > $testroot/stdout.expected
183 (cd $testroot/wt && got log -l1 -c $tag | grep ^commit \
185 cmp -s $testroot/stdout.expected $testroot/stdout
187 if [ "$ret" != "0" ]; then
188 diff -u $testroot/stdout.expected $testroot/stdout
189 test_done "$testroot" "$ret"
193 # test a "lightweight" tag
194 (cd $testroot/repo && git tag $tag2)
196 echo "commit $commit_id (master, tags/$tag, tags/$tag2)" \
197 > $testroot/stdout.expected
198 (cd $testroot/wt && got log -l1 -c $tag2 | grep ^commit \
200 cmp -s $testroot/stdout.expected $testroot/stdout
202 if [ "$ret" != "0" ]; then
203 diff -u $testroot/stdout.expected $testroot/stdout
205 test_done "$testroot" "$ret"
208 function test_log_limit {
209 local testroot=`test_init log_limit`
210 local commit_id0=`git_show_head $testroot/repo`
212 got checkout $testroot/repo $testroot/wt > /dev/null
214 if [ "$ret" != "0" ]; then
215 test_done "$testroot" "$ret"
219 echo "modified alpha" > $testroot/wt/alpha
220 (cd $testroot/wt && got commit -m 'test log_limit' > /dev/null)
221 local commit_id1=`git_show_head $testroot/repo`
223 (cd $testroot/wt && got rm beta >/dev/null)
224 (cd $testroot/wt && got commit -m 'test log_limit' > /dev/null)
225 local commit_id2=`git_show_head $testroot/repo`
227 echo "new file" > $testroot/wt/new
228 (cd $testroot/wt && got add new >/dev/null)
229 (cd $testroot/wt && got commit -m 'test log_limit' > /dev/null)
230 local commit_id3=`git_show_head $testroot/repo`
232 # -l1 should print the first commit only
233 echo "commit $commit_id3 (master)" > $testroot/stdout.expected
234 (cd $testroot/wt && got log -l1 | grep ^commit > $testroot/stdout)
235 cmp -s $testroot/stdout.expected $testroot/stdout
237 if [ "$ret" != "0" ]; then
238 diff -u $testroot/stdout.expected $testroot/stdout
239 test_done "$testroot" "$ret"
243 # env var can be used to set a log limit without -l option
244 echo "commit $commit_id3 (master)" > $testroot/stdout.expected
245 echo "commit $commit_id2" >> $testroot/stdout.expected
246 (cd $testroot/wt && env GOT_LOG_DEFAULT_LIMIT=2 got log | \
247 grep ^commit > $testroot/stdout)
248 cmp -s $testroot/stdout.expected $testroot/stdout
250 if [ "$ret" != "0" ]; then
251 diff -u $testroot/stdout.expected $testroot/stdout
252 test_done "$testroot" "$ret"
256 # non-numeric env var is ignored
257 (cd $testroot/wt && env GOT_LOG_DEFAULT_LIMIT=foobar got log | \
258 grep ^commit > $testroot/stdout)
259 echo "commit $commit_id3 (master)" > $testroot/stdout.expected
260 echo "commit $commit_id2" >> $testroot/stdout.expected
261 echo "commit $commit_id1" >> $testroot/stdout.expected
262 echo "commit $commit_id0" >> $testroot/stdout.expected
263 cmp -s $testroot/stdout.expected $testroot/stdout
265 if [ "$ret" != "0" ]; then
266 diff -u $testroot/stdout.expected $testroot/stdout
267 test_done "$testroot" "$ret"
271 # -l option takes precedence over env var
272 echo "commit $commit_id3 (master)" > $testroot/stdout.expected
273 echo "commit $commit_id2" >> $testroot/stdout.expected
274 echo "commit $commit_id1" >> $testroot/stdout.expected
275 echo "commit $commit_id0" >> $testroot/stdout.expected
276 (cd $testroot/wt && env GOT_LOG_DEFAULT_LIMIT=1 got log -l0 | \
277 grep ^commit > $testroot/stdout)
278 cmp -s $testroot/stdout.expected $testroot/stdout
280 if [ "$ret" != "0" ]; then
281 diff -u $testroot/stdout.expected $testroot/stdout
283 test_done "$testroot" "0"
286 function test_log_patch_added_file {
287 local testroot=`test_init log_patch_added_file`
288 local commit_id0=`git_show_head $testroot/repo`
290 got checkout $testroot/repo $testroot/wt > /dev/null
292 if [ "$ret" != "0" ]; then
293 test_done "$testroot" "$ret"
297 echo "new file" > $testroot/wt/new
298 (cd $testroot/wt && got add new >/dev/null)
299 (cd $testroot/wt && got commit -m 'test log_limit' > /dev/null)
300 local commit_id1=`git_show_head $testroot/repo`
302 echo "commit $commit_id1 (master)" > $testroot/stdout.expected
303 # This used to fail with 'got: no such entry found in tree'
304 (cd $testroot/wt && got log -l1 -p new > $testroot/stdout.patch)
306 if [ "$ret" != "0" ]; then
307 echo "got log command failed unexpectedly" >&2
308 test_done "$testroot" "$ret"
311 grep ^commit $testroot/stdout.patch > $testroot/stdout
312 cmp -s $testroot/stdout.expected $testroot/stdout
314 if [ "$ret" != "0" ]; then
315 diff -u $testroot/stdout.expected $testroot/stdout
317 test_done "$testroot" "$ret"
320 function test_log_nonexistent_path {
321 local testroot=`test_init log_nonexistent_path`
322 local head_rev=`git_show_head $testroot/repo`
324 echo "commit $head_rev (master)" > $testroot/stdout.expected
326 (cd $testroot/repo && got log this/does/not/exist \
327 > $testroot/stdout 2> $testroot/stderr)
329 if [ "$ret" == "0" ]; then
330 echo "log command succeeded unexpectedly" >&2
331 test_done "$testroot" "1"
335 echo -n > $testroot/stdout.expected
336 cmp -s $testroot/stdout.expected $testroot/stdout
338 if [ "$ret" != "0" ]; then
339 diff -u $testroot/stdout.expected $testroot/stdout
340 test_done "$testroot" "$ret"
344 echo "got: this/does/not/exist: no such entry found in tree" \
345 > $testroot/stderr.expected
346 cmp -s $testroot/stderr.expected $testroot/stderr
348 if [ "$ret" != "0" ]; then
349 diff -u $testroot/stderr.expected $testroot/stderr
351 test_done "$testroot" "$ret"
354 function test_log_end_at_commit {
355 local testroot=`test_init log_end_at_commit`
356 local commit_id0=`git_show_head $testroot/repo`
358 got checkout $testroot/repo $testroot/wt > /dev/null
360 if [ "$ret" != "0" ]; then
361 test_done "$testroot" "$ret"
365 echo "modified alpha" > $testroot/wt/alpha
366 (cd $testroot/wt && got commit -m 'test log_limit' > /dev/null)
367 local commit_id1=`git_show_head $testroot/repo`
369 (cd $testroot/wt && got rm beta >/dev/null)
370 (cd $testroot/wt && got commit -m 'test log_limit' > /dev/null)
371 local commit_id2=`git_show_head $testroot/repo`
373 echo "new file" > $testroot/wt/new
374 (cd $testroot/wt && got add new >/dev/null)
375 (cd $testroot/wt && got commit -m 'test log_limit' > /dev/null)
376 local commit_id3=`git_show_head $testroot/repo`
378 # Print commit 3 only
379 echo "commit $commit_id3 (master)" > $testroot/stdout.expected
380 (cd $testroot/wt && got log -x $commit_id3 | grep ^commit \
382 cmp -s $testroot/stdout.expected $testroot/stdout
384 if [ "$ret" != "0" ]; then
385 diff -u $testroot/stdout.expected $testroot/stdout
386 test_done "$testroot" "$ret"
390 # Print commit 3 up to commit 1 inclusive
391 echo "commit $commit_id3 (master)" > $testroot/stdout.expected
392 echo "commit $commit_id2" >> $testroot/stdout.expected
393 echo "commit $commit_id1" >> $testroot/stdout.expected
394 (cd $testroot/wt && got log -c $commit_id3 -x $commit_id1 | \
395 grep ^commit > $testroot/stdout)
396 cmp -s $testroot/stdout.expected $testroot/stdout
398 if [ "$ret" != "0" ]; then
399 diff -u $testroot/stdout.expected $testroot/stdout
400 test_done "$testroot" "$ret"
404 # Create commits on an unrelated branch
405 (cd $testroot/wt && got br foo > /dev/null)
406 echo bar >> $testroot/wt/alpha
407 (cd $testroot/wt && got commit -m "change on branch foo" >/dev/null)
408 local commit_id4=`git_show_branch_head $testroot/repo foo`
410 # Print commit 4 only (in work tree)
411 echo "commit $commit_id4 (foo)" > $testroot/stdout.expected
412 (cd $testroot/wt && got log -x foo | grep ^commit \
414 cmp -s $testroot/stdout.expected $testroot/stdout
416 if [ "$ret" != "0" ]; then
417 diff -u $testroot/stdout.expected $testroot/stdout
418 test_done "$testroot" "$ret"
422 # Print commit 4 only (in repository)
423 echo "commit $commit_id4 (foo)" > $testroot/stdout.expected
424 (cd $testroot/repo && got log -c foo -x foo | grep ^commit \
426 cmp -s $testroot/stdout.expected $testroot/stdout
428 if [ "$ret" != "0" ]; then
429 diff -u $testroot/stdout.expected $testroot/stdout
430 test_done "$testroot" "$ret"
434 # Repository's HEAD is on master branch so -x foo without an explicit
435 # '-c foo' start commit has no effect there
436 echo "commit $commit_id3 (master)" > $testroot/stdout.expected
437 echo "commit $commit_id2" >> $testroot/stdout.expected
438 echo "commit $commit_id1" >> $testroot/stdout.expected
439 echo "commit $commit_id0" >> $testroot/stdout.expected
440 (cd $testroot/repo && got log -x foo | grep ^commit \
442 cmp -s $testroot/stdout.expected $testroot/stdout
444 if [ "$ret" != "0" ]; then
445 diff -u $testroot/stdout.expected $testroot/stdout
446 test_done "$testroot" "$ret"
450 # got will refuse -x with a non-existent commit
451 (cd $testroot/wt && got log -x nonexistent \
452 > $testroot/stdout 2> $testroot/stderr)
454 if [ "$ret" == "0" ]; then
455 echo "log command succeeded unexpectedly" >&2
456 test_done "$testroot" "1"
459 echo -n > $testroot/stdout.expected
460 echo "got: nonexistent: bad object id string" \
461 > $testroot/stderr.expected
462 cmp -s $testroot/stderr.expected $testroot/stderr
464 if [ "$ret" != "0" ]; then
465 diff -u $testroot/stderr.expected $testroot/stderr
466 test_done "$testroot" "$ret"
469 cmp -s $testroot/stdout.expected $testroot/stdout
471 if [ "$ret" != "0" ]; then
472 diff -u $testroot/stdout.expected $testroot/stdout
473 test_done "$testroot" "$ret"
477 # try the same with the hash of an empty string which is very
478 # unlikely to match any object
479 local empty_sha1=da39a3ee5e6b4b0d3255bfef95601890afd80709
480 (cd $testroot/wt && got log -x $empty_sha1 \
481 > $testroot/stdout 2> $testroot/stderr)
483 if [ "$ret" == "0" ]; then
484 echo "log command succeeded unexpectedly" >&2
485 test_done "$testroot" "1"
488 echo -n > $testroot/stdout.expected
489 echo "got: $empty_sha1: object not found" > $testroot/stderr.expected
490 cmp -s $testroot/stderr.expected $testroot/stderr
492 if [ "$ret" != "0" ]; then
493 diff -u $testroot/stderr.expected $testroot/stderr
494 test_done "$testroot" "$ret"
497 cmp -s $testroot/stdout.expected $testroot/stdout
499 if [ "$ret" != "0" ]; then
500 diff -u $testroot/stdout.expected $testroot/stdout
501 test_done "$testroot" "$ret"
505 test_done "$testroot" "0"
508 function test_log_reverse_display {
509 local testroot=`test_init log_reverse_display`
510 local commit_id0=`git_show_head $testroot/repo`
512 got checkout $testroot/repo $testroot/wt > /dev/null
514 if [ "$ret" != "0" ]; then
515 test_done "$testroot" "$ret"
519 echo "modified alpha" > $testroot/wt/alpha
520 (cd $testroot/wt && got commit -m 'commit1' > /dev/null)
521 local commit_id1=`git_show_head $testroot/repo`
523 (cd $testroot/wt && got rm beta >/dev/null)
524 (cd $testroot/wt && got commit -m 'commit2' > /dev/null)
525 local commit_id2=`git_show_head $testroot/repo`
527 echo "new file" > $testroot/wt/new
528 (cd $testroot/wt && got add new >/dev/null)
529 (cd $testroot/wt && got commit -m 'commit3' > /dev/null)
530 local commit_id3=`git_show_head $testroot/repo`
532 # -R alone should display all commits in reverse
533 echo "commit $commit_id0" > $testroot/stdout.expected
534 echo "commit $commit_id1" >> $testroot/stdout.expected
535 echo "commit $commit_id2" >> $testroot/stdout.expected
536 echo "commit $commit_id3 (master)" >> $testroot/stdout.expected
537 (cd $testroot/wt && got log -R | grep ^commit > $testroot/stdout)
538 cmp -s $testroot/stdout.expected $testroot/stdout
540 if [ "$ret" != "0" ]; then
541 diff -u $testroot/stdout.expected $testroot/stdout
542 test_done "$testroot" "$ret"
546 # -R takes effect after the -l commit traversal limit
547 echo "commit $commit_id2" > $testroot/stdout.expected
548 echo "commit $commit_id3 (master)" >> $testroot/stdout.expected
549 (cd $testroot/wt && got log -R -l2 | grep ^commit > $testroot/stdout)
550 cmp -s $testroot/stdout.expected $testroot/stdout
552 if [ "$ret" != "0" ]; then
553 diff -u $testroot/stdout.expected $testroot/stdout
554 test_done "$testroot" "$ret"
558 # -R works with commit ranges specified via -c and -x
559 echo "commit $commit_id1" > $testroot/stdout.expected
560 echo "commit $commit_id2" >> $testroot/stdout.expected
561 echo "commit $commit_id3 (master)" >> $testroot/stdout.expected
562 (cd $testroot/wt && got log -R -c $commit_id3 -x $commit_id1 | \
563 grep ^commit > $testroot/stdout)
564 cmp -s $testroot/stdout.expected $testroot/stdout
566 if [ "$ret" != "0" ]; then
567 diff -u $testroot/stdout.expected $testroot/stdout
568 test_done "$testroot" "$ret"
571 # commit matching with -s applies before -R
572 echo "commit $commit_id1" > $testroot/stdout.expected
573 echo "commit $commit_id2" >> $testroot/stdout.expected
574 (cd $testroot/wt && got log -R -s 'commit[12]' | \
575 grep ^commit > $testroot/stdout)
576 cmp -s $testroot/stdout.expected $testroot/stdout
578 if [ "$ret" != "0" ]; then
579 diff -u $testroot/stdout.expected $testroot/stdout
581 test_done "$testroot" "$ret"
584 function test_log_in_worktree_different_repo {
585 local testroot=`test_init log_in_worktree_different_repo 1`
587 make_test_tree $testroot/repo
588 mkdir -p $testroot/repo/epsilon/d
589 echo foo > $testroot/repo/epsilon/d/foo
590 (cd $testroot/repo && git add .)
591 git_commit $testroot/repo -m "adding the test tree"
592 local head_commit=`git_show_head $testroot/repo`
594 got init $testroot/other-repo
595 mkdir -p $testroot/tree
596 make_test_tree $testroot/tree
597 got import -mm -b foo -r $testroot/other-repo $testroot/tree >/dev/null
598 got checkout -b foo $testroot/other-repo $testroot/wt > /dev/null
600 if [ "$ret" != "0" ]; then
601 test_done "$testroot" "$ret"
605 echo "commit $head_commit (master)" > $testroot/stdout.expected
607 # 'got log' used to fail with "reference refs/heads/foo not found"
608 # even though that reference belongs to an unrelated repository
609 # found via a worktree via the current working directory
610 for p in "" alpha epsilon; do
611 (cd $testroot/wt && got log -r $testroot/repo $p | \
612 grep ^commit > $testroot/stdout)
613 cmp -s $testroot/stdout.expected $testroot/stdout
615 if [ "$ret" != "0" ]; then
616 diff -u $testroot/stdout.expected $testroot/stdout
617 test_done "$testroot" "$ret"
622 for p in "" epsilon/zeta; do
623 (cd $testroot/wt/epsilon && got log -r $testroot/repo $p | \
624 grep ^commit > $testroot/stdout)
625 cmp -s $testroot/stdout.expected $testroot/stdout
627 if [ "$ret" != "0" ]; then
628 diff -u $testroot/stdout.expected $testroot/stdout
629 test_done "$testroot" "$ret"
635 (cd $testroot/wt/epsilon && got log -r $testroot/repo epsilon/d/$p | \
636 grep ^commit > $testroot/stdout)
637 cmp -s $testroot/stdout.expected $testroot/stdout
639 if [ "$ret" != "0" ]; then
640 diff -u $testroot/stdout.expected $testroot/stdout
641 test_done "$testroot" "$ret"
646 test_done "$testroot" "0"
649 function test_log_changed_paths {
650 local testroot=`test_init log_changed_paths`
651 local commit_id0=`git_show_head $testroot/repo`
653 got checkout $testroot/repo $testroot/wt > /dev/null
655 if [ "$ret" != "0" ]; then
656 test_done "$testroot" "$ret"
660 echo "modified alpha" > $testroot/wt/alpha
661 (cd $testroot/wt && got commit -m 'test log_changed_paths' > /dev/null)
662 local commit_id1=`git_show_head $testroot/repo`
664 (cd $testroot/wt && got rm beta >/dev/null)
665 (cd $testroot/wt && chmod +x epsilon/zeta >/dev/null)
666 (cd $testroot/wt && got commit -m 'test log_changed_paths' > /dev/null)
667 local commit_id2=`git_show_head $testroot/repo`
669 echo "new file" > $testroot/wt/new
670 (cd $testroot/wt && got add new >/dev/null)
671 (cd $testroot/wt && got commit -m 'test log_changed_paths' > /dev/null)
672 local commit_id3=`git_show_head $testroot/repo`
674 (cd $testroot/wt && got log -P | grep '^ [MDmA]' > $testroot/stdout)
676 echo " A new" > $testroot/stdout.expected
677 echo " D beta" >> $testroot/stdout.expected
678 echo " m epsilon/zeta" >> $testroot/stdout.expected
679 echo " M alpha" >> $testroot/stdout.expected
680 echo " A alpha" >> $testroot/stdout.expected
681 echo " A beta" >> $testroot/stdout.expected
682 echo " A epsilon/zeta" >> $testroot/stdout.expected
683 echo " A gamma/delta" >> $testroot/stdout.expected
685 cmp -s $testroot/stdout.expected $testroot/stdout
687 if [ "$ret" != "0" ]; then
688 diff -u $testroot/stdout.expected $testroot/stdout
690 test_done "$testroot" "$ret"
693 function test_log_submodule {
694 local testroot=`test_init log_submodule`
696 make_single_file_repo $testroot/repo2 foo
698 (cd $testroot/repo && git submodule -q add ../repo2)
699 (cd $testroot/repo && git commit -q -m 'adding submodule')
700 local head_commit=`git_show_head $testroot/repo`
702 echo "commit $head_commit (master)" > $testroot/stdout.expected
704 got log -r $testroot/repo -l1 repo2 | grep ^commit > $testroot/stdout
705 cmp -s $testroot/stdout.expected $testroot/stdout
707 if [ "$ret" != "0" ]; then
708 diff -u $testroot/stdout.expected $testroot/stdout
709 test_done "$testroot" "$ret"
713 echo " A .gitmodules" > $testroot/stdout.expected
715 got log -r $testroot/repo -l1 -P repo2 | grep '^ [MDmA]' \
717 cmp -s $testroot/stdout.expected $testroot/stdout
719 if [ "$ret" != "0" ]; then
720 diff -u $testroot/stdout.expected $testroot/stdout
721 test_done "$testroot" "$ret"
725 got log -p -r $testroot/repo -l1 repo2 \
726 > $testroot/stdout 2> $testroot/stderr
728 if [ "$ret" == "0" ]; then
729 echo "log command succeeded unexpectedly" >&2
730 test_done "$testroot" "1"
733 local submodule_id=$(got tree -r $testroot/repo -i | \
734 grep 'repo2\$$' | cut -d ' ' -f1)
735 echo "got: object $submodule_id not found" > $testroot/stderr.expected
737 cmp -s $testroot/stderr.expected $testroot/stderr
739 if [ "$ret" != "0" ]; then
740 diff -u $testroot/stderr.expected $testroot/stderr
741 test_done "$testroot" "$ret"
745 echo "modified foo" > $testroot/repo2/foo
746 (cd $testroot/repo2 && git commit -q -a -m 'modified a submodule')
748 # Update the repo/repo2 submodule link
749 (cd $testroot/repo && git -C repo2 pull -q)
750 (cd $testroot/repo && git add repo2)
751 git_commit $testroot/repo -m "changed submodule link"
753 # log -P does not show the changed submodule path
754 got log -P -r $testroot/repo -l1 repo2 > $testroot/stdout.full
756 if [ "$ret" != "0" ]; then
757 echo "log command failed unexpectedly" >&2
758 test_done "$testroot" "1"
761 grep '^ [MDmA]' $testroot/stdout.full > $testroot/stdout
763 echo -n > $testroot/stdout.expected
764 cmp -s $testroot/stdout.expected $testroot/stdout
766 if [ "$ret" != "0" ]; then
767 diff -u $testroot/stdout.expected $testroot/stdout
769 test_done "$testroot" "$ret"
772 run_test test_log_in_repo
773 run_test test_log_in_bare_repo
774 run_test test_log_in_worktree
775 run_test test_log_in_worktree_with_path_prefix
776 run_test test_log_tag
777 run_test test_log_limit
778 run_test test_log_patch_added_file
779 run_test test_log_nonexistent_path
780 run_test test_log_end_at_commit
781 run_test test_log_reverse_display
782 run_test test_log_in_worktree_different_repo
783 run_test test_log_changed_paths
784 run_test test_log_submodule