Skip to content

Commit

Permalink
Correctly report corrupted objects
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Björn Steinbrink authored and Junio C Hamano committed Jan 20, 2011
1 parent b20e9b0 commit 25f3af3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion sha1_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 25f3af3

Please sign in to comment.