Skip to content

Commit 0a043b1

Browse files
Michael J Grubergitster
authored andcommitted
tag -d: print sha1 of deleted tag
Print the sha1 of the deleted tag (in addition to the tag name) so that one can easily recreate a mistakenly deleted tag: git tag -d tagname Deleted tag 'tagname' (was DEADBEEF) git tag 'tagname' DEADBEEF We output the previous ref also in the case of forcefully overwriting tags. Signed-off-by: Michael J Gruber <[email protected]> Suggested-by: Jari Aalto <[email protected]> Helped-by: Björn Steinbrink <[email protected]> Helped-by: Jeff King <[email protected]> Helped-by: Zoltán Füzesi <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 80d9361 commit 0a043b1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

builtin-tag.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ static int delete_tag(const char *name, const char *ref,
140140
{
141141
if (delete_ref(ref, sha1, 0))
142142
return 1;
143-
printf("Deleted tag '%s'\n", name);
143+
printf("Deleted tag '%s' (was %s)\n", name, find_unique_abbrev(sha1, DEFAULT_ABBREV));
144144
return 0;
145145
}
146146

@@ -479,6 +479,8 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
479479
die("%s: cannot lock the ref", ref);
480480
if (write_ref_sha1(lock, object, NULL) < 0)
481481
die("%s: cannot update the ref", ref);
482+
if (force && hashcmp(prev, object))
483+
printf("Updated tag '%s' (was %s)\n", tag, find_unique_abbrev(prev, DEFAULT_ABBREV));
482484

483485
strbuf_release(&buf);
484486
return 0;

0 commit comments

Comments
 (0)