From d2dadfe890b5da6f65fe061a414b6ec67c5efe9c Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 15 Dec 2008 00:36:56 -0800 Subject: git-show: do not segfault when showing a bad tag 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 --- builtin-log.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'builtin-log.c') diff --git a/builtin-log.c b/builtin-log.c index 2efe593734..db71e0da74 100644 --- a/builtin-log.c +++ b/builtin-log.c @@ -356,7 +356,13 @@ int cmd_show(int argc, const char **argv, const char *prefix) 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; } -- cgit v1.2.3