From: Qin ShiCheng via GitGitGadget Date: Mon, 26 Oct 2026 09:06:59 GMT Subject: [PATCH v4 2/3] pack-objects: add --ignore-pack-keep-from Message-ID: <91ffbdf4fa9beb215f92819c4c6d0ad2640a0c71.1793005620.git.gitgitgadget@gmail.com> In-Reply-To: From: Qin ShiCheng repack decides which packs to delete before it runs pack-objects, but pack-objects looks for ".keep" files on its own when it opens the packs. A ".keep" that appears in between, for example from a push or fetch whose index-pack wrote a pack identical to an existing one, makes pack-objects treat as kept a pack that repack is about to delete. Its objects are then left out of the new pack, or not loosened, or not kept as unreachable, and they are gone once repack deletes the pack. Not all of that goes through "--honor-pack-keep": loosening objects for "--unpack-unreachable", and collecting them for "--keep-unreachable" and "--cruft", skip packs with a ".keep" file regardless of it. Let the caller name such packs. "--ignore-pack-keep-from=" reads names of local packs, one per line, given and matched as for "--keep-pack", and treats them as if they had no ".keep" file. All of the above go by p->pack_keep, which is read from the disk once, when a pack is first seen, so clearing it for the named packs before anything looks at it covers every one of them. Other packs, including any that show up later, keep whatever their ".keep" files say. The names come from a file because there can be more of them than fit on a command line (on Windows, the whole command line is limited to 32767 characters), and the standard input is already taken in every mode repack uses. Signed-off-by: Qin ShiCheng --- Documentation/git-pack-objects.adoc | 12 ++++++++++ builtin/pack-objects.c | 37 +++++++++++++++++++++++++++++ t/t7700-repack.sh | 37 +++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+) diff --git a/Documentation/git-pack-objects.adoc b/Documentation/git-pack-objects.adoc index ccad938c5b..43fb206ef0 100644 --- a/Documentation/git-pack-objects.adoc +++ b/Documentation/git-pack-objects.adoc @@ -13,6 +13,7 @@ SYNOPSIS [--no-reuse-delta] [--delta-base-offset] [--non-empty] [--local] [--incremental] [--window=] [--depth=] [--revs [--unpacked | --all]] [--keep-pack=] + [--ignore-pack-keep-from=] [--cruft] [--cruft-expiration=