File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -660,6 +660,8 @@ int cmd_tag(int argc,
660
660
661
661
if (refs_read_ref (get_main_ref_store (the_repository ), ref .buf , & prev ))
662
662
oidclr (& prev , the_repository -> hash_algo );
663
+ else if (!create_tag_object && oideq (& object , & prev ))
664
+ exit (0 );
663
665
else if (!force )
664
666
die (_ ("tag '%s' already exists" ), tag );
665
667
Original file line number Diff line number Diff line change @@ -126,7 +126,7 @@ test_expect_success 'annotated tag with --create-reflog has correct message' '
126
126
'
127
127
128
128
test_expect_success ' --create-reflog does not create reflog on failure' '
129
- test_must_fail git tag --create-reflog mytag &&
129
+ test_must_fail git tag --create-reflog mytag no-such-object &&
130
130
test_must_fail git reflog exists refs/tags/mytag
131
131
'
132
132
@@ -183,8 +183,14 @@ test_expect_success 'listing tags using a non-matching pattern should output not
183
183
184
184
# special cases for creating tags:
185
185
186
- test_expect_success ' trying to create a tag with the name of one existing should fail' '
187
- test_must_fail git tag mytag
186
+ test_expect_success ' recreating a tag without --force' '
187
+ # light-weight tag pointing at the same thing
188
+ # now succeeds
189
+ git tag mytag HEAD &&
190
+ # light-weight tag pointing at a different thing
191
+ test_must_fail git tag mytag HEAD: &&
192
+ # creating annotated tag, pointing at the same object.
193
+ test_must_fail git tag -a -m anno mytag $taggedobject
188
194
'
189
195
190
196
test_expect_success ' trying to create a tag with a non-valid name should fail' '
You can’t perform that action at this time.
0 commit comments