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

[PATCH] sha1_file: avoid re-preparing duplicate packs

From
Jeff King <peff@peff.net>
Date
Jun 2, 2006, 16:49 UTC
Message-ID
<20060602164932.GA10216@coredump.intra.peff.net>
In-Reply-To
<7vk67zbksv.fsf@assigned-by-dhcp.cox.net>

When adding packs, skip the pack if we already have it in the packed_git list. This might happen if we are re-preparing our packs because of a missing object. ---

On Fri, Jun 02, 2006 at 09:10:24AM -0700, Junio C Hamano wrote:
> I agree 100% on "shouldn't" part.  What I wonder is if everybody
> works correctly if we mmap the same file (all available .idx are

This patch avoids duplicates in the packed_git list. It's not necessary under Linux, at least, but it just seems cleaner, and it's simple to do. The list might still have packs that are now gone. I didn't want to purge anything from the packed_git list since I'm not clear on whether other code might have pointers into the mmap'd portion.

 sha1_file.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/sha1_file.c b/sha1_file.c
index 696e53f..aea0f40 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -617,6 +617,12 @@ static void prepare_packed_git_one(char 
 
 		/* we have .idx.  Is it a file we can map? */
 		strcpy(path + len, de->d_name);
+		for (p = packed_git; p; p = p->next) {
+			if (!memcmp(path, p->pack_name, len + namelen - 4))
+				break;
+		}
+		if (p)
+			continue;
 		p = add_packed_git(path, len + namelen, local);
 		if (!p)
 			continue;
-- 
1.3.3.gfb825
Previous: Junio C HamanoNext: Linus Torvalds
Message 6 of 7 in “handle concurrent pruning of packed objects”
  1. handle concurrent pruning of packed objectsJeff King, Jun 2, 2006
  2. Junio C HamanoJun 2, 2006
  3. Junio C HamanoJun 2, 2006
  4. Jeff KingJun 2, 2006
  5. Junio C HamanoJun 2, 2006
  6. sha1_file: avoid re-preparing duplicate packsJeff King, Jun 2, 2006
  7. Linus TorvaldsJun 2, 2006

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.