Subject: Re: git-tag bug? confusing git fast-export with double tag objects

From: Johannes Sixt <[email-masked]>
Date: Fri, 15 May 2009 16:54:09 +0200

Jakub Narebski schrieb:
> "Matthias Andree" <[email-masked]> writes:
>> 	commit <-- signed-by-- NIL (removed) <--signed-by-- tag1.
> 
> THIS IS A FEATURE, NOT A BUG.

Please stop it. Everone agrees about this.

Matthias only wants a patch like below. Matthias, if you are serious about
it, please pick this up and turn it into a proper submission. I don't care
enough.

-- Hannes

diff --git a/builtin-tag.c b/builtin-tag.c
index 01e7374..35d39a2 100644
--- a/builtin-tag.c
+++ b/builtin-tag.c
@@ -367,6 +367,7 @@ int cmd_tag(int argc, const char **argv, const char
*prefix)
 	unsigned char object[20], prev[20];
 	char ref[PATH_MAX];
 	const char *object_ref, *tag;
+	struct tag *tag_object;
 	struct ref_lock *lock;

 	int annotate = 0, sign = 0, force = 0, lines = -1,
@@ -472,6 +473,15 @@ int cmd_tag(int argc, const char **argv, const char
 	else if (!force)
 		die("tag '%s' already exists", tag);

+	if ((tag_object = (struct tag *)parse_object(object)) &&
+	    tag_object->object.type == OBJ_TAG &&
+	    tag_object->tag &&
+	    !strcmp(tag_object->tag, tag)) {
+		error("A tag cannot tag itself. If you meant to tag the commit");
+		error("that the tag refers to, use 'git tag %s %s^{}'.", tag, object_ref);
+		exit(1);
+	}
+
 	if (annotate)
 		create_tag(object, tag, &buf, msg.given || msgfile,
 			   sign, prev, object);