repack: add config to skip updating server info
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>
Patrick Steinhardt committed
Mar 14, 2022 at 08:42 UTC
a2565c48e410864c049e66a64393fd6e26eb9a55
3 files changed
+28
-1
Documentation/config/repack.txt
+5
@@ -25,3 +25,8 @@ repack.writeBitmaps::
25
space and extra time spent on the initial repack. This has
26
no effect if multiple packfiles are created.
27
Defaults to true on bare repos, false otherwise.
28
+
29
+repack.updateServerInfo::
30
+ If set to false, linkgit:git-repack[1] will not run
31
+ linkgit:git-update-server-info[1]. Defaults to true. Can be overridden
32
+ when true by the `-n` option of linkgit:git-repack[1].
builtin/repack.c
+5
-1
@@ -22,6 +22,7 @@ static int delta_base_offset = 1;
22
static int pack_kept_objects = -1;
23
static int write_bitmaps = -1;
24
static int use_delta_islands;
25
+static int run_update_server_info = 1;
26
static char *packdir, *packtmp_name, *packtmp;
27
28
static const char *const git_repack_usage[] = {
@@ -54,6 +55,10 @@ static int repack_config(const char *var, const char *value, void *cb)
55
use_delta_islands = git_config_bool(var, value);
56
return 0;
57
}
58
+ if (strcmp(var, "repack.updateserverinfo") == 0) {
59
+ run_update_server_info = git_config_bool(var, value);
60
+ return 0;
61
+ }
62
return git_default_config(var, value, cb);
63
}
64
@@ -620,7 +625,6 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
625
const char *unpack_unreachable = NULL;
626
int keep_unreachable = 0;
627
struct string_list keep_pack_list = STRING_LIST_INIT_NODUP;
623
- int run_update_server_info = 1;
628
struct pack_objects_args po_args = {NULL};
629
int geometric_factor = 0;
630
int write_midx = 0;
t/t7700-repack.sh
+18
@@ -417,4 +417,22 @@ test_expect_success '-n skips updating server info' '
417
test_server_info_missing
418
'
419
420
+test_expect_success 'repack.updateServerInfo=true updates server info' '
421
+ test_server_info_cleanup &&
422
+ git -C update-server-info -c repack.updateServerInfo=true repack &&
423
+ test_server_info_present
424
+'
425
+
426
+test_expect_success 'repack.updateServerInfo=false skips updating server info' '
427
+ test_server_info_cleanup &&
428
+ git -C update-server-info -c repack.updateServerInfo=false repack &&
429
+ test_server_info_missing
430
+'
431
+
432
+test_expect_success '-n overrides repack.updateServerInfo=true' '
433
+ test_server_info_cleanup &&
434
+ git -C update-server-info -c repack.updateServerInfo=true repack -n &&
435
+ test_server_info_missing
436
+'
437
+
438
test_done