t / t7004-tag.shon commit clean: replace match_pathspec() with dir_path_match() (05b8502)
   1#!/bin/sh
   2#
   3# Copyright (c) 2007 Carlos Rica
   4#
   5
   6test_description='git tag
   7
   8Tests for operations with tags.'
   9
  10. ./test-lib.sh
  11. "$TEST_DIRECTORY"/lib-gpg.sh
  12
  13# creating and listing lightweight tags:
  14
  15tag_exists () {
  16        git show-ref --quiet --verify refs/tags/"$1"
  17}
  18
  19# todo: git tag -l now returns always zero, when fixed, change this test
  20test_expect_success 'listing all tags in an empty tree should succeed' '
  21        git tag -l &&
  22        git tag
  23'
  24
  25test_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
  28'
  29
  30test_expect_success 'looking for a tag in an empty tree should fail' \
  31        '! (tag_exists mytag)'
  32
  33test_expect_success 'creating a tag in an empty tree should fail' '
  34        test_must_fail git tag mynotag &&
  35        ! tag_exists mynotag
  36'
  37
  38test_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
  41'
  42
  43test_expect_success 'creating a tag for an unknown revision should fail' '
  44        test_must_fail git tag mytagnorev aaaaaaaaaaa &&
  45        ! tag_exists mytagnorev
  46'
  47
  48# commit used in the tests, test_tick is also called here to freeze the date:
  49test_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'
  56
  57test_expect_success 'listing all tags if one exists should succeed' '
  58        git tag -l &&
  59        git tag
  60'
  61
  62test_expect_success 'listing all tags if one exists should output that tag' '
  63        test `git tag -l` = mytag &&
  64        test `git tag` = mytag
  65'
  66
  67# pattern matching:
  68
  69test_expect_success 'listing a tag using a matching pattern should succeed' \
  70        'git tag -l mytag'
  71
  72test_expect_success \
  73        'listing a tag using a matching pattern should output that tag' \
  74        'test `git tag -l mytag` = mytag'
  75
  76# todo: git tag -l now returns always zero, when fixed, change this test
  77test_expect_success \
  78        'listing tags using a non-matching pattern should suceed' \
  79        'git tag -l xxx'
  80
  81test_expect_success \
  82        'listing tags using a non-matching pattern should output nothing' \
  83        'test `git tag -l xxx | wc -l` -eq 0'
  84
  85# special cases for creating tags:
  86
  87test_expect_success \
  88        'trying to create a tag with the name of one existing should fail' \
  89        'test_must_fail git tag mytag'
  90
  91test_expect_success \
  92        'trying to create a tag with a non-valid name should fail' '
  93        test `git tag -l | wc -l` -eq 1 &&
  94        test_must_fail git tag "" &&
  95        test_must_fail git tag .othertag &&
  96        test_must_fail git tag "other tag" &&
  97        test_must_fail git tag "othertag^" &&
  98        test_must_fail git tag "other~tag" &&
  99        test `git tag -l | wc -l` -eq 1
 100'
 101
 102test_expect_success 'creating a tag using HEAD directly should succeed' '
 103        git tag myhead HEAD &&
 104        tag_exists myhead
 105'
 106
 107test_expect_success '--force can create a tag with the name of one existing' '
 108        tag_exists mytag &&
 109        git tag --force mytag &&
 110        tag_exists mytag'
 111
 112test_expect_success '--force is moot with a non-existing tag name' '
 113        git tag newtag >expect &&
 114        git tag --force forcetag >actual &&
 115        test_cmp expect actual
 116'
 117git tag -d newtag forcetag
 118
 119# deleting tags:
 120
 121test_expect_success 'trying to delete an unknown tag should fail' '
 122        ! tag_exists unknown-tag &&
 123        test_must_fail git tag -d unknown-tag
 124'
 125
 126cat >expect <<EOF
 127myhead
 128mytag
 129EOF
 130test_expect_success \
 131        'trying to delete tags without params should succeed and do nothing' '
 132        git tag -l > actual && test_cmp expect actual &&
 133        git tag -d &&
 134        git tag -l > actual && test_cmp expect actual
 135'
 136
 137test_expect_success \
 138        'deleting two existing tags in one command should succeed' '
 139        tag_exists mytag &&
 140        tag_exists myhead &&
 141        git tag -d mytag myhead &&
 142        ! tag_exists mytag &&
 143        ! tag_exists myhead
 144'
 145
 146test_expect_success \
 147        'creating a tag with the name of another deleted one should succeed' '
 148        ! tag_exists mytag &&
 149        git tag mytag &&
 150        tag_exists mytag
 151'
 152
 153test_expect_success \
 154        'trying to delete two tags, existing and not, should fail in the 2nd' '
 155        tag_exists mytag &&
 156        ! tag_exists myhead &&
 157        test_must_fail git tag -d mytag anothertag &&
 158        ! tag_exists mytag &&
 159        ! tag_exists myhead
 160'
 161
 162test_expect_success 'trying to delete an already deleted tag should fail' \
 163        'test_must_fail git tag -d mytag'
 164
 165# listing various tags with pattern matching:
 166
 167cat >expect <<EOF
 168a1
 169aa1
 170cba
 171t210
 172t211
 173v0.2.1
 174v1.0
 175v1.0.1
 176v1.1.3
 177EOF
 178test_expect_success 'listing all tags should print them ordered' '
 179        git tag v1.0.1 &&
 180        git tag t211 &&
 181        git tag aa1 &&
 182        git tag v0.2.1 &&
 183        git tag v1.1.3 &&
 184        git tag cba &&
 185        git tag a1 &&
 186        git tag v1.0 &&
 187        git tag t210 &&
 188        git tag -l > actual &&
 189        test_cmp expect actual &&
 190        git tag > actual &&
 191        test_cmp expect actual
 192'
 193
 194cat >expect <<EOF
 195a1
 196aa1
 197cba
 198EOF
 199test_expect_success \
 200        'listing tags with substring as pattern must print those matching' '
 201        rm *a* &&
 202        git tag -l "*a*" > current &&
 203        test_cmp expect current
 204'
 205
 206cat >expect <<EOF
 207v0.2.1
 208v1.0.1
 209EOF
 210test_expect_success \
 211        'listing tags with a suffix as pattern must print those matching' '
 212        git tag -l "*.1" > actual &&
 213        test_cmp expect actual
 214'
 215
 216cat >expect <<EOF
 217t210
 218t211
 219EOF
 220test_expect_success \
 221        'listing tags with a prefix as pattern must print those matching' '
 222        git tag -l "t21*" > actual &&
 223        test_cmp expect actual
 224'
 225
 226cat >expect <<EOF
 227a1
 228EOF
 229test_expect_success \
 230        'listing tags using a name as pattern must print that one matching' '
 231        git tag -l a1 > actual &&
 232        test_cmp expect actual
 233'
 234
 235cat >expect <<EOF
 236v1.0
 237EOF
 238test_expect_success \
 239        'listing tags using a name as pattern must print that one matching' '
 240        git tag -l v1.0 > actual &&
 241        test_cmp expect actual
 242'
 243
 244cat >expect <<EOF
 245v1.0.1
 246v1.1.3
 247EOF
 248test_expect_success \
 249        'listing tags with ? in the pattern should print those matching' '
 250        git tag -l "v1.?.?" > actual &&
 251        test_cmp expect actual
 252'
 253
 254>expect
 255test_expect_success \
 256        'listing tags using v.* should print nothing because none have v.' '
 257        git tag -l "v.*" > actual &&
 258        test_cmp expect actual
 259'
 260
 261cat >expect <<EOF
 262v0.2.1
 263v1.0
 264v1.0.1
 265v1.1.3
 266EOF
 267test_expect_success \
 268        'listing tags using v* should print only those having v' '
 269        git tag -l "v*" > actual &&
 270        test_cmp expect actual
 271'
 272
 273test_expect_success 'tag -l can accept multiple patterns' '
 274        git tag -l "v1*" "v0*" >actual &&
 275        test_cmp expect actual
 276'
 277
 278test_expect_success 'listing tags in column' '
 279        COLUMNS=40 git tag -l --column=row >actual &&
 280        cat >expected <<\EOF &&
 281a1      aa1     cba     t210    t211
 282v0.2.1  v1.0    v1.0.1  v1.1.3
 283EOF
 284        test_cmp expected actual
 285'
 286
 287test_expect_success 'listing tags in column with column.*' '
 288        git config column.tag row &&
 289        git config column.ui dense &&
 290        COLUMNS=40 git tag -l >actual &&
 291        git config --unset column.ui &&
 292        git config --unset column.tag &&
 293        cat >expected <<\EOF &&
 294a1      aa1   cba     t210    t211
 295v0.2.1  v1.0  v1.0.1  v1.1.3
 296EOF
 297        test_cmp expected actual
 298'
 299
 300test_expect_success 'listing tag with -n --column should fail' '
 301        test_must_fail git tag --column -n
 302'
 303
 304test_expect_success 'listing tags -n in column with column.ui ignored' '
 305        git config column.ui "row dense" &&
 306        COLUMNS=40 git tag -l -n >actual &&
 307        git config --unset column.ui &&
 308        cat >expected <<\EOF &&
 309a1              Foo
 310aa1             Foo
 311cba             Foo
 312t210            Foo
 313t211            Foo
 314v0.2.1          Foo
 315v1.0            Foo
 316v1.0.1          Foo
 317v1.1.3          Foo
 318EOF
 319        test_cmp expected actual
 320'
 321
 322# creating and verifying lightweight tags:
 323
 324test_expect_success \
 325        'a non-annotated tag created without parameters should point to HEAD' '
 326        git tag non-annotated-tag &&
 327        test $(git cat-file -t non-annotated-tag) = commit &&
 328        test $(git rev-parse non-annotated-tag) = $(git rev-parse HEAD)
 329'
 330
 331test_expect_success 'trying to verify an unknown tag should fail' \
 332        'test_must_fail git tag -v unknown-tag'
 333
 334test_expect_success \
 335        'trying to verify a non-annotated and non-signed tag should fail' \
 336        'test_must_fail git tag -v non-annotated-tag'
 337
 338test_expect_success \
 339        'trying to verify many non-annotated or unknown tags, should fail' \
 340        'test_must_fail git tag -v unknown-tag1 non-annotated-tag unknown-tag2'
 341
 342# creating annotated tags:
 343
 344get_tag_msg () {
 345        git cat-file tag "$1" | sed -e "/BEGIN PGP/q"
 346}
 347
 348# run test_tick before committing always gives the time in that timezone
 349get_tag_header () {
 350cat <<EOF
 351object $2
 352type $3
 353tag $1
 354tagger C O Mitter <committer@example.com> $4 -0700
 355
 356EOF
 357}
 358
 359commit=$(git rev-parse HEAD)
 360time=$test_tick
 361
 362get_tag_header annotated-tag $commit commit $time >expect
 363echo "A message" >>expect
 364test_expect_success \
 365        'creating an annotated tag with -m message should succeed' '
 366        git tag -m "A message" annotated-tag &&
 367        get_tag_msg annotated-tag >actual &&
 368        test_cmp expect actual
 369'
 370
 371cat >msgfile <<EOF
 372Another message
 373in a file.
 374EOF
 375get_tag_header file-annotated-tag $commit commit $time >expect
 376cat msgfile >>expect
 377test_expect_success \
 378        'creating an annotated tag with -F messagefile should succeed' '
 379        git tag -F msgfile file-annotated-tag &&
 380        get_tag_msg file-annotated-tag >actual &&
 381        test_cmp expect actual
 382'
 383
 384cat >inputmsg <<EOF
 385A message from the
 386standard input
 387EOF
 388get_tag_header stdin-annotated-tag $commit commit $time >expect
 389cat inputmsg >>expect
 390test_expect_success 'creating an annotated tag with -F - should succeed' '
 391        git tag -F - stdin-annotated-tag <inputmsg &&
 392        get_tag_msg stdin-annotated-tag >actual &&
 393        test_cmp expect actual
 394'
 395
 396test_expect_success \
 397        'trying to create a tag with a non-existing -F file should fail' '
 398        ! test -f nonexistingfile &&
 399        ! tag_exists notag &&
 400        test_must_fail git tag -F nonexistingfile notag &&
 401        ! tag_exists notag
 402'
 403
 404test_expect_success \
 405        'trying to create tags giving both -m or -F options should fail' '
 406        echo "message file 1" >msgfile1 &&
 407        echo "message file 2" >msgfile2 &&
 408        ! tag_exists msgtag &&
 409        test_must_fail git tag -m "message 1" -F msgfile1 msgtag &&
 410        ! tag_exists msgtag &&
 411        test_must_fail git tag -F msgfile1 -m "message 1" msgtag &&
 412        ! tag_exists msgtag &&
 413        test_must_fail git tag -m "message 1" -F msgfile1 \
 414                -m "message 2" msgtag &&
 415        ! tag_exists msgtag
 416'
 417
 418# blank and empty messages:
 419
 420get_tag_header empty-annotated-tag $commit commit $time >expect
 421test_expect_success \
 422        'creating a tag with an empty -m message should succeed' '
 423        git tag -m "" empty-annotated-tag &&
 424        get_tag_msg empty-annotated-tag >actual &&
 425        test_cmp expect actual
 426'
 427
 428>emptyfile
 429get_tag_header emptyfile-annotated-tag $commit commit $time >expect
 430test_expect_success \
 431        'creating a tag with an empty -F messagefile should succeed' '
 432        git tag -F emptyfile emptyfile-annotated-tag &&
 433        get_tag_msg emptyfile-annotated-tag >actual &&
 434        test_cmp expect actual
 435'
 436
 437printf '\n\n  \n\t\nLeading blank lines\n' >blanksfile
 438printf '\n\t \t  \nRepeated blank lines\n' >>blanksfile
 439printf '\n\n\nTrailing spaces      \t  \n' >>blanksfile
 440printf '\nTrailing blank lines\n\n\t \n\n' >>blanksfile
 441get_tag_header blanks-annotated-tag $commit commit $time >expect
 442cat >>expect <<EOF
 443Leading blank lines
 444
 445Repeated blank lines
 446
 447Trailing spaces
 448
 449Trailing blank lines
 450EOF
 451test_expect_success \
 452        'extra blanks in the message for an annotated tag should be removed' '
 453        git tag -F blanksfile blanks-annotated-tag &&
 454        get_tag_msg blanks-annotated-tag >actual &&
 455        test_cmp expect actual
 456'
 457
 458get_tag_header blank-annotated-tag $commit commit $time >expect
 459test_expect_success \
 460        'creating a tag with blank -m message with spaces should succeed' '
 461        git tag -m "     " blank-annotated-tag &&
 462        get_tag_msg blank-annotated-tag >actual &&
 463        test_cmp expect actual
 464'
 465
 466echo '     ' >blankfile
 467echo ''      >>blankfile
 468echo '  '    >>blankfile
 469get_tag_header blankfile-annotated-tag $commit commit $time >expect
 470test_expect_success \
 471        'creating a tag with blank -F messagefile with spaces should succeed' '
 472        git tag -F blankfile blankfile-annotated-tag &&
 473        get_tag_msg blankfile-annotated-tag >actual &&
 474        test_cmp expect actual
 475'
 476
 477printf '      ' >blanknonlfile
 478get_tag_header blanknonlfile-annotated-tag $commit commit $time >expect
 479test_expect_success \
 480        'creating a tag with -F file of spaces and no newline should succeed' '
 481        git tag -F blanknonlfile blanknonlfile-annotated-tag &&
 482        get_tag_msg blanknonlfile-annotated-tag >actual &&
 483        test_cmp expect actual
 484'
 485
 486# messages with commented lines:
 487
 488cat >commentsfile <<EOF
 489# A comment
 490
 491############
 492The message.
 493############
 494One line.
 495
 496
 497# commented lines
 498# commented lines
 499
 500Another line.
 501# comments
 502
 503Last line.
 504EOF
 505get_tag_header comments-annotated-tag $commit commit $time >expect
 506cat >>expect <<EOF
 507The message.
 508One line.
 509
 510Another line.
 511
 512Last line.
 513EOF
 514test_expect_success \
 515        'creating a tag using a -F messagefile with #comments should succeed' '
 516        git tag -F commentsfile comments-annotated-tag &&
 517        get_tag_msg comments-annotated-tag >actual &&
 518        test_cmp expect actual
 519'
 520
 521get_tag_header comment-annotated-tag $commit commit $time >expect
 522test_expect_success \
 523        'creating a tag with a #comment in the -m message should succeed' '
 524        git tag -m "#comment" comment-annotated-tag &&
 525        get_tag_msg comment-annotated-tag >actual &&
 526        test_cmp expect actual
 527'
 528
 529echo '#comment' >commentfile
 530echo ''         >>commentfile
 531echo '####'     >>commentfile
 532get_tag_header commentfile-annotated-tag $commit commit $time >expect
 533test_expect_success \
 534        'creating a tag with #comments in the -F messagefile should succeed' '
 535        git tag -F commentfile commentfile-annotated-tag &&
 536        get_tag_msg commentfile-annotated-tag >actual &&
 537        test_cmp expect actual
 538'
 539
 540printf '#comment' >commentnonlfile
 541get_tag_header commentnonlfile-annotated-tag $commit commit $time >expect
 542test_expect_success \
 543        'creating a tag with a file of #comment and no newline should succeed' '
 544        git tag -F commentnonlfile commentnonlfile-annotated-tag &&
 545        get_tag_msg commentnonlfile-annotated-tag >actual &&
 546        test_cmp expect actual
 547'
 548
 549# listing messages for annotated non-signed tags:
 550
 551test_expect_success \
 552        'listing the one-line message of a non-signed tag should succeed' '
 553        git tag -m "A msg" tag-one-line &&
 554
 555        echo "tag-one-line" >expect &&
 556        git tag -l | grep "^tag-one-line" >actual &&
 557        test_cmp expect actual &&
 558        git tag -n0 -l | grep "^tag-one-line" >actual &&
 559        test_cmp expect actual &&
 560        git tag -n0 -l tag-one-line >actual &&
 561        test_cmp expect actual &&
 562
 563        echo "tag-one-line    A msg" >expect &&
 564        git tag -n1 -l | grep "^tag-one-line" >actual &&
 565        test_cmp expect actual &&
 566        git tag -n -l | grep "^tag-one-line" >actual &&
 567        test_cmp expect actual &&
 568        git tag -n1 -l tag-one-line >actual &&
 569        test_cmp expect actual &&
 570        git tag -n2 -l tag-one-line >actual &&
 571        test_cmp expect actual &&
 572        git tag -n999 -l tag-one-line >actual &&
 573        test_cmp expect actual
 574'
 575
 576test_expect_success \
 577        'listing the zero-lines message of a non-signed tag should succeed' '
 578        git tag -m "" tag-zero-lines &&
 579
 580        echo "tag-zero-lines" >expect &&
 581        git tag -l | grep "^tag-zero-lines" >actual &&
 582        test_cmp expect actual &&
 583        git tag -n0 -l | grep "^tag-zero-lines" >actual &&
 584        test_cmp expect actual &&
 585        git tag -n0 -l tag-zero-lines >actual &&
 586        test_cmp expect actual &&
 587
 588        echo "tag-zero-lines  " >expect &&
 589        git tag -n1 -l | grep "^tag-zero-lines" >actual &&
 590        test_cmp expect actual &&
 591        git tag -n -l | grep "^tag-zero-lines" >actual &&
 592        test_cmp expect actual &&
 593        git tag -n1 -l tag-zero-lines >actual &&
 594        test_cmp expect actual &&
 595        git tag -n2 -l tag-zero-lines >actual &&
 596        test_cmp expect actual &&
 597        git tag -n999 -l tag-zero-lines >actual &&
 598        test_cmp expect actual
 599'
 600
 601echo 'tag line one' >annotagmsg
 602echo 'tag line two' >>annotagmsg
 603echo 'tag line three' >>annotagmsg
 604test_expect_success \
 605        'listing many message lines of a non-signed tag should succeed' '
 606        git tag -F annotagmsg tag-lines &&
 607
 608        echo "tag-lines" >expect &&
 609        git tag -l | grep "^tag-lines" >actual &&
 610        test_cmp expect actual &&
 611        git tag -n0 -l | grep "^tag-lines" >actual &&
 612        test_cmp expect actual &&
 613        git tag -n0 -l tag-lines >actual &&
 614        test_cmp expect actual &&
 615
 616        echo "tag-lines       tag line one" >expect &&
 617        git tag -n1 -l | grep "^tag-lines" >actual &&
 618        test_cmp expect actual &&
 619        git tag -n -l | grep "^tag-lines" >actual &&
 620        test_cmp expect actual &&
 621        git tag -n1 -l tag-lines >actual &&
 622        test_cmp expect actual &&
 623
 624        echo "    tag line two" >>expect &&
 625        git tag -n2 -l | grep "^ *tag.line" >actual &&
 626        test_cmp expect actual &&
 627        git tag -n2 -l tag-lines >actual &&
 628        test_cmp expect actual &&
 629
 630        echo "    tag line three" >>expect &&
 631        git tag -n3 -l | grep "^ *tag.line" >actual &&
 632        test_cmp expect actual &&
 633        git tag -n3 -l tag-lines >actual &&
 634        test_cmp expect actual &&
 635        git tag -n4 -l | grep "^ *tag.line" >actual &&
 636        test_cmp expect actual &&
 637        git tag -n4 -l tag-lines >actual &&
 638        test_cmp expect actual &&
 639        git tag -n99 -l | grep "^ *tag.line" >actual &&
 640        test_cmp expect actual &&
 641        git tag -n99 -l tag-lines >actual &&
 642        test_cmp expect actual
 643'
 644
 645test_expect_success 'annotations for blobs are empty' '
 646        blob=$(git hash-object -w --stdin <<-\EOF
 647        Blob paragraph 1.
 648
 649        Blob paragraph 2.
 650        EOF
 651        ) &&
 652        git tag tag-blob $blob &&
 653        echo "tag-blob        " >expect &&
 654        git tag -n1 -l tag-blob >actual &&
 655        test_cmp expect actual
 656'
 657
 658# trying to verify annotated non-signed tags:
 659
 660test_expect_success GPG \
 661        'trying to verify an annotated non-signed tag should fail' '
 662        tag_exists annotated-tag &&
 663        test_must_fail git tag -v annotated-tag
 664'
 665
 666test_expect_success GPG \
 667        'trying to verify a file-annotated non-signed tag should fail' '
 668        tag_exists file-annotated-tag &&
 669        test_must_fail git tag -v file-annotated-tag
 670'
 671
 672test_expect_success GPG \
 673        'trying to verify two annotated non-signed tags should fail' '
 674        tag_exists annotated-tag file-annotated-tag &&
 675        test_must_fail git tag -v annotated-tag file-annotated-tag
 676'
 677
 678# creating and verifying signed tags:
 679
 680get_tag_header signed-tag $commit commit $time >expect
 681echo 'A signed tag message' >>expect
 682echo '-----BEGIN PGP SIGNATURE-----' >>expect
 683test_expect_success GPG 'creating a signed tag with -m message should succeed' '
 684        git tag -s -m "A signed tag message" signed-tag &&
 685        get_tag_msg signed-tag >actual &&
 686        test_cmp expect actual
 687'
 688
 689get_tag_header u-signed-tag $commit commit $time >expect
 690echo 'Another message' >>expect
 691echo '-----BEGIN PGP SIGNATURE-----' >>expect
 692test_expect_success GPG 'sign with a given key id' '
 693
 694        git tag -u committer@example.com -m "Another message" u-signed-tag &&
 695        get_tag_msg u-signed-tag >actual &&
 696        test_cmp expect actual
 697
 698'
 699
 700test_expect_success GPG 'sign with an unknown id (1)' '
 701
 702        test_must_fail git tag -u author@example.com \
 703                -m "Another message" o-signed-tag
 704
 705'
 706
 707test_expect_success GPG 'sign with an unknown id (2)' '
 708
 709        test_must_fail git tag -u DEADBEEF -m "Another message" o-signed-tag
 710
 711'
 712
 713cat >fakeeditor <<'EOF'
 714#!/bin/sh
 715test -n "$1" && exec >"$1"
 716echo A signed tag message
 717echo from a fake editor.
 718EOF
 719chmod +x fakeeditor
 720
 721get_tag_header implied-sign $commit commit $time >expect
 722./fakeeditor >>expect
 723echo '-----BEGIN PGP SIGNATURE-----' >>expect
 724test_expect_success GPG '-u implies signed tag' '
 725        GIT_EDITOR=./fakeeditor git tag -u CDDE430D implied-sign &&
 726        get_tag_msg implied-sign >actual &&
 727        test_cmp expect actual
 728'
 729
 730cat >sigmsgfile <<EOF
 731Another signed tag
 732message in a file.
 733EOF
 734get_tag_header file-signed-tag $commit commit $time >expect
 735cat sigmsgfile >>expect
 736echo '-----BEGIN PGP SIGNATURE-----' >>expect
 737test_expect_success GPG \
 738        'creating a signed tag with -F messagefile should succeed' '
 739        git tag -s -F sigmsgfile file-signed-tag &&
 740        get_tag_msg file-signed-tag >actual &&
 741        test_cmp expect actual
 742'
 743
 744cat >siginputmsg <<EOF
 745A signed tag message from
 746the standard input
 747EOF
 748get_tag_header stdin-signed-tag $commit commit $time >expect
 749cat siginputmsg >>expect
 750echo '-----BEGIN PGP SIGNATURE-----' >>expect
 751test_expect_success GPG 'creating a signed tag with -F - should succeed' '
 752        git tag -s -F - stdin-signed-tag <siginputmsg &&
 753        get_tag_msg stdin-signed-tag >actual &&
 754        test_cmp expect actual
 755'
 756
 757get_tag_header implied-annotate $commit commit $time >expect
 758./fakeeditor >>expect
 759echo '-----BEGIN PGP SIGNATURE-----' >>expect
 760test_expect_success GPG '-s implies annotated tag' '
 761        GIT_EDITOR=./fakeeditor git tag -s implied-annotate &&
 762        get_tag_msg implied-annotate >actual &&
 763        test_cmp expect actual
 764'
 765
 766test_expect_success GPG \
 767        'trying to create a signed tag with non-existing -F file should fail' '
 768        ! test -f nonexistingfile &&
 769        ! tag_exists nosigtag &&
 770        test_must_fail git tag -s -F nonexistingfile nosigtag &&
 771        ! tag_exists nosigtag
 772'
 773
 774test_expect_success GPG 'verifying a signed tag should succeed' \
 775        'git tag -v signed-tag'
 776
 777test_expect_success GPG 'verifying two signed tags in one command should succeed' \
 778        'git tag -v signed-tag file-signed-tag'
 779
 780test_expect_success GPG \
 781        'verifying many signed and non-signed tags should fail' '
 782        test_must_fail git tag -v signed-tag annotated-tag &&
 783        test_must_fail git tag -v file-annotated-tag file-signed-tag &&
 784        test_must_fail git tag -v annotated-tag \
 785                file-signed-tag file-annotated-tag &&
 786        test_must_fail git tag -v signed-tag annotated-tag file-signed-tag
 787'
 788
 789test_expect_success GPG 'verifying a forged tag should fail' '
 790        forged=$(git cat-file tag signed-tag |
 791                sed -e "s/signed-tag/forged-tag/" |
 792                git mktag) &&
 793        git tag forged-tag $forged &&
 794        test_must_fail git tag -v forged-tag
 795'
 796
 797# blank and empty messages for signed tags:
 798
 799get_tag_header empty-signed-tag $commit commit $time >expect
 800echo '-----BEGIN PGP SIGNATURE-----' >>expect
 801test_expect_success GPG \
 802        'creating a signed tag with an empty -m message should succeed' '
 803        git tag -s -m "" empty-signed-tag &&
 804        get_tag_msg empty-signed-tag >actual &&
 805        test_cmp expect actual &&
 806        git tag -v empty-signed-tag
 807'
 808
 809>sigemptyfile
 810get_tag_header emptyfile-signed-tag $commit commit $time >expect
 811echo '-----BEGIN PGP SIGNATURE-----' >>expect
 812test_expect_success GPG \
 813        'creating a signed tag with an empty -F messagefile should succeed' '
 814        git tag -s -F sigemptyfile emptyfile-signed-tag &&
 815        get_tag_msg emptyfile-signed-tag >actual &&
 816        test_cmp expect actual &&
 817        git tag -v emptyfile-signed-tag
 818'
 819
 820printf '\n\n  \n\t\nLeading blank lines\n' > sigblanksfile
 821printf '\n\t \t  \nRepeated blank lines\n' >>sigblanksfile
 822printf '\n\n\nTrailing spaces      \t  \n' >>sigblanksfile
 823printf '\nTrailing blank lines\n\n\t \n\n' >>sigblanksfile
 824get_tag_header blanks-signed-tag $commit commit $time >expect
 825cat >>expect <<EOF
 826Leading blank lines
 827
 828Repeated blank lines
 829
 830Trailing spaces
 831
 832Trailing blank lines
 833EOF
 834echo '-----BEGIN PGP SIGNATURE-----' >>expect
 835test_expect_success GPG \
 836        'extra blanks in the message for a signed tag should be removed' '
 837        git tag -s -F sigblanksfile blanks-signed-tag &&
 838        get_tag_msg blanks-signed-tag >actual &&
 839        test_cmp expect actual &&
 840        git tag -v blanks-signed-tag
 841'
 842
 843get_tag_header blank-signed-tag $commit commit $time >expect
 844echo '-----BEGIN PGP SIGNATURE-----' >>expect
 845test_expect_success GPG \
 846        'creating a signed tag with a blank -m message should succeed' '
 847        git tag -s -m "     " blank-signed-tag &&
 848        get_tag_msg blank-signed-tag >actual &&
 849        test_cmp expect actual &&
 850        git tag -v blank-signed-tag
 851'
 852
 853echo '     ' >sigblankfile
 854echo ''      >>sigblankfile
 855echo '  '    >>sigblankfile
 856get_tag_header blankfile-signed-tag $commit commit $time >expect
 857echo '-----BEGIN PGP SIGNATURE-----' >>expect
 858test_expect_success GPG \
 859        'creating a signed tag with blank -F file with spaces should succeed' '
 860        git tag -s -F sigblankfile blankfile-signed-tag &&
 861        get_tag_msg blankfile-signed-tag >actual &&
 862        test_cmp expect actual &&
 863        git tag -v blankfile-signed-tag
 864'
 865
 866printf '      ' >sigblanknonlfile
 867get_tag_header blanknonlfile-signed-tag $commit commit $time >expect
 868echo '-----BEGIN PGP SIGNATURE-----' >>expect
 869test_expect_success GPG \
 870        'creating a signed tag with spaces and no newline should succeed' '
 871        git tag -s -F sigblanknonlfile blanknonlfile-signed-tag &&
 872        get_tag_msg blanknonlfile-signed-tag >actual &&
 873        test_cmp expect actual &&
 874        git tag -v signed-tag
 875'
 876
 877# messages with commented lines for signed tags:
 878
 879cat >sigcommentsfile <<EOF
 880# A comment
 881
 882############
 883The message.
 884############
 885One line.
 886
 887
 888# commented lines
 889# commented lines
 890
 891Another line.
 892# comments
 893
 894Last line.
 895EOF
 896get_tag_header comments-signed-tag $commit commit $time >expect
 897cat >>expect <<EOF
 898The message.
 899One line.
 900
 901Another line.
 902
 903Last line.
 904EOF
 905echo '-----BEGIN PGP SIGNATURE-----' >>expect
 906test_expect_success GPG \
 907        'creating a signed tag with a -F file with #comments should succeed' '
 908        git tag -s -F sigcommentsfile comments-signed-tag &&
 909        get_tag_msg comments-signed-tag >actual &&
 910        test_cmp expect actual &&
 911        git tag -v comments-signed-tag
 912'
 913
 914get_tag_header comment-signed-tag $commit commit $time >expect
 915echo '-----BEGIN PGP SIGNATURE-----' >>expect
 916test_expect_success GPG \
 917        'creating a signed tag with #commented -m message should succeed' '
 918        git tag -s -m "#comment" comment-signed-tag &&
 919        get_tag_msg comment-signed-tag >actual &&
 920        test_cmp expect actual &&
 921        git tag -v comment-signed-tag
 922'
 923
 924echo '#comment' >sigcommentfile
 925echo ''         >>sigcommentfile
 926echo '####'     >>sigcommentfile
 927get_tag_header commentfile-signed-tag $commit commit $time >expect
 928echo '-----BEGIN PGP SIGNATURE-----' >>expect
 929test_expect_success GPG \
 930        'creating a signed tag with #commented -F messagefile should succeed' '
 931        git tag -s -F sigcommentfile commentfile-signed-tag &&
 932        get_tag_msg commentfile-signed-tag >actual &&
 933        test_cmp expect actual &&
 934        git tag -v commentfile-signed-tag
 935'
 936
 937printf '#comment' >sigcommentnonlfile
 938get_tag_header commentnonlfile-signed-tag $commit commit $time >expect
 939echo '-----BEGIN PGP SIGNATURE-----' >>expect
 940test_expect_success GPG \
 941        'creating a signed tag with a #comment and no newline should succeed' '
 942        git tag -s -F sigcommentnonlfile commentnonlfile-signed-tag &&
 943        get_tag_msg commentnonlfile-signed-tag >actual &&
 944        test_cmp expect actual &&
 945        git tag -v commentnonlfile-signed-tag
 946'
 947
 948# listing messages for signed tags:
 949
 950test_expect_success GPG \
 951        'listing the one-line message of a signed tag should succeed' '
 952        git tag -s -m "A message line signed" stag-one-line &&
 953
 954        echo "stag-one-line" >expect &&
 955        git tag -l | grep "^stag-one-line" >actual &&
 956        test_cmp expect actual &&
 957        git tag -n0 -l | grep "^stag-one-line" >actual &&
 958        test_cmp expect actual &&
 959        git tag -n0 -l stag-one-line >actual &&
 960        test_cmp expect actual &&
 961
 962        echo "stag-one-line   A message line signed" >expect &&
 963        git tag -n1 -l | grep "^stag-one-line" >actual &&
 964        test_cmp expect actual &&
 965        git tag -n -l | grep "^stag-one-line" >actual &&
 966        test_cmp expect actual &&
 967        git tag -n1 -l stag-one-line >actual &&
 968        test_cmp expect actual &&
 969        git tag -n2 -l stag-one-line >actual &&
 970        test_cmp expect actual &&
 971        git tag -n999 -l stag-one-line >actual &&
 972        test_cmp expect actual
 973'
 974
 975test_expect_success GPG \
 976        'listing the zero-lines message of a signed tag should succeed' '
 977        git tag -s -m "" stag-zero-lines &&
 978
 979        echo "stag-zero-lines" >expect &&
 980        git tag -l | grep "^stag-zero-lines" >actual &&
 981        test_cmp expect actual &&
 982        git tag -n0 -l | grep "^stag-zero-lines" >actual &&
 983        test_cmp expect actual &&
 984        git tag -n0 -l stag-zero-lines >actual &&
 985        test_cmp expect actual &&
 986
 987        echo "stag-zero-lines " >expect &&
 988        git tag -n1 -l | grep "^stag-zero-lines" >actual &&
 989        test_cmp expect actual &&
 990        git tag -n -l | grep "^stag-zero-lines" >actual &&
 991        test_cmp expect actual &&
 992        git tag -n1 -l stag-zero-lines >actual &&
 993        test_cmp expect actual &&
 994        git tag -n2 -l stag-zero-lines >actual &&
 995        test_cmp expect actual &&
 996        git tag -n999 -l stag-zero-lines >actual &&
 997        test_cmp expect actual
 998'
 999
1000echo 'stag line one' >sigtagmsg
1001echo 'stag line two' >>sigtagmsg
1002echo 'stag line three' >>sigtagmsg
1003test_expect_success GPG \
1004        'listing many message lines of a signed tag should succeed' '
1005        git tag -s -F sigtagmsg stag-lines &&
1006
1007        echo "stag-lines" >expect &&
1008        git tag -l | grep "^stag-lines" >actual &&
1009        test_cmp expect actual &&
1010        git tag -n0 -l | grep "^stag-lines" >actual &&
1011        test_cmp expect actual &&
1012        git tag -n0 -l stag-lines >actual &&
1013        test_cmp expect actual &&
1014
1015        echo "stag-lines      stag line one" >expect &&
1016        git tag -n1 -l | grep "^stag-lines" >actual &&
1017        test_cmp expect actual &&
1018        git tag -n -l | grep "^stag-lines" >actual &&
1019        test_cmp expect actual &&
1020        git tag -n1 -l stag-lines >actual &&
1021        test_cmp expect actual &&
1022
1023        echo "    stag line two" >>expect &&
1024        git tag -n2 -l | grep "^ *stag.line" >actual &&
1025        test_cmp expect actual &&
1026        git tag -n2 -l stag-lines >actual &&
1027        test_cmp expect actual &&
1028
1029        echo "    stag line three" >>expect &&
1030        git tag -n3 -l | grep "^ *stag.line" >actual &&
1031        test_cmp expect actual &&
1032        git tag -n3 -l stag-lines >actual &&
1033        test_cmp expect actual &&
1034        git tag -n4 -l | grep "^ *stag.line" >actual &&
1035        test_cmp expect actual &&
1036        git tag -n4 -l stag-lines >actual &&
1037        test_cmp expect actual &&
1038        git tag -n99 -l | grep "^ *stag.line" >actual &&
1039        test_cmp expect actual &&
1040        git tag -n99 -l stag-lines >actual &&
1041        test_cmp expect actual
1042'
1043
1044# tags pointing to objects different from commits:
1045
1046tree=$(git rev-parse HEAD^{tree})
1047blob=$(git rev-parse HEAD:foo)
1048tag=$(git rev-parse signed-tag 2>/dev/null)
1049
1050get_tag_header tree-signed-tag $tree tree $time >expect
1051echo "A message for a tree" >>expect
1052echo '-----BEGIN PGP SIGNATURE-----' >>expect
1053test_expect_success GPG \
1054        'creating a signed tag pointing to a tree should succeed' '
1055        git tag -s -m "A message for a tree" tree-signed-tag HEAD^{tree} &&
1056        get_tag_msg tree-signed-tag >actual &&
1057        test_cmp expect actual
1058'
1059
1060get_tag_header blob-signed-tag $blob blob $time >expect
1061echo "A message for a blob" >>expect
1062echo '-----BEGIN PGP SIGNATURE-----' >>expect
1063test_expect_success GPG \
1064        'creating a signed tag pointing to a blob should succeed' '
1065        git tag -s -m "A message for a blob" blob-signed-tag HEAD:foo &&
1066        get_tag_msg blob-signed-tag >actual &&
1067        test_cmp expect actual
1068'
1069
1070get_tag_header tag-signed-tag $tag tag $time >expect
1071echo "A message for another tag" >>expect
1072echo '-----BEGIN PGP SIGNATURE-----' >>expect
1073test_expect_success GPG \
1074        'creating a signed tag pointing to another tag should succeed' '
1075        git tag -s -m "A message for another tag" tag-signed-tag signed-tag &&
1076        get_tag_msg tag-signed-tag >actual &&
1077        test_cmp expect actual
1078'
1079
1080# usage with rfc1991 signatures
1081get_tag_header rfc1991-signed-tag $commit commit $time >expect
1082echo "RFC1991 signed tag" >>expect
1083echo '-----BEGIN PGP MESSAGE-----' >>expect
1084test_expect_success GPG \
1085        'creating a signed tag with rfc1991' '
1086        echo "rfc1991" >gpghome/gpg.conf &&
1087        git tag -s -m "RFC1991 signed tag" rfc1991-signed-tag $commit &&
1088        get_tag_msg rfc1991-signed-tag >actual &&
1089        test_cmp expect actual
1090'
1091
1092cat >fakeeditor <<'EOF'
1093#!/bin/sh
1094cp "$1" actual
1095EOF
1096chmod +x fakeeditor
1097
1098test_expect_success GPG \
1099        'reediting a signed tag body omits signature' '
1100        echo "rfc1991" >gpghome/gpg.conf &&
1101        echo "RFC1991 signed tag" >expect &&
1102        GIT_EDITOR=./fakeeditor git tag -f -s rfc1991-signed-tag $commit &&
1103        test_cmp expect actual
1104'
1105
1106test_expect_success GPG \
1107        'verifying rfc1991 signature' '
1108        echo "rfc1991" >gpghome/gpg.conf &&
1109        git tag -v rfc1991-signed-tag
1110'
1111
1112test_expect_success GPG \
1113        'list tag with rfc1991 signature' '
1114        echo "rfc1991" >gpghome/gpg.conf &&
1115        echo "rfc1991-signed-tag RFC1991 signed tag" >expect &&
1116        git tag -l -n1 rfc1991-signed-tag >actual &&
1117        test_cmp expect actual &&
1118        git tag -l -n2 rfc1991-signed-tag >actual &&
1119        test_cmp expect actual &&
1120        git tag -l -n999 rfc1991-signed-tag >actual &&
1121        test_cmp expect actual
1122'
1123
1124rm -f gpghome/gpg.conf
1125
1126test_expect_success GPG \
1127        'verifying rfc1991 signature without --rfc1991' '
1128        git tag -v rfc1991-signed-tag
1129'
1130
1131test_expect_success GPG \
1132        'list tag with rfc1991 signature without --rfc1991' '
1133        echo "rfc1991-signed-tag RFC1991 signed tag" >expect &&
1134        git tag -l -n1 rfc1991-signed-tag >actual &&
1135        test_cmp expect actual &&
1136        git tag -l -n2 rfc1991-signed-tag >actual &&
1137        test_cmp expect actual &&
1138        git tag -l -n999 rfc1991-signed-tag >actual &&
1139        test_cmp expect actual
1140'
1141
1142test_expect_success GPG \
1143        'reediting a signed tag body omits signature' '
1144        echo "RFC1991 signed tag" >expect &&
1145        GIT_EDITOR=./fakeeditor git tag -f -s rfc1991-signed-tag $commit &&
1146        test_cmp expect actual
1147'
1148
1149# try to sign with bad user.signingkey
1150git config user.signingkey BobTheMouse
1151test_expect_success GPG \
1152        'git tag -s fails if gpg is misconfigured' \
1153        'test_must_fail git tag -s -m tail tag-gpg-failure'
1154git config --unset user.signingkey
1155
1156# try to verify without gpg:
1157
1158rm -rf gpghome
1159test_expect_success GPG \
1160        'verify signed tag fails when public key is not present' \
1161        'test_must_fail git tag -v signed-tag'
1162
1163test_expect_success \
1164        'git tag -a fails if tag annotation is empty' '
1165        ! (GIT_EDITOR=cat git tag -a initial-comment)
1166'
1167
1168test_expect_success \
1169        'message in editor has initial comment' '
1170        ! (GIT_EDITOR=cat git tag -a initial-comment > actual)
1171'
1172
1173test_expect_success 'message in editor has initial comment: first line' '
1174        # check the first line --- should be empty
1175        echo >first.expect &&
1176        sed -e 1q <actual >first.actual &&
1177        test_i18ncmp first.expect first.actual
1178'
1179
1180test_expect_success \
1181        'message in editor has initial comment: remainder' '
1182        # remove commented lines from the remainder -- should be empty
1183        >rest.expect
1184        sed -e 1d -e '/^#/d' <actual >rest.actual &&
1185        test_cmp rest.expect rest.actual
1186'
1187
1188get_tag_header reuse $commit commit $time >expect
1189echo "An annotation to be reused" >> expect
1190test_expect_success \
1191        'overwriting an annoted tag should use its previous body' '
1192        git tag -a -m "An annotation to be reused" reuse &&
1193        GIT_EDITOR=true git tag -f -a reuse &&
1194        get_tag_msg reuse >actual &&
1195        test_cmp expect actual
1196'
1197
1198test_expect_success 'filename for the message is relative to cwd' '
1199        mkdir subdir &&
1200        echo "Tag message in top directory" >msgfile-5 &&
1201        echo "Tag message in sub directory" >subdir/msgfile-5 &&
1202        (
1203                cd subdir &&
1204                git tag -a -F msgfile-5 tag-from-subdir
1205        ) &&
1206        git cat-file tag tag-from-subdir | grep "in sub directory"
1207'
1208
1209test_expect_success 'filename for the message is relative to cwd' '
1210        echo "Tag message in sub directory" >subdir/msgfile-6 &&
1211        (
1212                cd subdir &&
1213                git tag -a -F msgfile-6 tag-from-subdir-2
1214        ) &&
1215        git cat-file tag tag-from-subdir-2 | grep "in sub directory"
1216'
1217
1218# create a few more commits to test --contains
1219
1220hash1=$(git rev-parse HEAD)
1221
1222test_expect_success 'creating second commit and tag' '
1223        echo foo-2.0 >foo &&
1224        git add foo &&
1225        git commit -m second &&
1226        git tag v2.0
1227'
1228
1229hash2=$(git rev-parse HEAD)
1230
1231test_expect_success 'creating third commit without tag' '
1232        echo foo-dev >foo &&
1233        git add foo &&
1234        git commit -m third
1235'
1236
1237hash3=$(git rev-parse HEAD)
1238
1239# simple linear checks of --continue
1240
1241cat > expected <<EOF
1242v0.2.1
1243v1.0
1244v1.0.1
1245v1.1.3
1246v2.0
1247EOF
1248
1249test_expect_success 'checking that first commit is in all tags (hash)' "
1250        git tag -l --contains $hash1 v* >actual &&
1251        test_cmp expected actual
1252"
1253
1254# other ways of specifying the commit
1255test_expect_success 'checking that first commit is in all tags (tag)' "
1256        git tag -l --contains v1.0 v* >actual &&
1257        test_cmp expected actual
1258"
1259
1260test_expect_success 'checking that first commit is in all tags (relative)' "
1261        git tag -l --contains HEAD~2 v* >actual &&
1262        test_cmp expected actual
1263"
1264
1265cat > expected <<EOF
1266v2.0
1267EOF
1268
1269test_expect_success 'checking that second commit only has one tag' "
1270        git tag -l --contains $hash2 v* >actual &&
1271        test_cmp expected actual
1272"
1273
1274
1275cat > expected <<EOF
1276EOF
1277
1278test_expect_success 'checking that third commit has no tags' "
1279        git tag -l --contains $hash3 v* >actual &&
1280        test_cmp expected actual
1281"
1282
1283# how about a simple merge?
1284
1285test_expect_success 'creating simple branch' '
1286        git branch stable v2.0 &&
1287        git checkout stable &&
1288        echo foo-3.0 > foo &&
1289        git commit foo -m fourth &&
1290        git tag v3.0
1291'
1292
1293hash4=$(git rev-parse HEAD)
1294
1295cat > expected <<EOF
1296v3.0
1297EOF
1298
1299test_expect_success 'checking that branch head only has one tag' "
1300        git tag -l --contains $hash4 v* >actual &&
1301        test_cmp expected actual
1302"
1303
1304test_expect_success 'merging original branch into this branch' '
1305        git merge --strategy=ours master &&
1306        git tag v4.0
1307'
1308
1309cat > expected <<EOF
1310v4.0
1311EOF
1312
1313test_expect_success 'checking that original branch head has one tag now' "
1314        git tag -l --contains $hash3 v* >actual &&
1315        test_cmp expected actual
1316"
1317
1318cat > expected <<EOF
1319v0.2.1
1320v1.0
1321v1.0.1
1322v1.1.3
1323v2.0
1324v3.0
1325v4.0
1326EOF
1327
1328test_expect_success 'checking that initial commit is in all tags' "
1329        git tag -l --contains $hash1 v* >actual &&
1330        test_cmp expected actual
1331"
1332
1333# mixing modes and options:
1334
1335test_expect_success 'mixing incompatibles modes and options is forbidden' '
1336        test_must_fail git tag -a &&
1337        test_must_fail git tag -l -v &&
1338        test_must_fail git tag -n 100 &&
1339        test_must_fail git tag -l -m msg &&
1340        test_must_fail git tag -l -F some file &&
1341        test_must_fail git tag -v -s
1342'
1343
1344# check points-at
1345
1346test_expect_success '--points-at cannot be used in non-list mode' '
1347        test_must_fail git tag --points-at=v4.0 foo
1348'
1349
1350test_expect_success '--points-at finds lightweight tags' '
1351        echo v4.0 >expect &&
1352        git tag --points-at v4.0 >actual &&
1353        test_cmp expect actual
1354'
1355
1356test_expect_success '--points-at finds annotated tags of commits' '
1357        git tag -m "v4.0, annotated" annotated-v4.0 v4.0 &&
1358        echo annotated-v4.0 >expect &&
1359        git tag -l --points-at v4.0 "annotated*" >actual &&
1360        test_cmp expect actual
1361'
1362
1363test_expect_success '--points-at finds annotated tags of tags' '
1364        git tag -m "describing the v4.0 tag object" \
1365                annotated-again-v4.0 annotated-v4.0 &&
1366        cat >expect <<-\EOF &&
1367        annotated-again-v4.0
1368        annotated-v4.0
1369        EOF
1370        git tag --points-at=annotated-v4.0 >actual &&
1371        test_cmp expect actual
1372'
1373
1374test_expect_success 'multiple --points-at are OR-ed together' '
1375        cat >expect <<-\EOF &&
1376        v2.0
1377        v3.0
1378        EOF
1379        git tag --points-at=v2.0 --points-at=v3.0 >actual &&
1380        test_cmp expect actual
1381'
1382
1383test_done