Subject: Re: git describe --tags --long barfs on new tags?

From: Abhijit Menon-Sen <[email-masked]>
Date: Thu, 3 Jul 2008 08:19:56 +0530

(Sorry for the broken References. I deleted the message before realising
that I wanted to reply to it; and I couldn't easily find an mbox archive
to snarf the whole message from.)

> ~/git[master]$ git tag mb
> ~/git[master]$ git describe
> v1.5.6.1-156-ge903b40
> ~/git[master]$ git describe --tags
> mb
> ~/git[master]$ git describe --tags --long
> Segmentation fault (core dumped)

Not on new tags, but on un-annotated ones (which the --tags brings into
consideration). The appended patch fixes the problem for me, but I'd be
grateful if someone could confirm that it's the right thing to do.

-- ams

diff --git a/builtin-describe.c b/builtin-describe.c
index 3da99c1..7ed4757 100644
--- a/builtin-describe.c
+++ b/builtin-describe.c
@@ -203,8 +203,12 @@ static void describe(const char *arg, int last_one)
 		 * Exact match to an existing ref.
 		 */
 		display_name(n);
-		if (longformat)
-			show_suffix(0, n->tag->tagged->sha1);
+		if (longformat) {
+			const unsigned char *sha1 = n->sha1;
+			if (n->tag)
+				sha1 = n->tag->tagged->sha1;
+			show_suffix(0, sha1);
+		}
 		printf("\n");
 		return;
 	}