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

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

From
AMAbhijit Menon-Sen <ams@toroid.org>
Date
Jul 3, 2008, 02:49 UTC
Message-ID
<20080703024956.GA1080@toroid.org>
In-Reply-To
<237967ef0807021256j3e67bceaoecbb8f37112db2ab@mail.gmail.com>

(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.)

Show 7 quoted lines
> ~/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;
 	}
Previous: Junio C Hamano
Message 5 of 5 in “git describe --tags --long barfs on new tags?”
  1. Mark BurtonJul 2, 2008
  2. Mikael MagnussonJul 2, 2008
  3. Fix describe --tags --long so it does not segfaultShawn O. Pearce, Jul 3, 2008
  4. Junio C HamanoJul 3, 2008
  5. Abhijit Menon-SenJul 3, 2008

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.