{"thread":{"id":"62676","subject":"[RFC PATCH] builtin/repack: Honor --keep-pack and .keep when repacking promisor objects","startedAt":"2024-12-20T15:56:48Z","lastAt":"2024-12-20T15:56:48Z","messageCount":1,"participants":["Tomáš Trnka"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"509405","messageId":"26692704.1r3eYUQgxm@electra","threadId":"62676","inReplyTo":null,"subject":"[RFC PATCH] builtin/repack: Honor --keep-pack and .keep when repacking promisor objects","fromName":"Tomáš Trnka","fromEmail":"trnka@scm.com","sentAt":"2024-12-20T15:50:16Z","receivedAt":"2024-12-20T15:56:48Z","isPatch":true,"sender":{"key":"trnka@scm.com","avatar":null},"body":"git-repack currently does not pass --keep-pack or --honor-pack-keep to\nthe git-pack-objects handling promisor packs. This means that settings\nlike gc.bigPackThreshold are completely ignored for promisor packs.\n\nThe simple fix is to just copy the keep-pack logic into\nrepack_promisor_objects(), although this could possibly be improved by\nmaking prepare_pack_objects() handle it instead.\n\nSigned-off-by: Tomáš Trnka <trnka@scm.com>\n---\n\nRFC: This probably needs a test, but where and how should it be\nimplemented? Perhaps in t7700-repack.sh, copying one of the tests using\nprepare_for_keep_packs and just touching .promisor files? Or instead in\nt/t0410-partial-clone.sh using a copy/variant of one of the basic \nrepack tests there?\n\n builtin/repack.c | 12 ++++++++++--\n 1 file changed, 10 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/repack.c b/builtin/repack.c\nindex d6bb37e84a..fe62fe03eb 100644\n--- a/builtin/repack.c\n+++ b/builtin/repack.c\n@@ -388,15 +388,23 @@ static int has_pack_ext(const struct generated_pack_data *data,\n }\n \n static void repack_promisor_objects(const struct pack_objects_args *args,\n-\t\t\t\t    struct string_list *names)\n+\t\t\t\t    struct string_list *names,\n+\t\t\t\t    struct string_list *keep_pack_list)\n {\n \tstruct child_process cmd = CHILD_PROCESS_INIT;\n \tFILE *out;\n \tstruct strbuf line = STRBUF_INIT;\n+\tint i;\n \n \tprepare_pack_objects(&cmd, args, packtmp);\n \tcmd.in = -1;\n \n+\tif (!pack_kept_objects)\n+\t\tstrvec_push(&cmd.args, \"--honor-pack-keep\");\n+\tfor (i = 0; i < keep_pack_list->nr; i++)\n+\t\tstrvec_pushf(&cmd.args, \"--keep-pack=%s\",\n+\t\t\t     keep_pack_list->items[i].string);\n+\n \t/*\n \t * NEEDSWORK: Giving pack-objects only the OIDs without any ordering\n \t * hints may result in suboptimal deltas in the resulting pack. See if\n@@ -1350,7 +1358,7 @@ int cmd_repack(int argc,\n \t\tstrvec_push(&cmd.args, \"--delta-islands\");\n \n \tif (pack_everything & ALL_INTO_ONE) {\n-\t\trepack_promisor_objects(&po_args, &names);\n+\t\trepack_promisor_objects(&po_args, &names, &keep_pack_list);\n \n \t\tif (has_existing_non_kept_packs(&existing) &&\n \t\t    delete_redundant &&\n\nbase-commit: 92999a42db1c5f43f330e4f2bca4026b5b81576f\n-- \n2.47.1\n\n\n\n\n"}]}