Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
  • Loading branch information...
commit 9e72a566995ae84862a341e3a149a4bcaf96385d 2 parents fa0a6a4 + 3ae851e
Junio C Hamano authored April 03, 2013
2  builtin/tag.c
@@ -582,7 +582,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
582 582
 		die(_("%s: cannot lock the ref"), ref.buf);
583 583
 	if (write_ref_sha1(lock, object, NULL) < 0)
584 584
 		die(_("%s: cannot update the ref"), ref.buf);
585  
-	if (force && hashcmp(prev, object))
  585
+	if (force && !is_null_sha1(prev) && hashcmp(prev, object))
586 586
 		printf(_("Updated tag '%s' (was %s)\n"), tag, find_unique_abbrev(prev, DEFAULT_ABBREV));
587 587
 
588 588
 	strbuf_release(&buf);
12  t/t7004-tag.sh
@@ -104,6 +104,18 @@ test_expect_success 'creating a tag using HEAD directly should succeed' '
104 104
 	tag_exists myhead
105 105
 '
106 106
 
  107
+test_expect_success '--force can create a tag with the name of one existing' '
  108
+	tag_exists mytag &&
  109
+	git tag --force mytag &&
  110
+	tag_exists mytag'
  111
+
  112
+test_expect_success '--force is moot with a non-existing tag name' '
  113
+	git tag newtag >expect &&
  114
+	git tag --force forcetag >actual &&
  115
+	test_cmp expect actual
  116
+'
  117
+git tag -d newtag forcetag
  118
+
107 119
 # deleting tags:
108 120
 
109 121
 test_expect_success 'trying to delete an unknown tag should fail' '

0 notes on commit 9e72a56

Please sign in to comment.
Something went wrong with that request. Please try again.