|
|
@ -291,6 +291,7 @@ struct pll * get_all_permutations(struct pack_list *list) |
|
|
|
hint[0] = new_pll; |
|
|
|
hint[0] = new_pll; |
|
|
|
new_pll->next = NULL; |
|
|
|
new_pll->next = NULL; |
|
|
|
new_pll->pl = list; |
|
|
|
new_pll->pl = list; |
|
|
|
|
|
|
|
new_pll->pl_size = 1; |
|
|
|
return new_pll; |
|
|
|
return new_pll; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -439,7 +440,7 @@ void minimize(struct pack_list **min) |
|
|
|
break; /* ignore all larger permutations */ |
|
|
|
break; /* ignore all larger permutations */ |
|
|
|
if (is_superset(perm->pl, missing)) { |
|
|
|
if (is_superset(perm->pl, missing)) { |
|
|
|
new_perm = xmalloc(sizeof(struct pll)); |
|
|
|
new_perm = xmalloc(sizeof(struct pll)); |
|
|
|
new_perm->pl = perm->pl; |
|
|
|
memcpy(new_perm, perm, sizeof(struct pll)); |
|
|
|
new_perm->next = perm_ok; |
|
|
|
new_perm->next = perm_ok; |
|
|
|
perm_ok = new_perm; |
|
|
|
perm_ok = new_perm; |
|
|
|
} |
|
|
|
} |
|
|
@ -496,7 +497,7 @@ void load_all_objects() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* this scales like O(n^2) */ |
|
|
|
/* this scales like O(n^2) */ |
|
|
|
void cmp_packs() |
|
|
|
void cmp_local_packs() |
|
|
|
{ |
|
|
|
{ |
|
|
|
struct pack_list *subset, *pl = local_packs; |
|
|
|
struct pack_list *subset, *pl = local_packs; |
|
|
|
|
|
|
|
|
|
|
@ -505,16 +506,21 @@ void cmp_packs() |
|
|
|
cmp_two_packs(pl, subset); |
|
|
|
cmp_two_packs(pl, subset); |
|
|
|
pl = pl->next; |
|
|
|
pl = pl->next; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pl = altodb_packs; |
|
|
|
void scan_alt_odb_packs() |
|
|
|
while (pl) { |
|
|
|
{ |
|
|
|
subset = local_packs; |
|
|
|
struct pack_list *local, *alt; |
|
|
|
while (subset) { |
|
|
|
|
|
|
|
llist_sorted_difference_inplace(subset->unique_objects, |
|
|
|
alt = altodb_packs; |
|
|
|
pl->all_objects); |
|
|
|
while (alt) { |
|
|
|
subset = subset->next; |
|
|
|
local = local_packs; |
|
|
|
|
|
|
|
while (local) { |
|
|
|
|
|
|
|
llist_sorted_difference_inplace(local->unique_objects, |
|
|
|
|
|
|
|
alt->all_objects); |
|
|
|
|
|
|
|
local = local->next; |
|
|
|
} |
|
|
|
} |
|
|
|
pl = pl->next; |
|
|
|
alt = alt->next; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -524,6 +530,9 @@ struct pack_list * add_pack(struct packed_git *p) |
|
|
|
size_t off; |
|
|
|
size_t off; |
|
|
|
void *base; |
|
|
|
void *base; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!p->pack_local && !(alt_odb || verbose)) |
|
|
|
|
|
|
|
return NULL; |
|
|
|
|
|
|
|
|
|
|
|
l.pack = p; |
|
|
|
l.pack = p; |
|
|
|
llist_init(&l.all_objects); |
|
|
|
llist_init(&l.all_objects); |
|
|
|
|
|
|
|
|
|
|
@ -531,14 +540,14 @@ struct pack_list * add_pack(struct packed_git *p) |
|
|
|
base = (void *)p->index_base; |
|
|
|
base = (void *)p->index_base; |
|
|
|
while (off <= p->index_size - 3 * 20) { |
|
|
|
while (off <= p->index_size - 3 * 20) { |
|
|
|
llist_insert_back(l.all_objects, base + off); |
|
|
|
llist_insert_back(l.all_objects, base + off); |
|
|
|
off+=24; |
|
|
|
off += 24; |
|
|
|
} |
|
|
|
} |
|
|
|
/* this list will be pruned in cmp_two_packs later */ |
|
|
|
/* this list will be pruned in cmp_two_packs later */ |
|
|
|
l.unique_objects = llist_copy(l.all_objects); |
|
|
|
l.unique_objects = llist_copy(l.all_objects); |
|
|
|
if (p->pack_local) |
|
|
|
if (p->pack_local) |
|
|
|
return pack_list_insert(&local_packs, &l); |
|
|
|
return pack_list_insert(&local_packs, &l); |
|
|
|
else |
|
|
|
else |
|
|
|
return alt_odb ? pack_list_insert(&altodb_packs, &l) : NULL; |
|
|
|
return pack_list_insert(&altodb_packs, &l); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
struct pack_list * add_pack_file(char *filename) |
|
|
|
struct pack_list * add_pack_file(char *filename) |
|
|
@ -606,11 +615,14 @@ int main(int argc, char **argv) |
|
|
|
if (local_packs == NULL) |
|
|
|
if (local_packs == NULL) |
|
|
|
die("Zero packs found!\n"); |
|
|
|
die("Zero packs found!\n"); |
|
|
|
|
|
|
|
|
|
|
|
cmp_packs(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
load_all_objects(); |
|
|
|
load_all_objects(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cmp_local_packs(); |
|
|
|
|
|
|
|
if (alt_odb) |
|
|
|
|
|
|
|
scan_alt_odb_packs(); |
|
|
|
|
|
|
|
|
|
|
|
minimize(&min); |
|
|
|
minimize(&min); |
|
|
|
|
|
|
|
|
|
|
|
if (verbose) { |
|
|
|
if (verbose) { |
|
|
|
fprintf(stderr, "There are %lu packs available in alt-odbs.\n", |
|
|
|
fprintf(stderr, "There are %lu packs available in alt-odbs.\n", |
|
|
|
(unsigned long)pack_list_size(altodb_packs)); |
|
|
|
(unsigned long)pack_list_size(altodb_packs)); |
|
|
|