[PATCH] sha1_file: avoid re-preparing duplicate packs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
-
: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]