if (refs_read_ref(get_main_ref_store(the_repository), ref.buf, &prev))
oidclr(&prev, the_repository->hash_algo);
+ else if (!create_tag_object && oideq(&object, &prev))
+ exit(0);
else if (!force)
die(_("tag '%s' already exists"), tag);
'
test_expect_success '--create-reflog does not create reflog on failure' '
- test_must_fail git tag --create-reflog mytag &&
+ test_must_fail git tag --create-reflog mytag no-such-object &&
test_must_fail git reflog exists refs/tags/mytag
'
# special cases for creating tags:
-test_expect_success 'trying to create a tag with the name of one existing should fail' '
- test_must_fail git tag mytag
+test_expect_success 'recreating a tag without --force' '
+ # light-weight tag pointing at the same thing
+ # now succeeds
+ git tag mytag HEAD &&
+ # light-weight tag pointing at a different thing
+ test_must_fail git tag mytag HEAD: &&
+ # creating annotated tag, pointing at the same object.
+ test_must_fail git tag -a -m anno mytag $taggedobject
'
test_expect_success 'trying to create a tag with a non-valid name should fail' '