Skip to content

Commit a2565c4

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 64a6151 commit a2565c4

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

Documentation/config/repack.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,8 @@ repack.writeBitmaps::
2525
space and extra time spent on the initial repack. This has
2626
no effect if multiple packfiles are created.
2727
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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ static int delta_base_offset = 1;
2222
static int pack_kept_objects = -1;
2323
static int write_bitmaps = -1;
2424
static int use_delta_islands;
25+
static int run_update_server_info = 1;
2526
static char *packdir, *packtmp_name, *packtmp;
2627

2728
static const char *const git_repack_usage[] = {
@@ -54,6 +55,10 @@ static int repack_config(const char *var, const char *value, void *cb)
5455
use_delta_islands = git_config_bool(var, value);
5556
return 0;
5657
}
58+
if (strcmp(var, "repack.updateserverinfo") == 0) {
59+
run_update_server_info = git_config_bool(var, value);
60+
return 0;
61+
}
5762
return git_default_config(var, value, cb);
5863
}
5964

@@ -620,7 +625,6 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
620625
const char *unpack_unreachable = NULL;
621626
int keep_unreachable = 0;
622627
struct string_list keep_pack_list = STRING_LIST_INIT_NODUP;
623-
int run_update_server_info = 1;
624628
struct pack_objects_args po_args = {NULL};
625629
int geometric_factor = 0;
626630
int write_midx = 0;

t/t7700-repack.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,4 +417,22 @@ test_expect_success '-n skips updating server info' '
417417
test_server_info_missing
418418
'
419419

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+
420438
test_done

0 commit comments

Comments
 (0)