@matheusbsbs / matheus-bagliano / commits / 3ba7a06552
Fork 0

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 <gitster@pobox.com>

Junio C Hamano committed Oct 28, 2010 at 11:13 UTC 3ba7a065527a27f45659398e882feaa1165cbb4c
1 file changed +6 -1
sha1_file.c
+6 -1
@@ -2090,16 +2090,21 @@ void *read_sha1_file_repl(const unsigned char *sha1,
2090 const unsigned char **replacement)
2091 {
2092 const unsigned char *repl = lookup_replace_object(sha1);
2093 - void *data = read_object(repl, type, size);
2093 + void *data;
2094 char *path;
2095 const struct packed_git *p;
2096
2097 + errno = 0;
2098 + data = read_object(repl, type, size);
2099 if (data) {
2100 if (replacement)
2101 *replacement = repl;
2102 return data;
2103 }
2104
2105 + if (errno != ENOENT)
2106 + die_errno("failed to read object %s", sha1_to_hex(sha1));
2107 +
2108 /* die if we replaced an object with one that does not exist */
2109 if (repl != sha1)
2110 die("replacement %s not found for %s",