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>maint
							parent
							
								
									b6c4ceccb3
								
							
						
					
					
						commit
						3ba7a06552
					
				|  | @ -2090,16 +2090,21 @@ void *read_sha1_file_repl(const unsigned char *sha1, | ||||||
| 			  const unsigned char **replacement) | 			  const unsigned char **replacement) | ||||||
| { | { | ||||||
| 	const unsigned char *repl = lookup_replace_object(sha1); | 	const unsigned char *repl = lookup_replace_object(sha1); | ||||||
| 	void *data = read_object(repl, type, size); | 	void *data; | ||||||
| 	char *path; | 	char *path; | ||||||
| 	const struct packed_git *p; | 	const struct packed_git *p; | ||||||
|  |  | ||||||
|  | 	errno = 0; | ||||||
|  | 	data = read_object(repl, type, size); | ||||||
| 	if (data) { | 	if (data) { | ||||||
| 		if (replacement) | 		if (replacement) | ||||||
| 			*replacement = repl; | 			*replacement = repl; | ||||||
| 		return data; | 		return data; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	if (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 */ | 	/* die if we replaced an object with one that does not exist */ | ||||||
| 	if (repl != sha1) | 	if (repl != sha1) | ||||||
| 		die("replacement %s not found for %s", | 		die("replacement %s not found for %s", | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 Junio C Hamano
						Junio C Hamano