Subject: Re: Remove unneeded packs

From: Marcel Holtmann <[email-masked]>
Date: Sat, 12 Nov 2005 14:30:38 +0100

Hi Andreas,

> > every time Linus re-creates the pack for his linux-2.6 tree, I end up
> > with another pack. I use HTTP as transport and thus the new pack will be
> > download (which is almost 100 MB), but that is fine. However it seems
> > that the old (previous) pack will never be deleted. For the no longer
> > needed object files I can use git-prune-packed, but the old pack I have
> > to identify and delete by myself. Exists an easy and nice way to get rid
> > of old unneeded packs? Can't git-prune-packed also do this job?
> > 
> 
> A patchset was posted to the list 2005-11-09 by Lukas Sandström, adding 
> "git-pack-intersect" which was subsequently renamed to the more 
> appropriate "git-pack-redundant".
> 
> If I remember the commit messages and understand your question correctly 
> it does what you want.

you are right. It is exactly what I was looking for. I just saw it some
minutes ago, when I pulled the latest git tree. However to make an old
GCC 2.95 happy, the attached patch is needed.

I am not sure if it is fully working. It deletes a lot of old packs, but
in case of the linux-2.6 tree it leaves on additional behind.

.git/objects/pack/pack-4d7682fb8230fef33eb518fa8e53885ec675795e.idx
.git/objects/pack/pack-4d7682fb8230fef33eb518fa8e53885ec675795e.pack
.git/objects/pack/pack-b3c6fbdfa36a326815de6358885c7a570a986b1b.pack
.git/objects/pack/pack-b3c6fbdfa36a326815de6358885c7a570a986b1b.idx

The 4d76... is the current pack, but the b3c6... is an old one that is
not needed anymore.

Regards

Marcel

diff --git a/pack-redundant.c b/pack-redundant.c
index 1f8c577..4ed974e 100644
--- a/pack-redundant.c
+++ b/pack-redundant.c
@@ -358,11 +358,11 @@ size_t sizeof_union(struct packed_git *p
 size_t get_pack_redundancy(struct pack_list *pl)
 {
 	struct pack_list *subset;
+	size_t ret = 0;
 
 	if (pl == NULL)
 		return 0;
 
-	size_t ret = 0;
 	while ((subset = pl->next)) {
 		while(subset) {
 			ret += sizeof_union(pl->pack, subset->pack);