3 # Copyright (c) 2007 Carlos Rica
6 test_description
='git-tag
8 Tests for operations with tags.'
12 # creating and listing lightweight tags:
15 git show-ref
--quiet --verify refs
/tags
/"$1"
18 # todo: git tag -l now returns always zero, when fixed, change this test
19 test_expect_success
'listing all tags in an empty tree should succeed' '
24 test_expect_success
'listing all tags in an empty tree should output nothing' '
25 test `git-tag -l | wc -l` -eq 0 &&
26 test `git-tag | wc -l` -eq 0
29 test_expect_failure
'looking for a tag in an empty tree should fail' \
32 test_expect_success
'creating a tag in an empty tree should fail' '
37 test_expect_success
'creating a tag for HEAD in an empty tree should fail' '
38 ! git-tag mytaghead HEAD &&
39 ! tag_exists mytaghead
42 test_expect_success
'creating a tag for an unknown revision should fail' '
43 ! git-tag mytagnorev aaaaaaaaaaa &&
44 ! tag_exists mytagnorev
47 # commit used in the tests, test_tick is also called here to freeze the date:
48 test_expect_success
'creating a tag using default HEAD should succeed' '
56 test_expect_success
'listing all tags if one exists should succeed' '
61 test_expect_success
'listing all tags if one exists should output that tag' '
62 test `git-tag -l` = mytag &&
63 test `git-tag` = mytag
68 test_expect_success
'listing a tag using a matching pattern should succeed' \
72 'listing a tag using a matching pattern should output that tag' \
73 'test `git-tag -l mytag` = mytag'
75 # todo: git tag -l now returns always zero, when fixed, change this test
77 'listing tags using a non-matching pattern should suceed' \
81 'listing tags using a non-matching pattern should output nothing' \
82 'test `git-tag -l xxx | wc -l` -eq 0'
84 # special cases for creating tags:
87 'trying to create a tag with the name of one existing should fail' \
91 'trying to create a tag with a non-valid name should fail' '
92 test `git-tag -l | wc -l` -eq 1 &&
94 ! git tag .othertag &&
95 ! git tag "other tag" &&
96 ! git tag "othertag^" &&
97 ! git tag "other~tag" &&
98 test `git-tag -l | wc -l` -eq 1
101 test_expect_success
'creating a tag using HEAD directly should succeed' '
102 git tag myhead HEAD &&
108 test_expect_success
'trying to delete an unknown tag should fail' '
109 ! tag_exists unknown-tag &&
110 ! git-tag -d unknown-tag
117 test_expect_success \
118 'trying to delete tags without params should succeed and do nothing' '
119 git tag -l | cat > actual && git diff expect actual &&
121 git tag -l | cat > actual && git diff expect actual
124 test_expect_success \
125 'deleting two existing tags in one command should succeed' '
128 git-tag -d mytag myhead &&
129 ! tag_exists mytag &&
133 test_expect_success \
134 'creating a tag with the name of another deleted one should succeed' '
135 ! tag_exists mytag &&
140 test_expect_success \
141 'trying to delete two tags, existing and not, should fail in the 2nd' '
143 ! tag_exists myhead &&
144 ! git-tag -d mytag anothertag &&
145 ! tag_exists mytag &&
149 test_expect_failure
'trying to delete an already deleted tag should fail' \
152 # listing various tags with pattern matching:
165 test_expect_success
'listing all tags should print them ordered' '
175 git tag -l > actual &&
176 git diff expect actual &&
178 git diff expect actual
186 test_expect_success \
187 'listing tags with substring as pattern must print those matching' '
189 git-tag -l "*a*" > current &&
190 git diff expect current
197 test_expect_success \
198 'listing tags with a suffix as pattern must print those matching' '
199 git-tag -l "*.1" > actual &&
200 git diff expect actual
207 test_expect_success \
208 'listing tags with a prefix as pattern must print those matching' '
209 git-tag -l "t21*" > actual &&
210 git diff expect actual
216 test_expect_success \
217 'listing tags using a name as pattern must print that one matching' '
218 git-tag -l a1 > actual &&
219 git diff expect actual
225 test_expect_success \
226 'listing tags using a name as pattern must print that one matching' '
227 git-tag -l v1.0 > actual &&
228 git diff expect actual
235 test_expect_success \
236 'listing tags with ? in the pattern should print those matching' '
237 git-tag -l "v1.?.?" > actual &&
238 git diff expect actual
242 test_expect_success \
243 'listing tags using v.* should print nothing because none have v.' '
244 git-tag -l "v.*" > actual &&
245 git diff expect actual
254 test_expect_success \
255 'listing tags using v* should print only those having v' '
256 git-tag -l "v*" > actual &&
257 git diff expect actual
260 # creating and verifying lightweight tags:
262 test_expect_success \
263 'a non-annotated tag created without parameters should point to HEAD' '
264 git-tag non-annotated-tag &&
265 test $(git cat-file -t non-annotated-tag) = commit &&
266 test $(git rev-parse non-annotated-tag) = $(git rev-parse HEAD)
269 test_expect_failure
'trying to verify an unknown tag should fail' \
270 'git-tag -v unknown-tag'
272 test_expect_failure \
273 'trying to verify a non-annotated and non-signed tag should fail' \
274 'git-tag -v non-annotated-tag'
276 test_expect_failure \
277 'trying to verify many non-annotated or unknown tags, should fail' \
278 'git-tag -v unknown-tag1 non-annotated-tag unknown-tag2'
280 # creating annotated tags:
283 git cat-file tag
"$1" |
sed -e "/BEGIN PGP/q"
286 # run test_tick before committing always gives the time in that timezone
292 tagger C O Mitter <committer@example.com> $4 -0700
297 commit
=$
(git rev-parse HEAD
)
300 get_tag_header annotated-tag
$commit commit
$time >expect
301 echo "A message" >>expect
302 test_expect_success \
303 'creating an annotated tag with -m message should succeed' '
304 git-tag -m "A message" annotated-tag &&
305 get_tag_msg annotated-tag >actual &&
306 git diff expect actual
313 get_tag_header file-annotated-tag
$commit commit
$time >expect
315 test_expect_success \
316 'creating an annotated tag with -F messagefile should succeed' '
317 git-tag -F msgfile file-annotated-tag &&
318 get_tag_msg file-annotated-tag >actual &&
319 git diff expect actual
326 get_tag_header stdin-annotated-tag
$commit commit
$time >expect
327 cat inputmsg
>>expect
328 test_expect_success
'creating an annotated tag with -F - should succeed' '
329 git-tag -F - stdin-annotated-tag <inputmsg &&
330 get_tag_msg stdin-annotated-tag >actual &&
331 git diff expect actual
334 test_expect_success \
335 'trying to create a tag with a non-existing -F file should fail' '
336 ! test -f nonexistingfile &&
337 ! tag_exists notag &&
338 ! git-tag -F nonexistingfile notag &&
342 test_expect_success \
343 'trying to create tags giving many -m or -F options should fail' '
344 echo "message file 1" >msgfile1 &&
345 echo "message file 2" >msgfile2 &&
346 ! tag_exists msgtag &&
347 ! git-tag -m "message 1" -m "message 2" msgtag &&
348 ! tag_exists msgtag &&
349 ! git-tag -F msgfile1 -F msgfile2 msgtag &&
350 ! tag_exists msgtag &&
351 ! git-tag -m "message 1" -F msgfile1 msgtag &&
352 ! tag_exists msgtag &&
353 ! git-tag -F msgfile1 -m "message 1" msgtag &&
354 ! tag_exists msgtag &&
355 ! git-tag -F msgfile1 -m "message 1" -F msgfile2 msgtag &&
356 ! tag_exists msgtag &&
357 ! git-tag -m "message 1" -F msgfile1 -m "message 2" msgtag &&
361 # blank and empty messages:
363 get_tag_header empty-annotated-tag
$commit commit
$time >expect
364 test_expect_success \
365 'creating a tag with an empty -m message should succeed' '
366 git-tag -m "" empty-annotated-tag &&
367 get_tag_msg empty-annotated-tag >actual &&
368 git diff expect actual
372 get_tag_header emptyfile-annotated-tag
$commit commit
$time >expect
373 test_expect_success \
374 'creating a tag with an empty -F messagefile should succeed' '
375 git-tag -F emptyfile emptyfile-annotated-tag &&
376 get_tag_msg emptyfile-annotated-tag >actual &&
377 git diff expect actual
380 printf '\n\n \n\t\nLeading blank lines\n' >blanksfile
381 printf '\n\t \t \nRepeated blank lines\n' >>blanksfile
382 printf '\n\n\nTrailing spaces \t \n' >>blanksfile
383 printf '\nTrailing blank lines\n\n\t \n\n' >>blanksfile
384 get_tag_header blanks-annotated-tag
$commit commit
$time >expect
394 test_expect_success \
395 'extra blanks in the message for an annotated tag should be removed' '
396 git-tag -F blanksfile blanks-annotated-tag &&
397 get_tag_msg blanks-annotated-tag >actual &&
398 git diff expect actual
401 get_tag_header blank-annotated-tag
$commit commit
$time >expect
402 test_expect_success \
403 'creating a tag with blank -m message with spaces should succeed' '
404 git-tag -m " " blank-annotated-tag &&
405 get_tag_msg blank-annotated-tag >actual &&
406 git diff expect actual
412 get_tag_header blankfile-annotated-tag
$commit commit
$time >expect
413 test_expect_success \
414 'creating a tag with blank -F messagefile with spaces should succeed' '
415 git-tag -F blankfile blankfile-annotated-tag &&
416 get_tag_msg blankfile-annotated-tag >actual &&
417 git diff expect actual
420 printf ' ' >blanknonlfile
421 get_tag_header blanknonlfile-annotated-tag
$commit commit
$time >expect
422 test_expect_success \
423 'creating a tag with -F file of spaces and no newline should succeed' '
424 git-tag -F blanknonlfile blanknonlfile-annotated-tag &&
425 get_tag_msg blanknonlfile-annotated-tag >actual &&
426 git diff expect actual
429 # messages with commented lines:
431 cat >commentsfile
<<EOF
448 get_tag_header comments-annotated-tag
$commit commit
$time >expect
457 test_expect_success \
458 'creating a tag using a -F messagefile with #comments should succeed' '
459 git-tag -F commentsfile comments-annotated-tag &&
460 get_tag_msg comments-annotated-tag >actual &&
461 git diff expect actual
464 get_tag_header comment-annotated-tag
$commit commit
$time >expect
465 test_expect_success \
466 'creating a tag with a #comment in the -m message should succeed' '
467 git-tag -m "#comment" comment-annotated-tag &&
468 get_tag_msg comment-annotated-tag >actual &&
469 git diff expect actual
472 echo '#comment' >commentfile
473 echo '' >>commentfile
474 echo '####' >>commentfile
475 get_tag_header commentfile-annotated-tag
$commit commit
$time >expect
476 test_expect_success \
477 'creating a tag with #comments in the -F messagefile should succeed' '
478 git-tag -F commentfile commentfile-annotated-tag &&
479 get_tag_msg commentfile-annotated-tag >actual &&
480 git diff expect actual
483 printf '#comment' >commentnonlfile
484 get_tag_header commentnonlfile-annotated-tag
$commit commit
$time >expect
485 test_expect_success \
486 'creating a tag with a file of #comment and no newline should succeed' '
487 git-tag -F commentnonlfile commentnonlfile-annotated-tag &&
488 get_tag_msg commentnonlfile-annotated-tag >actual &&
489 git diff expect actual
492 # listing messages for annotated non-signed tags:
494 test_expect_success \
495 'listing the one-line message of a non-signed tag should succeed' '
496 git-tag -m "A msg" tag-one-line &&
498 echo "tag-one-line" >expect &&
499 git-tag -l | grep "^tag-one-line" >actual &&
500 git diff expect actual &&
501 git-tag -n 0 -l | grep "^tag-one-line" >actual &&
502 git diff expect actual &&
503 git-tag -n 0 -l tag-one-line >actual &&
504 git diff expect actual &&
506 echo "tag-one-line A msg" >expect &&
507 git-tag -n xxx -l | grep "^tag-one-line" >actual &&
508 git diff expect actual &&
509 git-tag -n "" -l | grep "^tag-one-line" >actual &&
510 git diff expect actual &&
511 git-tag -n 1 -l | grep "^tag-one-line" >actual &&
512 git diff expect actual &&
513 git-tag -n -l | grep "^tag-one-line" >actual &&
514 git diff expect actual &&
515 git-tag -n 1 -l tag-one-line >actual &&
516 git diff expect actual &&
517 git-tag -n 2 -l tag-one-line >actual &&
518 git diff expect actual &&
519 git-tag -n 999 -l tag-one-line >actual &&
520 git diff expect actual
523 test_expect_success \
524 'listing the zero-lines message of a non-signed tag should succeed' '
525 git-tag -m "" tag-zero-lines &&
527 echo "tag-zero-lines" >expect &&
528 git-tag -l | grep "^tag-zero-lines" >actual &&
529 git diff expect actual &&
530 git-tag -n 0 -l | grep "^tag-zero-lines" >actual &&
531 git diff expect actual &&
532 git-tag -n 0 -l tag-zero-lines >actual &&
533 git diff expect actual &&
535 echo "tag-zero-lines " >expect &&
536 git-tag -n 1 -l | grep "^tag-zero-lines" >actual &&
537 git diff expect actual &&
538 git-tag -n -l | grep "^tag-zero-lines" >actual &&
539 git diff expect actual &&
540 git-tag -n 1 -l tag-zero-lines >actual &&
541 git diff expect actual &&
542 git-tag -n 2 -l tag-zero-lines >actual &&
543 git diff expect actual &&
544 git-tag -n 999 -l tag-zero-lines >actual &&
545 git diff expect actual
548 echo 'tag line one' >annotagmsg
549 echo 'tag line two' >>annotagmsg
550 echo 'tag line three' >>annotagmsg
551 test_expect_success \
552 'listing many message lines of a non-signed tag should succeed' '
553 git-tag -F annotagmsg tag-lines &&
555 echo "tag-lines" >expect &&
556 git-tag -l | grep "^tag-lines" >actual &&
557 git diff expect actual &&
558 git-tag -n 0 -l | grep "^tag-lines" >actual &&
559 git diff expect actual &&
560 git-tag -n 0 -l tag-lines >actual &&
561 git diff expect actual &&
563 echo "tag-lines tag line one" >expect &&
564 git-tag -n 1 -l | grep "^tag-lines" >actual &&
565 git diff expect actual &&
566 git-tag -n -l | grep "^tag-lines" >actual &&
567 git diff expect actual &&
568 git-tag -n 1 -l tag-lines >actual &&
569 git diff expect actual &&
571 echo " tag line two" >>expect &&
572 git-tag -n 2 -l | grep "^ *tag.line" >actual &&
573 git diff expect actual &&
574 git-tag -n 2 -l tag-lines >actual &&
575 git diff expect actual &&
577 echo " tag line three" >>expect &&
578 git-tag -n 3 -l | grep "^ *tag.line" >actual &&
579 git diff expect actual &&
580 git-tag -n 3 -l tag-lines >actual &&
581 git diff expect actual &&
582 git-tag -n 4 -l | grep "^ *tag.line" >actual &&
583 git diff expect actual &&
584 git-tag -n 4 -l tag-lines >actual &&
585 git diff expect actual &&
586 git-tag -n 99 -l | grep "^ *tag.line" >actual &&
587 git diff expect actual &&
588 git-tag -n 99 -l tag-lines >actual &&
589 git diff expect actual
592 # trying to verify annotated non-signed tags:
594 test_expect_success \
595 'trying to verify an annotated non-signed tag should fail' '
596 tag_exists annotated-tag &&
597 ! git-tag -v annotated-tag
600 test_expect_success \
601 'trying to verify a file-annotated non-signed tag should fail' '
602 tag_exists file-annotated-tag &&
603 ! git-tag -v file-annotated-tag
606 test_expect_success \
607 'trying to verify two annotated non-signed tags should fail' '
608 tag_exists annotated-tag file-annotated-tag &&
609 ! git-tag -v annotated-tag file-annotated-tag
612 # creating and verifying signed tags:
614 gpg
--version >/dev
/null
615 if [ $?
-eq 127 ]; then
616 echo "Skipping signed tags tests, because gpg was not found"
621 # As said here: http://www.gnupg.org/documentation/faqs.html#q6.19
622 # the gpg version 1.0.6 didn't parse trust packets correctly, so for
623 # that version, creation of signed tags using the generated key fails.
624 case "$(gpg --version)" in
625 'gpg (GnuPG) 1.0.6'*)
626 echo "Skipping signed tag tests, because a bug in 1.0.6 version"
632 # key generation info: gpg --homedir t/t7004 --gen-key
633 # Type DSA and Elgamal, size 2048 bits, no expiration date.
634 # Name and email: C O Mitter <committer@example.com>
635 # No password given, to enable non-interactive operation.
637 cp -R ..
/t7004 .
/gpghome
639 export GNUPGHOME
="$(pwd)/gpghome"
641 get_tag_header signed-tag
$commit commit
$time >expect
642 echo 'A signed tag message' >>expect
643 echo '-----BEGIN PGP SIGNATURE-----' >>expect
644 test_expect_success
'creating a signed tag with -m message should succeed' '
645 git-tag -s -m "A signed tag message" signed-tag &&
646 get_tag_msg signed-tag >actual &&
647 git diff expect actual
650 cat >sigmsgfile
<<EOF
654 get_tag_header file-signed-tag
$commit commit
$time >expect
655 cat sigmsgfile
>>expect
656 echo '-----BEGIN PGP SIGNATURE-----' >>expect
657 test_expect_success \
658 'creating a signed tag with -F messagefile should succeed' '
659 git-tag -s -F sigmsgfile file-signed-tag &&
660 get_tag_msg file-signed-tag >actual &&
661 git diff expect actual
664 cat >siginputmsg
<<EOF
665 A signed tag message from
668 get_tag_header stdin-signed-tag
$commit commit
$time >expect
669 cat siginputmsg
>>expect
670 echo '-----BEGIN PGP SIGNATURE-----' >>expect
671 test_expect_success
'creating a signed tag with -F - should succeed' '
672 git-tag -s -F - stdin-signed-tag <siginputmsg &&
673 get_tag_msg stdin-signed-tag >actual &&
674 git diff expect actual
677 test_expect_success \
678 'trying to create a signed tag with non-existing -F file should fail' '
679 ! test -f nonexistingfile &&
680 ! tag_exists nosigtag &&
681 ! git-tag -s -F nonexistingfile nosigtag &&
682 ! tag_exists nosigtag
685 test_expect_success
'verifying a signed tag should succeed' \
686 'git-tag -v signed-tag'
688 test_expect_success
'verifying two signed tags in one command should succeed' \
689 'git-tag -v signed-tag file-signed-tag'
691 test_expect_success \
692 'verifying many signed and non-signed tags should fail' '
693 ! git-tag -v signed-tag annotated-tag &&
694 ! git-tag -v file-annotated-tag file-signed-tag &&
695 ! git-tag -v annotated-tag file-signed-tag file-annotated-tag &&
696 ! git-tag -v signed-tag annotated-tag file-signed-tag
699 test_expect_success
'verifying a forged tag should fail' '
700 forged=$(git cat-file tag signed-tag |
701 sed -e "s/signed-tag/forged-tag/" |
703 git tag forged-tag $forged &&
704 ! git-tag -v forged-tag
707 # blank and empty messages for signed tags:
709 get_tag_header empty-signed-tag
$commit commit
$time >expect
710 echo '-----BEGIN PGP SIGNATURE-----' >>expect
711 test_expect_success \
712 'creating a signed tag with an empty -m message should succeed' '
713 git-tag -s -m "" empty-signed-tag &&
714 get_tag_msg empty-signed-tag >actual &&
715 git diff expect actual &&
716 git-tag -v empty-signed-tag
720 get_tag_header emptyfile-signed-tag
$commit commit
$time >expect
721 echo '-----BEGIN PGP SIGNATURE-----' >>expect
722 test_expect_success \
723 'creating a signed tag with an empty -F messagefile should succeed' '
724 git-tag -s -F sigemptyfile emptyfile-signed-tag &&
725 get_tag_msg emptyfile-signed-tag >actual &&
726 git diff expect actual &&
727 git-tag -v emptyfile-signed-tag
730 printf '\n\n \n\t\nLeading blank lines\n' > sigblanksfile
731 printf '\n\t \t \nRepeated blank lines\n' >>sigblanksfile
732 printf '\n\n\nTrailing spaces \t \n' >>sigblanksfile
733 printf '\nTrailing blank lines\n\n\t \n\n' >>sigblanksfile
734 get_tag_header blanks-signed-tag
$commit commit
$time >expect
744 echo '-----BEGIN PGP SIGNATURE-----' >>expect
745 test_expect_success \
746 'extra blanks in the message for a signed tag should be removed' '
747 git-tag -s -F sigblanksfile blanks-signed-tag &&
748 get_tag_msg blanks-signed-tag >actual &&
749 git diff expect actual &&
750 git-tag -v blanks-signed-tag
753 get_tag_header blank-signed-tag
$commit commit
$time >expect
754 echo '-----BEGIN PGP SIGNATURE-----' >>expect
755 test_expect_success \
756 'creating a signed tag with a blank -m message should succeed' '
757 git-tag -s -m " " blank-signed-tag &&
758 get_tag_msg blank-signed-tag >actual &&
759 git diff expect actual &&
760 git-tag -v blank-signed-tag
763 echo ' ' >sigblankfile
764 echo '' >>sigblankfile
765 echo ' ' >>sigblankfile
766 get_tag_header blankfile-signed-tag
$commit commit
$time >expect
767 echo '-----BEGIN PGP SIGNATURE-----' >>expect
768 test_expect_success \
769 'creating a signed tag with blank -F file with spaces should succeed' '
770 git-tag -s -F sigblankfile blankfile-signed-tag &&
771 get_tag_msg blankfile-signed-tag >actual &&
772 git diff expect actual &&
773 git-tag -v blankfile-signed-tag
776 printf ' ' >sigblanknonlfile
777 get_tag_header blanknonlfile-signed-tag
$commit commit
$time >expect
778 echo '-----BEGIN PGP SIGNATURE-----' >>expect
779 test_expect_success \
780 'creating a signed tag with spaces and no newline should succeed' '
781 git-tag -s -F sigblanknonlfile blanknonlfile-signed-tag &&
782 get_tag_msg blanknonlfile-signed-tag >actual &&
783 git diff expect actual &&
784 git-tag -v signed-tag
787 # messages with commented lines for signed tags:
789 cat >sigcommentsfile
<<EOF
806 get_tag_header comments-signed-tag
$commit commit
$time >expect
815 echo '-----BEGIN PGP SIGNATURE-----' >>expect
816 test_expect_success \
817 'creating a signed tag with a -F file with #comments should succeed' '
818 git-tag -s -F sigcommentsfile comments-signed-tag &&
819 get_tag_msg comments-signed-tag >actual &&
820 git diff expect actual &&
821 git-tag -v comments-signed-tag
824 get_tag_header comment-signed-tag
$commit commit
$time >expect
825 echo '-----BEGIN PGP SIGNATURE-----' >>expect
826 test_expect_success \
827 'creating a signed tag with #commented -m message should succeed' '
828 git-tag -s -m "#comment" comment-signed-tag &&
829 get_tag_msg comment-signed-tag >actual &&
830 git diff expect actual &&
831 git-tag -v comment-signed-tag
834 echo '#comment' >sigcommentfile
835 echo '' >>sigcommentfile
836 echo '####' >>sigcommentfile
837 get_tag_header commentfile-signed-tag
$commit commit
$time >expect
838 echo '-----BEGIN PGP SIGNATURE-----' >>expect
839 test_expect_success \
840 'creating a signed tag with #commented -F messagefile should succeed' '
841 git-tag -s -F sigcommentfile commentfile-signed-tag &&
842 get_tag_msg commentfile-signed-tag >actual &&
843 git diff expect actual &&
844 git-tag -v commentfile-signed-tag
847 printf '#comment' >sigcommentnonlfile
848 get_tag_header commentnonlfile-signed-tag
$commit commit
$time >expect
849 echo '-----BEGIN PGP SIGNATURE-----' >>expect
850 test_expect_success \
851 'creating a signed tag with a #comment and no newline should succeed' '
852 git-tag -s -F sigcommentnonlfile commentnonlfile-signed-tag &&
853 get_tag_msg commentnonlfile-signed-tag >actual &&
854 git diff expect actual &&
855 git-tag -v commentnonlfile-signed-tag
858 # listing messages for signed tags:
860 test_expect_success \
861 'listing the one-line message of a signed tag should succeed' '
862 git-tag -s -m "A message line signed" stag-one-line &&
864 echo "stag-one-line" >expect &&
865 git-tag -l | grep "^stag-one-line" >actual &&
866 git diff expect actual &&
867 git-tag -n 0 -l | grep "^stag-one-line" >actual &&
868 git diff expect actual &&
869 git-tag -n 0 -l stag-one-line >actual &&
870 git diff expect actual &&
872 echo "stag-one-line A message line signed" >expect &&
873 git-tag -n xxx -l | grep "^stag-one-line" >actual &&
874 git diff expect actual &&
875 git-tag -n "" -l | grep "^stag-one-line" >actual &&
876 git diff expect actual &&
877 git-tag -n 1 -l | grep "^stag-one-line" >actual &&
878 git diff expect actual &&
879 git-tag -n -l | grep "^stag-one-line" >actual &&
880 git diff expect actual &&
881 git-tag -n 1 -l stag-one-line >actual &&
882 git diff expect actual &&
883 git-tag -n 2 -l stag-one-line >actual &&
884 git diff expect actual &&
885 git-tag -n 999 -l stag-one-line >actual &&
886 git diff expect actual
889 test_expect_success \
890 'listing the zero-lines message of a signed tag should succeed' '
891 git-tag -s -m "" stag-zero-lines &&
893 echo "stag-zero-lines" >expect &&
894 git-tag -l | grep "^stag-zero-lines" >actual &&
895 git diff expect actual &&
896 git-tag -n 0 -l | grep "^stag-zero-lines" >actual &&
897 git diff expect actual &&
898 git-tag -n 0 -l stag-zero-lines >actual &&
899 git diff expect actual &&
901 echo "stag-zero-lines " >expect &&
902 git-tag -n 1 -l | grep "^stag-zero-lines" >actual &&
903 git diff expect actual &&
904 git-tag -n -l | grep "^stag-zero-lines" >actual &&
905 git diff expect actual &&
906 git-tag -n 1 -l stag-zero-lines >actual &&
907 git diff expect actual &&
908 git-tag -n 2 -l stag-zero-lines >actual &&
909 git diff expect actual &&
910 git-tag -n 999 -l stag-zero-lines >actual &&
911 git diff expect actual
914 echo 'stag line one' >sigtagmsg
915 echo 'stag line two' >>sigtagmsg
916 echo 'stag line three' >>sigtagmsg
917 test_expect_success \
918 'listing many message lines of a signed tag should succeed' '
919 git-tag -s -F sigtagmsg stag-lines &&
921 echo "stag-lines" >expect &&
922 git-tag -l | grep "^stag-lines" >actual &&
923 git diff expect actual &&
924 git-tag -n 0 -l | grep "^stag-lines" >actual &&
925 git diff expect actual &&
926 git-tag -n 0 -l stag-lines >actual &&
927 git diff expect actual &&
929 echo "stag-lines stag line one" >expect &&
930 git-tag -n 1 -l | grep "^stag-lines" >actual &&
931 git diff expect actual &&
932 git-tag -n -l | grep "^stag-lines" >actual &&
933 git diff expect actual &&
934 git-tag -n 1 -l stag-lines >actual &&
935 git diff expect actual &&
937 echo " stag line two" >>expect &&
938 git-tag -n 2 -l | grep "^ *stag.line" >actual &&
939 git diff expect actual &&
940 git-tag -n 2 -l stag-lines >actual &&
941 git diff expect actual &&
943 echo " stag line three" >>expect &&
944 git-tag -n 3 -l | grep "^ *stag.line" >actual &&
945 git diff expect actual &&
946 git-tag -n 3 -l stag-lines >actual &&
947 git diff expect actual &&
948 git-tag -n 4 -l | grep "^ *stag.line" >actual &&
949 git diff expect actual &&
950 git-tag -n 4 -l stag-lines >actual &&
951 git diff expect actual &&
952 git-tag -n 99 -l | grep "^ *stag.line" >actual &&
953 git diff expect actual &&
954 git-tag -n 99 -l stag-lines >actual &&
955 git diff expect actual
958 # tags pointing to objects different from commits:
960 tree
=$
(git rev-parse HEAD^
{tree
})
961 blob
=$
(git rev-parse HEAD
:foo
)
962 tag
=$
(git rev-parse signed-tag
)
964 get_tag_header tree-signed-tag
$tree tree
$time >expect
965 echo "A message for a tree" >>expect
966 echo '-----BEGIN PGP SIGNATURE-----' >>expect
967 test_expect_success \
968 'creating a signed tag pointing to a tree should succeed' '
969 git-tag -s -m "A message for a tree" tree-signed-tag HEAD^{tree} &&
970 get_tag_msg tree-signed-tag >actual &&
971 git diff expect actual
974 get_tag_header blob-signed-tag
$blob blob
$time >expect
975 echo "A message for a blob" >>expect
976 echo '-----BEGIN PGP SIGNATURE-----' >>expect
977 test_expect_success \
978 'creating a signed tag pointing to a blob should succeed' '
979 git-tag -s -m "A message for a blob" blob-signed-tag HEAD:foo &&
980 get_tag_msg blob-signed-tag >actual &&
981 git diff expect actual
984 get_tag_header tag-signed-tag
$tag tag
$time >expect
985 echo "A message for another tag" >>expect
986 echo '-----BEGIN PGP SIGNATURE-----' >>expect
987 test_expect_success \
988 'creating a signed tag pointing to another tag should succeed' '
989 git-tag -s -m "A message for another tag" tag-signed-tag signed-tag &&
990 get_tag_msg tag-signed-tag >actual &&
991 git diff expect actual
994 # try to verify without gpg:
997 test_expect_failure \
998 'verify signed tag fails when public key is not present' \
999 'git-tag -v signed-tag'