Correctly report corrupted objects
authorBjörn Steinbrink <B.Steinbrink@gmx.de>
Thu, 20 Jan 2011 20:12:20 +0000 (21:12 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 20 Jan 2011 21:18:51 +0000 (13:18 -0800)
commit25f3af3f9d351a3d50cb9fc2bf7bddf941e4bc58
treedc2ec1e79f80cbf5389654912d22ddcb66d99c75
parentb20e9b0b521a416b00a81d6c4788dfd2df25efc0
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 <wmpalmer@gmail.com>
Signed-off-by: Björn Steinbrink <B.Steinbrink@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sha1_file.c