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

[PATCH v2] builtin/repack.c: set a default factor for '--geometric'

From
Taylor Blau <me@ttaylorr.com>
Date
Apr 20, 2021, 20:32 UTC
Message-ID
<8d8dea2e2c149303891cfe6ae8dbec06b538622c.1618950726.git.me@ttaylorr.com>
In-Reply-To
<1ecab817396fae6a1cbafde1ca8b3ebfd9ae4c11.1618883241.git.me@ttaylorr.com>

The '--geometric=<n>' argument specifies that each pack must contain at least 'n' times as many objects as the size of the next-largest pack. The factor 'n' is customizable, but setting it to '2' is a sane default.

Instead of making the factor a required argument, make the argument optional with a default value of '2'.

To ensure that the option is setup correctly, modify the most complex test of t7703 to drop the explicit factor.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
---
Range-diff against v1:
1:  1ecab81739 ! 1:  8d8dea2e2c builtin/repack.c: set a default factor for '--geometric'
    @@ Documentation/git-repack.txt: depth is 4095.
      
     --g=<factor>::
     ---geometric=<factor>::
    -+-g=[<factor>]::
    ++-g[=<factor>]::
     +--geometric[=<factor>]::
      	Arrange resulting pack structure so that each successive pack
    --	contains at least `<factor>` times the number of objects as the
    + 	contains at least `<factor>` times the number of objects as the
     -	next-largest pack.
    -+	contains at least `<factor>` (`2` if unspecified) times the
    -+	number of objects as the next-largest pack.
    ++	next-largest pack. If `<factor>` is not specified, then `2` is
    ++	used by default.
      +
      `git repack` ensures this by determining a "cut" of packfiles that need
      to be repacked into one in order to ensure a geometric progression. It
 Documentation/git-repack.txt | 7 ++++---
 builtin/repack.c             | 5 +++--
 t/t7703-repack-geometric.sh  | 2 +-
 3 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/Documentation/git-repack.txt b/Documentation/git-repack.txt
index 317d63cf0d..f7c7e0aeae 100644
--- a/Documentation/git-repack.txt
+++ b/Documentation/git-repack.txt
@@ -165,11 +165,12 @@ depth is 4095.
 	Pass the `--delta-islands` option to `git-pack-objects`, see
 	linkgit:git-pack-objects[1].
 
--g=<factor>::
---geometric=<factor>::
+-g[=<factor>]::
+--geometric[=<factor>]::
 	Arrange resulting pack structure so that each successive pack
 	contains at least `<factor>` times the number of objects as the
-	next-largest pack.
+	next-largest pack. If `<factor>` is not specified, then `2` is
+	used by default.
 +
 `git repack` ensures this by determining a "cut" of packfiles that need
 to be repacked into one in order to ensure a geometric progression. It
diff --git a/builtin/repack.c b/builtin/repack.c
index 2847fdfbab..f2359c9d3a 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -494,8 +494,9 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
 				N_("repack objects in packs marked with .keep")),
 		OPT_STRING_LIST(0, "keep-pack", &keep_pack_list, N_("name"),
 				N_("do not repack this pack")),
-		OPT_INTEGER('g', "geometric", &geometric_factor,
-			    N_("find a geometric progression with factor <N>")),
+		{ OPTION_INTEGER, 'g', "geometric", &geometric_factor, N_("n"),
+				N_("find a geometric progression with factor <n>"),
+				PARSE_OPT_OPTARG, NULL, 2 },
 		OPT_END()
 	};
 
diff --git a/t/t7703-repack-geometric.sh b/t/t7703-repack-geometric.sh
index 5ccaa440e0..77cd5f2284 100755
--- a/t/t7703-repack-geometric.sh
+++ b/t/t7703-repack-geometric.sh
@@ -123,7 +123,7 @@ test_expect_success '--geometric with small- and large-pack rollup' '
 
 		find $objdir/pack -name "*.pack" | sort >before &&
 
-		git repack --geometric 2 -d &&
+		git repack --geometric -d &&
 
 		find $objdir/pack -name "*.pack" | sort >after &&
 		comm -12 before after >untouched &&
-- 
2.31.1.163.ga65ce7f831
Previous: Taylor BlauNext: Andreas Schwab
Message 5 of 6 in “builtin/repack.c: set a default factor for '--geometric'”
  1. builtin/repack.c: set a default factor for '--geometric'Taylor Blau, Apr 20, 2021
  2. Derrick StoleeApr 20, 2021
  3. Junio C HamanoApr 20, 2021
  4. Taylor BlauApr 20, 2021
  5. builtin/repack.c: set a default factor for '--geometric'Taylor Blau, Apr 20, 2021
  6. Andreas SchwabApr 20, 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.