From 0a043b1fe5615a1182aceda29da65faebaf6e970 Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Thu, 10 Dec 2009 15:01:10 +0100 Subject: [PATCH] tag -d: print sha1 of deleted tag MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Suggested-by: Jari Aalto Helped-by: Björn Steinbrink Helped-by: Jeff King Helped-by: Zoltán Füzesi Signed-off-by: Junio C Hamano --- builtin-tag.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/builtin-tag.c b/builtin-tag.c index c4790185eb..4ef1c4f508 100644 --- a/builtin-tag.c +++ b/builtin-tag.c @@ -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; -- 2.11.4.GIT