Skip to content

Commit 25f3af3

Browse files
dotdashgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Björn Steinbrink <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b20e9b0 commit 25f3af3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

sha1_file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2141,7 +2141,7 @@ void *read_sha1_file_repl(const unsigned char *sha1,
21412141
return data;
21422142
}
21432143

2144-
if (errno != ENOENT)
2144+
if (errno && errno != ENOENT)
21452145
die_errno("failed to read object %s", sha1_to_hex(sha1));
21462146

21472147
/* die if we replaced an object with one that does not exist */

0 commit comments

Comments
 (0)