Merge branch 'st/verify-tag'
authorJunio C Hamano <gitster@pobox.com>
Mon, 27 Mar 2017 17:59:22 +0000 (10:59 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 27 Mar 2017 17:59:23 +0000 (10:59 -0700)
A few unterminated here documents in tests were fixed, which in
turn revealed incorrect expectations the tests make. These tests
have been updated.

* st/verify-tag:
t7004, t7030: fix here-doc syntax errors

1  2 
t/t7004-tag.sh
diff --combined t/t7004-tag.sh
index b4698ab5f53c2ce92bd349fe4fa336e5fc5ca3e5,f67bbb8abc531dc3bf7f1eb0bd65d3f48fd2554f..772dc9ed960be0ea74bac52c571bb7a6f5b22053
@@@ -27,30 -27,6 +27,30 @@@ test_expect_success 'listing all tags i
        test $(git tag | wc -l) -eq 0
  '
  
 +test_expect_success 'sort tags, ignore case' '
 +      (
 +              git init sort &&
 +              cd sort &&
 +              test_commit initial &&
 +              git tag tag-one &&
 +              git tag TAG-two &&
 +              git tag -l >actual &&
 +              cat >expected <<-\EOF &&
 +              TAG-two
 +              initial
 +              tag-one
 +              EOF
 +              test_cmp expected actual &&
 +              git tag -l -i >actual &&
 +              cat >expected <<-\EOF &&
 +              initial
 +              tag-one
 +              TAG-two
 +              EOF
 +              test_cmp expected actual
 +      )
 +'
 +
  test_expect_success 'looking for a tag in an empty tree should fail' \
        '! (tag_exists mytag)'
  
@@@ -71,7 -47,6 +71,7 @@@ test_expect_success 'creating a tag fo
  
  # commit used in the tests, test_tick is also called here to freeze the date:
  test_expect_success 'creating a tag using default HEAD should succeed' '
 +      test_config core.logAllRefUpdates true &&
        test_tick &&
        echo foo >foo &&
        git add foo &&
  '
  
  test_expect_success 'creating a tag with --create-reflog should create reflog' '
 +      git log -1 \
 +              --format="format:tag: tagging %h (%s, %cd)%n" \
 +              --date=format:%Y-%m-%d >expected &&
        test_when_finished "git tag -d tag_with_reflog" &&
        git tag --create-reflog tag_with_reflog &&
 -      git reflog exists refs/tags/tag_with_reflog
 +      git reflog exists refs/tags/tag_with_reflog &&
 +      sed -e "s/^.*   //" .git/logs/refs/tags/tag_with_reflog >actual &&
 +      test_cmp expected actual
 +'
 +
 +test_expect_success 'annotated tag with --create-reflog has correct message' '
 +      git log -1 \
 +              --format="format:tag: tagging %h (%s, %cd)%n" \
 +              --date=format:%Y-%m-%d >expected &&
 +      test_when_finished "git tag -d tag_with_reflog" &&
 +      git tag -m "annotated tag" --create-reflog tag_with_reflog &&
 +      git reflog exists refs/tags/tag_with_reflog &&
 +      sed -e "s/^.*   //" .git/logs/refs/tags/tag_with_reflog >actual &&
 +      test_cmp expected actual
  '
  
  test_expect_success '--create-reflog does not create reflog on failure' '
        test_must_fail git reflog exists refs/tags/mytag
  '
  
 +test_expect_success 'option core.logAllRefUpdates=always creates reflog' '
 +      test_when_finished "git tag -d tag_with_reflog" &&
 +      test_config core.logAllRefUpdates always &&
 +      git tag tag_with_reflog &&
 +      git reflog exists refs/tags/tag_with_reflog
 +'
 +
  test_expect_success 'listing all tags if one exists should succeed' '
        git tag -l &&
        git tag
@@@ -129,9 -81,6 +129,9 @@@ test_expect_success 'listing all tags i
  test_expect_success 'listing a tag using a matching pattern should succeed' \
        'git tag -l mytag'
  
 +test_expect_success 'listing a tag with --ignore-case' \
 +      'test $(git tag -l --ignore-case MYTAG) = mytag'
 +
  test_expect_success \
        'listing a tag using a matching pattern should output that tag' \
        'test $(git tag -l mytag) = mytag'
@@@ -173,11 -122,11 +173,11 @@@ test_expect_success '--force can creat
        tag_exists mytag'
  
  test_expect_success '--force is moot with a non-existing tag name' '
 +      test_when_finished git tag -d newtag forcetag &&
        git tag newtag >expect &&
        git tag --force forcetag >actual &&
        test_cmp expect actual
  '
 -git tag -d newtag forcetag
  
  # deleting tags:
  
@@@ -348,9 -297,11 +348,9 @@@ EO
  '
  
  test_expect_success 'listing tags in column with column.*' '
 -      git config column.tag row &&
 -      git config column.ui dense &&
 +      test_config column.tag row &&
 +      test_config column.ui dense &&
        COLUMNS=40 git tag -l >actual &&
 -      git config --unset column.ui &&
 -      git config --unset column.tag &&
        cat >expected <<\EOF &&
  a1      aa1   cba     t210    t211
  v0.2.1  v1.0  v1.0.1  v1.1.3
@@@ -363,8 -314,9 +363,8 @@@ test_expect_success 'listing tag with -
  '
  
  test_expect_success 'listing tags -n in column with column.ui ignored' '
 -      git config column.ui "row dense" &&
 +      test_config column.ui "row dense" &&
        COLUMNS=40 git tag -l -n >actual &&
 -      git config --unset column.ui &&
        cat >expected <<\EOF &&
  a1              Foo
  aa1             Foo
@@@ -895,18 -847,16 +895,16 @@@ test_expect_success GPG 'verifying a fo
        test_must_fail git tag -v forged-tag
  '
  
- test_expect_success 'verifying a proper tag with --format pass and format accordingly' '
-       cat >expect <<-\EOF
+ test_expect_success GPG 'verifying a proper tag with --format pass and format accordingly' '
+       cat >expect <<-\EOF &&
        tagname : signed-tag
-       EOF &&
+       EOF
        git tag -v --format="tagname : %(tag)" "signed-tag" >actual &&
        test_cmp expect actual
  '
  
- test_expect_success 'verifying a forged tag with --format fail and format accordingly' '
-       cat >expect <<-\EOF
-       tagname : forged-tag
-       EOF &&
+ test_expect_success GPG 'verifying a forged tag with --format should fail silently' '
+       >expect &&
        test_must_fail git tag -v --format="tagname : %(tag)" "forged-tag" >actual &&
        test_cmp expect actual
  '
@@@ -1264,10 -1214,11 +1262,10 @@@ test_expect_success GPG,RFC1991 
  '
  
  # try to sign with bad user.signingkey
 -git config user.signingkey BobTheMouse
  test_expect_success GPG \
        'git tag -s fails if gpg is misconfigured (bad key)' \
 -      'test_must_fail git tag -s -m tail tag-gpg-failure'
 -git config --unset user.signingkey
 +      'test_config user.signingkey BobTheMouse &&
 +      test_must_fail git tag -s -m tail tag-gpg-failure'
  
  # try to produce invalid signature
  test_expect_success GPG \
@@@ -1547,7 -1498,7 +1545,7 @@@ test_expect_success 'reverse lexical so
  '
  
  test_expect_success 'configured lexical sort' '
 -      git config tag.sort "v:refname" &&
 +      test_config tag.sort "v:refname" &&
        git tag -l "foo*" >actual &&
        cat >expect <<-\EOF &&
        foo1.3
  '
  
  test_expect_success 'option override configured sort' '
 +      test_config tag.sort "v:refname" &&
        git tag -l --sort=-refname "foo*" >actual &&
        cat >expect <<-\EOF &&
        foo1.6
@@@ -1573,12 -1523,13 +1571,12 @@@ test_expect_success 'invalid sort param
  '
  
  test_expect_success 'invalid sort parameter in configuratoin' '
 -      git config tag.sort "v:notvalid" &&
 +      test_config tag.sort "v:notvalid" &&
        test_must_fail git tag -l "foo*"
  '
  
  test_expect_success 'version sort with prerelease reordering' '
 -      git config --unset tag.sort &&
 -      git config versionsort.prereleaseSuffix -rc &&
 +      test_config versionsort.prereleaseSuffix -rc &&
        git tag foo1.6-rc1 &&
        git tag foo1.6-rc2 &&
        git tag -l --sort=version:refname "foo*" >actual &&
  '
  
  test_expect_success 'reverse version sort with prerelease reordering' '
 +      test_config versionsort.prereleaseSuffix -rc &&
        git tag -l --sort=-version:refname "foo*" >actual &&
        cat >expect <<-\EOF &&
        foo1.10
        test_cmp expect actual
  '
  
 +test_expect_success 'version sort with prerelease reordering and common leading character' '
 +      test_config versionsort.prereleaseSuffix -before &&
 +      git tag foo1.7-before1 &&
 +      git tag foo1.7 &&
 +      git tag foo1.7-after1 &&
 +      git tag -l --sort=version:refname "foo1.7*" >actual &&
 +      cat >expect <<-\EOF &&
 +      foo1.7-before1
 +      foo1.7
 +      foo1.7-after1
 +      EOF
 +      test_cmp expect actual
 +'
 +
 +test_expect_success 'version sort with prerelease reordering, multiple suffixes and common leading character' '
 +      test_config versionsort.prereleaseSuffix -before &&
 +      git config --add versionsort.prereleaseSuffix -after &&
 +      git tag -l --sort=version:refname "foo1.7*" >actual &&
 +      cat >expect <<-\EOF &&
 +      foo1.7-before1
 +      foo1.7-after1
 +      foo1.7
 +      EOF
 +      test_cmp expect actual
 +'
 +
 +test_expect_success 'version sort with prerelease reordering, multiple suffixes match the same tag' '
 +      test_config versionsort.prereleaseSuffix -bar &&
 +      git config --add versionsort.prereleaseSuffix -foo-baz &&
 +      git config --add versionsort.prereleaseSuffix -foo-bar &&
 +      git tag foo1.8-foo-bar &&
 +      git tag foo1.8-foo-baz &&
 +      git tag foo1.8 &&
 +      git tag -l --sort=version:refname "foo1.8*" >actual &&
 +      cat >expect <<-\EOF &&
 +      foo1.8-foo-baz
 +      foo1.8-foo-bar
 +      foo1.8
 +      EOF
 +      test_cmp expect actual
 +'
 +
 +test_expect_success 'version sort with prerelease reordering, multiple suffixes match starting at the same position' '
 +      test_config versionsort.prereleaseSuffix -pre &&
 +      git config --add versionsort.prereleaseSuffix -prerelease &&
 +      git tag foo1.9-pre1 &&
 +      git tag foo1.9-pre2 &&
 +      git tag foo1.9-prerelease1 &&
 +      git tag -l --sort=version:refname "foo1.9*" >actual &&
 +      cat >expect <<-\EOF &&
 +      foo1.9-pre1
 +      foo1.9-pre2
 +      foo1.9-prerelease1
 +      EOF
 +      test_cmp expect actual
 +'
 +
 +test_expect_success 'version sort with general suffix reordering' '
 +      test_config versionsort.suffix -alpha &&
 +      git config --add versionsort.suffix -beta &&
 +      git config --add versionsort.suffix ""  &&
 +      git config --add versionsort.suffix -gamma &&
 +      git config --add versionsort.suffix -delta &&
 +      git tag foo1.10-alpha &&
 +      git tag foo1.10-beta &&
 +      git tag foo1.10-gamma &&
 +      git tag foo1.10-delta &&
 +      git tag foo1.10-unlisted-suffix &&
 +      git tag -l --sort=version:refname "foo1.10*" >actual &&
 +      cat >expect <<-\EOF &&
 +      foo1.10-alpha
 +      foo1.10-beta
 +      foo1.10
 +      foo1.10-unlisted-suffix
 +      foo1.10-gamma
 +      foo1.10-delta
 +      EOF
 +      test_cmp expect actual
 +'
 +
 +test_expect_success 'versionsort.suffix overrides versionsort.prereleaseSuffix' '
 +      test_config versionsort.suffix -before &&
 +      test_config versionsort.prereleaseSuffix -after &&
 +      git tag -l --sort=version:refname "foo1.7*" >actual &&
 +      cat >expect <<-\EOF &&
 +      foo1.7-before1
 +      foo1.7
 +      foo1.7-after1
 +      EOF
 +      test_cmp expect actual
 +'
 +
 +test_expect_success 'version sort with very long prerelease suffix' '
 +      test_config versionsort.prereleaseSuffix -very-looooooooooooooooooooooooong-prerelease-suffix &&
 +      git tag -l --sort=version:refname
 +'
 +
  run_with_limited_stack () {
        (ulimit -s 128 && "$@")
  }
  
  test_expect_success '--format should list tags as per format given' '
        cat >expect <<-\EOF &&
 -      refname : refs/tags/foo1.10
 -      refname : refs/tags/foo1.3
 -      refname : refs/tags/foo1.6
 -      refname : refs/tags/foo1.6-rc1
 -      refname : refs/tags/foo1.6-rc2
 +      refname : refs/tags/v1.0
 +      refname : refs/tags/v1.0.1
 +      refname : refs/tags/v1.1.3
        EOF
 -      git tag -l --format="refname : %(refname)" "foo*" >actual &&
 +      git tag -l --format="refname : %(refname)" "v1*" >actual &&
        test_cmp expect actual
  '