test-lib.sh: unset XDG_CACHE_HOME
[gitweb.git] / t / t7004-tag.sh
index c7aaace8cde5474d0eed43a6ac283ad8dbd8bbb8..b8ad076c25680cad1f9faa1de544980c78547f6c 100755 (executable)
@@ -27,6 +27,30 @@ test_expect_success 'listing all tags in an empty tree should output nothing' '
        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)'
 
@@ -47,6 +71,7 @@ test_expect_success 'creating a tag for an unknown revision should fail' '
 
 # 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 &&
@@ -66,6 +91,13 @@ 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
@@ -81,6 +113,9 @@ test_expect_success 'listing all tags if one exists should output that tag' '
 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'
@@ -844,6 +879,20 @@ test_expect_success GPG 'verifying a forged tag should fail' '
        test_must_fail git tag -v forged-tag
 '
 
+test_expect_success GPG 'verifying a proper tag with --format pass and format accordingly' '
+       cat >expect <<-\EOF &&
+       tagname : signed-tag
+       EOF
+       git tag -v --format="tagname : %(tag)" "signed-tag" >actual &&
+       test_cmp expect actual
+'
+
+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
+'
+
 # blank and empty messages for signed tags:
 
 get_tag_header empty-signed-tag $commit commit $time >expect
@@ -1564,6 +1613,72 @@ test_expect_success 'version sort with prerelease reordering, multiple suffixes
        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