git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2] A loose object is not corrupt if it cannot be read due to EMFILE

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 28, 2010, 20:53 UTC
Message-ID
<1288299210-27092-2-git-send-email-gitster@pobox.com>
In-Reply-To
<1288299210-27092-1-git-send-email-gitster@pobox.com>

"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>
---
 sha1_file.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/sha1_file.c b/sha1_file.c
index 5ed5497..f709ed6 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -2090,16 +2090,21 @@ void *read_sha1_file_repl(const unsigned char *sha1,
 			  const unsigned char **replacement)
 {
 	const unsigned char *repl = lookup_replace_object(sha1);
-	void *data = read_object(repl, type, size);
+	void *data;
 	char *path;
 	const struct packed_git *p;
 
+	errno = 0;
+	data = read_object(repl, type, size);
 	if (data) {
 		if (replacement)
 			*replacement = repl;
 		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 */
 	if (repl != sha1)
 		die("replacement %s not found for %s",
-- 
1.7.3.2.191.g2d0e57
Previous: Junio C HamanoNext: Erik Faye-Lund
Message 2 of 10 in “read_sha1_file(): report correct name of packfile with a corrupt object”
  1. 1/2 read_sha1_file(): report correct name of packfile with a corrupt objectJunio C Hamano, Oct 28, 2010
  2. 2/2 A loose object is not corrupt if it cannot be read due to EMFILEJunio C Hamano, Oct 28, 2010
  3. Erik Faye-LundNov 18, 2010
  4. Johannes SixtNov 18, 2010
  5. Erik Faye-LundNov 18, 2010
  6. Jonathan NiederNov 18, 2010
  7. Erik Faye-LundNov 18, 2010
  8. Casey DahlinNov 18, 2010
  9. Jonathan NiederNov 18, 2010
  10. Johannes SixtOct 29, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.