git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Taylor Blau <me@ttaylorr.com>
To: git@vger.kernel.org
Cc: peff@peff.net, dstolee@microsoft.com, gitster@pobox.com
Subject: [PATCH] builtin/repack.c: set a default factor for '--geometric'
Date: Mon, 19 Apr 2021 21:47:26 -0400	[thread overview]
Message-ID: <1ecab817396fae6a1cbafde1ca8b3ebfd9ae4c11.1618883241.git.me@ttaylorr.com> (raw)

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>
---
 Documentation/git-repack.txt | 8 ++++----
 builtin/repack.c             | 5 +++--
 t/t7703-repack-geometric.sh  | 2 +-
 3 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/Documentation/git-repack.txt b/Documentation/git-repack.txt
index 317d63cf0d..d948a2913d 100644
--- a/Documentation/git-repack.txt
+++ b/Documentation/git-repack.txt
@@ -165,11 +165,11 @@ 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.
+	contains at least `<factor>` (`2` if unspecified) times the
+	number of objects as the next-largest pack.
 +
 `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

             reply	other threads:[~2021-04-20  1:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-20  1:47 Taylor Blau [this message]
2021-04-20 12:39 ` [PATCH] builtin/repack.c: set a default factor for '--geometric' Derrick Stolee
2021-04-20 20:25 ` Junio C Hamano
2021-04-20 20:31   ` Taylor Blau
2021-04-20 20:32 ` [PATCH v2] " Taylor Blau
2021-04-20 21:44   ` Andreas Schwab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1ecab817396fae6a1cbafde1ca8b3ebfd9ae4c11.1618883241.git.me@ttaylorr.com \
    --to=me@ttaylorr.com \
    --cc=dstolee@microsoft.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).