Skip to content

Commit bfce3e7

Browse files
committed
Merge branch 'ps/repack-with-server-info'
"git repack" learned a new configuration to disable triggering of age-old "update-server-info" command, which is rarely useful these days. * ps/repack-with-server-info: repack: add config to skip updating server info repack: refactor to avoid double-negation of update-server-info
2 parents ecb939a + a2565c4 commit bfce3e7

File tree

3 files changed

+63
-4
lines changed

3 files changed

+63
-4
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: 8 additions & 4 deletions
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 no_update_server_info = 0;
624628
struct pack_objects_args po_args = {NULL};
625629
int geometric_factor = 0;
626630
int write_midx = 0;
@@ -637,8 +641,8 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
637641
N_("pass --no-reuse-delta to git-pack-objects")),
638642
OPT_BOOL('F', NULL, &po_args.no_reuse_object,
639643
N_("pass --no-reuse-object to git-pack-objects")),
640-
OPT_BOOL('n', NULL, &no_update_server_info,
641-
N_("do not run git-update-server-info")),
644+
OPT_NEGBIT('n', NULL, &run_update_server_info,
645+
N_("do not run git-update-server-info"), 1),
642646
OPT__QUIET(&po_args.quiet, N_("be quiet")),
643647
OPT_BOOL('l', "local", &po_args.local,
644648
N_("pass --local to git-pack-objects")),
@@ -939,7 +943,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
939943
prune_shallow(PRUNE_QUICK);
940944
}
941945

942-
if (!no_update_server_info)
946+
if (run_update_server_info)
943947
update_server_info(0);
944948
remove_temporary_files();
945949

t/t7700-repack.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,4 +381,54 @@ test_expect_success TTY '--quiet disables progress' '
381381
test_must_be_empty stderr
382382
'
383383

384+
test_expect_success 'setup for update-server-info' '
385+
git init update-server-info &&
386+
test_commit -C update-server-info message
387+
'
388+
389+
test_server_info_present () {
390+
test_path_is_file update-server-info/.git/objects/info/packs &&
391+
test_path_is_file update-server-info/.git/info/refs
392+
}
393+
394+
test_server_info_missing () {
395+
test_path_is_missing update-server-info/.git/objects/info/packs &&
396+
test_path_is_missing update-server-info/.git/info/refs
397+
}
398+
399+
test_server_info_cleanup () {
400+
rm -f update-server-info/.git/objects/info/packs update-server-info/.git/info/refs &&
401+
test_server_info_missing
402+
}
403+
404+
test_expect_success 'updates server info by default' '
405+
test_server_info_cleanup &&
406+
git -C update-server-info repack &&
407+
test_server_info_present
408+
'
409+
410+
test_expect_success '-n skips updating server info' '
411+
test_server_info_cleanup &&
412+
git -C update-server-info repack -n &&
413+
test_server_info_missing
414+
'
415+
416+
test_expect_success 'repack.updateServerInfo=true updates server info' '
417+
test_server_info_cleanup &&
418+
git -C update-server-info -c repack.updateServerInfo=true repack &&
419+
test_server_info_present
420+
'
421+
422+
test_expect_success 'repack.updateServerInfo=false skips updating server info' '
423+
test_server_info_cleanup &&
424+
git -C update-server-info -c repack.updateServerInfo=false repack &&
425+
test_server_info_missing
426+
'
427+
428+
test_expect_success '-n overrides repack.updateServerInfo=true' '
429+
test_server_info_cleanup &&
430+
git -C update-server-info -c repack.updateServerInfo=true repack -n &&
431+
test_server_info_missing
432+
'
433+
384434
test_done

0 commit comments

Comments
 (0)