@matheusbsbs / matheus-bagliano / commits / 0a043b1fe5
Fork 0

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 <git@drmicha.warpmail.net> Suggested-by: Jari Aalto <jari.aalto@cante.net> Helped-by: Björn Steinbrink <B.Steinbrink@gmx.de> Helped-by: Jeff King <peff@peff.net> Helped-by: Zoltán Füzesi <zfuzesi@eaglet.hu> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael J Gruber committed Dec 10, 2009 at 15:01 UTC 0a043b1fe5615a1182aceda29da65faebaf6e970
1 file changed +3 -1
builtin-tag.c
+3 -1
@@ -140,7 +140,7 @@ static int delete_tag(const char *name, const char *ref,
140 {
141 if (delete_ref(ref, sha1, 0))
142 return 1;
143 - printf("Deleted tag '%s'\n", name);
143 + printf("Deleted tag '%s' (was %s)\n", name, find_unique_abbrev(sha1, DEFAULT_ABBREV));
144 return 0;
145 }
146
@@ -479,6 +479,8 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
479 die("%s: cannot lock the ref", ref);
480 if (write_ref_sha1(lock, object, NULL) < 0)
481 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));
484
485 strbuf_release(&buf);
486 return 0;