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

[PATCH 3/5] builtin/repack.c: assign pack split later

From
Taylor Blau <me@ttaylorr.com>
Date
Mar 5, 2021, 15:21 UTC
Message-ID
<60f13524bd602517c41554898b213161e9d603ce.1614957681.git.me@ttaylorr.com>
In-Reply-To
<cover.1614957681.git.me@ttaylorr.com>

To determine the where to place the split when repacking with the '--geometric' option, split_pack_geometry() assigns the "split" variable and then decrements it in a loop.

It would be equivalent (and more readable) to assign the split to the loop position after exiting the loop, so do that instead.

Suggested-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
---
 builtin/repack.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/builtin/repack.c b/builtin/repack.c
index 4ca2f647b4..21a5778e73 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -356,8 +356,6 @@ static void split_pack_geometry(struct pack_geometry *geometry, int factor)
 		return;
 	}
 
-	split = geometry->pack_nr - 1;
-
 	/*
 	 * First, count the number of packs (in descending order of size) which
 	 * already form a geometric progression.
@@ -365,12 +363,12 @@ static void split_pack_geometry(struct pack_geometry *geometry, int factor)
 	for (i = geometry->pack_nr - 1; i > 0; i--) {
 		struct packed_git *ours = geometry->pack[i];
 		struct packed_git *prev = geometry->pack[i - 1];
-		if (geometry_pack_weight(ours) >= factor * geometry_pack_weight(prev))
-			split--;
-		else
+		if (geometry_pack_weight(ours) < factor * geometry_pack_weight(prev))
 			break;
 	}
 
+	split = i;
+
 	if (split) {
 		/*
 		 * Move the split one to the right, since the top element in the
-- 
2.30.0.667.g81c0cbc6fd
Previous: Taylor Blau
Message 12 of 12 in “clean-ups to geometric repacking”
  1. 0/5 clean-ups to geometric repackingTaylor Blau, Mar 5, 2021
  2. 1/5 builtin/repack.c: do not repack single packs with --geometricTaylor Blau, Mar 5, 2021
  3. Junio C HamanoMar 5, 2021
  4. Taylor BlauMar 5, 2021
  5. Taylor BlauMar 5, 2021
  6. 2/5 t7703: test --geometric repack with loose objectsTaylor Blau, Mar 5, 2021
  7. 4/5 builtin/repack.c: be more conservative with unsigned overflowsTaylor Blau, Mar 5, 2021
  8. Junio C HamanoMar 5, 2021
  9. Taylor BlauMar 5, 2021
  10. Jeff KingMar 10, 2021
  11. 5/5 builtin/repack.c: reword comment around pack-objects flagsTaylor Blau, Mar 5, 2021
  12. 3/5 builtin/repack.c: assign pack split laterTaylor Blau, Mar 5, 2021

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.