]> git.ipfire.org Git - thirdparty/git.git/commitdiff
repack: add config to skip updating server info
authorPatrick Steinhardt <ps@pks.im>
Mon, 14 Mar 2022 07:42:51 +0000 (08:42 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 14 Mar 2022 22:25:13 +0000 (22:25 +0000)
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/config/repack.txt
builtin/repack.c
t/t7700-repack.sh

index 9c413e177e02c6f28865ed79d84de3c5ccf43dd9..41ac6953c87eb55f14b01471a5b6013bb318859e 100644 (file)
@@ -25,3 +25,8 @@ 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, linkgit:git-repack[1] will not run
+       linkgit:git-update-server-info[1]. Defaults to true. Can be overridden
+       when true by the `-n` option of linkgit:git-repack[1].
index f2ac8ad14b48472f33832436ee7e8101bcf1f9f1..d1a563d5b65666b68596ad353a945e8e11c6ac70 100644 (file)
@@ -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 run_update_server_info = 1;
 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) {
+               run_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 run_update_server_info = 1;
        struct pack_objects_args po_args = {NULL};
        int geometric_factor = 0;
        int write_midx = 0;
index 73270477e4cc46d9799481eb712bcd6e3805b210..a2f52a3faf62a4de1af0d98f44190b3119b31d11 100755 (executable)
@@ -417,4 +417,22 @@ test_expect_success '-n skips updating server info' '
        test_server_info_missing
 '
 
+test_expect_success 'repack.updateServerInfo=true updates server info' '
+       test_server_info_cleanup &&
+       git -C update-server-info -c repack.updateServerInfo=true repack &&
+       test_server_info_present
+'
+
+test_expect_success 'repack.updateServerInfo=false skips updating server info' '
+       test_server_info_cleanup &&
+       git -C update-server-info -c repack.updateServerInfo=false repack &&
+       test_server_info_missing
+'
+
+test_expect_success '-n overrides repack.updateServerInfo=true' '
+       test_server_info_cleanup &&
+       git -C update-server-info -c repack.updateServerInfo=true repack -n &&
+       test_server_info_missing
+'
+
 test_done