From: Björn Steinbrink Date: Thu, 20 Jan 2011 20:12:20 +0000 (+0100) Subject: Correctly report corrupted objects X-Git-Tag: v1.7.4-rc3~4 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=25f3af3f9d351a3d50cb9fc2bf7bddf941e4bc58;p=git.git Correctly report corrupted objects The errno check added in commit 3ba7a06 "A loose object is not corrupt if it cannot be read due to EMFILE" only checked for whether errno is not ENOENT and thus incorrectly treated "no error" as an error condition. Because of that, it never reached the code path that would report that the object is corrupted and instead caused funny errors like: fatal: failed to read object 333c4768ce595793fdab1ef3a036413e2a883853: Success So we have to extend the check to cover the case in which the object file was successfully read, but its contents are corrupted. Reported-by: Will Palmer Signed-off-by: Björn Steinbrink Signed-off-by: Junio C Hamano --- diff --git a/sha1_file.c b/sha1_file.c index 1cafdfa61..d86a8db69 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -2141,7 +2141,7 @@ void *read_sha1_file_repl(const unsigned char *sha1, return data; } - if (errno != ENOENT) + if (errno && errno != ENOENT) die_errno("failed to read object %s", sha1_to_hex(sha1)); /* die if we replaced an object with one that does not exist */