diff options
author | Junio C Hamano <gitster@pobox.com> | 2013-12-05 12:54:01 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-12-05 12:54:01 -0800 |
commit | 5bb62059f21ebe8a38226f6fbe76f0f9b6ad65f7 (patch) | |
tree | 52523c896b1eb72ed8cddb52261b7f9a909b71f0 /commit.c | |
parent | b2a0afd96a40d6cdbba96ac9735a7b489d8d563e (diff) | |
parent | 3c62183929080c17299d5b404eb092e3d53c161a (diff) | |
download | git-5bb62059f21ebe8a38226f6fbe76f0f9b6ad65f7.tar.gz |
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
Diffstat (limited to 'commit.c')
-rw-r--r-- | commit.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -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; |