Code

Fix describe --tags --long so it does not segfault
authorShawn O. Pearce <spearce@spearce.org>
Thu, 3 Jul 2008 02:32:45 +0000 (02:32 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 3 Jul 2008 04:21:59 +0000 (21:21 -0700)
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.

Reported-by: Mark Burton <markb@ordern.com>
Backtraced-by: Mikael Magnusson <mikachu@gmail.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-describe.c
t/t6120-describe.sh

index 3da99c1d06f1eeb85e760036dc881282558603d6..e515f9ca9b5d0ec13e96a7866e27bdd9e852b435 100644 (file)
@@ -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;
        }
index c6be2597f73dbd49e6301d01b5ea3c86ac8c34cb..2fb672c3b43a9efe4cb9c85465f6b33f23724e48 100755 (executable)
@@ -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