3 # Copyright (c) 2007 Carlos Rica
6 test_description='git tag
8 Tests for operations with tags.'
11 . "$TEST_DIRECTORY"/lib-gpg.sh
13 # creating and listing lightweight tags:
16 git show-ref --quiet --verify refs/tags/"$1"
19 # todo: git tag -l now returns always zero, when fixed, change this test
20 test_expect_success 'listing all tags in an empty tree should succeed' '
25 test_expect_success 'listing all tags in an empty tree should output nothing' '
26 test $(git tag -l | wc -l) -eq 0 &&
27 test $(git tag | wc -l) -eq 0
30 test_expect_success 'sort tags, ignore case' '
34 test_commit initial &&
38 cat >expected <<-\EOF &&
43 test_cmp expected actual &&
44 git tag -l -i >actual &&
45 cat >expected <<-\EOF &&
50 test_cmp expected actual
54 test_expect_success 'looking for a tag in an empty tree should fail' \
55 '! (tag_exists mytag)'
57 test_expect_success 'creating a tag in an empty tree should fail' '
58 test_must_fail git tag mynotag &&
62 test_expect_success 'creating a tag for HEAD in an empty tree should fail' '
63 test_must_fail git tag mytaghead HEAD &&
64 ! tag_exists mytaghead
67 test_expect_success 'creating a tag for an unknown revision should fail' '
68 test_must_fail git tag mytagnorev aaaaaaaaaaa &&
69 ! tag_exists mytagnorev
72 # commit used in the tests, test_tick is also called here to freeze the date:
73 test_expect_success 'creating a tag using default HEAD should succeed' '
79 test_must_fail git reflog exists refs/tags/mytag
82 test_expect_success 'creating a tag with --create-reflog should create reflog' '
83 test_when_finished "git tag -d tag_with_reflog" &&
84 git tag --create-reflog tag_with_reflog &&
85 git reflog exists refs/tags/tag_with_reflog
88 test_expect_success '--create-reflog does not create reflog on failure' '
89 test_must_fail git tag --create-reflog mytag &&
90 test_must_fail git reflog exists refs/tags/mytag
93 test_expect_success 'listing all tags if one exists should succeed' '
98 test_expect_success 'listing all tags if one exists should output that tag' '
99 test $(git tag -l) = mytag &&
100 test $(git tag) = mytag
105 test_expect_success 'listing a tag using a matching pattern should succeed' \
108 test_expect_success 'listing a tag with --ignore-case' \
109 'test $(git tag -l --ignore-case MYTAG) = mytag'
111 test_expect_success \
112 'listing a tag using a matching pattern should output that tag' \
113 'test $(git tag -l mytag) = mytag'
115 # todo: git tag -l now returns always zero, when fixed, change this test
116 test_expect_success \
117 'listing tags using a non-matching pattern should suceed' \
120 test_expect_success \
121 'listing tags using a non-matching pattern should output nothing' \
122 'test $(git tag -l xxx | wc -l) -eq 0'
124 # special cases for creating tags:
126 test_expect_success \
127 'trying to create a tag with the name of one existing should fail' \
128 'test_must_fail git tag mytag'
130 test_expect_success \
131 'trying to create a tag with a non-valid name should fail' '
132 test $(git tag -l | wc -l) -eq 1 &&
133 test_must_fail git tag "" &&
134 test_must_fail git tag .othertag &&
135 test_must_fail git tag "other tag" &&
136 test_must_fail git tag "othertag^" &&
137 test_must_fail git tag "other~tag" &&
138 test $(git tag -l | wc -l) -eq 1
141 test_expect_success 'creating a tag using HEAD directly should succeed' '
142 git tag myhead HEAD &&
146 test_expect_success '--force can create a tag with the name of one existing' '
148 git tag --force mytag &&
151 test_expect_success '--force is moot with a non-existing tag name' '
152 test_when_finished git tag -d newtag forcetag &&
153 git tag newtag >expect &&
154 git tag --force forcetag >actual &&
155 test_cmp expect actual
160 test_expect_success 'trying to delete an unknown tag should fail' '
161 ! tag_exists unknown-tag &&
162 test_must_fail git tag -d unknown-tag
169 test_expect_success \
170 'trying to delete tags without params should succeed and do nothing' '
171 git tag -l > actual && test_cmp expect actual &&
173 git tag -l > actual && test_cmp expect actual
176 test_expect_success \
177 'deleting two existing tags in one command should succeed' '
180 git tag -d mytag myhead &&
181 ! tag_exists mytag &&
185 test_expect_success \
186 'creating a tag with the name of another deleted one should succeed' '
187 ! tag_exists mytag &&
192 test_expect_success \
193 'trying to delete two tags, existing and not, should fail in the 2nd' '
195 ! tag_exists myhead &&
196 test_must_fail git tag -d mytag anothertag &&
197 ! tag_exists mytag &&
201 test_expect_success 'trying to delete an already deleted tag should fail' \
202 'test_must_fail git tag -d mytag'
204 # listing various tags with pattern matching:
217 test_expect_success 'listing all tags should print them ordered' '
227 git tag -l > actual &&
228 test_cmp expect actual &&
230 test_cmp expect actual
238 test_expect_success \
239 'listing tags with substring as pattern must print those matching' '
241 git tag -l "*a*" > current &&
242 test_cmp expect current
249 test_expect_success \
250 'listing tags with a suffix as pattern must print those matching' '
251 git tag -l "*.1" > actual &&
252 test_cmp expect actual
259 test_expect_success \
260 'listing tags with a prefix as pattern must print those matching' '
261 git tag -l "t21*" > actual &&
262 test_cmp expect actual
268 test_expect_success \
269 'listing tags using a name as pattern must print that one matching' '
270 git tag -l a1 > actual &&
271 test_cmp expect actual
277 test_expect_success \
278 'listing tags using a name as pattern must print that one matching' '
279 git tag -l v1.0 > actual &&
280 test_cmp expect actual
287 test_expect_success \
288 'listing tags with ? in the pattern should print those matching' '
289 git tag -l "v1.?.?" > actual &&
290 test_cmp expect actual
294 test_expect_success \
295 'listing tags using v.* should print nothing because none have v.' '
296 git tag -l "v.*" > actual &&
297 test_cmp expect actual
306 test_expect_success \
307 'listing tags using v* should print only those having v' '
308 git tag -l "v*" > actual &&
309 test_cmp expect actual
312 test_expect_success 'tag -l can accept multiple patterns' '
313 git tag -l "v1*" "v0*" >actual &&
314 test_cmp expect actual
317 test_expect_success 'listing tags in column' '
318 COLUMNS=40 git tag -l --column=row >actual &&
319 cat >expected <<\EOF &&
321 v0.2.1 v1.0 v1.0.1 v1.1.3
323 test_cmp expected actual
326 test_expect_success 'listing tags in column with column.*' '
327 test_config column.tag row &&
328 test_config column.ui dense &&
329 COLUMNS=40 git tag -l >actual &&
330 cat >expected <<\EOF &&
332 v0.2.1 v1.0 v1.0.1 v1.1.3
334 test_cmp expected actual
337 test_expect_success 'listing tag with -n --column should fail' '
338 test_must_fail git tag --column -n
341 test_expect_success 'listing tags -n in column with column.ui ignored' '
342 test_config column.ui "row dense" &&
343 COLUMNS=40 git tag -l -n >actual &&
344 cat >expected <<\EOF &&
355 test_cmp expected actual
358 # creating and verifying lightweight tags:
360 test_expect_success \
361 'a non-annotated tag created without parameters should point to HEAD' '
362 git tag non-annotated-tag &&
363 test $(git cat-file -t non-annotated-tag) = commit &&
364 test $(git rev-parse non-annotated-tag) = $(git rev-parse HEAD)
367 test_expect_success 'trying to verify an unknown tag should fail' \
368 'test_must_fail git tag -v unknown-tag'
370 test_expect_success \
371 'trying to verify a non-annotated and non-signed tag should fail' \
372 'test_must_fail git tag -v non-annotated-tag'
374 test_expect_success \
375 'trying to verify many non-annotated or unknown tags, should fail' \
376 'test_must_fail git tag -v unknown-tag1 non-annotated-tag unknown-tag2'
378 # creating annotated tags:
381 git cat-file tag "$1" | sed -e "/BEGIN PGP/q"
384 # run test_tick before committing always gives the time in that timezone
390 tagger C O Mitter <committer@example.com> $4 -0700
395 commit=$(git rev-parse HEAD)
398 get_tag_header annotated-tag $commit commit $time >expect
399 echo "A message" >>expect
400 test_expect_success \
401 'creating an annotated tag with -m message should succeed' '
402 git tag -m "A message" annotated-tag &&
403 get_tag_msg annotated-tag >actual &&
404 test_cmp expect actual
411 get_tag_header file-annotated-tag $commit commit $time >expect
413 test_expect_success \
414 'creating an annotated tag with -F messagefile should succeed' '
415 git tag -F msgfile file-annotated-tag &&
416 get_tag_msg file-annotated-tag >actual &&
417 test_cmp expect actual
424 get_tag_header stdin-annotated-tag $commit commit $time >expect
425 cat inputmsg >>expect
426 test_expect_success 'creating an annotated tag with -F - should succeed' '
427 git tag -F - stdin-annotated-tag <inputmsg &&
428 get_tag_msg stdin-annotated-tag >actual &&
429 test_cmp expect actual
432 test_expect_success \
433 'trying to create a tag with a non-existing -F file should fail' '
434 ! test -f nonexistingfile &&
435 ! tag_exists notag &&
436 test_must_fail git tag -F nonexistingfile notag &&
440 test_expect_success \
441 'trying to create tags giving both -m or -F options should fail' '
442 echo "message file 1" >msgfile1 &&
443 echo "message file 2" >msgfile2 &&
444 ! tag_exists msgtag &&
445 test_must_fail git tag -m "message 1" -F msgfile1 msgtag &&
446 ! tag_exists msgtag &&
447 test_must_fail git tag -F msgfile1 -m "message 1" msgtag &&
448 ! tag_exists msgtag &&
449 test_must_fail git tag -m "message 1" -F msgfile1 \
450 -m "message 2" msgtag &&
454 # blank and empty messages:
456 get_tag_header empty-annotated-tag $commit commit $time >expect
457 test_expect_success \
458 'creating a tag with an empty -m message should succeed' '
459 git tag -m "" empty-annotated-tag &&
460 get_tag_msg empty-annotated-tag >actual &&
461 test_cmp expect actual
465 get_tag_header emptyfile-annotated-tag $commit commit $time >expect
466 test_expect_success \
467 'creating a tag with an empty -F messagefile should succeed' '
468 git tag -F emptyfile emptyfile-annotated-tag &&
469 get_tag_msg emptyfile-annotated-tag >actual &&
470 test_cmp expect actual
473 printf '\n\n \n\t\nLeading blank lines\n' >blanksfile
474 printf '\n\t \t \nRepeated blank lines\n' >>blanksfile
475 printf '\n\n\nTrailing spaces \t \n' >>blanksfile
476 printf '\nTrailing blank lines\n\n\t \n\n' >>blanksfile
477 get_tag_header blanks-annotated-tag $commit commit $time >expect
487 test_expect_success \
488 'extra blanks in the message for an annotated tag should be removed' '
489 git tag -F blanksfile blanks-annotated-tag &&
490 get_tag_msg blanks-annotated-tag >actual &&
491 test_cmp expect actual
494 get_tag_header blank-annotated-tag $commit commit $time >expect
495 test_expect_success \
496 'creating a tag with blank -m message with spaces should succeed' '
497 git tag -m " " blank-annotated-tag &&
498 get_tag_msg blank-annotated-tag >actual &&
499 test_cmp expect actual
505 get_tag_header blankfile-annotated-tag $commit commit $time >expect
506 test_expect_success \
507 'creating a tag with blank -F messagefile with spaces should succeed' '
508 git tag -F blankfile blankfile-annotated-tag &&
509 get_tag_msg blankfile-annotated-tag >actual &&
510 test_cmp expect actual
513 printf ' ' >blanknonlfile
514 get_tag_header blanknonlfile-annotated-tag $commit commit $time >expect
515 test_expect_success \
516 'creating a tag with -F file of spaces and no newline should succeed' '
517 git tag -F blanknonlfile blanknonlfile-annotated-tag &&
518 get_tag_msg blanknonlfile-annotated-tag >actual &&
519 test_cmp expect actual
522 # messages with commented lines:
524 cat >commentsfile <<EOF
541 get_tag_header comments-annotated-tag $commit commit $time >expect
550 test_expect_success \
551 'creating a tag using a -F messagefile with #comments should succeed' '
552 git tag -F commentsfile comments-annotated-tag &&
553 get_tag_msg comments-annotated-tag >actual &&
554 test_cmp expect actual
557 get_tag_header comment-annotated-tag $commit commit $time >expect
558 test_expect_success \
559 'creating a tag with a #comment in the -m message should succeed' '
560 git tag -m "#comment" comment-annotated-tag &&
561 get_tag_msg comment-annotated-tag >actual &&
562 test_cmp expect actual
565 echo '#comment' >commentfile
566 echo '' >>commentfile
567 echo '####' >>commentfile
568 get_tag_header commentfile-annotated-tag $commit commit $time >expect
569 test_expect_success \
570 'creating a tag with #comments in the -F messagefile should succeed' '
571 git tag -F commentfile commentfile-annotated-tag &&
572 get_tag_msg commentfile-annotated-tag >actual &&
573 test_cmp expect actual
576 printf '#comment' >commentnonlfile
577 get_tag_header commentnonlfile-annotated-tag $commit commit $time >expect
578 test_expect_success \
579 'creating a tag with a file of #comment and no newline should succeed' '
580 git tag -F commentnonlfile commentnonlfile-annotated-tag &&
581 get_tag_msg commentnonlfile-annotated-tag >actual &&
582 test_cmp expect actual
585 # listing messages for annotated non-signed tags:
587 test_expect_success \
588 'listing the one-line message of a non-signed tag should succeed' '
589 git tag -m "A msg" tag-one-line &&
591 echo "tag-one-line" >expect &&
592 git tag -l | grep "^tag-one-line" >actual &&
593 test_cmp expect actual &&
594 git tag -n0 -l | grep "^tag-one-line" >actual &&
595 test_cmp expect actual &&
596 git tag -n0 -l tag-one-line >actual &&
597 test_cmp expect actual &&
599 echo "tag-one-line A msg" >expect &&
600 git tag -n1 -l | grep "^tag-one-line" >actual &&
601 test_cmp expect actual &&
602 git tag -n -l | grep "^tag-one-line" >actual &&
603 test_cmp expect actual &&
604 git tag -n1 -l tag-one-line >actual &&
605 test_cmp expect actual &&
606 git tag -n2 -l tag-one-line >actual &&
607 test_cmp expect actual &&
608 git tag -n999 -l tag-one-line >actual &&
609 test_cmp expect actual
612 test_expect_success \
613 'listing the zero-lines message of a non-signed tag should succeed' '
614 git tag -m "" tag-zero-lines &&
616 echo "tag-zero-lines" >expect &&
617 git tag -l | grep "^tag-zero-lines" >actual &&
618 test_cmp expect actual &&
619 git tag -n0 -l | grep "^tag-zero-lines" >actual &&
620 test_cmp expect actual &&
621 git tag -n0 -l tag-zero-lines >actual &&
622 test_cmp expect actual &&
624 echo "tag-zero-lines " >expect &&
625 git tag -n1 -l | grep "^tag-zero-lines" >actual &&
626 test_cmp expect actual &&
627 git tag -n -l | grep "^tag-zero-lines" >actual &&
628 test_cmp expect actual &&
629 git tag -n1 -l tag-zero-lines >actual &&
630 test_cmp expect actual &&
631 git tag -n2 -l tag-zero-lines >actual &&
632 test_cmp expect actual &&
633 git tag -n999 -l tag-zero-lines >actual &&
634 test_cmp expect actual
637 echo 'tag line one' >annotagmsg
638 echo 'tag line two' >>annotagmsg
639 echo 'tag line three' >>annotagmsg
640 test_expect_success \
641 'listing many message lines of a non-signed tag should succeed' '
642 git tag -F annotagmsg tag-lines &&
644 echo "tag-lines" >expect &&
645 git tag -l | grep "^tag-lines" >actual &&
646 test_cmp expect actual &&
647 git tag -n0 -l | grep "^tag-lines" >actual &&
648 test_cmp expect actual &&
649 git tag -n0 -l tag-lines >actual &&
650 test_cmp expect actual &&
652 echo "tag-lines tag line one" >expect &&
653 git tag -n1 -l | grep "^tag-lines" >actual &&
654 test_cmp expect actual &&
655 git tag -n -l | grep "^tag-lines" >actual &&
656 test_cmp expect actual &&
657 git tag -n1 -l tag-lines >actual &&
658 test_cmp expect actual &&
660 echo " tag line two" >>expect &&
661 git tag -n2 -l | grep "^ *tag.line" >actual &&
662 test_cmp expect actual &&
663 git tag -n2 -l tag-lines >actual &&
664 test_cmp expect actual &&
666 echo " tag line three" >>expect &&
667 git tag -n3 -l | grep "^ *tag.line" >actual &&
668 test_cmp expect actual &&
669 git tag -n3 -l tag-lines >actual &&
670 test_cmp expect actual &&
671 git tag -n4 -l | grep "^ *tag.line" >actual &&
672 test_cmp expect actual &&
673 git tag -n4 -l tag-lines >actual &&
674 test_cmp expect actual &&
675 git tag -n99 -l | grep "^ *tag.line" >actual &&
676 test_cmp expect actual &&
677 git tag -n99 -l tag-lines >actual &&
678 test_cmp expect actual
681 test_expect_success 'annotations for blobs are empty' '
682 blob=$(git hash-object -w --stdin <<-\EOF
688 git tag tag-blob $blob &&
689 echo "tag-blob " >expect &&
690 git tag -n1 -l tag-blob >actual &&
691 test_cmp expect actual
694 # trying to verify annotated non-signed tags:
696 test_expect_success GPG \
697 'trying to verify an annotated non-signed tag should fail' '
698 tag_exists annotated-tag &&
699 test_must_fail git tag -v annotated-tag
702 test_expect_success GPG \
703 'trying to verify a file-annotated non-signed tag should fail' '
704 tag_exists file-annotated-tag &&
705 test_must_fail git tag -v file-annotated-tag
708 test_expect_success GPG \
709 'trying to verify two annotated non-signed tags should fail' '
710 tag_exists annotated-tag file-annotated-tag &&
711 test_must_fail git tag -v annotated-tag file-annotated-tag
714 # creating and verifying signed tags:
716 get_tag_header signed-tag $commit commit $time >expect
717 echo 'A signed tag message' >>expect
718 echo '-----BEGIN PGP SIGNATURE-----' >>expect
719 test_expect_success GPG 'creating a signed tag with -m message should succeed' '
720 git tag -s -m "A signed tag message" signed-tag &&
721 get_tag_msg signed-tag >actual &&
722 test_cmp expect actual
725 get_tag_header u-signed-tag $commit commit $time >expect
726 echo 'Another message' >>expect
727 echo '-----BEGIN PGP SIGNATURE-----' >>expect
728 test_expect_success GPG 'sign with a given key id' '
730 git tag -u committer@example.com -m "Another message" u-signed-tag &&
731 get_tag_msg u-signed-tag >actual &&
732 test_cmp expect actual
736 test_expect_success GPG 'sign with an unknown id (1)' '
738 test_must_fail git tag -u author@example.com \
739 -m "Another message" o-signed-tag
743 test_expect_success GPG 'sign with an unknown id (2)' '
745 test_must_fail git tag -u DEADBEEF -m "Another message" o-signed-tag
749 cat >fakeeditor <<'EOF'
751 test -n "$1" && exec >"$1"
752 echo A signed tag message
753 echo from a fake editor.
757 get_tag_header implied-sign $commit commit $time >expect
758 ./fakeeditor >>expect
759 echo '-----BEGIN PGP SIGNATURE-----' >>expect
760 test_expect_success GPG '-u implies signed tag' '
761 GIT_EDITOR=./fakeeditor git tag -u CDDE430D implied-sign &&
762 get_tag_msg implied-sign >actual &&
763 test_cmp expect actual
766 cat >sigmsgfile <<EOF
770 get_tag_header file-signed-tag $commit commit $time >expect
771 cat sigmsgfile >>expect
772 echo '-----BEGIN PGP SIGNATURE-----' >>expect
773 test_expect_success GPG \
774 'creating a signed tag with -F messagefile should succeed' '
775 git tag -s -F sigmsgfile file-signed-tag &&
776 get_tag_msg file-signed-tag >actual &&
777 test_cmp expect actual
780 cat >siginputmsg <<EOF
781 A signed tag message from
784 get_tag_header stdin-signed-tag $commit commit $time >expect
785 cat siginputmsg >>expect
786 echo '-----BEGIN PGP SIGNATURE-----' >>expect
787 test_expect_success GPG 'creating a signed tag with -F - should succeed' '
788 git tag -s -F - stdin-signed-tag <siginputmsg &&
789 get_tag_msg stdin-signed-tag >actual &&
790 test_cmp expect actual
793 get_tag_header implied-annotate $commit commit $time >expect
794 ./fakeeditor >>expect
795 echo '-----BEGIN PGP SIGNATURE-----' >>expect
796 test_expect_success GPG '-s implies annotated tag' '
797 GIT_EDITOR=./fakeeditor git tag -s implied-annotate &&
798 get_tag_msg implied-annotate >actual &&
799 test_cmp expect actual
802 get_tag_header forcesignannotated-implied-sign $commit commit $time >expect
803 echo "A message" >>expect
804 echo '-----BEGIN PGP SIGNATURE-----' >>expect
805 test_expect_success GPG \
806 'git tag -s implied if configured with tag.forcesignannotated' \
807 'test_config tag.forcesignannotated true &&
808 git tag -m "A message" forcesignannotated-implied-sign &&
809 get_tag_msg forcesignannotated-implied-sign >actual &&
810 test_cmp expect actual
813 test_expect_success GPG \
814 'lightweight with no message when configured with tag.forcesignannotated' \
815 'test_config tag.forcesignannotated true &&
816 git tag forcesignannotated-lightweight &&
817 tag_exists forcesignannotated-lightweight &&
818 test_must_fail git tag -v forcesignannotated-no-message
821 get_tag_header forcesignannotated-annotate $commit commit $time >expect
822 echo "A message" >>expect
823 test_expect_success GPG \
824 'git tag -a disable configured tag.forcesignannotated' \
825 'test_config tag.forcesignannotated true &&
826 git tag -a -m "A message" forcesignannotated-annotate &&
827 get_tag_msg forcesignannotated-annotate >actual &&
828 test_cmp expect actual &&
829 test_must_fail git tag -v forcesignannotated-annotate
832 get_tag_header forcesignannotated-disabled $commit commit $time >expect
833 echo "A message" >>expect
834 echo '-----BEGIN PGP SIGNATURE-----' >>expect
835 test_expect_success GPG \
836 'git tag --sign enable GPG sign' \
837 'test_config tag.forcesignannotated false &&
838 git tag --sign -m "A message" forcesignannotated-disabled &&
839 get_tag_msg forcesignannotated-disabled >actual &&
840 test_cmp expect actual
843 test_expect_success GPG \
844 'trying to create a signed tag with non-existing -F file should fail' '
845 ! test -f nonexistingfile &&
846 ! tag_exists nosigtag &&
847 test_must_fail git tag -s -F nonexistingfile nosigtag &&
848 ! tag_exists nosigtag
851 test_expect_success GPG 'verifying a signed tag should succeed' \
852 'git tag -v signed-tag'
854 test_expect_success GPG 'verifying two signed tags in one command should succeed' \
855 'git tag -v signed-tag file-signed-tag'
857 test_expect_success GPG \
858 'verifying many signed and non-signed tags should fail' '
859 test_must_fail git tag -v signed-tag annotated-tag &&
860 test_must_fail git tag -v file-annotated-tag file-signed-tag &&
861 test_must_fail git tag -v annotated-tag \
862 file-signed-tag file-annotated-tag &&
863 test_must_fail git tag -v signed-tag annotated-tag file-signed-tag
866 test_expect_success GPG 'verifying a forged tag should fail' '
867 forged=$(git cat-file tag signed-tag |
868 sed -e "s/signed-tag/forged-tag/" |
870 git tag forged-tag $forged &&
871 test_must_fail git tag -v forged-tag
874 test_expect_success 'verifying a proper tag with --format pass and format accordingly' '
878 git tag -v --format="tagname : %(tag)" "signed-tag" >actual &&
879 test_cmp expect actual
882 test_expect_success 'verifying a forged tag with --format fail and format accordingly' '
886 test_must_fail git tag -v --format="tagname : %(tag)" "forged-tag" >actual &&
887 test_cmp expect actual
890 # blank and empty messages for signed tags:
892 get_tag_header empty-signed-tag $commit commit $time >expect
893 echo '-----BEGIN PGP SIGNATURE-----' >>expect
894 test_expect_success GPG \
895 'creating a signed tag with an empty -m message should succeed' '
896 git tag -s -m "" empty-signed-tag &&
897 get_tag_msg empty-signed-tag >actual &&
898 test_cmp expect actual &&
899 git tag -v empty-signed-tag
903 get_tag_header emptyfile-signed-tag $commit commit $time >expect
904 echo '-----BEGIN PGP SIGNATURE-----' >>expect
905 test_expect_success GPG \
906 'creating a signed tag with an empty -F messagefile should succeed' '
907 git tag -s -F sigemptyfile emptyfile-signed-tag &&
908 get_tag_msg emptyfile-signed-tag >actual &&
909 test_cmp expect actual &&
910 git tag -v emptyfile-signed-tag
913 printf '\n\n \n\t\nLeading blank lines\n' > sigblanksfile
914 printf '\n\t \t \nRepeated blank lines\n' >>sigblanksfile
915 printf '\n\n\nTrailing spaces \t \n' >>sigblanksfile
916 printf '\nTrailing blank lines\n\n\t \n\n' >>sigblanksfile
917 get_tag_header blanks-signed-tag $commit commit $time >expect
927 echo '-----BEGIN PGP SIGNATURE-----' >>expect
928 test_expect_success GPG \
929 'extra blanks in the message for a signed tag should be removed' '
930 git tag -s -F sigblanksfile blanks-signed-tag &&
931 get_tag_msg blanks-signed-tag >actual &&
932 test_cmp expect actual &&
933 git tag -v blanks-signed-tag
936 get_tag_header blank-signed-tag $commit commit $time >expect
937 echo '-----BEGIN PGP SIGNATURE-----' >>expect
938 test_expect_success GPG \
939 'creating a signed tag with a blank -m message should succeed' '
940 git tag -s -m " " blank-signed-tag &&
941 get_tag_msg blank-signed-tag >actual &&
942 test_cmp expect actual &&
943 git tag -v blank-signed-tag
946 echo ' ' >sigblankfile
947 echo '' >>sigblankfile
948 echo ' ' >>sigblankfile
949 get_tag_header blankfile-signed-tag $commit commit $time >expect
950 echo '-----BEGIN PGP SIGNATURE-----' >>expect
951 test_expect_success GPG \
952 'creating a signed tag with blank -F file with spaces should succeed' '
953 git tag -s -F sigblankfile blankfile-signed-tag &&
954 get_tag_msg blankfile-signed-tag >actual &&
955 test_cmp expect actual &&
956 git tag -v blankfile-signed-tag
959 printf ' ' >sigblanknonlfile
960 get_tag_header blanknonlfile-signed-tag $commit commit $time >expect
961 echo '-----BEGIN PGP SIGNATURE-----' >>expect
962 test_expect_success GPG \
963 'creating a signed tag with spaces and no newline should succeed' '
964 git tag -s -F sigblanknonlfile blanknonlfile-signed-tag &&
965 get_tag_msg blanknonlfile-signed-tag >actual &&
966 test_cmp expect actual &&
967 git tag -v signed-tag
970 # messages with commented lines for signed tags:
972 cat >sigcommentsfile <<EOF
989 get_tag_header comments-signed-tag $commit commit $time >expect
998 echo '-----BEGIN PGP SIGNATURE-----' >>expect
999 test_expect_success GPG \
1000 'creating a signed tag with a -F file with #comments should succeed' '
1001 git tag -s -F sigcommentsfile comments-signed-tag &&
1002 get_tag_msg comments-signed-tag >actual &&
1003 test_cmp expect actual &&
1004 git tag -v comments-signed-tag
1007 get_tag_header comment-signed-tag $commit commit $time >expect
1008 echo '-----BEGIN PGP SIGNATURE-----' >>expect
1009 test_expect_success GPG \
1010 'creating a signed tag with #commented -m message should succeed' '
1011 git tag -s -m "#comment" comment-signed-tag &&
1012 get_tag_msg comment-signed-tag >actual &&
1013 test_cmp expect actual &&
1014 git tag -v comment-signed-tag
1017 echo '#comment' >sigcommentfile
1018 echo '' >>sigcommentfile
1019 echo '####' >>sigcommentfile
1020 get_tag_header commentfile-signed-tag $commit commit $time >expect
1021 echo '-----BEGIN PGP SIGNATURE-----' >>expect
1022 test_expect_success GPG \
1023 'creating a signed tag with #commented -F messagefile should succeed' '
1024 git tag -s -F sigcommentfile commentfile-signed-tag &&
1025 get_tag_msg commentfile-signed-tag >actual &&
1026 test_cmp expect actual &&
1027 git tag -v commentfile-signed-tag
1030 printf '#comment' >sigcommentnonlfile
1031 get_tag_header commentnonlfile-signed-tag $commit commit $time >expect
1032 echo '-----BEGIN PGP SIGNATURE-----' >>expect
1033 test_expect_success GPG \
1034 'creating a signed tag with a #comment and no newline should succeed' '
1035 git tag -s -F sigcommentnonlfile commentnonlfile-signed-tag &&
1036 get_tag_msg commentnonlfile-signed-tag >actual &&
1037 test_cmp expect actual &&
1038 git tag -v commentnonlfile-signed-tag
1041 # listing messages for signed tags:
1043 test_expect_success GPG \
1044 'listing the one-line message of a signed tag should succeed' '
1045 git tag -s -m "A message line signed" stag-one-line &&
1047 echo "stag-one-line" >expect &&
1048 git tag -l | grep "^stag-one-line" >actual &&
1049 test_cmp expect actual &&
1050 git tag -n0 -l | grep "^stag-one-line" >actual &&
1051 test_cmp expect actual &&
1052 git tag -n0 -l stag-one-line >actual &&
1053 test_cmp expect actual &&
1055 echo "stag-one-line A message line signed" >expect &&
1056 git tag -n1 -l | grep "^stag-one-line" >actual &&
1057 test_cmp expect actual &&
1058 git tag -n -l | grep "^stag-one-line" >actual &&
1059 test_cmp expect actual &&
1060 git tag -n1 -l stag-one-line >actual &&
1061 test_cmp expect actual &&
1062 git tag -n2 -l stag-one-line >actual &&
1063 test_cmp expect actual &&
1064 git tag -n999 -l stag-one-line >actual &&
1065 test_cmp expect actual
1068 test_expect_success GPG \
1069 'listing the zero-lines message of a signed tag should succeed' '
1070 git tag -s -m "" stag-zero-lines &&
1072 echo "stag-zero-lines" >expect &&
1073 git tag -l | grep "^stag-zero-lines" >actual &&
1074 test_cmp expect actual &&
1075 git tag -n0 -l | grep "^stag-zero-lines" >actual &&
1076 test_cmp expect actual &&
1077 git tag -n0 -l stag-zero-lines >actual &&
1078 test_cmp expect actual &&
1080 echo "stag-zero-lines " >expect &&
1081 git tag -n1 -l | grep "^stag-zero-lines" >actual &&
1082 test_cmp expect actual &&
1083 git tag -n -l | grep "^stag-zero-lines" >actual &&
1084 test_cmp expect actual &&
1085 git tag -n1 -l stag-zero-lines >actual &&
1086 test_cmp expect actual &&
1087 git tag -n2 -l stag-zero-lines >actual &&
1088 test_cmp expect actual &&
1089 git tag -n999 -l stag-zero-lines >actual &&
1090 test_cmp expect actual
1093 echo 'stag line one' >sigtagmsg
1094 echo 'stag line two' >>sigtagmsg
1095 echo 'stag line three' >>sigtagmsg
1096 test_expect_success GPG \
1097 'listing many message lines of a signed tag should succeed' '
1098 git tag -s -F sigtagmsg stag-lines &&
1100 echo "stag-lines" >expect &&
1101 git tag -l | grep "^stag-lines" >actual &&
1102 test_cmp expect actual &&
1103 git tag -n0 -l | grep "^stag-lines" >actual &&
1104 test_cmp expect actual &&
1105 git tag -n0 -l stag-lines >actual &&
1106 test_cmp expect actual &&
1108 echo "stag-lines stag line one" >expect &&
1109 git tag -n1 -l | grep "^stag-lines" >actual &&
1110 test_cmp expect actual &&
1111 git tag -n -l | grep "^stag-lines" >actual &&
1112 test_cmp expect actual &&
1113 git tag -n1 -l stag-lines >actual &&
1114 test_cmp expect actual &&
1116 echo " stag line two" >>expect &&
1117 git tag -n2 -l | grep "^ *stag.line" >actual &&
1118 test_cmp expect actual &&
1119 git tag -n2 -l stag-lines >actual &&
1120 test_cmp expect actual &&
1122 echo " stag line three" >>expect &&
1123 git tag -n3 -l | grep "^ *stag.line" >actual &&
1124 test_cmp expect actual &&
1125 git tag -n3 -l stag-lines >actual &&
1126 test_cmp expect actual &&
1127 git tag -n4 -l | grep "^ *stag.line" >actual &&
1128 test_cmp expect actual &&
1129 git tag -n4 -l stag-lines >actual &&
1130 test_cmp expect actual &&
1131 git tag -n99 -l | grep "^ *stag.line" >actual &&
1132 test_cmp expect actual &&
1133 git tag -n99 -l stag-lines >actual &&
1134 test_cmp expect actual
1137 # tags pointing to objects different from commits:
1139 tree=$(git rev-parse HEAD^{tree})
1140 blob=$(git rev-parse HEAD:foo)
1141 tag=$(git rev-parse signed-tag 2>/dev/null)
1143 get_tag_header tree-signed-tag $tree tree $time >expect
1144 echo "A message for a tree" >>expect
1145 echo '-----BEGIN PGP SIGNATURE-----' >>expect
1146 test_expect_success GPG \
1147 'creating a signed tag pointing to a tree should succeed' '
1148 git tag -s -m "A message for a tree" tree-signed-tag HEAD^{tree} &&
1149 get_tag_msg tree-signed-tag >actual &&
1150 test_cmp expect actual
1153 get_tag_header blob-signed-tag $blob blob $time >expect
1154 echo "A message for a blob" >>expect
1155 echo '-----BEGIN PGP SIGNATURE-----' >>expect
1156 test_expect_success GPG \
1157 'creating a signed tag pointing to a blob should succeed' '
1158 git tag -s -m "A message for a blob" blob-signed-tag HEAD:foo &&
1159 get_tag_msg blob-signed-tag >actual &&
1160 test_cmp expect actual
1163 get_tag_header tag-signed-tag $tag tag $time >expect
1164 echo "A message for another tag" >>expect
1165 echo '-----BEGIN PGP SIGNATURE-----' >>expect
1166 test_expect_success GPG \
1167 'creating a signed tag pointing to another tag should succeed' '
1168 git tag -s -m "A message for another tag" tag-signed-tag signed-tag &&
1169 get_tag_msg tag-signed-tag >actual &&
1170 test_cmp expect actual
1173 # usage with rfc1991 signatures
1174 get_tag_header rfc1991-signed-tag $commit commit $time >expect
1175 echo "RFC1991 signed tag" >>expect
1176 echo '-----BEGIN PGP MESSAGE-----' >>expect
1177 test_expect_success GPG,RFC1991 \
1178 'creating a signed tag with rfc1991' '
1179 echo "rfc1991" >gpghome/gpg.conf &&
1180 git tag -s -m "RFC1991 signed tag" rfc1991-signed-tag $commit &&
1181 get_tag_msg rfc1991-signed-tag >actual &&
1182 test_cmp expect actual
1185 cat >fakeeditor <<'EOF'
1191 test_expect_success GPG,RFC1991 \
1192 'reediting a signed tag body omits signature' '
1193 echo "rfc1991" >gpghome/gpg.conf &&
1194 echo "RFC1991 signed tag" >expect &&
1195 GIT_EDITOR=./fakeeditor git tag -f -s rfc1991-signed-tag $commit &&
1196 test_cmp expect actual
1199 test_expect_success GPG,RFC1991 \
1200 'verifying rfc1991 signature' '
1201 echo "rfc1991" >gpghome/gpg.conf &&
1202 git tag -v rfc1991-signed-tag
1205 test_expect_success GPG,RFC1991 \
1206 'list tag with rfc1991 signature' '
1207 echo "rfc1991" >gpghome/gpg.conf &&
1208 echo "rfc1991-signed-tag RFC1991 signed tag" >expect &&
1209 git tag -l -n1 rfc1991-signed-tag >actual &&
1210 test_cmp expect actual &&
1211 git tag -l -n2 rfc1991-signed-tag >actual &&
1212 test_cmp expect actual &&
1213 git tag -l -n999 rfc1991-signed-tag >actual &&
1214 test_cmp expect actual
1217 rm -f gpghome/gpg.conf
1219 test_expect_success GPG,RFC1991 \
1220 'verifying rfc1991 signature without --rfc1991' '
1221 git tag -v rfc1991-signed-tag
1224 test_expect_success GPG,RFC1991 \
1225 'list tag with rfc1991 signature without --rfc1991' '
1226 echo "rfc1991-signed-tag RFC1991 signed tag" >expect &&
1227 git tag -l -n1 rfc1991-signed-tag >actual &&
1228 test_cmp expect actual &&
1229 git tag -l -n2 rfc1991-signed-tag >actual &&
1230 test_cmp expect actual &&
1231 git tag -l -n999 rfc1991-signed-tag >actual &&
1232 test_cmp expect actual
1235 test_expect_success GPG,RFC1991 \
1236 'reediting a signed tag body omits signature' '
1237 echo "RFC1991 signed tag" >expect &&
1238 GIT_EDITOR=./fakeeditor git tag -f -s rfc1991-signed-tag $commit &&
1239 test_cmp expect actual
1242 # try to sign with bad user.signingkey
1243 test_expect_success GPG \
1244 'git tag -s fails if gpg is misconfigured (bad key)' \
1245 'test_config user.signingkey BobTheMouse &&
1246 test_must_fail git tag -s -m tail tag-gpg-failure'
1248 # try to produce invalid signature
1249 test_expect_success GPG \
1250 'git tag -s fails if gpg is misconfigured (bad signature format)' \
1251 'test_config gpg.program echo &&
1252 test_must_fail git tag -s -m tail tag-gpg-failure'
1255 # try to verify without gpg:
1258 test_expect_success GPG \
1259 'verify signed tag fails when public key is not present' \
1260 'test_must_fail git tag -v signed-tag'
1262 test_expect_success \
1263 'git tag -a fails if tag annotation is empty' '
1264 ! (GIT_EDITOR=cat git tag -a initial-comment)
1267 test_expect_success \
1268 'message in editor has initial comment' '
1269 ! (GIT_EDITOR=cat git tag -a initial-comment > actual)
1272 test_expect_success 'message in editor has initial comment: first line' '
1273 # check the first line --- should be empty
1274 echo >first.expect &&
1275 sed -e 1q <actual >first.actual &&
1276 test_i18ncmp first.expect first.actual
1279 test_expect_success \
1280 'message in editor has initial comment: remainder' '
1281 # remove commented lines from the remainder -- should be empty
1283 sed -e 1d -e "/^#/d" <actual >rest.actual &&
1284 test_cmp rest.expect rest.actual
1287 get_tag_header reuse $commit commit $time >expect
1288 echo "An annotation to be reused" >> expect
1289 test_expect_success \
1290 'overwriting an annoted tag should use its previous body' '
1291 git tag -a -m "An annotation to be reused" reuse &&
1292 GIT_EDITOR=true git tag -f -a reuse &&
1293 get_tag_msg reuse >actual &&
1294 test_cmp expect actual
1297 test_expect_success 'filename for the message is relative to cwd' '
1299 echo "Tag message in top directory" >msgfile-5 &&
1300 echo "Tag message in sub directory" >subdir/msgfile-5 &&
1303 git tag -a -F msgfile-5 tag-from-subdir
1305 git cat-file tag tag-from-subdir | grep "in sub directory"
1308 test_expect_success 'filename for the message is relative to cwd' '
1309 echo "Tag message in sub directory" >subdir/msgfile-6 &&
1312 git tag -a -F msgfile-6 tag-from-subdir-2
1314 git cat-file tag tag-from-subdir-2 | grep "in sub directory"
1317 # create a few more commits to test --contains
1319 hash1=$(git rev-parse HEAD)
1321 test_expect_success 'creating second commit and tag' '
1322 echo foo-2.0 >foo &&
1324 git commit -m second &&
1328 hash2=$(git rev-parse HEAD)
1330 test_expect_success 'creating third commit without tag' '
1331 echo foo-dev >foo &&
1336 hash3=$(git rev-parse HEAD)
1338 # simple linear checks of --continue
1340 cat > expected <<EOF
1348 test_expect_success 'checking that first commit is in all tags (hash)' "
1349 git tag -l --contains $hash1 v* >actual &&
1350 test_cmp expected actual
1353 # other ways of specifying the commit
1354 test_expect_success 'checking that first commit is in all tags (tag)' "
1355 git tag -l --contains v1.0 v* >actual &&
1356 test_cmp expected actual
1359 test_expect_success 'checking that first commit is in all tags (relative)' "
1360 git tag -l --contains HEAD~2 v* >actual &&
1361 test_cmp expected actual
1364 cat > expected <<EOF
1368 test_expect_success 'checking that second commit only has one tag' "
1369 git tag -l --contains $hash2 v* >actual &&
1370 test_cmp expected actual
1374 cat > expected <<EOF
1377 test_expect_success 'checking that third commit has no tags' "
1378 git tag -l --contains $hash3 v* >actual &&
1379 test_cmp expected actual
1382 # how about a simple merge?
1384 test_expect_success 'creating simple branch' '
1385 git branch stable v2.0 &&
1386 git checkout stable &&
1387 echo foo-3.0 > foo &&
1388 git commit foo -m fourth &&
1392 hash4=$(git rev-parse HEAD)
1394 cat > expected <<EOF
1398 test_expect_success 'checking that branch head only has one tag' "
1399 git tag -l --contains $hash4 v* >actual &&
1400 test_cmp expected actual
1403 test_expect_success 'merging original branch into this branch' '
1404 git merge --strategy=ours master &&
1408 cat > expected <<EOF
1412 test_expect_success 'checking that original branch head has one tag now' "
1413 git tag -l --contains $hash3 v* >actual &&
1414 test_cmp expected actual
1417 cat > expected <<EOF
1427 test_expect_success 'checking that initial commit is in all tags' "
1428 git tag -l --contains $hash1 v* >actual &&
1429 test_cmp expected actual
1432 # mixing modes and options:
1434 test_expect_success 'mixing incompatibles modes and options is forbidden' '
1435 test_must_fail git tag -a &&
1436 test_must_fail git tag -l -v &&
1437 test_must_fail git tag -n 100 &&
1438 test_must_fail git tag -l -m msg &&
1439 test_must_fail git tag -l -F some file &&
1440 test_must_fail git tag -v -s
1445 test_expect_success '--points-at cannot be used in non-list mode' '
1446 test_must_fail git tag --points-at=v4.0 foo
1449 test_expect_success '--points-at finds lightweight tags' '
1450 echo v4.0 >expect &&
1451 git tag --points-at v4.0 >actual &&
1452 test_cmp expect actual
1455 test_expect_success '--points-at finds annotated tags of commits' '
1456 git tag -m "v4.0, annotated" annotated-v4.0 v4.0 &&
1457 echo annotated-v4.0 >expect &&
1458 git tag -l --points-at v4.0 "annotated*" >actual &&
1459 test_cmp expect actual
1462 test_expect_success '--points-at finds annotated tags of tags' '
1463 git tag -m "describing the v4.0 tag object" \
1464 annotated-again-v4.0 annotated-v4.0 &&
1465 cat >expect <<-\EOF &&
1466 annotated-again-v4.0
1469 git tag --points-at=annotated-v4.0 >actual &&
1470 test_cmp expect actual
1473 test_expect_success 'multiple --points-at are OR-ed together' '
1474 cat >expect <<-\EOF &&
1478 git tag --points-at=v2.0 --points-at=v3.0 >actual &&
1479 test_cmp expect actual
1482 test_expect_success 'lexical sort' '
1486 git tag -l --sort=refname "foo*" >actual &&
1487 cat >expect <<-\EOF &&
1492 test_cmp expect actual
1495 test_expect_success 'version sort' '
1496 git tag -l --sort=version:refname "foo*" >actual &&
1497 cat >expect <<-\EOF &&
1502 test_cmp expect actual
1505 test_expect_success 'reverse version sort' '
1506 git tag -l --sort=-version:refname "foo*" >actual &&
1507 cat >expect <<-\EOF &&
1512 test_cmp expect actual
1515 test_expect_success 'reverse lexical sort' '
1516 git tag -l --sort=-refname "foo*" >actual &&
1517 cat >expect <<-\EOF &&
1522 test_cmp expect actual
1525 test_expect_success 'configured lexical sort' '
1526 test_config tag.sort "v:refname" &&
1527 git tag -l "foo*" >actual &&
1528 cat >expect <<-\EOF &&
1533 test_cmp expect actual
1536 test_expect_success 'option override configured sort' '
1537 test_config tag.sort "v:refname" &&
1538 git tag -l --sort=-refname "foo*" >actual &&
1539 cat >expect <<-\EOF &&
1544 test_cmp expect actual
1547 test_expect_success 'invalid sort parameter on command line' '
1548 test_must_fail git tag -l --sort=notvalid "foo*" >actual
1551 test_expect_success 'invalid sort parameter in configuratoin' '
1552 test_config tag.sort "v:notvalid" &&
1553 test_must_fail git tag -l "foo*"
1556 test_expect_success 'version sort with prerelease reordering' '
1557 test_config versionsort.prereleaseSuffix -rc &&
1558 git tag foo1.6-rc1 &&
1559 git tag foo1.6-rc2 &&
1560 git tag -l --sort=version:refname "foo*" >actual &&
1561 cat >expect <<-\EOF &&
1568 test_cmp expect actual
1571 test_expect_success 'reverse version sort with prerelease reordering' '
1572 test_config versionsort.prereleaseSuffix -rc &&
1573 git tag -l --sort=-version:refname "foo*" >actual &&
1574 cat >expect <<-\EOF &&
1581 test_cmp expect actual
1584 test_expect_success 'version sort with prerelease reordering and common leading character' '
1585 test_config versionsort.prereleaseSuffix -before &&
1586 git tag foo1.7-before1 &&
1588 git tag foo1.7-after1 &&
1589 git tag -l --sort=version:refname "foo1.7*" >actual &&
1590 cat >expect <<-\EOF &&
1595 test_cmp expect actual
1598 test_expect_success 'version sort with prerelease reordering, multiple suffixes and common leading character' '
1599 test_config versionsort.prereleaseSuffix -before &&
1600 git config --add versionsort.prereleaseSuffix -after &&
1601 git tag -l --sort=version:refname "foo1.7*" >actual &&
1602 cat >expect <<-\EOF &&
1607 test_cmp expect actual
1610 test_expect_success 'version sort with prerelease reordering, multiple suffixes match the same tag' '
1611 test_config versionsort.prereleaseSuffix -bar &&
1612 git config --add versionsort.prereleaseSuffix -foo-baz &&
1613 git config --add versionsort.prereleaseSuffix -foo-bar &&
1614 git tag foo1.8-foo-bar &&
1615 git tag foo1.8-foo-baz &&
1617 git tag -l --sort=version:refname "foo1.8*" >actual &&
1618 cat >expect <<-\EOF &&
1623 test_cmp expect actual
1626 test_expect_success 'version sort with prerelease reordering, multiple suffixes match starting at the same position' '
1627 test_config versionsort.prereleaseSuffix -pre &&
1628 git config --add versionsort.prereleaseSuffix -prerelease &&
1629 git tag foo1.9-pre1 &&
1630 git tag foo1.9-pre2 &&
1631 git tag foo1.9-prerelease1 &&
1632 git tag -l --sort=version:refname "foo1.9*" >actual &&
1633 cat >expect <<-\EOF &&
1638 test_cmp expect actual
1641 test_expect_success 'version sort with general suffix reordering' '
1642 test_config versionsort.suffix -alpha &&
1643 git config --add versionsort.suffix -beta &&
1644 git config --add versionsort.suffix "" &&
1645 git config --add versionsort.suffix -gamma &&
1646 git config --add versionsort.suffix -delta &&
1647 git tag foo1.10-alpha &&
1648 git tag foo1.10-beta &&
1649 git tag foo1.10-gamma &&
1650 git tag foo1.10-delta &&
1651 git tag foo1.10-unlisted-suffix &&
1652 git tag -l --sort=version:refname "foo1.10*" >actual &&
1653 cat >expect <<-\EOF &&
1657 foo1.10-unlisted-suffix
1661 test_cmp expect actual
1664 test_expect_success 'versionsort.suffix overrides versionsort.prereleaseSuffix' '
1665 test_config versionsort.suffix -before &&
1666 test_config versionsort.prereleaseSuffix -after &&
1667 git tag -l --sort=version:refname "foo1.7*" >actual &&
1668 cat >expect <<-\EOF &&
1673 test_cmp expect actual
1676 test_expect_success 'version sort with very long prerelease suffix' '
1677 test_config versionsort.prereleaseSuffix -very-looooooooooooooooooooooooong-prerelease-suffix &&
1678 git tag -l --sort=version:refname
1681 run_with_limited_stack () {
1682 (ulimit -s 128 && "$@")
1685 test_lazy_prereq ULIMIT_STACK_SIZE 'run_with_limited_stack true'
1687 # we require ulimit, this excludes Windows
1688 test_expect_success ULIMIT_STACK_SIZE '--contains works in a deep repo' '
1691 while test $i -lt 8000
1693 echo "commit refs/heads/master
1694 committer A U Thor <author@example.com> $((1000000000 + $i * 100)) +0200
1698 test $i = 1 && echo "from refs/heads/master^0"
1700 done | git fast-import &&
1701 git checkout master &&
1702 git tag far-far-away HEAD^ &&
1703 run_with_limited_stack git tag --contains HEAD >actual &&
1704 test_cmp expect actual
1707 test_expect_success '--format should list tags as per format given' '
1708 cat >expect <<-\EOF &&
1709 refname : refs/tags/v1.0
1710 refname : refs/tags/v1.0.1
1711 refname : refs/tags/v1.1.3
1713 git tag -l --format="refname : %(refname)" "v1*" >actual &&
1714 test_cmp expect actual
1717 test_expect_success 'setup --merged test tags' '
1718 git tag mergetest-1 HEAD~2 &&
1719 git tag mergetest-2 HEAD~1 &&
1720 git tag mergetest-3 HEAD
1723 test_expect_success '--merged cannot be used in non-list mode' '
1724 test_must_fail git tag --merged=mergetest-2 foo
1727 test_expect_success '--merged shows merged tags' '
1728 cat >expect <<-\EOF &&
1732 git tag -l --merged=mergetest-2 mergetest-* >actual &&
1733 test_cmp expect actual
1736 test_expect_success '--no-merged show unmerged tags' '
1737 cat >expect <<-\EOF &&
1740 git tag -l --no-merged=mergetest-2 mergetest-* >actual &&
1741 test_cmp expect actual
1744 test_expect_success 'ambiguous branch/tags not marked' '
1745 git tag ambiguous &&
1746 git branch ambiguous &&
1747 echo ambiguous >expect &&
1748 git tag -l ambiguous >actual &&
1749 test_cmp expect actual