strbuf: make stripspace() part of strbuf
[git/debian.git] / t / t7004-tag.sh
blobd31788cc6ce6a5698c34ffe6ee8a59fccacab90c
1 #!/bin/sh
3 # Copyright (c) 2007 Carlos Rica
6 test_description='git tag
8 Tests for operations with tags.'
10 . ./test-lib.sh
11 . "$TEST_DIRECTORY"/lib-gpg.sh
13 # creating and listing lightweight tags:
15 tag_exists () {
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' '
21 git tag -l &&
22 git tag
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 'looking for a tag in an empty tree should fail' \
31 '! (tag_exists mytag)'
33 test_expect_success 'creating a tag in an empty tree should fail' '
34 test_must_fail git tag mynotag &&
35 ! tag_exists mynotag
38 test_expect_success 'creating a tag for HEAD in an empty tree should fail' '
39 test_must_fail git tag mytaghead HEAD &&
40 ! tag_exists mytaghead
43 test_expect_success 'creating a tag for an unknown revision should fail' '
44 test_must_fail git tag mytagnorev aaaaaaaaaaa &&
45 ! tag_exists mytagnorev
48 # commit used in the tests, test_tick is also called here to freeze the date:
49 test_expect_success 'creating a tag using default HEAD should succeed' '
50 test_tick &&
51 echo foo >foo &&
52 git add foo &&
53 git commit -m Foo &&
54 git tag mytag &&
55 test_must_fail git reflog exists refs/tags/mytag
58 test_expect_success 'creating a tag with --create-reflog should create reflog' '
59 test_when_finished "git tag -d tag_with_reflog" &&
60 git tag --create-reflog tag_with_reflog &&
61 git reflog exists refs/tags/tag_with_reflog
64 test_expect_success '--create-reflog does not create reflog on failure' '
65 test_must_fail git tag --create-reflog mytag &&
66 test_must_fail git reflog exists refs/tags/mytag
69 test_expect_success 'listing all tags if one exists should succeed' '
70 git tag -l &&
71 git tag
74 test_expect_success 'listing all tags if one exists should output that tag' '
75 test `git tag -l` = mytag &&
76 test `git tag` = mytag
79 # pattern matching:
81 test_expect_success 'listing a tag using a matching pattern should succeed' \
82 'git tag -l mytag'
84 test_expect_success \
85 'listing a tag using a matching pattern should output that tag' \
86 'test `git tag -l mytag` = mytag'
88 # todo: git tag -l now returns always zero, when fixed, change this test
89 test_expect_success \
90 'listing tags using a non-matching pattern should suceed' \
91 'git tag -l xxx'
93 test_expect_success \
94 'listing tags using a non-matching pattern should output nothing' \
95 'test `git tag -l xxx | wc -l` -eq 0'
97 # special cases for creating tags:
99 test_expect_success \
100 'trying to create a tag with the name of one existing should fail' \
101 'test_must_fail git tag mytag'
103 test_expect_success \
104 'trying to create a tag with a non-valid name should fail' '
105 test `git tag -l | wc -l` -eq 1 &&
106 test_must_fail git tag "" &&
107 test_must_fail git tag .othertag &&
108 test_must_fail git tag "other tag" &&
109 test_must_fail git tag "othertag^" &&
110 test_must_fail git tag "other~tag" &&
111 test `git tag -l | wc -l` -eq 1
114 test_expect_success 'creating a tag using HEAD directly should succeed' '
115 git tag myhead HEAD &&
116 tag_exists myhead
119 test_expect_success '--force can create a tag with the name of one existing' '
120 tag_exists mytag &&
121 git tag --force mytag &&
122 tag_exists mytag'
124 test_expect_success '--force is moot with a non-existing tag name' '
125 git tag newtag >expect &&
126 git tag --force forcetag >actual &&
127 test_cmp expect actual
129 git tag -d newtag forcetag
131 # deleting tags:
133 test_expect_success 'trying to delete an unknown tag should fail' '
134 ! tag_exists unknown-tag &&
135 test_must_fail git tag -d unknown-tag
138 cat >expect <<EOF
139 myhead
140 mytag
142 test_expect_success \
143 'trying to delete tags without params should succeed and do nothing' '
144 git tag -l > actual && test_cmp expect actual &&
145 git tag -d &&
146 git tag -l > actual && test_cmp expect actual
149 test_expect_success \
150 'deleting two existing tags in one command should succeed' '
151 tag_exists mytag &&
152 tag_exists myhead &&
153 git tag -d mytag myhead &&
154 ! tag_exists mytag &&
155 ! tag_exists myhead
158 test_expect_success \
159 'creating a tag with the name of another deleted one should succeed' '
160 ! tag_exists mytag &&
161 git tag mytag &&
162 tag_exists mytag
165 test_expect_success \
166 'trying to delete two tags, existing and not, should fail in the 2nd' '
167 tag_exists mytag &&
168 ! tag_exists myhead &&
169 test_must_fail git tag -d mytag anothertag &&
170 ! tag_exists mytag &&
171 ! tag_exists myhead
174 test_expect_success 'trying to delete an already deleted tag should fail' \
175 'test_must_fail git tag -d mytag'
177 # listing various tags with pattern matching:
179 cat >expect <<EOF
183 t210
184 t211
185 v0.2.1
186 v1.0
187 v1.0.1
188 v1.1.3
190 test_expect_success 'listing all tags should print them ordered' '
191 git tag v1.0.1 &&
192 git tag t211 &&
193 git tag aa1 &&
194 git tag v0.2.1 &&
195 git tag v1.1.3 &&
196 git tag cba &&
197 git tag a1 &&
198 git tag v1.0 &&
199 git tag t210 &&
200 git tag -l > actual &&
201 test_cmp expect actual &&
202 git tag > actual &&
203 test_cmp expect actual
206 cat >expect <<EOF
211 test_expect_success \
212 'listing tags with substring as pattern must print those matching' '
213 rm *a* &&
214 git tag -l "*a*" > current &&
215 test_cmp expect current
218 cat >expect <<EOF
219 v0.2.1
220 v1.0.1
222 test_expect_success \
223 'listing tags with a suffix as pattern must print those matching' '
224 git tag -l "*.1" > actual &&
225 test_cmp expect actual
228 cat >expect <<EOF
229 t210
230 t211
232 test_expect_success \
233 'listing tags with a prefix as pattern must print those matching' '
234 git tag -l "t21*" > actual &&
235 test_cmp expect actual
238 cat >expect <<EOF
241 test_expect_success \
242 'listing tags using a name as pattern must print that one matching' '
243 git tag -l a1 > actual &&
244 test_cmp expect actual
247 cat >expect <<EOF
248 v1.0
250 test_expect_success \
251 'listing tags using a name as pattern must print that one matching' '
252 git tag -l v1.0 > actual &&
253 test_cmp expect actual
256 cat >expect <<EOF
257 v1.0.1
258 v1.1.3
260 test_expect_success \
261 'listing tags with ? in the pattern should print those matching' '
262 git tag -l "v1.?.?" > actual &&
263 test_cmp expect actual
266 >expect
267 test_expect_success \
268 'listing tags using v.* should print nothing because none have v.' '
269 git tag -l "v.*" > actual &&
270 test_cmp expect actual
273 cat >expect <<EOF
274 v0.2.1
275 v1.0
276 v1.0.1
277 v1.1.3
279 test_expect_success \
280 'listing tags using v* should print only those having v' '
281 git tag -l "v*" > actual &&
282 test_cmp expect actual
285 test_expect_success 'tag -l can accept multiple patterns' '
286 git tag -l "v1*" "v0*" >actual &&
287 test_cmp expect actual
290 test_expect_success 'listing tags in column' '
291 COLUMNS=40 git tag -l --column=row >actual &&
292 cat >expected <<\EOF &&
293 a1 aa1 cba t210 t211
294 v0.2.1 v1.0 v1.0.1 v1.1.3
296 test_cmp expected actual
299 test_expect_success 'listing tags in column with column.*' '
300 git config column.tag row &&
301 git config column.ui dense &&
302 COLUMNS=40 git tag -l >actual &&
303 git config --unset column.ui &&
304 git config --unset column.tag &&
305 cat >expected <<\EOF &&
306 a1 aa1 cba t210 t211
307 v0.2.1 v1.0 v1.0.1 v1.1.3
309 test_cmp expected actual
312 test_expect_success 'listing tag with -n --column should fail' '
313 test_must_fail git tag --column -n
316 test_expect_success 'listing tags -n in column with column.ui ignored' '
317 git config column.ui "row dense" &&
318 COLUMNS=40 git tag -l -n >actual &&
319 git config --unset column.ui &&
320 cat >expected <<\EOF &&
321 a1 Foo
322 aa1 Foo
323 cba Foo
324 t210 Foo
325 t211 Foo
326 v0.2.1 Foo
327 v1.0 Foo
328 v1.0.1 Foo
329 v1.1.3 Foo
331 test_cmp expected actual
334 # creating and verifying lightweight tags:
336 test_expect_success \
337 'a non-annotated tag created without parameters should point to HEAD' '
338 git tag non-annotated-tag &&
339 test $(git cat-file -t non-annotated-tag) = commit &&
340 test $(git rev-parse non-annotated-tag) = $(git rev-parse HEAD)
343 test_expect_success 'trying to verify an unknown tag should fail' \
344 'test_must_fail git tag -v unknown-tag'
346 test_expect_success \
347 'trying to verify a non-annotated and non-signed tag should fail' \
348 'test_must_fail git tag -v non-annotated-tag'
350 test_expect_success \
351 'trying to verify many non-annotated or unknown tags, should fail' \
352 'test_must_fail git tag -v unknown-tag1 non-annotated-tag unknown-tag2'
354 # creating annotated tags:
356 get_tag_msg () {
357 git cat-file tag "$1" | sed -e "/BEGIN PGP/q"
360 # run test_tick before committing always gives the time in that timezone
361 get_tag_header () {
362 cat <<EOF
363 object $2
364 type $3
365 tag $1
366 tagger C O Mitter <committer@example.com> $4 -0700
371 commit=$(git rev-parse HEAD)
372 time=$test_tick
374 get_tag_header annotated-tag $commit commit $time >expect
375 echo "A message" >>expect
376 test_expect_success \
377 'creating an annotated tag with -m message should succeed' '
378 git tag -m "A message" annotated-tag &&
379 get_tag_msg annotated-tag >actual &&
380 test_cmp expect actual
383 cat >msgfile <<EOF
384 Another message
385 in a file.
387 get_tag_header file-annotated-tag $commit commit $time >expect
388 cat msgfile >>expect
389 test_expect_success \
390 'creating an annotated tag with -F messagefile should succeed' '
391 git tag -F msgfile file-annotated-tag &&
392 get_tag_msg file-annotated-tag >actual &&
393 test_cmp expect actual
396 cat >inputmsg <<EOF
397 A message from the
398 standard input
400 get_tag_header stdin-annotated-tag $commit commit $time >expect
401 cat inputmsg >>expect
402 test_expect_success 'creating an annotated tag with -F - should succeed' '
403 git tag -F - stdin-annotated-tag <inputmsg &&
404 get_tag_msg stdin-annotated-tag >actual &&
405 test_cmp expect actual
408 test_expect_success \
409 'trying to create a tag with a non-existing -F file should fail' '
410 ! test -f nonexistingfile &&
411 ! tag_exists notag &&
412 test_must_fail git tag -F nonexistingfile notag &&
413 ! tag_exists notag
416 test_expect_success \
417 'trying to create tags giving both -m or -F options should fail' '
418 echo "message file 1" >msgfile1 &&
419 echo "message file 2" >msgfile2 &&
420 ! tag_exists msgtag &&
421 test_must_fail git tag -m "message 1" -F msgfile1 msgtag &&
422 ! tag_exists msgtag &&
423 test_must_fail git tag -F msgfile1 -m "message 1" msgtag &&
424 ! tag_exists msgtag &&
425 test_must_fail git tag -m "message 1" -F msgfile1 \
426 -m "message 2" msgtag &&
427 ! tag_exists msgtag
430 # blank and empty messages:
432 get_tag_header empty-annotated-tag $commit commit $time >expect
433 test_expect_success \
434 'creating a tag with an empty -m message should succeed' '
435 git tag -m "" empty-annotated-tag &&
436 get_tag_msg empty-annotated-tag >actual &&
437 test_cmp expect actual
440 >emptyfile
441 get_tag_header emptyfile-annotated-tag $commit commit $time >expect
442 test_expect_success \
443 'creating a tag with an empty -F messagefile should succeed' '
444 git tag -F emptyfile emptyfile-annotated-tag &&
445 get_tag_msg emptyfile-annotated-tag >actual &&
446 test_cmp expect actual
449 printf '\n\n \n\t\nLeading blank lines\n' >blanksfile
450 printf '\n\t \t \nRepeated blank lines\n' >>blanksfile
451 printf '\n\n\nTrailing spaces \t \n' >>blanksfile
452 printf '\nTrailing blank lines\n\n\t \n\n' >>blanksfile
453 get_tag_header blanks-annotated-tag $commit commit $time >expect
454 cat >>expect <<EOF
455 Leading blank lines
457 Repeated blank lines
459 Trailing spaces
461 Trailing blank lines
463 test_expect_success \
464 'extra blanks in the message for an annotated tag should be removed' '
465 git tag -F blanksfile blanks-annotated-tag &&
466 get_tag_msg blanks-annotated-tag >actual &&
467 test_cmp expect actual
470 get_tag_header blank-annotated-tag $commit commit $time >expect
471 test_expect_success \
472 'creating a tag with blank -m message with spaces should succeed' '
473 git tag -m " " blank-annotated-tag &&
474 get_tag_msg blank-annotated-tag >actual &&
475 test_cmp expect actual
478 echo ' ' >blankfile
479 echo '' >>blankfile
480 echo ' ' >>blankfile
481 get_tag_header blankfile-annotated-tag $commit commit $time >expect
482 test_expect_success \
483 'creating a tag with blank -F messagefile with spaces should succeed' '
484 git tag -F blankfile blankfile-annotated-tag &&
485 get_tag_msg blankfile-annotated-tag >actual &&
486 test_cmp expect actual
489 printf ' ' >blanknonlfile
490 get_tag_header blanknonlfile-annotated-tag $commit commit $time >expect
491 test_expect_success \
492 'creating a tag with -F file of spaces and no newline should succeed' '
493 git tag -F blanknonlfile blanknonlfile-annotated-tag &&
494 get_tag_msg blanknonlfile-annotated-tag >actual &&
495 test_cmp expect actual
498 # messages with commented lines:
500 cat >commentsfile <<EOF
501 # A comment
503 ############
504 The message.
505 ############
506 One line.
509 # commented lines
510 # commented lines
512 Another line.
513 # comments
515 Last line.
517 get_tag_header comments-annotated-tag $commit commit $time >expect
518 cat >>expect <<EOF
519 The message.
520 One line.
522 Another line.
524 Last line.
526 test_expect_success \
527 'creating a tag using a -F messagefile with #comments should succeed' '
528 git tag -F commentsfile comments-annotated-tag &&
529 get_tag_msg comments-annotated-tag >actual &&
530 test_cmp expect actual
533 get_tag_header comment-annotated-tag $commit commit $time >expect
534 test_expect_success \
535 'creating a tag with a #comment in the -m message should succeed' '
536 git tag -m "#comment" comment-annotated-tag &&
537 get_tag_msg comment-annotated-tag >actual &&
538 test_cmp expect actual
541 echo '#comment' >commentfile
542 echo '' >>commentfile
543 echo '####' >>commentfile
544 get_tag_header commentfile-annotated-tag $commit commit $time >expect
545 test_expect_success \
546 'creating a tag with #comments in the -F messagefile should succeed' '
547 git tag -F commentfile commentfile-annotated-tag &&
548 get_tag_msg commentfile-annotated-tag >actual &&
549 test_cmp expect actual
552 printf '#comment' >commentnonlfile
553 get_tag_header commentnonlfile-annotated-tag $commit commit $time >expect
554 test_expect_success \
555 'creating a tag with a file of #comment and no newline should succeed' '
556 git tag -F commentnonlfile commentnonlfile-annotated-tag &&
557 get_tag_msg commentnonlfile-annotated-tag >actual &&
558 test_cmp expect actual
561 # listing messages for annotated non-signed tags:
563 test_expect_success \
564 'listing the one-line message of a non-signed tag should succeed' '
565 git tag -m "A msg" tag-one-line &&
567 echo "tag-one-line" >expect &&
568 git tag -l | grep "^tag-one-line" >actual &&
569 test_cmp expect actual &&
570 git tag -n0 -l | grep "^tag-one-line" >actual &&
571 test_cmp expect actual &&
572 git tag -n0 -l tag-one-line >actual &&
573 test_cmp expect actual &&
575 echo "tag-one-line A msg" >expect &&
576 git tag -n1 -l | grep "^tag-one-line" >actual &&
577 test_cmp expect actual &&
578 git tag -n -l | grep "^tag-one-line" >actual &&
579 test_cmp expect actual &&
580 git tag -n1 -l tag-one-line >actual &&
581 test_cmp expect actual &&
582 git tag -n2 -l tag-one-line >actual &&
583 test_cmp expect actual &&
584 git tag -n999 -l tag-one-line >actual &&
585 test_cmp expect actual
588 test_expect_success \
589 'listing the zero-lines message of a non-signed tag should succeed' '
590 git tag -m "" tag-zero-lines &&
592 echo "tag-zero-lines" >expect &&
593 git tag -l | grep "^tag-zero-lines" >actual &&
594 test_cmp expect actual &&
595 git tag -n0 -l | grep "^tag-zero-lines" >actual &&
596 test_cmp expect actual &&
597 git tag -n0 -l tag-zero-lines >actual &&
598 test_cmp expect actual &&
600 echo "tag-zero-lines " >expect &&
601 git tag -n1 -l | grep "^tag-zero-lines" >actual &&
602 test_cmp expect actual &&
603 git tag -n -l | grep "^tag-zero-lines" >actual &&
604 test_cmp expect actual &&
605 git tag -n1 -l tag-zero-lines >actual &&
606 test_cmp expect actual &&
607 git tag -n2 -l tag-zero-lines >actual &&
608 test_cmp expect actual &&
609 git tag -n999 -l tag-zero-lines >actual &&
610 test_cmp expect actual
613 echo 'tag line one' >annotagmsg
614 echo 'tag line two' >>annotagmsg
615 echo 'tag line three' >>annotagmsg
616 test_expect_success \
617 'listing many message lines of a non-signed tag should succeed' '
618 git tag -F annotagmsg tag-lines &&
620 echo "tag-lines" >expect &&
621 git tag -l | grep "^tag-lines" >actual &&
622 test_cmp expect actual &&
623 git tag -n0 -l | grep "^tag-lines" >actual &&
624 test_cmp expect actual &&
625 git tag -n0 -l tag-lines >actual &&
626 test_cmp expect actual &&
628 echo "tag-lines tag line one" >expect &&
629 git tag -n1 -l | grep "^tag-lines" >actual &&
630 test_cmp expect actual &&
631 git tag -n -l | grep "^tag-lines" >actual &&
632 test_cmp expect actual &&
633 git tag -n1 -l tag-lines >actual &&
634 test_cmp expect actual &&
636 echo " tag line two" >>expect &&
637 git tag -n2 -l | grep "^ *tag.line" >actual &&
638 test_cmp expect actual &&
639 git tag -n2 -l tag-lines >actual &&
640 test_cmp expect actual &&
642 echo " tag line three" >>expect &&
643 git tag -n3 -l | grep "^ *tag.line" >actual &&
644 test_cmp expect actual &&
645 git tag -n3 -l tag-lines >actual &&
646 test_cmp expect actual &&
647 git tag -n4 -l | grep "^ *tag.line" >actual &&
648 test_cmp expect actual &&
649 git tag -n4 -l tag-lines >actual &&
650 test_cmp expect actual &&
651 git tag -n99 -l | grep "^ *tag.line" >actual &&
652 test_cmp expect actual &&
653 git tag -n99 -l tag-lines >actual &&
654 test_cmp expect actual
657 test_expect_success 'annotations for blobs are empty' '
658 blob=$(git hash-object -w --stdin <<-\EOF
659 Blob paragraph 1.
661 Blob paragraph 2.
663 ) &&
664 git tag tag-blob $blob &&
665 echo "tag-blob " >expect &&
666 git tag -n1 -l tag-blob >actual &&
667 test_cmp expect actual
670 # trying to verify annotated non-signed tags:
672 test_expect_success GPG \
673 'trying to verify an annotated non-signed tag should fail' '
674 tag_exists annotated-tag &&
675 test_must_fail git tag -v annotated-tag
678 test_expect_success GPG \
679 'trying to verify a file-annotated non-signed tag should fail' '
680 tag_exists file-annotated-tag &&
681 test_must_fail git tag -v file-annotated-tag
684 test_expect_success GPG \
685 'trying to verify two annotated non-signed tags should fail' '
686 tag_exists annotated-tag file-annotated-tag &&
687 test_must_fail git tag -v annotated-tag file-annotated-tag
690 # creating and verifying signed tags:
692 get_tag_header signed-tag $commit commit $time >expect
693 echo 'A signed tag message' >>expect
694 echo '-----BEGIN PGP SIGNATURE-----' >>expect
695 test_expect_success GPG 'creating a signed tag with -m message should succeed' '
696 git tag -s -m "A signed tag message" signed-tag &&
697 get_tag_msg signed-tag >actual &&
698 test_cmp expect actual
701 get_tag_header u-signed-tag $commit commit $time >expect
702 echo 'Another message' >>expect
703 echo '-----BEGIN PGP SIGNATURE-----' >>expect
704 test_expect_success GPG 'sign with a given key id' '
706 git tag -u committer@example.com -m "Another message" u-signed-tag &&
707 get_tag_msg u-signed-tag >actual &&
708 test_cmp expect actual
712 test_expect_success GPG 'sign with an unknown id (1)' '
714 test_must_fail git tag -u author@example.com \
715 -m "Another message" o-signed-tag
719 test_expect_success GPG 'sign with an unknown id (2)' '
721 test_must_fail git tag -u DEADBEEF -m "Another message" o-signed-tag
725 cat >fakeeditor <<'EOF'
726 #!/bin/sh
727 test -n "$1" && exec >"$1"
728 echo A signed tag message
729 echo from a fake editor.
731 chmod +x fakeeditor
733 get_tag_header implied-sign $commit commit $time >expect
734 ./fakeeditor >>expect
735 echo '-----BEGIN PGP SIGNATURE-----' >>expect
736 test_expect_success GPG '-u implies signed tag' '
737 GIT_EDITOR=./fakeeditor git tag -u CDDE430D implied-sign &&
738 get_tag_msg implied-sign >actual &&
739 test_cmp expect actual
742 cat >sigmsgfile <<EOF
743 Another signed tag
744 message in a file.
746 get_tag_header file-signed-tag $commit commit $time >expect
747 cat sigmsgfile >>expect
748 echo '-----BEGIN PGP SIGNATURE-----' >>expect
749 test_expect_success GPG \
750 'creating a signed tag with -F messagefile should succeed' '
751 git tag -s -F sigmsgfile file-signed-tag &&
752 get_tag_msg file-signed-tag >actual &&
753 test_cmp expect actual
756 cat >siginputmsg <<EOF
757 A signed tag message from
758 the standard input
760 get_tag_header stdin-signed-tag $commit commit $time >expect
761 cat siginputmsg >>expect
762 echo '-----BEGIN PGP SIGNATURE-----' >>expect
763 test_expect_success GPG 'creating a signed tag with -F - should succeed' '
764 git tag -s -F - stdin-signed-tag <siginputmsg &&
765 get_tag_msg stdin-signed-tag >actual &&
766 test_cmp expect actual
769 get_tag_header implied-annotate $commit commit $time >expect
770 ./fakeeditor >>expect
771 echo '-----BEGIN PGP SIGNATURE-----' >>expect
772 test_expect_success GPG '-s implies annotated tag' '
773 GIT_EDITOR=./fakeeditor git tag -s implied-annotate &&
774 get_tag_msg implied-annotate >actual &&
775 test_cmp expect actual
778 test_expect_success GPG \
779 'trying to create a signed tag with non-existing -F file should fail' '
780 ! test -f nonexistingfile &&
781 ! tag_exists nosigtag &&
782 test_must_fail git tag -s -F nonexistingfile nosigtag &&
783 ! tag_exists nosigtag
786 test_expect_success GPG 'verifying a signed tag should succeed' \
787 'git tag -v signed-tag'
789 test_expect_success GPG 'verifying two signed tags in one command should succeed' \
790 'git tag -v signed-tag file-signed-tag'
792 test_expect_success GPG \
793 'verifying many signed and non-signed tags should fail' '
794 test_must_fail git tag -v signed-tag annotated-tag &&
795 test_must_fail git tag -v file-annotated-tag file-signed-tag &&
796 test_must_fail git tag -v annotated-tag \
797 file-signed-tag file-annotated-tag &&
798 test_must_fail git tag -v signed-tag annotated-tag file-signed-tag
801 test_expect_success GPG 'verifying a forged tag should fail' '
802 forged=$(git cat-file tag signed-tag |
803 sed -e "s/signed-tag/forged-tag/" |
804 git mktag) &&
805 git tag forged-tag $forged &&
806 test_must_fail git tag -v forged-tag
809 # blank and empty messages for signed tags:
811 get_tag_header empty-signed-tag $commit commit $time >expect
812 echo '-----BEGIN PGP SIGNATURE-----' >>expect
813 test_expect_success GPG \
814 'creating a signed tag with an empty -m message should succeed' '
815 git tag -s -m "" empty-signed-tag &&
816 get_tag_msg empty-signed-tag >actual &&
817 test_cmp expect actual &&
818 git tag -v empty-signed-tag
821 >sigemptyfile
822 get_tag_header emptyfile-signed-tag $commit commit $time >expect
823 echo '-----BEGIN PGP SIGNATURE-----' >>expect
824 test_expect_success GPG \
825 'creating a signed tag with an empty -F messagefile should succeed' '
826 git tag -s -F sigemptyfile emptyfile-signed-tag &&
827 get_tag_msg emptyfile-signed-tag >actual &&
828 test_cmp expect actual &&
829 git tag -v emptyfile-signed-tag
832 printf '\n\n \n\t\nLeading blank lines\n' > sigblanksfile
833 printf '\n\t \t \nRepeated blank lines\n' >>sigblanksfile
834 printf '\n\n\nTrailing spaces \t \n' >>sigblanksfile
835 printf '\nTrailing blank lines\n\n\t \n\n' >>sigblanksfile
836 get_tag_header blanks-signed-tag $commit commit $time >expect
837 cat >>expect <<EOF
838 Leading blank lines
840 Repeated blank lines
842 Trailing spaces
844 Trailing blank lines
846 echo '-----BEGIN PGP SIGNATURE-----' >>expect
847 test_expect_success GPG \
848 'extra blanks in the message for a signed tag should be removed' '
849 git tag -s -F sigblanksfile blanks-signed-tag &&
850 get_tag_msg blanks-signed-tag >actual &&
851 test_cmp expect actual &&
852 git tag -v blanks-signed-tag
855 get_tag_header blank-signed-tag $commit commit $time >expect
856 echo '-----BEGIN PGP SIGNATURE-----' >>expect
857 test_expect_success GPG \
858 'creating a signed tag with a blank -m message should succeed' '
859 git tag -s -m " " blank-signed-tag &&
860 get_tag_msg blank-signed-tag >actual &&
861 test_cmp expect actual &&
862 git tag -v blank-signed-tag
865 echo ' ' >sigblankfile
866 echo '' >>sigblankfile
867 echo ' ' >>sigblankfile
868 get_tag_header blankfile-signed-tag $commit commit $time >expect
869 echo '-----BEGIN PGP SIGNATURE-----' >>expect
870 test_expect_success GPG \
871 'creating a signed tag with blank -F file with spaces should succeed' '
872 git tag -s -F sigblankfile blankfile-signed-tag &&
873 get_tag_msg blankfile-signed-tag >actual &&
874 test_cmp expect actual &&
875 git tag -v blankfile-signed-tag
878 printf ' ' >sigblanknonlfile
879 get_tag_header blanknonlfile-signed-tag $commit commit $time >expect
880 echo '-----BEGIN PGP SIGNATURE-----' >>expect
881 test_expect_success GPG \
882 'creating a signed tag with spaces and no newline should succeed' '
883 git tag -s -F sigblanknonlfile blanknonlfile-signed-tag &&
884 get_tag_msg blanknonlfile-signed-tag >actual &&
885 test_cmp expect actual &&
886 git tag -v signed-tag
889 # messages with commented lines for signed tags:
891 cat >sigcommentsfile <<EOF
892 # A comment
894 ############
895 The message.
896 ############
897 One line.
900 # commented lines
901 # commented lines
903 Another line.
904 # comments
906 Last line.
908 get_tag_header comments-signed-tag $commit commit $time >expect
909 cat >>expect <<EOF
910 The message.
911 One line.
913 Another line.
915 Last line.
917 echo '-----BEGIN PGP SIGNATURE-----' >>expect
918 test_expect_success GPG \
919 'creating a signed tag with a -F file with #comments should succeed' '
920 git tag -s -F sigcommentsfile comments-signed-tag &&
921 get_tag_msg comments-signed-tag >actual &&
922 test_cmp expect actual &&
923 git tag -v comments-signed-tag
926 get_tag_header comment-signed-tag $commit commit $time >expect
927 echo '-----BEGIN PGP SIGNATURE-----' >>expect
928 test_expect_success GPG \
929 'creating a signed tag with #commented -m message should succeed' '
930 git tag -s -m "#comment" comment-signed-tag &&
931 get_tag_msg comment-signed-tag >actual &&
932 test_cmp expect actual &&
933 git tag -v comment-signed-tag
936 echo '#comment' >sigcommentfile
937 echo '' >>sigcommentfile
938 echo '####' >>sigcommentfile
939 get_tag_header commentfile-signed-tag $commit commit $time >expect
940 echo '-----BEGIN PGP SIGNATURE-----' >>expect
941 test_expect_success GPG \
942 'creating a signed tag with #commented -F messagefile should succeed' '
943 git tag -s -F sigcommentfile commentfile-signed-tag &&
944 get_tag_msg commentfile-signed-tag >actual &&
945 test_cmp expect actual &&
946 git tag -v commentfile-signed-tag
949 printf '#comment' >sigcommentnonlfile
950 get_tag_header commentnonlfile-signed-tag $commit commit $time >expect
951 echo '-----BEGIN PGP SIGNATURE-----' >>expect
952 test_expect_success GPG \
953 'creating a signed tag with a #comment and no newline should succeed' '
954 git tag -s -F sigcommentnonlfile commentnonlfile-signed-tag &&
955 get_tag_msg commentnonlfile-signed-tag >actual &&
956 test_cmp expect actual &&
957 git tag -v commentnonlfile-signed-tag
960 # listing messages for signed tags:
962 test_expect_success GPG \
963 'listing the one-line message of a signed tag should succeed' '
964 git tag -s -m "A message line signed" stag-one-line &&
966 echo "stag-one-line" >expect &&
967 git tag -l | grep "^stag-one-line" >actual &&
968 test_cmp expect actual &&
969 git tag -n0 -l | grep "^stag-one-line" >actual &&
970 test_cmp expect actual &&
971 git tag -n0 -l stag-one-line >actual &&
972 test_cmp expect actual &&
974 echo "stag-one-line A message line signed" >expect &&
975 git tag -n1 -l | grep "^stag-one-line" >actual &&
976 test_cmp expect actual &&
977 git tag -n -l | grep "^stag-one-line" >actual &&
978 test_cmp expect actual &&
979 git tag -n1 -l stag-one-line >actual &&
980 test_cmp expect actual &&
981 git tag -n2 -l stag-one-line >actual &&
982 test_cmp expect actual &&
983 git tag -n999 -l stag-one-line >actual &&
984 test_cmp expect actual
987 test_expect_success GPG \
988 'listing the zero-lines message of a signed tag should succeed' '
989 git tag -s -m "" stag-zero-lines &&
991 echo "stag-zero-lines" >expect &&
992 git tag -l | grep "^stag-zero-lines" >actual &&
993 test_cmp expect actual &&
994 git tag -n0 -l | grep "^stag-zero-lines" >actual &&
995 test_cmp expect actual &&
996 git tag -n0 -l stag-zero-lines >actual &&
997 test_cmp expect actual &&
999 echo "stag-zero-lines " >expect &&
1000 git tag -n1 -l | grep "^stag-zero-lines" >actual &&
1001 test_cmp expect actual &&
1002 git tag -n -l | grep "^stag-zero-lines" >actual &&
1003 test_cmp expect actual &&
1004 git tag -n1 -l stag-zero-lines >actual &&
1005 test_cmp expect actual &&
1006 git tag -n2 -l stag-zero-lines >actual &&
1007 test_cmp expect actual &&
1008 git tag -n999 -l stag-zero-lines >actual &&
1009 test_cmp expect actual
1012 echo 'stag line one' >sigtagmsg
1013 echo 'stag line two' >>sigtagmsg
1014 echo 'stag line three' >>sigtagmsg
1015 test_expect_success GPG \
1016 'listing many message lines of a signed tag should succeed' '
1017 git tag -s -F sigtagmsg stag-lines &&
1019 echo "stag-lines" >expect &&
1020 git tag -l | grep "^stag-lines" >actual &&
1021 test_cmp expect actual &&
1022 git tag -n0 -l | grep "^stag-lines" >actual &&
1023 test_cmp expect actual &&
1024 git tag -n0 -l stag-lines >actual &&
1025 test_cmp expect actual &&
1027 echo "stag-lines stag line one" >expect &&
1028 git tag -n1 -l | grep "^stag-lines" >actual &&
1029 test_cmp expect actual &&
1030 git tag -n -l | grep "^stag-lines" >actual &&
1031 test_cmp expect actual &&
1032 git tag -n1 -l stag-lines >actual &&
1033 test_cmp expect actual &&
1035 echo " stag line two" >>expect &&
1036 git tag -n2 -l | grep "^ *stag.line" >actual &&
1037 test_cmp expect actual &&
1038 git tag -n2 -l stag-lines >actual &&
1039 test_cmp expect actual &&
1041 echo " stag line three" >>expect &&
1042 git tag -n3 -l | grep "^ *stag.line" >actual &&
1043 test_cmp expect actual &&
1044 git tag -n3 -l stag-lines >actual &&
1045 test_cmp expect actual &&
1046 git tag -n4 -l | grep "^ *stag.line" >actual &&
1047 test_cmp expect actual &&
1048 git tag -n4 -l stag-lines >actual &&
1049 test_cmp expect actual &&
1050 git tag -n99 -l | grep "^ *stag.line" >actual &&
1051 test_cmp expect actual &&
1052 git tag -n99 -l stag-lines >actual &&
1053 test_cmp expect actual
1056 # tags pointing to objects different from commits:
1058 tree=$(git rev-parse HEAD^{tree})
1059 blob=$(git rev-parse HEAD:foo)
1060 tag=$(git rev-parse signed-tag 2>/dev/null)
1062 get_tag_header tree-signed-tag $tree tree $time >expect
1063 echo "A message for a tree" >>expect
1064 echo '-----BEGIN PGP SIGNATURE-----' >>expect
1065 test_expect_success GPG \
1066 'creating a signed tag pointing to a tree should succeed' '
1067 git tag -s -m "A message for a tree" tree-signed-tag HEAD^{tree} &&
1068 get_tag_msg tree-signed-tag >actual &&
1069 test_cmp expect actual
1072 get_tag_header blob-signed-tag $blob blob $time >expect
1073 echo "A message for a blob" >>expect
1074 echo '-----BEGIN PGP SIGNATURE-----' >>expect
1075 test_expect_success GPG \
1076 'creating a signed tag pointing to a blob should succeed' '
1077 git tag -s -m "A message for a blob" blob-signed-tag HEAD:foo &&
1078 get_tag_msg blob-signed-tag >actual &&
1079 test_cmp expect actual
1082 get_tag_header tag-signed-tag $tag tag $time >expect
1083 echo "A message for another tag" >>expect
1084 echo '-----BEGIN PGP SIGNATURE-----' >>expect
1085 test_expect_success GPG \
1086 'creating a signed tag pointing to another tag should succeed' '
1087 git tag -s -m "A message for another tag" tag-signed-tag signed-tag &&
1088 get_tag_msg tag-signed-tag >actual &&
1089 test_cmp expect actual
1092 # usage with rfc1991 signatures
1093 get_tag_header rfc1991-signed-tag $commit commit $time >expect
1094 echo "RFC1991 signed tag" >>expect
1095 echo '-----BEGIN PGP MESSAGE-----' >>expect
1096 test_expect_success GPG,RFC1991 \
1097 'creating a signed tag with rfc1991' '
1098 echo "rfc1991" >gpghome/gpg.conf &&
1099 git tag -s -m "RFC1991 signed tag" rfc1991-signed-tag $commit &&
1100 get_tag_msg rfc1991-signed-tag >actual &&
1101 test_cmp expect actual
1104 cat >fakeeditor <<'EOF'
1105 #!/bin/sh
1106 cp "$1" actual
1108 chmod +x fakeeditor
1110 test_expect_success GPG,RFC1991 \
1111 'reediting a signed tag body omits signature' '
1112 echo "rfc1991" >gpghome/gpg.conf &&
1113 echo "RFC1991 signed tag" >expect &&
1114 GIT_EDITOR=./fakeeditor git tag -f -s rfc1991-signed-tag $commit &&
1115 test_cmp expect actual
1118 test_expect_success GPG,RFC1991 \
1119 'verifying rfc1991 signature' '
1120 echo "rfc1991" >gpghome/gpg.conf &&
1121 git tag -v rfc1991-signed-tag
1124 test_expect_success GPG,RFC1991 \
1125 'list tag with rfc1991 signature' '
1126 echo "rfc1991" >gpghome/gpg.conf &&
1127 echo "rfc1991-signed-tag RFC1991 signed tag" >expect &&
1128 git tag -l -n1 rfc1991-signed-tag >actual &&
1129 test_cmp expect actual &&
1130 git tag -l -n2 rfc1991-signed-tag >actual &&
1131 test_cmp expect actual &&
1132 git tag -l -n999 rfc1991-signed-tag >actual &&
1133 test_cmp expect actual
1136 rm -f gpghome/gpg.conf
1138 test_expect_success GPG,RFC1991 \
1139 'verifying rfc1991 signature without --rfc1991' '
1140 git tag -v rfc1991-signed-tag
1143 test_expect_success GPG,RFC1991 \
1144 'list tag with rfc1991 signature without --rfc1991' '
1145 echo "rfc1991-signed-tag RFC1991 signed tag" >expect &&
1146 git tag -l -n1 rfc1991-signed-tag >actual &&
1147 test_cmp expect actual &&
1148 git tag -l -n2 rfc1991-signed-tag >actual &&
1149 test_cmp expect actual &&
1150 git tag -l -n999 rfc1991-signed-tag >actual &&
1151 test_cmp expect actual
1154 test_expect_success GPG,RFC1991 \
1155 'reediting a signed tag body omits signature' '
1156 echo "RFC1991 signed tag" >expect &&
1157 GIT_EDITOR=./fakeeditor git tag -f -s rfc1991-signed-tag $commit &&
1158 test_cmp expect actual
1161 # try to sign with bad user.signingkey
1162 git config user.signingkey BobTheMouse
1163 test_expect_success GPG \
1164 'git tag -s fails if gpg is misconfigured' \
1165 'test_must_fail git tag -s -m tail tag-gpg-failure'
1166 git config --unset user.signingkey
1168 # try to verify without gpg:
1170 rm -rf gpghome
1171 test_expect_success GPG \
1172 'verify signed tag fails when public key is not present' \
1173 'test_must_fail git tag -v signed-tag'
1175 test_expect_success \
1176 'git tag -a fails if tag annotation is empty' '
1177 ! (GIT_EDITOR=cat git tag -a initial-comment)
1180 test_expect_success \
1181 'message in editor has initial comment' '
1182 ! (GIT_EDITOR=cat git tag -a initial-comment > actual)
1185 test_expect_success 'message in editor has initial comment: first line' '
1186 # check the first line --- should be empty
1187 echo >first.expect &&
1188 sed -e 1q <actual >first.actual &&
1189 test_i18ncmp first.expect first.actual
1192 test_expect_success \
1193 'message in editor has initial comment: remainder' '
1194 # remove commented lines from the remainder -- should be empty
1195 >rest.expect &&
1196 sed -e 1d -e "/^#/d" <actual >rest.actual &&
1197 test_cmp rest.expect rest.actual
1200 get_tag_header reuse $commit commit $time >expect
1201 echo "An annotation to be reused" >> expect
1202 test_expect_success \
1203 'overwriting an annoted tag should use its previous body' '
1204 git tag -a -m "An annotation to be reused" reuse &&
1205 GIT_EDITOR=true git tag -f -a reuse &&
1206 get_tag_msg reuse >actual &&
1207 test_cmp expect actual
1210 test_expect_success 'filename for the message is relative to cwd' '
1211 mkdir subdir &&
1212 echo "Tag message in top directory" >msgfile-5 &&
1213 echo "Tag message in sub directory" >subdir/msgfile-5 &&
1215 cd subdir &&
1216 git tag -a -F msgfile-5 tag-from-subdir
1217 ) &&
1218 git cat-file tag tag-from-subdir | grep "in sub directory"
1221 test_expect_success 'filename for the message is relative to cwd' '
1222 echo "Tag message in sub directory" >subdir/msgfile-6 &&
1224 cd subdir &&
1225 git tag -a -F msgfile-6 tag-from-subdir-2
1226 ) &&
1227 git cat-file tag tag-from-subdir-2 | grep "in sub directory"
1230 # create a few more commits to test --contains
1232 hash1=$(git rev-parse HEAD)
1234 test_expect_success 'creating second commit and tag' '
1235 echo foo-2.0 >foo &&
1236 git add foo &&
1237 git commit -m second &&
1238 git tag v2.0
1241 hash2=$(git rev-parse HEAD)
1243 test_expect_success 'creating third commit without tag' '
1244 echo foo-dev >foo &&
1245 git add foo &&
1246 git commit -m third
1249 hash3=$(git rev-parse HEAD)
1251 # simple linear checks of --continue
1253 cat > expected <<EOF
1254 v0.2.1
1255 v1.0
1256 v1.0.1
1257 v1.1.3
1258 v2.0
1261 test_expect_success 'checking that first commit is in all tags (hash)' "
1262 git tag -l --contains $hash1 v* >actual &&
1263 test_cmp expected actual
1266 # other ways of specifying the commit
1267 test_expect_success 'checking that first commit is in all tags (tag)' "
1268 git tag -l --contains v1.0 v* >actual &&
1269 test_cmp expected actual
1272 test_expect_success 'checking that first commit is in all tags (relative)' "
1273 git tag -l --contains HEAD~2 v* >actual &&
1274 test_cmp expected actual
1277 cat > expected <<EOF
1278 v2.0
1281 test_expect_success 'checking that second commit only has one tag' "
1282 git tag -l --contains $hash2 v* >actual &&
1283 test_cmp expected actual
1287 cat > expected <<EOF
1290 test_expect_success 'checking that third commit has no tags' "
1291 git tag -l --contains $hash3 v* >actual &&
1292 test_cmp expected actual
1295 # how about a simple merge?
1297 test_expect_success 'creating simple branch' '
1298 git branch stable v2.0 &&
1299 git checkout stable &&
1300 echo foo-3.0 > foo &&
1301 git commit foo -m fourth &&
1302 git tag v3.0
1305 hash4=$(git rev-parse HEAD)
1307 cat > expected <<EOF
1308 v3.0
1311 test_expect_success 'checking that branch head only has one tag' "
1312 git tag -l --contains $hash4 v* >actual &&
1313 test_cmp expected actual
1316 test_expect_success 'merging original branch into this branch' '
1317 git merge --strategy=ours master &&
1318 git tag v4.0
1321 cat > expected <<EOF
1322 v4.0
1325 test_expect_success 'checking that original branch head has one tag now' "
1326 git tag -l --contains $hash3 v* >actual &&
1327 test_cmp expected actual
1330 cat > expected <<EOF
1331 v0.2.1
1332 v1.0
1333 v1.0.1
1334 v1.1.3
1335 v2.0
1336 v3.0
1337 v4.0
1340 test_expect_success 'checking that initial commit is in all tags' "
1341 git tag -l --contains $hash1 v* >actual &&
1342 test_cmp expected actual
1345 # mixing modes and options:
1347 test_expect_success 'mixing incompatibles modes and options is forbidden' '
1348 test_must_fail git tag -a &&
1349 test_must_fail git tag -l -v &&
1350 test_must_fail git tag -n 100 &&
1351 test_must_fail git tag -l -m msg &&
1352 test_must_fail git tag -l -F some file &&
1353 test_must_fail git tag -v -s
1356 # check points-at
1358 test_expect_success '--points-at cannot be used in non-list mode' '
1359 test_must_fail git tag --points-at=v4.0 foo
1362 test_expect_success '--points-at finds lightweight tags' '
1363 echo v4.0 >expect &&
1364 git tag --points-at v4.0 >actual &&
1365 test_cmp expect actual
1368 test_expect_success '--points-at finds annotated tags of commits' '
1369 git tag -m "v4.0, annotated" annotated-v4.0 v4.0 &&
1370 echo annotated-v4.0 >expect &&
1371 git tag -l --points-at v4.0 "annotated*" >actual &&
1372 test_cmp expect actual
1375 test_expect_success '--points-at finds annotated tags of tags' '
1376 git tag -m "describing the v4.0 tag object" \
1377 annotated-again-v4.0 annotated-v4.0 &&
1378 cat >expect <<-\EOF &&
1379 annotated-again-v4.0
1380 annotated-v4.0
1382 git tag --points-at=annotated-v4.0 >actual &&
1383 test_cmp expect actual
1386 test_expect_success 'multiple --points-at are OR-ed together' '
1387 cat >expect <<-\EOF &&
1388 v2.0
1389 v3.0
1391 git tag --points-at=v2.0 --points-at=v3.0 >actual &&
1392 test_cmp expect actual
1395 test_expect_success 'lexical sort' '
1396 git tag foo1.3 &&
1397 git tag foo1.6 &&
1398 git tag foo1.10 &&
1399 git tag -l --sort=refname "foo*" >actual &&
1400 cat >expect <<-\EOF &&
1401 foo1.10
1402 foo1.3
1403 foo1.6
1405 test_cmp expect actual
1408 test_expect_success 'version sort' '
1409 git tag -l --sort=version:refname "foo*" >actual &&
1410 cat >expect <<-\EOF &&
1411 foo1.3
1412 foo1.6
1413 foo1.10
1415 test_cmp expect actual
1418 test_expect_success 'reverse version sort' '
1419 git tag -l --sort=-version:refname "foo*" >actual &&
1420 cat >expect <<-\EOF &&
1421 foo1.10
1422 foo1.6
1423 foo1.3
1425 test_cmp expect actual
1428 test_expect_success 'reverse lexical sort' '
1429 git tag -l --sort=-refname "foo*" >actual &&
1430 cat >expect <<-\EOF &&
1431 foo1.6
1432 foo1.3
1433 foo1.10
1435 test_cmp expect actual
1438 test_expect_success 'configured lexical sort' '
1439 git config tag.sort "v:refname" &&
1440 git tag -l "foo*" >actual &&
1441 cat >expect <<-\EOF &&
1442 foo1.3
1443 foo1.6
1444 foo1.10
1446 test_cmp expect actual
1449 test_expect_success 'option override configured sort' '
1450 git tag -l --sort=-refname "foo*" >actual &&
1451 cat >expect <<-\EOF &&
1452 foo1.6
1453 foo1.3
1454 foo1.10
1456 test_cmp expect actual
1459 test_expect_success 'invalid sort parameter on command line' '
1460 test_must_fail git tag -l --sort=notvalid "foo*" >actual
1463 test_expect_success 'invalid sort parameter in configuratoin' '
1464 git config tag.sort "v:notvalid" &&
1465 git tag -l "foo*" >actual &&
1466 cat >expect <<-\EOF &&
1467 foo1.10
1468 foo1.3
1469 foo1.6
1471 test_cmp expect actual
1474 test_expect_success 'version sort with prerelease reordering' '
1475 git config --unset tag.sort &&
1476 git config versionsort.prereleaseSuffix -rc &&
1477 git tag foo1.6-rc1 &&
1478 git tag foo1.6-rc2 &&
1479 git tag -l --sort=version:refname "foo*" >actual &&
1480 cat >expect <<-\EOF &&
1481 foo1.3
1482 foo1.6-rc1
1483 foo1.6-rc2
1484 foo1.6
1485 foo1.10
1487 test_cmp expect actual
1490 test_expect_success 'reverse version sort with prerelease reordering' '
1491 git tag -l --sort=-version:refname "foo*" >actual &&
1492 cat >expect <<-\EOF &&
1493 foo1.10
1494 foo1.6
1495 foo1.6-rc2
1496 foo1.6-rc1
1497 foo1.3
1499 test_cmp expect actual
1502 run_with_limited_stack () {
1503 (ulimit -s 128 && "$@")
1506 test_lazy_prereq ULIMIT_STACK_SIZE 'run_with_limited_stack true'
1508 # we require ulimit, this excludes Windows
1509 test_expect_success ULIMIT_STACK_SIZE '--contains works in a deep repo' '
1510 >expect &&
1511 i=1 &&
1512 while test $i -lt 8000
1514 echo "commit refs/heads/master
1515 committer A U Thor <author@example.com> $((1000000000 + $i * 100)) +0200
1516 data <<EOF
1517 commit #$i
1518 EOF"
1519 test $i = 1 && echo "from refs/heads/master^0"
1520 i=$(($i + 1))
1521 done | git fast-import &&
1522 git checkout master &&
1523 git tag far-far-away HEAD^ &&
1524 run_with_limited_stack git tag --contains HEAD >actual &&
1525 test_cmp expect actual
1528 test_done