log_tree_diff: die when we fail to parse a commit
[gitweb.git] / commit.c
index a575564a15c1c340b36d10c90da8fa343692264d..26c1d5406d3b1229ffdd2b152a05dcb601ebe5ca 100644 (file)
--- a/commit.c
+++ b/commit.c
@@ -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;