diff --git a/diff.c b/diff.c index d156ff252fda8830f75401a6b31f87c03250f775..db5e84443bfe915b5e44ec2fc573ebdb95dd20c1 100644 --- a/diff.c +++ b/diff.c @@ -2391,10 +2391,14 @@ int diff_populate_filespec(struct diff_filespec *s, int size_only) } else { enum object_type type; - if (size_only) + if (size_only) { type = sha1_object_info(s->sha1, &s->size); - else { + if (type < 0) + die("unable to read %s", sha1_to_hex(s->sha1)); + } else { s->data = read_sha1_file(s->sha1, &type, &s->size); + if (!s->data) + die("unable to read %s", sha1_to_hex(s->sha1)); s->should_free = 1; } }