summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-11-29 17:52:33 -0800
committerJunio C Hamano <gitster@pobox.com>2010-11-29 17:52:33 -0800
commitf5a5531e4e08c22ff1c3f02c43954896b947b158 (patch)
tree3a9f543e07f7a3db4151288a4be08204aa060da3 /diff.c
parentf3f973a0176d5fe7870ca4f27085d347b96307d2 (diff)
parentc50c4316e1eed362bee387e4cbfbe1138957f75b (diff)
downloadgit-f5a5531e4e08c22ff1c3f02c43954896b947b158.tar.gz
Merge branch 'np/diff-in-corrupt-repository'
* np/diff-in-corrupt-repository: diff: don't presume empty file when corresponding object is missing
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/diff.c b/diff.c
index d156ff252f..db5e84443b 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;
}
}