| 125 | #define RETAIN_PACK 2 |
| 126 | |
| 127 | void existing_packs_collect(struct existing_packs *existing, |
| 128 | const struct string_list *extra_keep) |
| 129 | { |
| 130 | struct packed_git *p; |
| 131 | struct strbuf buf = STRBUF_INIT; |
| 132 | |
| 133 | repo_for_each_pack(existing->repo, p) { |
| 134 | size_t i; |
| 135 | const char *base; |
| 136 | |
| 137 | if (p->multi_pack_index) |
| 138 | string_list_append(&existing->midx_packs, |
| 139 | pack_basename(p)); |
| 140 | if (!p->pack_local) |
| 141 | continue; |
| 142 | |
| 143 | base = pack_basename(p); |
| 144 | |
| 145 | for (i = 0; i < extra_keep->nr; i++) |
| 146 | if (!fspathcmp(base, extra_keep->items[i].string)) |
| 147 | break; |
| 148 | |
| 149 | strbuf_reset(&buf); |
| 150 | strbuf_addstr(&buf, base); |
| 151 | strbuf_strip_suffix(&buf, ".pack"); |
| 152 | |
| 153 | if ((extra_keep->nr > 0 && i < extra_keep->nr) || p->pack_keep) |
| 154 | string_list_append(&existing->kept_packs, buf.buf); |
| 155 | else if (p->is_cruft) |
| 156 | string_list_append(&existing->cruft_packs, buf.buf); |
| 157 | else |
| 158 | string_list_append(&existing->non_kept_packs, buf.buf); |
| 159 | } |
| 160 | |
| 161 | existing->source = existing->repo->objects->sources; |
| 162 | |
| 163 | string_list_sort(&existing->kept_packs); |
| 164 | string_list_sort(&existing->non_kept_packs); |
| 165 | string_list_sort(&existing->cruft_packs); |
| 166 | string_list_sort(&existing->midx_packs); |
| 167 | strbuf_release(&buf); |
| 168 | } |
| 169 | |
| 170 | int existing_packs_has_non_kept(const struct existing_packs *existing) |
| 171 | { |
no test coverage detected