diff options
author | Junio C Hamano <gitster@pobox.com> | 2013-03-25 14:00:57 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-03-25 14:00:58 -0700 |
commit | 33c1506d6257897040eccc8167584a98fa8f88fe (patch) | |
tree | 1db2080386f66833d011ba7bd7fc321163b5573d | |
parent | f10a012088a7b6e418ec3f726142a8ddfa3d0264 (diff) | |
parent | 3ae851e6fbb4e99fa7281d18a5c6f95a3fb6d998 (diff) | |
download | git-33c1506d6257897040eccc8167584a98fa8f88fe.tar.gz git-33c1506d6257897040eccc8167584a98fa8f88fe.tar.xz |
Merge branch 'ph/tag-force-no-warn-on-creation'
"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
-rw-r--r-- | builtin/tag.c | 2 | ||||
-rwxr-xr-x | t/t7004-tag.sh | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/builtin/tag.c b/builtin/tag.c index f8266888c..af3af3f64 100644 --- a/builtin/tag.c +++ b/builtin/tag.c @@ -582,7 +582,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix) die(_("%s: cannot lock the ref"), ref.buf); if (write_ref_sha1(lock, object, NULL) < 0) 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)); strbuf_release(&buf); diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh index f5a79b13a..c8d6e9f88 100755 --- a/t/t7004-tag.sh +++ b/t/t7004-tag.sh @@ -104,6 +104,18 @@ test_expect_success 'creating a tag using HEAD directly should succeed' ' 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: test_expect_success 'trying to delete an unknown tag should fail' ' |