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
This commit is contained in:
commit
bfce3e7b92
@ -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].
|
||||
|
@ -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 no_update_server_info = 0;
|
||||
struct pack_objects_args po_args = {NULL};
|
||||
int geometric_factor = 0;
|
||||
int write_midx = 0;
|
||||
@ -637,8 +641,8 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
|
||||
N_("pass --no-reuse-delta to git-pack-objects")),
|
||||
OPT_BOOL('F', NULL, &po_args.no_reuse_object,
|
||||
N_("pass --no-reuse-object to git-pack-objects")),
|
||||
OPT_BOOL('n', NULL, &no_update_server_info,
|
||||
N_("do not run git-update-server-info")),
|
||||
OPT_NEGBIT('n', NULL, &run_update_server_info,
|
||||
N_("do not run git-update-server-info"), 1),
|
||||
OPT__QUIET(&po_args.quiet, N_("be quiet")),
|
||||
OPT_BOOL('l', "local", &po_args.local,
|
||||
N_("pass --local to git-pack-objects")),
|
||||
@ -939,7 +943,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
|
||||
prune_shallow(PRUNE_QUICK);
|
||||
}
|
||||
|
||||
if (!no_update_server_info)
|
||||
if (run_update_server_info)
|
||||
update_server_info(0);
|
||||
remove_temporary_files();
|
||||
|
||||
|
@ -381,4 +381,54 @@ test_expect_success TTY '--quiet disables progress' '
|
||||
test_must_be_empty stderr
|
||||
'
|
||||
|
||||
test_expect_success 'setup for update-server-info' '
|
||||
git init update-server-info &&
|
||||
test_commit -C update-server-info message
|
||||
'
|
||||
|
||||
test_server_info_present () {
|
||||
test_path_is_file update-server-info/.git/objects/info/packs &&
|
||||
test_path_is_file update-server-info/.git/info/refs
|
||||
}
|
||||
|
||||
test_server_info_missing () {
|
||||
test_path_is_missing update-server-info/.git/objects/info/packs &&
|
||||
test_path_is_missing update-server-info/.git/info/refs
|
||||
}
|
||||
|
||||
test_server_info_cleanup () {
|
||||
rm -f update-server-info/.git/objects/info/packs update-server-info/.git/info/refs &&
|
||||
test_server_info_missing
|
||||
}
|
||||
|
||||
test_expect_success 'updates server info by default' '
|
||||
test_server_info_cleanup &&
|
||||
git -C update-server-info repack &&
|
||||
test_server_info_present
|
||||
'
|
||||
|
||||
test_expect_success '-n skips updating server info' '
|
||||
test_server_info_cleanup &&
|
||||
git -C update-server-info repack -n &&
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user