From 683ff884cce955cc331929d857fac9d6bd69f46a Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 24 Oct 2013 04:53:46 -0400 Subject: use parse_commit_or_die instead of segfaulting Some unchecked calls to parse_commit should obviously die on error, because their next step is to start looking at the parsed fields, which will cause a segfault. These are obvious candidates for parse_commit_or_die, which will be a strict improvement in behavior. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- builtin/checkout.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'builtin/checkout.c') diff --git a/builtin/checkout.c b/builtin/checkout.c index 7025938ae3..88ab9480da 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -796,7 +796,7 @@ static int switch_branches(const struct checkout_opts *opts, new->commit = old.commit; if (!new->commit) die(_("You are on a branch yet to be born")); - parse_commit(new->commit); + parse_commit_or_die(new->commit); } ret = merge_working_tree(opts, &old, new, &writeout_error); @@ -959,7 +959,7 @@ static int parse_branchname_arg(int argc, const char **argv, /* not a commit */ *source_tree = parse_tree_indirect(rev); } else { - parse_commit(new->commit); + parse_commit_or_die(new->commit); *source_tree = new->commit->tree; } -- cgit v1.2.1