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

[PATCH 2/2] Flag and skip over packfiles known to be invalid.

From
Shawn O. Pearce <spearce@spearce.org>
Date
Feb 2, 2007, 08:00 UTC
Message-ID
<20070202080010.GB21094@spearce.org>
In-Reply-To
<dda240a4adf0511b3e1ab1eb74abdd28821358b0.1170403175.git.spearce@spearce.org>

If we've already looked at a packfile and determined it isn't valid/usable as a pack, we shouldn't try to use it again in the future either. This avoids multiple error messages from the same packfile.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 cache.h     |    1 +
 sha1_file.c |    5 +++++
 2 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/cache.h b/cache.h
index 9873ee9..64c2d3f 100644
--- a/cache.h
+++ b/cache.h
@@ -357,6 +357,7 @@ extern struct packed_git {
 	off_t pack_size;
 	int pack_fd;
 	int pack_local;
+	unsigned invalid:1;
 	unsigned char sha1[20];
 	/* something like ".git/objects/pack/xxxxx.pack" */
 	char pack_name[FLEX_ARRAY]; /* more */
diff --git a/sha1_file.c b/sha1_file.c
index ba1c799..9f6e94e 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -714,6 +714,7 @@ struct packed_git *add_packed_git(char *path, int path_len, int local)
 	p->next = NULL;
 	p->windows = NULL;
 	p->pack_fd = -1;
+	p->invalid = 0;
 	p->pack_local = local;
 	if ((path_len > 44) && !get_sha1_hex(path + path_len - 44, sha1))
 		hashcpy(p->sha1, sha1);
@@ -746,6 +747,7 @@ struct packed_git *parse_pack_index_file(const unsigned char *sha1, char *idx_pa
 	p->next = NULL;
 	p->windows = NULL;
 	p->pack_fd = -1;
+	p->invalid = 0;
 	hashcpy(p->sha1, sha1);
 	return p;
 }
@@ -1395,6 +1397,8 @@ static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e, cons
 	prepare_packed_git();
 
 	for (p = packed_git; p; p = p->next) {
+		if (p->invalid)
+			continue;
 		if (ignore_packed) {
 			const char **ig;
 			for (ig = ignore_packed; *ig; ig++)
@@ -1418,6 +1422,7 @@ static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e, cons
 					close(p->pack_fd);
 					p->pack_fd = -1;
 				}
+				p->invalid = 1;
 				error("packfile %s cannot be accessed", p->pack_name);
 				continue;
 			}
-- 
1.5.0.rc3.1.ge4b0e
Next: Junio C Hamano
Message 1 of 5 in “Flag and skip over packfiles known to be invalid.”
  1. 2/2 Flag and skip over packfiles known to be invalid.Shawn O. Pearce, Feb 2, 2007
  2. Junio C HamanoFeb 2, 2007
  3. Shawn O. PearceFeb 2, 2007
  4. Junio C HamanoFeb 3, 2007
  5. Shawn O. PearceFeb 4, 2007

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.