Initial bulk commit for "Git on MSys"
[msysgit/historical-msysgit.git] / git / t / t7004-tag.sh
blob99b417ada540fafa5093a15612595cebf2faed08
1 #!/bin/sh
3 # Copyright (c) 2007 Carlos Rica
6 test_description='git-tag
8 Basic tests for operations with tags.'
10 . ./test-lib.sh
12 # creating and listing lightweight tags:
14 tag_exists () {
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' \
20 'git tag -l'
22 test_expect_success 'listing all tags in an empty tree should output nothing' \
23 'test `git-tag -l | wc -l` -eq 0'
25 test_expect_failure 'looking for a tag in an empty tree should fail' \
26 'tag_exists mytag'
28 test_expect_success 'creating a tag in an empty tree should fail' '
29 ! git-tag mynotag &&
30 ! tag_exists mynotag
33 test_expect_success 'creating a tag for HEAD in an empty tree should fail' '
34 ! git-tag mytaghead HEAD &&
35 ! tag_exists mytaghead
38 test_expect_success 'creating a tag for an unknown revision should fail' '
39 ! git-tag mytagnorev aaaaaaaaaaa &&
40 ! tag_exists mytagnorev
43 # commit used in the tests, test_tick is also called here to freeze the date:
44 test_expect_success 'creating a tag using default HEAD should succeed' '
45 test_tick &&
46 echo foo >foo &&
47 git add foo &&
48 git commit -m Foo &&
49 git tag mytag
52 test_expect_success 'listing all tags if one exists should succeed' \
53 'git-tag -l'
55 test_expect_success 'listing all tags if one exists should output that tag' \
56 'test `git-tag -l` = mytag'
58 # pattern matching:
60 test_expect_success 'listing a tag using a matching pattern should succeed' \
61 'git-tag -l mytag'
63 test_expect_success \
64 'listing a tag using a matching pattern should output that tag' \
65 'test `git-tag -l mytag` = mytag'
67 # todo: git tag -l now returns always zero, when fixed, change this test
68 test_expect_success \
69 'listing tags using a non-matching pattern should suceed' \
70 'git-tag -l xxx'
72 test_expect_success \
73 'listing tags using a non-matching pattern should output nothing' \
74 'test `git-tag -l xxx | wc -l` -eq 0'
76 # special cases for creating tags:
78 test_expect_failure \
79 'trying to create a tag with the name of one existing should fail' \
80 'git tag mytag'
82 test_expect_success \
83 'trying to create a tag with a non-valid name should fail' '
84 test `git-tag -l | wc -l` -eq 1 &&
85 ! git tag "" &&
86 ! git tag .othertag &&
87 ! git tag "other tag" &&
88 ! git tag "othertag^" &&
89 ! git tag "other~tag" &&
90 test `git-tag -l | wc -l` -eq 1
93 test_expect_success 'creating a tag using HEAD directly should succeed' '
94 git tag myhead HEAD &&
95 tag_exists myhead
98 # deleting tags:
100 test_expect_success 'trying to delete an unknown tag should fail' '
101 ! tag_exists unknown-tag &&
102 ! git-tag -d unknown-tag
105 cat >expect <<EOF
106 myhead
107 mytag
109 test_expect_success \
110 'trying to delete tags without params should succeed and do nothing' '
111 git tag -l | cat > actual && git diff expect actual &&
112 git-tag -d &&
113 git tag -l | cat > actual && git diff expect actual
116 test_expect_success \
117 'deleting two existing tags in one command should succeed' '
118 tag_exists mytag &&
119 tag_exists myhead &&
120 git-tag -d mytag myhead &&
121 ! tag_exists mytag &&
122 ! tag_exists myhead
125 test_expect_success \
126 'creating a tag with the name of another deleted one should succeed' '
127 ! tag_exists mytag &&
128 git-tag mytag &&
129 tag_exists mytag
132 test_expect_success \
133 'trying to delete two tags, existing and not, should fail in the 2nd' '
134 tag_exists mytag &&
135 ! tag_exists myhead &&
136 ! git-tag -d mytag anothertag &&
137 ! tag_exists mytag &&
138 ! tag_exists myhead
141 test_expect_failure 'trying to delete an already deleted tag should fail' \
142 'git-tag -d mytag'
144 # listing various tags with pattern matching:
146 cat >expect <<EOF
150 t210
151 t211
152 v0.2.1
153 v1.0
154 v1.0.1
155 v1.1.3
157 test_expect_success 'listing all tags should print them ordered' '
158 git tag v1.0.1 &&
159 git tag t211 &&
160 git tag aa1 &&
161 git tag v0.2.1 &&
162 git tag v1.1.3 &&
163 git tag cba &&
164 git tag a1 &&
165 git tag v1.0 &&
166 git tag t210 &&
167 git tag -l | cat > actual &&
168 git diff expect actual
171 cat >expect <<EOF
176 test_expect_success \
177 'listing tags with substring as pattern must print those matching' '
178 git-tag -l a > actual &&
179 git diff expect actual
182 cat >expect <<EOF
183 v0.2.1
184 v1.0.1
185 v1.1.3
187 test_expect_success \
188 'listing tags with substring as pattern must print those matching' '
189 git-tag -l .1 > actual &&
190 git diff expect actual
193 cat >expect <<EOF
194 t210
195 t211
197 test_expect_success \
198 'listing tags with substring as pattern must print those matching' '
199 git-tag -l t21 > actual &&
200 git diff expect actual
203 cat >expect <<EOF
207 test_expect_success \
208 'listing tags using a name as pattern must print those matching' '
209 git-tag -l a1 > actual &&
210 git diff expect actual
213 cat >expect <<EOF
214 v1.0
215 v1.0.1
217 test_expect_success \
218 'listing tags using a name as pattern must print those matching' '
219 git-tag -l v1.0 > actual &&
220 git diff expect actual
223 cat >expect <<EOF
224 v1.1.3
226 test_expect_success \
227 'listing tags with ? in the pattern should print those matching' '
228 git-tag -l "1.1?" > actual &&
229 git diff expect actual
232 >expect
233 test_expect_success \
234 'listing tags using v.* should print nothing because none have v.' '
235 git-tag -l "v.*" > actual &&
236 git diff expect actual
239 cat >expect <<EOF
240 v0.2.1
241 v1.0
242 v1.0.1
243 v1.1.3
245 test_expect_success \
246 'listing tags using v* should print only those having v' '
247 git-tag -l "v*" > actual &&
248 git diff expect actual
251 # creating and verifying lightweight tags:
253 test_expect_success \
254 'a non-annotated tag created without parameters should point to HEAD' '
255 git-tag non-annotated-tag &&
256 test $(git cat-file -t non-annotated-tag) = commit &&
257 test $(git rev-parse non-annotated-tag) = $(git rev-parse HEAD)
260 test_expect_failure 'trying to verify an unknown tag should fail' \
261 'git-tag -v unknown-tag'
263 test_expect_failure \
264 'trying to verify a non-annotated and non-signed tag should fail' \
265 'git-tag -v non-annotated-tag'
267 # creating annotated tags:
269 get_tag_msg () {
270 git cat-file tag "$1" | sed -e "/BEGIN PGP/q"
273 # run test_tick before committing always gives the time in that timezone
274 get_tag_header () {
275 cat <<EOF
276 object $2
277 type $3
278 tag $1
279 tagger C O Mitter <committer@example.com> $4 -0700
284 commit=$(git rev-parse HEAD)
285 time=$test_tick
287 get_tag_header annotated-tag $commit commit $time >expect
288 echo "A message" >>expect
289 test_expect_success \
290 'creating an annotated tag with -m message should succeed' '
291 git-tag -m "A message" annotated-tag &&
292 get_tag_msg annotated-tag >actual &&
293 git diff expect actual
296 cat >msgfile <<EOF
297 Another message
298 in a file.
300 get_tag_header file-annotated-tag $commit commit $time >expect
301 cat msgfile >>expect
302 test_expect_success \
303 'creating an annotated tag with -F messagefile should succeed' '
304 git-tag -F msgfile file-annotated-tag &&
305 get_tag_msg file-annotated-tag >actual &&
306 git diff expect actual
309 # blank and empty messages:
311 get_tag_header empty-annotated-tag $commit commit $time >expect
312 test_expect_success \
313 'creating a tag with an empty -m message should succeed' '
314 git-tag -m "" empty-annotated-tag &&
315 get_tag_msg empty-annotated-tag >actual &&
316 git diff expect actual
319 >emptyfile
320 get_tag_header emptyfile-annotated-tag $commit commit $time >expect
321 test_expect_success \
322 'creating a tag with an empty -F messagefile should succeed' '
323 git-tag -F emptyfile emptyfile-annotated-tag &&
324 get_tag_msg emptyfile-annotated-tag >actual &&
325 git diff expect actual
328 printf '\n\n \n\t\nLeading blank lines\n' >blanksfile
329 printf '\n\t \t \nRepeated blank lines\n' >>blanksfile
330 printf '\n\n\nTrailing spaces \t \n' >>blanksfile
331 printf '\nTrailing blank lines\n\n\t \n\n' >>blanksfile
332 get_tag_header blanks-annotated-tag $commit commit $time >expect
333 cat >>expect <<EOF
334 Leading blank lines
336 Repeated blank lines
338 Trailing spaces
340 Trailing blank lines
342 test_expect_success \
343 'extra blanks in the message for an annotated tag should be removed' '
344 git-tag -F blanksfile blanks-annotated-tag &&
345 get_tag_msg blanks-annotated-tag >actual &&
346 git diff expect actual
349 get_tag_header blank-annotated-tag $commit commit $time >expect
350 test_expect_success \
351 'creating a tag with blank -m message with spaces should succeed' '
352 git-tag -m " " blank-annotated-tag &&
353 get_tag_msg blank-annotated-tag >actual &&
354 git diff expect actual
357 echo ' ' >blankfile
358 echo '' >>blankfile
359 echo ' ' >>blankfile
360 get_tag_header blankfile-annotated-tag $commit commit $time >expect
361 test_expect_success \
362 'creating a tag with blank -F messagefile with spaces should succeed' '
363 git-tag -F blankfile blankfile-annotated-tag &&
364 get_tag_msg blankfile-annotated-tag >actual &&
365 git diff expect actual
368 printf ' ' >blanknonlfile
369 get_tag_header blanknonlfile-annotated-tag $commit commit $time >expect
370 test_expect_success \
371 'creating a tag with -F file of spaces and no newline should succeed' '
372 git-tag -F blanknonlfile blanknonlfile-annotated-tag &&
373 get_tag_msg blanknonlfile-annotated-tag >actual &&
374 git diff expect actual
377 # messages with commented lines:
379 cat >commentsfile <<EOF
380 # A comment
382 ############
383 The message.
384 ############
385 One line.
388 # commented lines
389 # commented lines
391 Another line.
392 # comments
394 Last line.
396 get_tag_header comments-annotated-tag $commit commit $time >expect
397 cat >>expect <<EOF
398 The message.
399 One line.
401 Another line.
403 Last line.
405 test_expect_success \
406 'creating a tag using a -F messagefile with #comments should succeed' '
407 git-tag -F commentsfile comments-annotated-tag &&
408 get_tag_msg comments-annotated-tag >actual &&
409 git diff expect actual
412 get_tag_header comment-annotated-tag $commit commit $time >expect
413 test_expect_success \
414 'creating a tag with a #comment in the -m message should succeed' '
415 git-tag -m "#comment" comment-annotated-tag &&
416 get_tag_msg comment-annotated-tag >actual &&
417 git diff expect actual
420 echo '#comment' >commentfile
421 echo '' >>commentfile
422 echo '####' >>commentfile
423 get_tag_header commentfile-annotated-tag $commit commit $time >expect
424 test_expect_success \
425 'creating a tag with #comments in the -F messagefile should succeed' '
426 git-tag -F commentfile commentfile-annotated-tag &&
427 get_tag_msg commentfile-annotated-tag >actual &&
428 git diff expect actual
431 printf '#comment' >commentnonlfile
432 get_tag_header commentnonlfile-annotated-tag $commit commit $time >expect
433 test_expect_success \
434 'creating a tag with a file of #comment and no newline should succeed' '
435 git-tag -F commentnonlfile commentnonlfile-annotated-tag &&
436 get_tag_msg commentnonlfile-annotated-tag >actual &&
437 git diff expect actual
440 # listing messages for annotated non-signed tags:
442 test_expect_success \
443 'listing the one-line message of a non-signed tag should succeed' '
444 git-tag -m "A msg" tag-one-line &&
446 echo "tag-one-line" >expect &&
447 git-tag -l | grep "^tag-one-line" >actual &&
448 git diff expect actual &&
449 git-tag -n 0 -l | grep "^tag-one-line" >actual &&
450 git diff expect actual &&
451 git-tag -n 0 -l tag-one-line >actual &&
452 git diff expect actual &&
454 echo "tag-one-line A msg" >expect &&
455 git-tag -n xxx -l | grep "^tag-one-line" >actual &&
456 git diff expect actual &&
457 git-tag -n "" -l | grep "^tag-one-line" >actual &&
458 git diff expect actual &&
459 git-tag -n 1 -l | grep "^tag-one-line" >actual &&
460 git diff expect actual &&
461 git-tag -n -l | grep "^tag-one-line" >actual &&
462 git diff expect actual &&
463 git-tag -n 1 -l tag-one-line >actual &&
464 git diff expect actual &&
465 git-tag -n 2 -l tag-one-line >actual &&
466 git diff expect actual &&
467 git-tag -n 999 -l tag-one-line >actual &&
468 git diff expect actual
471 test_expect_success \
472 'listing the zero-lines message of a non-signed tag should succeed' '
473 git-tag -m "" tag-zero-lines &&
475 echo "tag-zero-lines" >expect &&
476 git-tag -l | grep "^tag-zero-lines" >actual &&
477 git diff expect actual &&
478 git-tag -n 0 -l | grep "^tag-zero-lines" >actual &&
479 git diff expect actual &&
480 git-tag -n 0 -l tag-zero-lines >actual &&
481 git diff expect actual &&
483 echo "tag-zero-lines " >expect &&
484 git-tag -n 1 -l | grep "^tag-zero-lines" >actual &&
485 git diff expect actual &&
486 git-tag -n -l | grep "^tag-zero-lines" >actual &&
487 git diff expect actual &&
488 git-tag -n 1 -l tag-zero-lines >actual &&
489 git diff expect actual &&
490 git-tag -n 2 -l tag-zero-lines >actual &&
491 git diff expect actual &&
492 git-tag -n 999 -l tag-zero-lines >actual &&
493 git diff expect actual
496 echo 'tag line one' >annotagmsg
497 echo 'tag line two' >>annotagmsg
498 echo 'tag line three' >>annotagmsg
499 test_expect_success \
500 'listing many message lines of a non-signed tag should succeed' '
501 git-tag -F annotagmsg tag-lines &&
503 echo "tag-lines" >expect &&
504 git-tag -l | grep "^tag-lines" >actual &&
505 git diff expect actual &&
506 git-tag -n 0 -l | grep "^tag-lines" >actual &&
507 git diff expect actual &&
508 git-tag -n 0 -l tag-lines >actual &&
509 git diff expect actual &&
511 echo "tag-lines tag line one" >expect &&
512 git-tag -n 1 -l | grep "^tag-lines" >actual &&
513 git diff expect actual &&
514 git-tag -n -l | grep "^tag-lines" >actual &&
515 git diff expect actual &&
516 git-tag -n 1 -l tag-lines >actual &&
517 git diff expect actual &&
519 echo " tag line two" >>expect &&
520 git-tag -n 2 -l | grep "^ *tag.line" >actual &&
521 git diff expect actual &&
522 git-tag -n 2 -l tag-lines >actual &&
523 git diff expect actual &&
525 echo " tag line three" >>expect &&
526 git-tag -n 3 -l | grep "^ *tag.line" >actual &&
527 git diff expect actual &&
528 git-tag -n 3 -l tag-lines >actual &&
529 git diff expect actual &&
530 git-tag -n 4 -l | grep "^ *tag.line" >actual &&
531 git diff expect actual &&
532 git-tag -n 4 -l tag-lines >actual &&
533 git diff expect actual &&
534 git-tag -n 99 -l | grep "^ *tag.line" >actual &&
535 git diff expect actual &&
536 git-tag -n 99 -l tag-lines >actual &&
537 git diff expect actual
540 # trying to verify annotated non-signed tags:
542 test_expect_success \
543 'trying to verify an annotated non-signed tag should fail' '
544 tag_exists annotated-tag &&
545 ! git-tag -v annotated-tag
548 test_expect_success \
549 'trying to verify a file-annotated non-signed tag should fail' '
550 tag_exists file-annotated-tag &&
551 ! git-tag -v file-annotated-tag
554 # creating and verifying signed tags:
556 gpg --version >/dev/null
557 if [ $? -eq 127 ]; then
558 echo "Skipping signed tags tests, because gpg was not found"
559 test_done
560 exit
563 # As said here: http://www.gnupg.org/documentation/faqs.html#q6.19
564 # the gpg version 1.0.6 didn't parse trust packets correctly, so for
565 # that version, creation of signed tags using the generated key fails.
566 case "$(gpg --version)" in
567 'gpg (GnuPG) 1.0.6'*)
568 echo "Skipping signed tag tests, because a bug in 1.0.6 version"
569 test_done
570 exit
572 esac
574 # key generation info: gpg --homedir t/t7004 --gen-key
575 # Type DSA and Elgamal, size 2048 bits, no expiration date.
576 # Name and email: C O Mitter <committer@example.com>
577 # No password given, to enable non-interactive operation.
579 cp -R ../t7004 ./gpghome
580 chmod 0700 gpghome
581 export GNUPGHOME="$(pwd)/gpghome"
583 get_tag_header signed-tag $commit commit $time >expect
584 echo 'A signed tag message' >>expect
585 echo '-----BEGIN PGP SIGNATURE-----' >>expect
586 test_expect_success 'creating a signed tag with -m message should succeed' '
587 git-tag -s -m "A signed tag message" signed-tag &&
588 get_tag_msg signed-tag >actual &&
589 git diff expect actual
592 test_expect_success 'verifying a signed tag should succeed' \
593 'git-tag -v signed-tag'
595 test_expect_success 'verifying a forged tag should fail' '
596 forged=$(git cat-file tag signed-tag |
597 sed -e "s/signed-tag/forged-tag/" |
598 git mktag) &&
599 git tag forged-tag $forged &&
600 ! git-tag -v forged-tag
603 # blank and empty messages for signed tags:
605 get_tag_header empty-signed-tag $commit commit $time >expect
606 echo '-----BEGIN PGP SIGNATURE-----' >>expect
607 test_expect_success \
608 'creating a signed tag with an empty -m message should succeed' '
609 git-tag -s -m "" empty-signed-tag &&
610 get_tag_msg empty-signed-tag >actual &&
611 git diff expect actual &&
612 git-tag -v empty-signed-tag
615 >sigemptyfile
616 get_tag_header emptyfile-signed-tag $commit commit $time >expect
617 echo '-----BEGIN PGP SIGNATURE-----' >>expect
618 test_expect_success \
619 'creating a signed tag with an empty -F messagefile should succeed' '
620 git-tag -s -F sigemptyfile emptyfile-signed-tag &&
621 get_tag_msg emptyfile-signed-tag >actual &&
622 git diff expect actual &&
623 git-tag -v emptyfile-signed-tag
626 printf '\n\n \n\t\nLeading blank lines\n' > sigblanksfile
627 printf '\n\t \t \nRepeated blank lines\n' >>sigblanksfile
628 printf '\n\n\nTrailing spaces \t \n' >>sigblanksfile
629 printf '\nTrailing blank lines\n\n\t \n\n' >>sigblanksfile
630 get_tag_header blanks-signed-tag $commit commit $time >expect
631 cat >>expect <<EOF
632 Leading blank lines
634 Repeated blank lines
636 Trailing spaces
638 Trailing blank lines
640 echo '-----BEGIN PGP SIGNATURE-----' >>expect
641 test_expect_success \
642 'extra blanks in the message for a signed tag should be removed' '
643 git-tag -s -F sigblanksfile blanks-signed-tag &&
644 get_tag_msg blanks-signed-tag >actual &&
645 git diff expect actual &&
646 git-tag -v blanks-signed-tag
649 get_tag_header blank-signed-tag $commit commit $time >expect
650 echo '-----BEGIN PGP SIGNATURE-----' >>expect
651 test_expect_success \
652 'creating a signed tag with a blank -m message should succeed' '
653 git-tag -s -m " " blank-signed-tag &&
654 get_tag_msg blank-signed-tag >actual &&
655 git diff expect actual &&
656 git-tag -v blank-signed-tag
659 echo ' ' >sigblankfile
660 echo '' >>sigblankfile
661 echo ' ' >>sigblankfile
662 get_tag_header blankfile-signed-tag $commit commit $time >expect
663 echo '-----BEGIN PGP SIGNATURE-----' >>expect
664 test_expect_success \
665 'creating a signed tag with blank -F file with spaces should succeed' '
666 git-tag -s -F sigblankfile blankfile-signed-tag &&
667 get_tag_msg blankfile-signed-tag >actual &&
668 git diff expect actual &&
669 git-tag -v blankfile-signed-tag
672 printf ' ' >sigblanknonlfile
673 get_tag_header blanknonlfile-signed-tag $commit commit $time >expect
674 echo '-----BEGIN PGP SIGNATURE-----' >>expect
675 test_expect_success \
676 'creating a signed tag with spaces and no newline should succeed' '
677 git-tag -s -F sigblanknonlfile blanknonlfile-signed-tag &&
678 get_tag_msg blanknonlfile-signed-tag >actual &&
679 git diff expect actual &&
680 git-tag -v signed-tag
683 # messages with commented lines for signed tags:
685 cat >sigcommentsfile <<EOF
686 # A comment
688 ############
689 The message.
690 ############
691 One line.
694 # commented lines
695 # commented lines
697 Another line.
698 # comments
700 Last line.
702 get_tag_header comments-signed-tag $commit commit $time >expect
703 cat >>expect <<EOF
704 The message.
705 One line.
707 Another line.
709 Last line.
711 echo '-----BEGIN PGP SIGNATURE-----' >>expect
712 test_expect_success \
713 'creating a signed tag with a -F file with #comments should succeed' '
714 git-tag -s -F sigcommentsfile comments-signed-tag &&
715 get_tag_msg comments-signed-tag >actual &&
716 git diff expect actual &&
717 git-tag -v comments-signed-tag
720 get_tag_header comment-signed-tag $commit commit $time >expect
721 echo '-----BEGIN PGP SIGNATURE-----' >>expect
722 test_expect_success \
723 'creating a signed tag with #commented -m message should succeed' '
724 git-tag -s -m "#comment" comment-signed-tag &&
725 get_tag_msg comment-signed-tag >actual &&
726 git diff expect actual &&
727 git-tag -v comment-signed-tag
730 echo '#comment' >sigcommentfile
731 echo '' >>sigcommentfile
732 echo '####' >>sigcommentfile
733 get_tag_header commentfile-signed-tag $commit commit $time >expect
734 echo '-----BEGIN PGP SIGNATURE-----' >>expect
735 test_expect_success \
736 'creating a signed tag with #commented -F messagefile should succeed' '
737 git-tag -s -F sigcommentfile commentfile-signed-tag &&
738 get_tag_msg commentfile-signed-tag >actual &&
739 git diff expect actual &&
740 git-tag -v commentfile-signed-tag
743 printf '#comment' >sigcommentnonlfile
744 get_tag_header commentnonlfile-signed-tag $commit commit $time >expect
745 echo '-----BEGIN PGP SIGNATURE-----' >>expect
746 test_expect_success \
747 'creating a signed tag with a #comment and no newline should succeed' '
748 git-tag -s -F sigcommentnonlfile commentnonlfile-signed-tag &&
749 get_tag_msg commentnonlfile-signed-tag >actual &&
750 git diff expect actual &&
751 git-tag -v commentnonlfile-signed-tag
754 # listing messages for signed tags:
756 test_expect_success \
757 'listing the one-line message of a signed tag should succeed' '
758 git-tag -s -m "A message line signed" stag-one-line &&
760 echo "stag-one-line" >expect &&
761 git-tag -l | grep "^stag-one-line" >actual &&
762 git diff expect actual &&
763 git-tag -n 0 -l | grep "^stag-one-line" >actual &&
764 git diff expect actual &&
765 git-tag -n 0 -l stag-one-line >actual &&
766 git diff expect actual &&
768 echo "stag-one-line A message line signed" >expect &&
769 git-tag -n xxx -l | grep "^stag-one-line" >actual &&
770 git diff expect actual &&
771 git-tag -n "" -l | grep "^stag-one-line" >actual &&
772 git diff expect actual &&
773 git-tag -n 1 -l | grep "^stag-one-line" >actual &&
774 git diff expect actual &&
775 git-tag -n -l | grep "^stag-one-line" >actual &&
776 git diff expect actual &&
777 git-tag -n 1 -l stag-one-line >actual &&
778 git diff expect actual &&
779 git-tag -n 2 -l stag-one-line >actual &&
780 git diff expect actual &&
781 git-tag -n 999 -l stag-one-line >actual &&
782 git diff expect actual
785 test_expect_success \
786 'listing the zero-lines message of a signed tag should succeed' '
787 git-tag -s -m "" stag-zero-lines &&
789 echo "stag-zero-lines" >expect &&
790 git-tag -l | grep "^stag-zero-lines" >actual &&
791 git diff expect actual &&
792 git-tag -n 0 -l | grep "^stag-zero-lines" >actual &&
793 git diff expect actual &&
794 git-tag -n 0 -l stag-zero-lines >actual &&
795 git diff expect actual &&
797 echo "stag-zero-lines " >expect &&
798 git-tag -n 1 -l | grep "^stag-zero-lines" >actual &&
799 git diff expect actual &&
800 git-tag -n -l | grep "^stag-zero-lines" >actual &&
801 git diff expect actual &&
802 git-tag -n 1 -l stag-zero-lines >actual &&
803 git diff expect actual &&
804 git-tag -n 2 -l stag-zero-lines >actual &&
805 git diff expect actual &&
806 git-tag -n 999 -l stag-zero-lines >actual &&
807 git diff expect actual
810 echo 'stag line one' >sigtagmsg
811 echo 'stag line two' >>sigtagmsg
812 echo 'stag line three' >>sigtagmsg
813 test_expect_success \
814 'listing many message lines of a signed tag should succeed' '
815 git-tag -s -F sigtagmsg stag-lines &&
817 echo "stag-lines" >expect &&
818 git-tag -l | grep "^stag-lines" >actual &&
819 git diff expect actual &&
820 git-tag -n 0 -l | grep "^stag-lines" >actual &&
821 git diff expect actual &&
822 git-tag -n 0 -l stag-lines >actual &&
823 git diff expect actual &&
825 echo "stag-lines stag line one" >expect &&
826 git-tag -n 1 -l | grep "^stag-lines" >actual &&
827 git diff expect actual &&
828 git-tag -n -l | grep "^stag-lines" >actual &&
829 git diff expect actual &&
830 git-tag -n 1 -l stag-lines >actual &&
831 git diff expect actual &&
833 echo " stag line two" >>expect &&
834 git-tag -n 2 -l | grep "^ *stag.line" >actual &&
835 git diff expect actual &&
836 git-tag -n 2 -l stag-lines >actual &&
837 git diff expect actual &&
839 echo " stag line three" >>expect &&
840 git-tag -n 3 -l | grep "^ *stag.line" >actual &&
841 git diff expect actual &&
842 git-tag -n 3 -l stag-lines >actual &&
843 git diff expect actual &&
844 git-tag -n 4 -l | grep "^ *stag.line" >actual &&
845 git diff expect actual &&
846 git-tag -n 4 -l stag-lines >actual &&
847 git diff expect actual &&
848 git-tag -n 99 -l | grep "^ *stag.line" >actual &&
849 git diff expect actual &&
850 git-tag -n 99 -l stag-lines >actual &&
851 git diff expect actual
854 # tags pointing to objects different from commits:
856 tree=$(git rev-parse HEAD^{tree})
857 blob=$(git rev-parse HEAD:foo)
858 tag=$(git rev-parse signed-tag)
860 get_tag_header tree-signed-tag $tree tree $time >expect
861 echo "A message for a tree" >>expect
862 echo '-----BEGIN PGP SIGNATURE-----' >>expect
863 test_expect_success \
864 'creating a signed tag pointing to a tree should succeed' '
865 git-tag -s -m "A message for a tree" tree-signed-tag HEAD^{tree} &&
866 get_tag_msg tree-signed-tag >actual &&
867 git diff expect actual
870 get_tag_header blob-signed-tag $blob blob $time >expect
871 echo "A message for a blob" >>expect
872 echo '-----BEGIN PGP SIGNATURE-----' >>expect
873 test_expect_success \
874 'creating a signed tag pointing to a blob should succeed' '
875 git-tag -s -m "A message for a blob" blob-signed-tag HEAD:foo &&
876 get_tag_msg blob-signed-tag >actual &&
877 git diff expect actual
880 get_tag_header tag-signed-tag $tag tag $time >expect
881 echo "A message for another tag" >>expect
882 echo '-----BEGIN PGP SIGNATURE-----' >>expect
883 test_expect_success \
884 'creating a signed tag pointing to another tag should succeed' '
885 git-tag -s -m "A message for another tag" tag-signed-tag signed-tag &&
886 get_tag_msg tag-signed-tag >actual &&
887 git diff expect actual
890 # try to verify without gpg:
892 rm -rf gpghome
893 test_expect_failure \
894 'verify signed tag fails when public key is not present' \
895 'git-tag -v signed-tag'
897 test_done