threads / rfc / 62872

RFC patchbuiltin/repack: Honor --keep-pack and .keep when repacking promisor objects

Subject: [RFC PATCH resend] builtin/repack: Honor --keep-pack and .keep when repacking promisor objects

## tl;dr

3 messages between Jan 30, 2025 and Jan 31, 2025. Diffs are folded; open one to read it.

replies: 2people: 2as markdown or json

Tomáš Trnka· Jan 30, 2025, 08:11 UTC · lore

git-repack currently does not pass --keep-pack or --honor-pack-keep to the git-pack-objects handling promisor packs. This means that settings like gc.bigPackThreshold are completely ignored for promisor packs.

The simple fix is to just copy the keep-pack logic into repack_promisor_objects(), although this could possibly be improved by making prepare_pack_objects() handle it instead.

Signed-off-by: Tomáš Trnka <trnka@scm.com>
---
RFC: This probably needs a test, but where and how should it be
implemented? Perhaps in t7700-repack.sh, copying one of the tests using
prepare_for_keep_packs and just touching .promisor files? Or instead in
t/t0410-partial-clone.sh using a copy/variant of one of the basic 
repack tests there?
 builtin/repack.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
Show changes to builtin/repack.c +10 −2
diff --git a/builtin/repack.c b/builtin/repack.c
index d6bb37e84a..fe62fe03eb 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -388,15 +388,23 @@ static int has_pack_ext(const struct generated_pack_data *data,
 }
 
 static void repack_promisor_objects(const struct pack_objects_args *args,
-				    struct string_list *names)
+				    struct string_list *names,
+				    struct string_list *keep_pack_list)
 {
 	struct child_process cmd = CHILD_PROCESS_INIT;
 	FILE *out;
 	struct strbuf line = STRBUF_INIT;
+	int i;
 
 	prepare_pack_objects(&cmd, args, packtmp);
 	cmd.in = -1;
 
+	if (!pack_kept_objects)
+		strvec_push(&cmd.args, "--honor-pack-keep");
+	for (i = 0; i < keep_pack_list->nr; i++)
+		strvec_pushf(&cmd.args, "--keep-pack=%s",
+			     keep_pack_list->items[i].string);
+
 	/*
 	 * NEEDSWORK: Giving pack-objects only the OIDs without any ordering
 	 * hints may result in suboptimal deltas in the resulting pack. See if
@@ -1350,7 +1358,7 @@ int cmd_repack(int argc,
 		strvec_push(&cmd.args, "--delta-islands");
 
 	if (pack_everything & ALL_INTO_ONE) {
-		repack_promisor_objects(&po_args, &names);
+		repack_promisor_objects(&po_args, &names, &keep_pack_list);
 
 		if (has_existing_non_kept_packs(&existing) &&
 		    delete_redundant &&

base-commit: 92999a42db1c5f43f330e4f2bca4026b5b81576f
-- 
2.47.1
Junio C Hamano· Jan 30, 2025, 22:32 UTC · re: Tomáš Trnka · lore

Re: [RFC PATCH resend] builtin/repack: Honor --keep-pack and .keep when repacking promisor objects

Tomáš Trnka <trnka@scm.com> writes:
Show 10 quoted lines
> git-repack currently does not pass --keep-pack or --honor-pack-keep to
> the git-pack-objects handling promisor packs. This means that settings
> like gc.bigPackThreshold are completely ignored for promisor packs.
>
> The simple fix is to just copy the keep-pack logic into
> repack_promisor_objects(), although this could possibly be improved by
> making prepare_pack_objects() handle it instead.
>
> Signed-off-by: Tomáš Trnka <trnka@scm.com>
> ---

I don't have a strong opinion about the technical aspects of this patch to be a reviewer. I have no idea how you decided whom to Cc:, but I recall these two threads that worked in the same "interaction between repack and promisor objects" area (I am not saying and I do not think they addressed the same problem as you are):

 * https://lore.kernel.org/git/20240925072021.77078-1-hanyang.tony@bytedance.com/
 * https://lore.kernel.org/git/cover.1730491845.git.jonathantanmy@google.com/

so asking review from the authors of these topics would be more relevant than sending it to me (I did that already, and that is why the remainder of the original patch is not culled from this response---after the next line, there is nothing I wrote but the original patch left for others' convenience).

Thanks.
Show 50 quoted lines
>
> RFC: This probably needs a test, but where and how should it be
> implemented? Perhaps in t7700-repack.sh, copying one of the tests using
> prepare_for_keep_packs and just touching .promisor files? Or instead in
> t/t0410-partial-clone.sh using a copy/variant of one of the basic 
> repack tests there?
>
>  builtin/repack.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/builtin/repack.c b/builtin/repack.c
> index d6bb37e84a..fe62fe03eb 100644
> --- a/builtin/repack.c
> +++ b/builtin/repack.c
> @@ -388,15 +388,23 @@ static int has_pack_ext(const struct generated_pack_data *data,
>  }
>  
>  static void repack_promisor_objects(const struct pack_objects_args *args,
> -				    struct string_list *names)
> +				    struct string_list *names,
> +				    struct string_list *keep_pack_list)
>  {
>  	struct child_process cmd = CHILD_PROCESS_INIT;
>  	FILE *out;
>  	struct strbuf line = STRBUF_INIT;
> +	int i;
>  
>  	prepare_pack_objects(&cmd, args, packtmp);
>  	cmd.in = -1;
>  
> +	if (!pack_kept_objects)
> +		strvec_push(&cmd.args, "--honor-pack-keep");
> +	for (i = 0; i < keep_pack_list->nr; i++)
> +		strvec_pushf(&cmd.args, "--keep-pack=%s",
> +			     keep_pack_list->items[i].string);
> +
>  	/*
>  	 * NEEDSWORK: Giving pack-objects only the OIDs without any ordering
>  	 * hints may result in suboptimal deltas in the resulting pack. See if
> @@ -1350,7 +1358,7 @@ int cmd_repack(int argc,
>  		strvec_push(&cmd.args, "--delta-islands");
>  
>  	if (pack_everything & ALL_INTO_ONE) {
> -		repack_promisor_objects(&po_args, &names);
> +		repack_promisor_objects(&po_args, &names, &keep_pack_list);
>  
>  		if (has_existing_non_kept_packs(&existing) &&
>  		    delete_redundant &&
>
> base-commit: 92999a42db1c5f43f330e4f2bca4026b5b81576f
Tomáš Trnka· Jan 31, 2025, 15:17 UTC · re: Junio C Hamano · lore

Re: [RFC PATCH resend] builtin/repack: Honor --keep-pack and .keep when repacking promisor objects

On Thursday, 30 January 2025 23:32:34, CET Junio C Hamano wrote:
> I don't have a strong opinion about the technical aspects of this
> patch to be a reviewer.  I have no idea how you decided whom to Cc:,

I'm sorry again for spamming you unnecessarily and many thanks for suggesting more suitable reviewers.

Being a complete newcomer to Git development, I went by what the git-contacts tool suggested when I gave it my patch, since its output seemed to roughly agree with git log on builtin/repack.c, plus I also thought you might have a high-level opinion on where the test belongs. I didn't check the mailing list archives too thoroughly, so I was not aware of those discussion threads.

2T

← back to recent threads