[RFC PATCH 7/8] repack: keep track of existing MIDX'd packs
- From
Taylor Blau <me@ttaylorr.com>
- Date
- Apr 11, 2025, 23:26 UTC
- Message-ID
- <ef0bc38cf0bfa056421e2288641f585a40a44ab0.1744413969.git.me@ttaylorr.com>
- In-Reply-To
- <cover.1744413969.git.me@ttaylorr.com>
The following commit will want to condition whether or not it generates a pack during geometric repacking with '--stdin-packs=follow' based on whether or not the existing MIDX has a cruft pack in it.
Keep track of that in the 'existing_packs' struct by adding an additional flag bit to denote which packs appear in a MIDX.
Signed-off-by: Taylor Blau <me@ttaylorr.com> --- builtin/repack.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/builtin/repack.c b/builtin/repack.c index f3330ade7b..bc47bede7b 100644 --- a/builtin/repack.c +++ b/builtin/repack.c @@ -31,6 +31,7 @@ #define DELETE_PACK 1 #define RETAIN_PACK 2 +#define PACK_IN_MIDX 4 static int pack_everything; static int delta_base_offset = 1; @@ -161,6 +162,11 @@ static int pack_is_retained(struct string_list_item *item) return (uintptr_t)item->util & RETAIN_PACK; } +static void pack_mark_in_midx(struct string_list_item *item) +{ + item->util = (void*)((uintptr_t)item->util | PACK_IN_MIDX); +} + static void mark_packs_for_deletion_1(struct string_list *names, struct string_list *list) { @@ -264,6 +270,7 @@ static void collect_pack_filenames(struct existing_packs *existing, for (p = get_all_packs(the_repository); p; p = p->next) { int i; const char *base; + struct string_list_item *item; if (!p->pack_local) continue; @@ -279,11 +286,17 @@ static void collect_pack_filenames(struct existing_packs *existing, strbuf_strip_suffix(&buf, ".pack"); if ((extra_keep->nr > 0 && i < extra_keep->nr) || p->pack_keep) - string_list_append(&existing->kept_packs, buf.buf); + item = string_list_append(&existing->kept_packs, + buf.buf); else if (p->is_cruft) - string_list_append(&existing->cruft_packs, buf.buf); + item = string_list_append(&existing->cruft_packs, + buf.buf); else - string_list_append(&existing->non_kept_packs, buf.buf); + item = string_list_append(&existing->non_kept_packs, + buf.buf); + + if (p->multi_pack_index) + pack_mark_in_midx(item); } string_list_sort(&existing->kept_packs);
-- 2.49.0.229.g19b69c1246