tag -d: print sha1 of deleted tag
authorMichael J Gruber <git@drmicha.warpmail.net>
Thu, 10 Dec 2009 14:01:10 +0000 (15:01 +0100)
committerJunio C Hamano <gitster@pobox.com>
Fri, 11 Dec 2009 02:45:34 +0000 (18:45 -0800)
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>
builtin-tag.c

index c4790185ebb9979a6772cf7159d16c2a1deeeaf3..4ef1c4f508b0261e725c360e96f2b8cbed50e9ce 100644 (file)
@@ -140,7 +140,7 @@ static int delete_tag(const char *name, const char *ref,
 {
        if (delete_ref(ref, sha1, 0))
                return 1;
-       printf("Deleted tag '%s'\n", name);
+       printf("Deleted tag '%s' (was %s)\n", name, find_unique_abbrev(sha1, DEFAULT_ABBREV));
        return 0;
 }
 
@@ -479,6 +479,8 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
                die("%s: cannot lock the ref", ref);
        if (write_ref_sha1(lock, object, NULL) < 0)
                die("%s: cannot update the ref", ref);
+       if (force && hashcmp(prev, object))
+               printf("Updated tag '%s' (was %s)\n", tag, find_unique_abbrev(prev, DEFAULT_ABBREV));
 
        strbuf_release(&buf);
        return 0;