git describe --tags --long barfs on new tags?
Howdy folks,
Discovered this today:
~/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)
Hope this is useful info.
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.
Cheers,
Mark
2008/7/2 Mark Burton <[email protected]>:
Quoted 13 lines
Howdy folks,
Discovered this today:
~/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)
Quoted 3 lines
Hope this is useful info.
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.
Here's a backtrace, i tried to follow the code but got confused and gave up.
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xa7cd26c0 (LWP 9670)]0x080615f2 in describe (arg=0x80e4e9e "HEAD", last_one=1) at builtin-describe.c:207
207 show_suffix(0, n->tag->tagged->sha1);
(gdb) bt
#0 0x080615f2 in describe (arg=0x80e4e9e "HEAD", last_one=1) at builtin-describe.c:207
#1 0x08061bd8 in cmd_describe (argc=0, argv=0xafcd25f4, prefix=0x0) at builtin-describe.c:360
#2 0x0804b1bf in handle_internal_command (argc=3, argv=0xafcd25f4) at git.c:252 #3 0x0804b888 in main (argc=3, argv=0x41c294c0) at git.c:463
(gdb) print n
$1 = <value optimized out>
(gdb) print cmit
$3 = (struct commit *) 0x81476a8
(gdb) print cmit->util
$4 = (void *) 0x8147430
(gdb) print *(struct commit_name*)cmit->util
$5 = {tag = 0x0, prio = 1, sha1 = "\tEt\"±d6ª\033\005\230\237\035ëR\226¼á\017\230",
path = 0x814744c "mb"}
Signature · 1 line
Mikael Magnusson
PATCH 1/1 Fix describe --tags --long so it does not segfault
If we match a lightweight (non-annotated tag) as the name to output and --long was requested we do not have a tag, nor do we have a tagged object to display. Instead we must use the object we were passed as input for the long format display.
---
Thanks Mikael, the backtrace really made it easy to figure out what the breakage was here.
builtin-describe.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
builtin-describe.c +1 -1
@@ -204,7 +204,7 @@ static void describe(const char *arg, int last_one)*/ display_name (n);if (longformat) -show_suffix (0 , n->tag->tagged->sha1); +show_suffix (0 , n->tag ? n->tag->tagged->sha1 : sha1);printf ("\n" );return ; }
Signature · 1 line
1.5.6.74.g8a5e
Re: [PATCH] Fix describe --tags --long so it does not segfault
Quoted 5 lines · Shawn O. Pearce
If we match a lightweight (non-annotated tag) as the name to output and --long was requested we do not have a tag, nor do we have a tagged object to display. Instead we must use the object we were passed as input for the long format display.
Quoted 7 lines
Reported-by Mark Burton <[email protected]>Backtraced-by Mikael Magnusson <[email protected]>Signed-off-by Shawn O. Pearce <[email protected]>---
Thanks Mikael, the backtrace really made it easy to figure out what the breakage was here.
Thanks. I'll squash this in and apply to 'maint'. Perhaps 1.5.6.2 after the 4th holiday.
t/t6120-describe.sh +2 -0
@@ -139,4 +139,6 @@ check_describe "test1-lightweight-*" --tags --match="test1-*" check_describe "test2-lightweight-*" --tags --match="test2-*" +check_describe "test2-lightweight-*" --long --tags --match="test2-*" HEAD^ + test_done
(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.)
Quoted 7 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
builtin-describe.c +6 -2
@@ -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 ; }