Merge branch 'ph/tag-force-no-warn-on-creation' into maint

"git tag -f <tag>" always said "Updated tag '<tag>'" even when
creating a new tag (i.e. not overwriting nor updating).

* ph/tag-force-no-warn-on-creation:
  tag: --force does not have to warn when creating tags
This commit is contained in:
Junio C Hamano 2013-04-03 09:24:51 -07:00
commit 9e72a56699
2 changed files with 13 additions and 1 deletions

View File

@ -582,7 +582,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
die(_("%s: cannot lock the ref"), ref.buf); die(_("%s: cannot lock the ref"), ref.buf);
if (write_ref_sha1(lock, object, NULL) < 0) if (write_ref_sha1(lock, object, NULL) < 0)
die(_("%s: cannot update the ref"), ref.buf); die(_("%s: cannot update the ref"), ref.buf);
if (force && hashcmp(prev, object)) if (force && !is_null_sha1(prev) && hashcmp(prev, object))
printf(_("Updated tag '%s' (was %s)\n"), tag, find_unique_abbrev(prev, DEFAULT_ABBREV)); printf(_("Updated tag '%s' (was %s)\n"), tag, find_unique_abbrev(prev, DEFAULT_ABBREV));
strbuf_release(&buf); strbuf_release(&buf);

View File

@ -104,6 +104,18 @@ test_expect_success 'creating a tag using HEAD directly should succeed' '
tag_exists myhead tag_exists myhead
' '
test_expect_success '--force can create a tag with the name of one existing' '
tag_exists mytag &&
git tag --force mytag &&
tag_exists mytag'
test_expect_success '--force is moot with a non-existing tag name' '
git tag newtag >expect &&
git tag --force forcetag >actual &&
test_cmp expect actual
'
git tag -d newtag forcetag
# deleting tags: # deleting tags:
test_expect_success 'trying to delete an unknown tag should fail' ' test_expect_success 'trying to delete an unknown tag should fail' '