Merge branch 'jk/robustify-parse-commit'
* jk/robustify-parse-commit: checkout: do not die when leaving broken detached HEAD use parse_commit_or_die instead of custom message use parse_commit_or_die instead of segfaulting assume parse_commit checks for NULL commit assume parse_commit checks commit->object.parsed log_tree_diff: die when we fail to parse a commit
This commit is contained in:
9
commit.c
9
commit.c
@ -79,7 +79,7 @@ struct commit *lookup_commit_reference_by_name(const char *name)
|
||||
if (get_sha1_committish(name, sha1))
|
||||
return NULL;
|
||||
commit = lookup_commit_reference(sha1);
|
||||
if (!commit || parse_commit(commit))
|
||||
if (parse_commit(commit))
|
||||
return NULL;
|
||||
return commit;
|
||||
}
|
||||
@ -341,6 +341,13 @@ int parse_commit(struct commit *item)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void parse_commit_or_die(struct commit *item)
|
||||
{
|
||||
if (parse_commit(item))
|
||||
die("unable to parse commit %s",
|
||||
item ? sha1_to_hex(item->object.sha1) : "(null)");
|
||||
}
|
||||
|
||||
int find_commit_subject(const char *commit_buffer, const char **subject)
|
||||
{
|
||||
const char *eol;
|
||||
|
Reference in New Issue
Block a user