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

[PATCH v2 8/8] builtin/repack.c: extract common cruft pack loop

From
Taylor Blau <me@ttaylorr.com>
Date
Sep 13, 2023, 19:18 UTC
Message-ID
<68748eb9c865ba8252852713533e2f47e2cac489.1694632644.git.me@ttaylorr.com>
In-Reply-To
<cover.1694632644.git.me@ttaylorr.com>

When generating the list of packs to store in a MIDX (when given the `--write-midx` option), we include any cruft packs both during --geometric and non-geometric repacks.

But the rules for when we do and don't have to check whether any of those cruft packs were queued for deletion differ slightly between the two cases.

But the two can be unified, provided there is a little bit of extra detail added in the comment to clarify when it is safe to avoid checking for any pending deletions (and why it is OK to do so even when not required).

Signed-off-by: Taylor Blau <me@ttaylorr.com>
---
 builtin/repack.c | 31 ++++++++++++++++++-------------
 1 file changed, 18 insertions(+), 13 deletions(-)
diff --git a/builtin/repack.c b/builtin/repack.c
index e9a091fbbc..529e13120d 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -702,26 +702,31 @@ static void midx_included_packs(struct string_list *include,
 
 			string_list_insert(include, strbuf_detach(&buf, NULL));
 		}
-
-		for_each_string_list_item(item, &existing->cruft_packs) {
-			/*
-			 * no need to check DELETE_PACK, since we're not
-			 * doing an ALL_INTO_ONE repack
-			 */
-			string_list_insert(include, xstrfmt("%s.idx", item->string));
-		}
 	} else {
 		for_each_string_list_item(item, &existing->non_kept_packs) {
 			if (pack_is_marked_for_deletion(item))
 				continue;
 			string_list_insert(include, xstrfmt("%s.idx", item->string));
 		}
+	}
 
-		for_each_string_list_item(item, &existing->cruft_packs) {
-			if (pack_is_marked_for_deletion(item))
-				continue;
-			string_list_insert(include, xstrfmt("%s.idx", item->string));
-		}
+	for_each_string_list_item(item, &existing->cruft_packs) {
+		/*
+		 * When doing a --geometric repack, there is no need to check
+		 * for deleted packs, since we're by definition not doing an
+		 * ALL_INTO_ONE repack (hence no packs will be deleted).
+		 * Otherwise we must check for and exclude any packs which are
+		 * enqueued for deletion.
+		 *
+		 * So we could omit the conditional below in the --geometric
+		 * case, but doing so is unnecessary since no packs are marked
+		 * as pending deletion (since we only call
+		 * `mark_packs_for_deletion()` when doing an all-into-one
+		 * repack).
+		 */
+		if (pack_is_marked_for_deletion(item))
+			continue;
+		string_list_insert(include, xstrfmt("%s.idx", item->string));
 	}
 }
 
-- 
2.42.0.166.g68748eb9c8
Previous: Taylor BlauNext: Junio C Hamano
Message 32 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.