summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 544ddb0)
raw | patch | inline | side by side (parent: 544ddb0)
author | Junio C Hamano <gitster@pobox.com> | |
Mon, 15 Dec 2008 08:36:56 +0000 (00:36 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 15 Dec 2008 09:29:44 +0000 (01:29 -0800) |
When a tag points at a bad or nonexistent object, we should diagnose the
breakage and exit. An earlier commit 4f3dcc2 (Fix 'git show' on signed
tag of signed tag of commit, 2008-07-01) lost this check and made it
segfault instead; not good.
This fixes it.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
breakage and exit. An earlier commit 4f3dcc2 (Fix 'git show' on signed
tag of signed tag of commit, 2008-07-01) lost this check and made it
segfault instead; not good.
This fixes it.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-log.c | patch | blob | history | |
t/t7007-show.sh | [new file with mode: 0755] | patch | blob |
diff --git a/builtin-log.c b/builtin-log.c
index 2efe5937346ee7c0a4d85e4087a4ea49a9806005..db71e0da745ee480f8705c81f2899daf1dc6c4f5 100644 (file)
--- a/builtin-log.c
+++ b/builtin-log.c
t->tag,
diff_get_color_opt(&rev.diffopt, DIFF_RESET));
ret = show_object(o->sha1, 1, &rev);
- objects[i].item = parse_object(t->tagged->sha1);
+ if (ret)
+ break;
+ o = parse_object(t->tagged->sha1);
+ if (!o)
+ ret = error("Could not read object %s",
+ sha1_to_hex(t->tagged->sha1));
+ objects[i].item = o;
i--;
break;
}
diff --git a/t/t7007-show.sh b/t/t7007-show.sh
--- /dev/null
+++ b/t/t7007-show.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+test_description='git show'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+ echo hello world >foo &&
+ H=$(git hash-object -w foo) &&
+ git tag -a foo-tag -m "Tags $H" $H &&
+ HH=$(expr "$H" : "\(..\)") &&
+ H38=$(expr "$H" : "..\(.*\)") &&
+ rm -f .git/objects/$HH/$H38
+'
+
+test_expect_success 'showing a tag that point at a missing object' '
+ test_must_fail git --no-pager show foo-tag
+'
+
+test_done