grep: plug a trivial memory leak
[gitweb.git] / t / t7004-tag.sh
index 1cfa8a21d23173e51e95906c00342fa13b85d955..b4698ab5f53c2ce92bd349fe4fa336e5fc5ca3e5 100755 (executable)
@@ -71,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 &&
@@ -80,9 +81,25 @@ test_expect_success 'creating a tag using default HEAD should succeed' '
 '
 
 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' '
@@ -90,6 +107,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
@@ -871,6 +895,22 @@ test_expect_success GPG 'verifying a forged tag should fail' '
        test_must_fail git tag -v forged-tag
 '
 
+test_expect_success '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 'verifying a forged tag with --format fail and format accordingly' '
+       cat >expect <<-\EOF
+       tagname : forged-tag
+       EOF &&
+       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