From: Jeff King Date: Fri, 02 Jun 2006 16:49:32 GMT Subject: [PATCH] sha1_file: avoid re-preparing duplicate packs 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