git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2] tag -d: print sha1 of deleted tag

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Dec 10, 2009, 14:01 UTC
Message-ID
<39e5cb38658919ed989f954a0917dfaa292f6350.1260453234.git.git@drmicha.warpmail.net>
In-Reply-To
<20091210133645.GA2149@coredump.intra.peff.net>

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>
---
v2 changes the wording to match with branch -d and uses the same
for forcefully overwriting tags.

Zoltán, I don't think we should make this into a race. Posting in the relevant thread (and actually following it) would help this.

Also, I think we should really compare the sha1 the tag points to, i.e. like below and like in your v1 (not v2). Different tag object is different tag (message may differ, e.g.).

 builtin-tag.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/builtin-tag.c b/builtin-tag.c
index c479018..4ef1c4f 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;
-- 
1.6.6.rc1.292.gd8fe
Previous: Jeff KingNext: Zoltán Füzesi
Message 9 of 10 in “FEATURE REQUEST: display <commit SHA> in message: git tag -d”
  1. Jari AaltoDec 10, 2009
  2. tag -d: print sha1 of deleted tagMichael J Gruber, Dec 10, 2009
  3. Björn SteinbrinkDec 10, 2009
  4. Michael J GruberDec 10, 2009
  5. Jeff KingDec 10, 2009
  6. Jari AaltoDec 10, 2009
  7. Michael J GruberDec 10, 2009
  8. Jeff KingDec 10, 2009
  9. tag -d: print sha1 of deleted tagMichael J Gruber, Dec 10, 2009
  10. Zoltán FüzesiDec 10, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.