All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: git@vger.kernel.org
Subject: [PATCH] repack: add config to skip updating server info
Date: Fri, 11 Mar 2022 12:09:30 +0100	[thread overview]
Message-ID: <659d5528df56f6b9aece6b1f3c4e2e5a4ae04e1e.1646996936.git.ps@pks.im> (raw)

[-- Attachment #1: Type: text/plain, Size: 4423 bytes --]

By default, git-repack(1) will update server info that is required by
the dumb HTTP transport. This can be skipped by passing the `-n` flag,
but what we're noticably missing is a config option to permanently
disable updating this information.

Add a new option "repack.updateServerInfo" which can be used to disable
the logic. Most hosting providers have turned off the dumb HTTP protocol
anyway, and on the client-side it woudln't typically be useful either.
Giving a persistent way to disable this feature thus makes quite some
sense to avoid wasting compute cycles and storage.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 Documentation/config/repack.txt |  3 +++
 builtin/repack.c                |  6 ++++-
 t/t7700-repack.sh               | 47 +++++++++++++++++++++++++++++++++
 3 files changed, 55 insertions(+), 1 deletion(-)

diff --git a/Documentation/config/repack.txt b/Documentation/config/repack.txt
index 9c413e177e..22bfc26afc 100644
--- a/Documentation/config/repack.txt
+++ b/Documentation/config/repack.txt
@@ -25,3 +25,6 @@ repack.writeBitmaps::
 	space and extra time spent on the initial repack.  This has
 	no effect if multiple packfiles are created.
 	Defaults to true on bare repos, false otherwise.
+
+repack.updateServerInfo::
+	If set to false, git-repack will not run git-update-server-info.
diff --git a/builtin/repack.c b/builtin/repack.c
index da1e364a75..3baa993da2 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -22,6 +22,7 @@ static int delta_base_offset = 1;
 static int pack_kept_objects = -1;
 static int write_bitmaps = -1;
 static int use_delta_islands;
+static int no_update_server_info = 0;
 static char *packdir, *packtmp_name, *packtmp;
 
 static const char *const git_repack_usage[] = {
@@ -54,6 +55,10 @@ static int repack_config(const char *var, const char *value, void *cb)
 		use_delta_islands = git_config_bool(var, value);
 		return 0;
 	}
+	if (strcmp(var, "repack.updateserverinfo") == 0) {
+		no_update_server_info = !git_config_bool(var, value);
+		return 0;
+	}
 	return git_default_config(var, value, cb);
 }
 
@@ -620,7 +625,6 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
 	const char *unpack_unreachable = NULL;
 	int keep_unreachable = 0;
 	struct string_list keep_pack_list = STRING_LIST_INIT_NODUP;
-	int no_update_server_info = 0;
 	struct pack_objects_args po_args = {NULL};
 	int geometric_factor = 0;
 	int write_midx = 0;
diff --git a/t/t7700-repack.sh b/t/t7700-repack.sh
index 5922fb5bdd..f049120022 100755
--- a/t/t7700-repack.sh
+++ b/t/t7700-repack.sh
@@ -381,4 +381,51 @@ test_expect_success TTY '--quiet disables progress' '
 	test_must_be_empty stderr
 '
 
+test_expect_success 'updates server info by default' '
+	git init repo &&
+	test_when_finished "rm -rf repo" &&
+	test_commit -C repo message &&
+	test_path_is_missing repo/.git/objects/info/packs &&
+	test_path_is_missing repo/.git/info/refs &&
+	git -C repo repack &&
+	test_path_is_file repo/.git/objects/info/packs &&
+	test_path_is_file repo/.git/info/refs
+'
+
+test_expect_success '-n skips updating server info' '
+	git init repo &&
+	test_when_finished "rm -rf repo" &&
+	test_commit -C repo message &&
+	git -C repo repack -n &&
+	test_path_is_missing repo/.git/objects/info/packs &&
+	test_path_is_missing repo/.git/info/refs
+'
+
+test_expect_success 'repack.updateServerInfo=true updates server info' '
+	git init repo &&
+	test_when_finished "rm -rf repo" &&
+	test_commit -C repo message &&
+	git -C repo -c repack.updateServerInfo=true repack &&
+	test_path_is_file repo/.git/objects/info/packs &&
+	test_path_is_file repo/.git/info/refs
+'
+
+test_expect_success 'repack.updateServerInfo=false skips updating server info' '
+	git init repo &&
+	test_when_finished "rm -rf repo" &&
+	test_commit -C repo message &&
+	git -C repo -c repack.updateServerInfo=false repack &&
+	test_path_is_missing repo/.git/objects/info/packs &&
+	test_path_is_missing repo/.git/info/refs
+'
+
+test_expect_success '-n overrides repack.updateServerInfo=true' '
+	git init repo &&
+	test_when_finished "rm -rf repo" &&
+	test_commit -C repo message &&
+	git -C repo -c repack.updateServerInfo=true repack -n &&
+	test_path_is_missing repo/.git/objects/info/packs &&
+	test_path_is_missing repo/.git/info/refs
+'
+
 test_done
-- 
2.35.1


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

             reply	other threads:[~2022-03-11 11:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-11 11:09 Patrick Steinhardt [this message]
2022-03-11 16:20 ` [PATCH] repack: add config to skip updating server info Taylor Blau
2022-03-14  7:19   ` Patrick Steinhardt
2022-03-14  7:42 ` [PATCH v2 0/2] " Patrick Steinhardt
2022-03-14  7:42   ` [PATCH v2 1/2] repack: refactor to avoid double-negation of update-server-info Patrick Steinhardt
2022-03-14  7:42   ` [PATCH v2 2/2] repack: add config to skip updating server info Patrick Steinhardt
2022-03-14 22:26     ` Junio C Hamano

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=659d5528df56f6b9aece6b1f3c4e2e5a4ae04e1e.1646996936.git.ps@pks.im \
    --to=ps@pks.im \
    --cc=git@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.