|
23 | 23 | #define PACK_CRUFT 4
|
24 | 24 |
|
25 | 25 | #define DELETE_PACK 1
|
| 26 | +#define CRUFT_PACK 2 |
26 | 27 |
|
27 | 28 | static int pack_everything;
|
28 | 29 | static int delta_base_offset = 1;
|
@@ -159,10 +160,15 @@ static void collect_pack_filenames(struct string_list *fname_nonkept_list,
|
159 | 160 | fname = xmemdupz(e->d_name, len);
|
160 | 161 |
|
161 | 162 | if ((extra_keep->nr > 0 && i < extra_keep->nr) ||
|
162 |
| - (file_exists(mkpath("%s/%s.keep", packdir, fname)))) |
| 163 | + (file_exists(mkpath("%s/%s.keep", packdir, fname)))) { |
163 | 164 | string_list_append_nodup(fname_kept_list, fname);
|
164 |
| - else |
165 |
| - string_list_append_nodup(fname_nonkept_list, fname); |
| 165 | + } else { |
| 166 | + struct string_list_item *item; |
| 167 | + item = string_list_append_nodup(fname_nonkept_list, |
| 168 | + fname); |
| 169 | + if (file_exists(mkpath("%s/%s.mtimes", packdir, fname))) |
| 170 | + item->util = (void*)(uintptr_t)CRUFT_PACK; |
| 171 | + } |
166 | 172 | }
|
167 | 173 | closedir(dir);
|
168 | 174 | }
|
@@ -564,6 +570,17 @@ static void midx_included_packs(struct string_list *include,
|
564 | 570 |
|
565 | 571 | string_list_insert(include, strbuf_detach(&buf, NULL));
|
566 | 572 | }
|
| 573 | + |
| 574 | + for_each_string_list_item(item, existing_nonkept_packs) { |
| 575 | + if (!((uintptr_t)item->util & CRUFT_PACK)) { |
| 576 | + /* |
| 577 | + * no need to check DELETE_PACK, since we're not |
| 578 | + * doing an ALL_INTO_ONE repack |
| 579 | + */ |
| 580 | + continue; |
| 581 | + } |
| 582 | + string_list_insert(include, xstrfmt("%s.idx", item->string)); |
| 583 | + } |
567 | 584 | } else {
|
568 | 585 | for_each_string_list_item(item, existing_nonkept_packs) {
|
569 | 586 | if ((uintptr_t)item->util & DELETE_PACK)
|
|
0 commit comments