pack-redundant: delete redundant code
[gitweb.git] / builtin / pack-redundant.c
index 0494dceff73d672ee430f1c5bd0ce9f8b70c83f6..4a06f057ddf3f5d6f948485b959b56da45344358 100644 (file)
@@ -254,6 +254,11 @@ static void cmp_two_packs(struct pack_list *p1, struct pack_list *p2)
        struct llist_item *p1_hint = NULL, *p2_hint = NULL;
        const unsigned int hashsz = the_hash_algo->rawsz;
 
+       if (!p1->unique_objects)
+               p1->unique_objects = llist_copy(p1->all_objects);
+       if (!p2->unique_objects)
+               p2->unique_objects = llist_copy(p2->all_objects);
+
        p1_base = p1->pack->index_data;
        p2_base = p2->pack->index_data;
        p1_base += 256 * 4 + ((p1->pack->index_version < 2) ? 4 : 8);
@@ -536,11 +541,10 @@ static void scan_alt_odb_packs(void)
        while (alt) {
                local = local_packs;
                while (local) {
-                       llist_sorted_difference_inplace(local->unique_objects,
+                       llist_sorted_difference_inplace(local->all_objects,
                                                        alt->all_objects);
                        local = local->next;
                }
-               llist_sorted_difference_inplace(all_objects, alt->all_objects);
                alt = alt->next;
        }
 }
@@ -567,8 +571,7 @@ static struct pack_list * add_pack(struct packed_git *p)
                llist_insert_back(l.all_objects, (const struct object_id *)(base + off));
                off += step;
        }
-       /* this list will be pruned in cmp_two_packs later */
-       l.unique_objects = llist_copy(l.all_objects);
+       l.unique_objects = NULL;
        if (p->pack_local)
                return pack_list_insert(&local_packs, &l);
        else
@@ -577,7 +580,7 @@ static struct pack_list * add_pack(struct packed_git *p)
 
 static struct pack_list * add_pack_file(const char *filename)
 {
-       struct packed_git *p = get_packed_git(the_repository);
+       struct packed_git *p = get_all_packs(the_repository);
 
        if (strlen(filename) < 40)
                die("Bad pack filename: %s", filename);
@@ -592,7 +595,7 @@ static struct pack_list * add_pack_file(const char *filename)
 
 static void load_all(void)
 {
-       struct packed_git *p = get_packed_git(the_repository);
+       struct packed_git *p = get_all_packs(the_repository);
 
        while (p) {
                add_pack(p);
@@ -646,7 +649,6 @@ int cmd_pack_redundant(int argc, const char **argv, const char *prefix)
 
        load_all_objects();
 
-       cmp_local_packs();
        if (alt_odb)
                scan_alt_odb_packs();
 
@@ -663,10 +665,12 @@ int cmd_pack_redundant(int argc, const char **argv, const char *prefix)
        llist_sorted_difference_inplace(all_objects, ignore);
        pl = local_packs;
        while (pl) {
-               llist_sorted_difference_inplace(pl->unique_objects, ignore);
+               llist_sorted_difference_inplace(pl->all_objects, ignore);
                pl = pl->next;
        }
 
+       cmp_local_packs();
+
        minimize(&min);
 
        if (verbose) {