{"thread":{"id":"14258","subject":"git describe --tags --long barfs on new tags?","startedAt":"2008-07-02T14:45:06Z","lastAt":"2008-07-03T04:23:28Z","messageCount":5,"participants":["Mark Burton","Mikael Magnusson","Shawn O. Pearce","Abhijit Menon-Sen","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"81986","messageId":"20080702154506.7b83bae8@crow","threadId":"14258","inReplyTo":null,"subject":"git describe --tags --long barfs on new tags?","fromName":"Mark Burton","fromEmail":"markb@ordern.com","sentAt":"2008-07-02T14:45:06Z","receivedAt":"2008-07-02T14:45:06Z","isPatch":false,"sender":{"key":"markb@ordern.com","avatar":null},"body":"\nHowdy folks,\n\nDiscovered this today:\n\n~/git[master]$ git tag mb\n~/git[master]$ git describe \nv1.5.6.1-156-ge903b40\n~/git[master]$ git describe --tags\nmb\n~/git[master]$ git describe --tags --long\nSegmentation fault (core dumped)\n\nHope this is useful info.\n\nBTW - just started using git and I am very impressed with it - took me a while to get my head around the \"index\" but now I wonder what the problem was.\n\nCheers,\n\nMark\n"},{"id":"82026","messageId":"237967ef0807021256j3e67bceaoecbb8f37112db2ab@mail.gmail.com","threadId":"14258","inReplyTo":"20080702154506.7b83bae8@crow","subject":"Re: git describe --tags --long barfs on new tags?","fromName":"Mikael Magnusson","fromEmail":"mikachu@gmail.com","sentAt":"2008-07-02T19:56:19Z","receivedAt":"2008-07-02T19:56:19Z","isPatch":false,"sender":{"key":"mikachu@gmail.com","avatar":null},"body":"2008/7/2 Mark Burton <markb@ordern.com>:\n>\n> Howdy folks,\n>\n> Discovered this today:\n>\n> ~/git[master]$ git tag mb\n> ~/git[master]$ git describe\n> v1.5.6.1-156-ge903b40\n> ~/git[master]$ git describe --tags\n> mb\n> ~/git[master]$ git describe --tags --long\n> Segmentation fault (core dumped)\n>\n> Hope this is useful info.\n>\n> BTW - just started using git and I am very impressed with it - took me a while to get my head around the \"index\" but now I wonder what the problem was.\n\n\nHere's a backtrace, i tried to follow the code but got confused and gave up.\n\nProgram received signal SIGSEGV, Segmentation fault.\n[Switching to Thread 0xa7cd26c0 (LWP 9670)]\n0x080615f2 in describe (arg=0x80e4e9e \"HEAD\", last_one=1) at\nbuiltin-describe.c:207\n207\t\t\t\tshow_suffix(0, n->tag->tagged->sha1);\n(gdb) bt\n#0  0x080615f2 in describe (arg=0x80e4e9e \"HEAD\", last_one=1) at\nbuiltin-describe.c:207\n#1  0x08061bd8 in cmd_describe (argc=0, argv=0xafcd25f4, prefix=0x0)\nat builtin-describe.c:360\n#2  0x0804b1bf in handle_internal_command (argc=3, argv=0xafcd25f4) at git.c:252\n#3  0x0804b888 in main (argc=3, argv=0x41c294c0) at git.c:463\n(gdb) print n\n$1 = <value optimized out>\n(gdb) print cmit\n$3 = (struct commit *) 0x81476a8\n(gdb) print cmit->util\n$4 = (void *) 0x8147430\n(gdb) print *(struct commit_name*)cmit->util\n$5 = {tag = 0x0, prio = 1, sha1 =\n\"\\tEt\\\"±d6ª\\033\\005\\230\\237\\035ëR\\226¼á\\017\\230\",\n  path = 0x814744c \"mb\"}\n\n-- \nMikael Magnusson\n"},{"id":"82060","messageId":"20080703023245.GA31579@spearce.org","threadId":"14258","inReplyTo":"237967ef0807021256j3e67bceaoecbb8f37112db2ab@mail.gmail.com","subject":"[PATCH] Fix describe --tags --long so it does not segfault","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-07-03T02:32:45Z","receivedAt":"2008-07-03T02:32:45Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"If we match a lightweight (non-annotated tag) as the name to\noutput and --long was requested we do not have a tag, nor do\nwe have a tagged object to display.  Instead we must use the\nobject we were passed as input for the long format display.\n\nReported-by: Mark Burton <markb@ordern.com>\nBacktraced-by: Mikael Magnusson <mikachu@gmail.com>\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n\n Thanks Mikael, the backtrace really made it easy to figure out\n what the breakage was here.\n\n builtin-describe.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-describe.c b/builtin-describe.c\nindex 3da99c1..e515f9c 100644\n--- a/builtin-describe.c\n+++ b/builtin-describe.c\n@@ -204,7 +204,7 @@ static void describe(const char *arg, int last_one)\n \t\t */\n \t\tdisplay_name(n);\n \t\tif (longformat)\n-\t\t\tshow_suffix(0, n->tag->tagged->sha1);\n+\t\t\tshow_suffix(0, n->tag ? n->tag->tagged->sha1 : sha1);\n \t\tprintf(\"\\n\");\n \t\treturn;\n \t}\n-- \n1.5.6.74.g8a5e\n"},{"id":"82076","messageId":"20080703024956.GA1080@toroid.org","threadId":"14258","inReplyTo":"237967ef0807021256j3e67bceaoecbb8f37112db2ab@mail.gmail.com","subject":"Re: git describe --tags --long barfs on new tags?","fromName":"Abhijit Menon-Sen","fromEmail":"ams@toroid.org","sentAt":"2008-07-03T02:49:56Z","receivedAt":"2008-07-03T02:49:56Z","isPatch":false,"sender":{"key":"ams@toroid.org","avatar":null},"body":"(Sorry for the broken References. I deleted the message before realising\nthat I wanted to reply to it; and I couldn't easily find an mbox archive\nto snarf the whole message from.)\n\n> ~/git[master]$ git tag mb\n> ~/git[master]$ git describe\n> v1.5.6.1-156-ge903b40\n> ~/git[master]$ git describe --tags\n> mb\n> ~/git[master]$ git describe --tags --long\n> Segmentation fault (core dumped)\n\nNot on new tags, but on un-annotated ones (which the --tags brings into\nconsideration). The appended patch fixes the problem for me, but I'd be\ngrateful if someone could confirm that it's the right thing to do.\n\n-- ams\n\ndiff --git a/builtin-describe.c b/builtin-describe.c\nindex 3da99c1..7ed4757 100644\n--- a/builtin-describe.c\n+++ b/builtin-describe.c\n@@ -203,8 +203,12 @@ static void describe(const char *arg, int last_one)\n \t\t * Exact match to an existing ref.\n \t\t */\n \t\tdisplay_name(n);\n-\t\tif (longformat)\n-\t\t\tshow_suffix(0, n->tag->tagged->sha1);\n+\t\tif (longformat) {\n+\t\t\tconst unsigned char *sha1 = n->sha1;\n+\t\t\tif (n->tag)\n+\t\t\t\tsha1 = n->tag->tagged->sha1;\n+\t\t\tshow_suffix(0, sha1);\n+\t\t}\n \t\tprintf(\"\\n\");\n \t\treturn;\n \t}\n"},{"id":"82085","messageId":"7vvdzn4mv3.fsf@gitster.siamese.dyndns.org","threadId":"14258","inReplyTo":"20080703023245.GA31579@spearce.org","subject":"Re: [PATCH] Fix describe --tags --long so it does not segfault","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-07-03T04:23:28Z","receivedAt":"2008-07-03T04:23:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Shawn O. Pearce\" <spearce@spearce.org> writes:\n\n> If we match a lightweight (non-annotated tag) as the name to\n> output and --long was requested we do not have a tag, nor do\n> we have a tagged object to display.  Instead we must use the\n> object we were passed as input for the long format display.\n>\n> Reported-by: Mark Burton <markb@ordern.com>\n> Backtraced-by: Mikael Magnusson <mikachu@gmail.com>\n> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>\n> ---\n>\n>  Thanks Mikael, the backtrace really made it easy to figure out\n>  what the breakage was here.\n\nThanks.  I'll squash this in and apply to 'maint'.  Perhaps 1.5.6.2\nafter the 4th holiday.\n\ndiff --git a/t/t6120-describe.sh b/t/t6120-describe.sh\nindex c6be259..2fb672c 100755\n--- a/t/t6120-describe.sh\n+++ b/t/t6120-describe.sh\n@@ -139,4 +139,6 @@ check_describe \"test1-lightweight-*\" --tags --match=\"test1-*\"\n \n check_describe \"test2-lightweight-*\" --tags --match=\"test2-*\"\n \n+check_describe \"test2-lightweight-*\" --long --tags --match=\"test2-*\" HEAD^\n+\n test_done\n"}]}