git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 0/8] repack: refactor pack snapshot-ing logic

From
Taylor Blau <me@ttaylorr.com>
Date
Sep 14, 2023, 18:01 UTC
Message-ID
<ZQNKkn0YYLUyN5Ih@nand.local>
In-Reply-To
<CAP8UFD1rDb-iYf4LYb7n=K4KpQ-JR-JK4TkQpGJ-TCfTNFFbnA@mail.gmail.com>
On Thu, Sep 14, 2023 at 01:10:38PM +0200, Christian Couder wrote:
> Ok, I will try to review and merge this with
> cc/repack-sift-filtered-objects-to-separate-pack soon.

I took a look at how much/little effort was going to be required, and luckily the changes are isolated only to a single patch. It's just your f1ffa71e8f (repack: add `--filter=<filter-spec>` option, 2023-09-11), and in particular the `write_filtered_pack()` function.

I started messing around with it myself and generated the following fixup! which can be applied on top of your version of f1ffa71e8f. It's mostly straightforward, but there is a gotcha that the loop over non-kept packs has to change to:

    for_each_string_list_item(item, &existing->non_kept_packs)
            /* ... */
    for_each_string_list_item(item, &existing->cruft_packs)
            /* ... */

, instead of just the first loop over non_kept_packs, since cruft packs are stored in a separate list.

In any event, here's the fixup! I generated on top of that patch:
--- 8< ---
Subject: [PATCH] fixup! repack: add `--filter=<filter-spec>` option
Signed-off-by: Taylor Blau <me@ttaylorr.com>
---
 builtin/repack.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)
diff --git a/builtin/repack.c b/builtin/repack.c
index 120f4241c0..0d23323d05 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -834,15 +834,13 @@ static int finish_pack_objects_cmd(struct child_process *cmd,
 static int write_filtered_pack(const struct pack_objects_args *args,
 			       const char *destination,
 			       const char *pack_prefix,
-			       struct string_list *keep_pack_list,
-			       struct string_list *names,
-			       struct string_list *existing_packs,
-			       struct string_list *existing_kept_packs)
+			       struct existing_packs *existing,
+			       struct string_list *names)
 {
 	struct child_process cmd = CHILD_PROCESS_INIT;
 	struct string_list_item *item;
 	FILE *in;
-	int ret, i;
+	int ret;
 	const char *caret;
 	const char *scratch;
 	int local = skip_prefix(destination, packdir, &scratch);
@@ -853,9 +851,8 @@ static int write_filtered_pack(const struct pack_objects_args *args,

 	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);
+	for_each_string_list_item(item, &existing->kept_packs)
+		strvec_pushf(&cmd.args, "--keep-pack=%s", item->string);

 	cmd.in = -1;

@@ -872,10 +869,12 @@ static int write_filtered_pack(const struct pack_objects_args *args,
 	in = xfdopen(cmd.in, "w");
 	for_each_string_list_item(item, names)
 		fprintf(in, "^%s-%s.pack\n", pack_prefix, item->string);
-	for_each_string_list_item(item, existing_packs)
+	for_each_string_list_item(item, &existing->non_kept_packs)
+		fprintf(in, "%s.pack\n", item->string);
+	for_each_string_list_item(item, &existing->cruft_packs)
 		fprintf(in, "%s.pack\n", item->string);
 	caret = pack_kept_objects ? "" : "^";
-	for_each_string_list_item(item, existing_kept_packs)
+	for_each_string_list_item(item, &existing->kept_packs)
 		fprintf(in, "%s%s.pack\n", caret, item->string);
 	fclose(in);

@@ -1261,10 +1260,8 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
 		ret = write_filtered_pack(&po_args,
 					  packtmp,
 					  find_pack_prefix(packdir, packtmp),
-					  &keep_pack_list,
-					  &names,
-					  &existing_nonkept_packs,
-					  &existing_kept_packs);
+					  &existing,
+					  &names);
 		if (ret)
 			goto cleanup;
 	}
--
2.42.0.137.g6fe1dff026
--- >8 ---

Thanks,
Taylor
Previous: Christian CouderNext: Christian Couder
Message 37 of 39 in “repack: refactor pack snapshot-ing logic”
  1. 0/8 repack: refactor pack snapshot-ing logicTaylor Blau, Sep 5, 2023
  2. 2/8 builtin/repack.c: extract marking packs for deletionTaylor Blau, Sep 5, 2023
  3. Jeff KingSep 7, 2023
  4. Taylor BlauSep 7, 2023
  5. 5/8 builtin/repack.c: extract `has_existing_non_kept_packs()`Taylor Blau, Sep 5, 2023
  6. Jeff KingSep 7, 2023
  7. 3/8 builtin/repack.c: extract redundant pack cleanup for --geometricTaylor Blau, Sep 5, 2023
  8. Jeff KingSep 7, 2023
  9. 1/8 builtin/repack.c: extract structure to store existing packsTaylor Blau, Sep 5, 2023
  10. Jeff KingSep 7, 2023
  11. 4/8 builtin/repack.c: extract redundant pack cleanup for existing packsTaylor Blau, Sep 5, 2023
  12. Jeff KingSep 7, 2023
  13. 6/8 builtin/repack.c: store existing cruft packs separatelyTaylor Blau, Sep 5, 2023
  14. Jeff KingSep 7, 2023
  15. 7/8 builtin/repack.c: drop `DELETE_PACK` macroTaylor Blau, Sep 5, 2023
  16. Junio C HamanoSep 6, 2023
  17. Taylor BlauSep 6, 2023
  18. Patrick SteinhardtSep 7, 2023
  19. Junio C HamanoSep 7, 2023
  20. Jeff KingSep 7, 2023
  21. 8/8 builtin/repack.c: extract common cruft pack loopTaylor Blau, Sep 5, 2023
  22. Jeff KingSep 7, 2023
  23. 0/8 repack: refactor pack snapshot-ing logicTaylor Blau, Sep 13, 2023
  24. 1/8 builtin/repack.c: extract structure to store existing packsTaylor Blau, Sep 13, 2023
  25. 2/8 builtin/repack.c: extract marking packs for deletionTaylor Blau, Sep 13, 2023
  26. 3/8 builtin/repack.c: extract redundant pack cleanup for --geometricTaylor Blau, Sep 13, 2023
  27. 4/8 builtin/repack.c: extract redundant pack cleanup for existing packsTaylor Blau, Sep 13, 2023
  28. 5/8 builtin/repack.c: extract `has_existing_non_kept_packs()`Taylor Blau, Sep 13, 2023
  29. Christian CouderSep 15, 2023
  30. 6/8 builtin/repack.c: store existing cruft packs separatelyTaylor Blau, Sep 13, 2023
  31. 7/8 builtin/repack.c: avoid directly inspecting "util"Taylor Blau, Sep 13, 2023
  32. 8/8 builtin/repack.c: extract common cruft pack loopTaylor Blau, Sep 13, 2023
  33. Junio C HamanoSep 13, 2023
  34. Jeff KingSep 14, 2023
  35. Patrick SteinhardtSep 14, 2023
  36. Christian CouderSep 14, 2023
  37. Taylor BlauSep 14, 2023
  38. Christian CouderSep 15, 2023
  39. Christian CouderSep 15, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.