#!/bin/sh
## Copyright (c) 2007 Carlos Rica#test_description='git tag
Tests for operations with tags.'. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-gpg.sh
# creating and listing lightweight tags:tag_exists () {
git show-ref --quiet --verify refs/tags/"$1"}
# todo: git tag -l now returns always zero, when fixed, change this testtest_expect_success 'listing all tags in an empty tree should succeed''
git tag -l &&
git tag
'test_expect_success 'listing all tags in an empty tree should output nothing''
test `git tag -l | wc -l` -eq 0 &&
test `git tag | wc -l` -eq 0
'test_expect_success 'looking for a tag in an empty tree should fail'\
'! (tag_exists mytag)'test_expect_success 'creating a tag in an empty tree should fail''
test_must_fail git tag mynotag &&
! tag_exists mynotag
'test_expect_success 'creating a tag for HEAD in an empty tree should fail''
test_must_fail git tag mytaghead HEAD &&
! tag_exists mytaghead
'test_expect_success 'creating a tag for an unknown revision should fail''
test_must_fail git tag mytagnorev aaaaaaaaaaa &&
! tag_exists mytagnorev
'# 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_tick &&
echo foo >foo &&
git add foo &&
git commit -m Foo &&
git tag mytag &&
test_must_fail git reflog exists refs/tags/mytag
'test_expect_success 'creating a tag with --create-reflog should create reflog''
test_when_finished "git tag -d tag_with_reflog" &&
git tag --create-reflog tag_with_reflog &&
git reflog exists refs/tags/tag_with_reflog
'test_expect_success '--create-reflog does not create reflog on failure''
test_must_fail git tag --create-reflog mytag &&
test_must_fail git reflog exists refs/tags/mytag
'test_expect_success 'listing all tags if one exists should succeed''
git tag -l &&