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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxxxx>
Suggested-by: Jari Aalto <jari.aalto@xxxxxxxxx>
Helped-by: Björn Steinbrink <B.Steinbrink@xxxxxx>
Helped-by: Jeff King <peff@xxxxxxxx>
Helped-by: Zoltán Füzesi <zfuzesi@xxxxxxxxx>
---
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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]