Skip to content

Commit 3ba7a06

Browse files
committed
A loose object is not corrupt if it cannot be read due to EMFILE
"git fsck" bails out with a claim that a loose object that cannot be read but exists on the filesystem to be corrupt, which is wrong when read_object() failed due to e.g. EMFILE. Signed-off-by: Junio C Hamano <[email protected]>
1 parent b6c4cec commit 3ba7a06

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

sha1_file.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2090,16 +2090,21 @@ void *read_sha1_file_repl(const unsigned char *sha1,
20902090
const unsigned char **replacement)
20912091
{
20922092
const unsigned char *repl = lookup_replace_object(sha1);
2093-
void *data = read_object(repl, type, size);
2093+
void *data;
20942094
char *path;
20952095
const struct packed_git *p;
20962096

2097+
errno = 0;
2098+
data = read_object(repl, type, size);
20972099
if (data) {
20982100
if (replacement)
20992101
*replacement = repl;
21002102
return data;
21012103
}
21022104

2105+
if (errno != ENOENT)
2106+
die_errno("failed to read object %s", sha1_to_hex(sha1));
2107+
21032108
/* die if we replaced an object with one that does not exist */
21042109
if (repl != sha1)
21052110
die("replacement %s not found for %s",

0 commit comments

Comments
 (0)