Skip to content

Commit 8577def

Browse files
committed
Merge branch 'np/diff-in-corrupt-repository' into maint
* np/diff-in-corrupt-repository: diff: don't presume empty file when corresponding object is missing
2 parents a59c872 + c50c431 commit 8577def

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

diff.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2391,10 +2391,14 @@ int diff_populate_filespec(struct diff_filespec *s, int size_only)
23912391
}
23922392
else {
23932393
enum object_type type;
2394-
if (size_only)
2394+
if (size_only) {
23952395
type = sha1_object_info(s->sha1, &s->size);
2396-
else {
2396+
if (type < 0)
2397+
die("unable to read %s", sha1_to_hex(s->sha1));
2398+
} else {
23972399
s->data = read_sha1_file(s->sha1, &type, &s->size);
2400+
if (!s->data)
2401+
die("unable to read %s", sha1_to_hex(s->sha1));
23982402
s->should_free = 1;
23992403
}
24002404
}

0 commit comments

Comments
 (0)