scalar: allow reconfiguring an existing enlistment
This comes in handy during Scalar upgrades, or when config settings were messed up by mistake. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
7020c88c30
commit
cb59d55ec1
@ -108,18 +108,20 @@ static int run_git(const char *arg, ...)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int set_recommended_config(void)
|
static int set_recommended_config(int reconfigure)
|
||||||
{
|
{
|
||||||
struct {
|
struct {
|
||||||
const char *key;
|
const char *key;
|
||||||
const char *value;
|
const char *value;
|
||||||
|
int overwrite_on_reconfigure;
|
||||||
} config[] = {
|
} config[] = {
|
||||||
{ "am.keepCR", "true" },
|
/* Required */
|
||||||
{ "core.FSCache", "true" },
|
{ "am.keepCR", "true", 1 },
|
||||||
{ "core.multiPackIndex", "true" },
|
{ "core.FSCache", "true", 1 },
|
||||||
{ "core.preloadIndex", "true" },
|
{ "core.multiPackIndex", "true", 1 },
|
||||||
|
{ "core.preloadIndex", "true", 1 },
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
{ "core.untrackedCache", "true" },
|
{ "core.untrackedCache", "true", 1 },
|
||||||
#else
|
#else
|
||||||
/*
|
/*
|
||||||
* Unfortunately, Scalar's Functional Tests demonstrated
|
* Unfortunately, Scalar's Functional Tests demonstrated
|
||||||
@ -133,28 +135,29 @@ static int set_recommended_config(void)
|
|||||||
* Therefore, with a sad heart, we disable this very useful
|
* Therefore, with a sad heart, we disable this very useful
|
||||||
* feature on Windows.
|
* feature on Windows.
|
||||||
*/
|
*/
|
||||||
{ "core.untrackedCache", "false" },
|
{ "core.untrackedCache", "false", 1 },
|
||||||
#endif
|
#endif
|
||||||
{ "core.logAllRefUpdates", "true" },
|
{ "core.logAllRefUpdates", "true", 1 },
|
||||||
{ "credential.https://dev.azure.com.useHttpPath", "true" },
|
{ "credential.https://dev.azure.com.useHttpPath", "true", 1 },
|
||||||
{ "credential.validate", "false" }, /* GCM4W-only */
|
{ "credential.validate", "false", 1 }, /* GCM4W-only */
|
||||||
{ "gc.auto", "0" },
|
{ "gc.auto", "0", 1 },
|
||||||
{ "gui.GCWarning", "false" },
|
{ "gui.GCWarning", "false", 1 },
|
||||||
{ "index.threads", "true" },
|
{ "index.threads", "true", 1 },
|
||||||
{ "index.version", "4" },
|
{ "index.version", "4", 1 },
|
||||||
{ "merge.stat", "false" },
|
{ "merge.stat", "false", 1 },
|
||||||
{ "merge.renames", "true" },
|
{ "merge.renames", "true", 1 },
|
||||||
{ "pack.useBitmaps", "false" },
|
{ "pack.useBitmaps", "false", 1 },
|
||||||
{ "pack.useSparse", "true" },
|
{ "pack.useSparse", "true", 1 },
|
||||||
{ "receive.autoGC", "false" },
|
{ "receive.autoGC", "false", 1 },
|
||||||
{ "reset.quiet", "true" },
|
{ "reset.quiet", "true", 1 },
|
||||||
{ "feature.manyFiles", "false" },
|
{ "feature.manyFiles", "false", 1 },
|
||||||
{ "feature.experimental", "false" },
|
{ "feature.experimental", "false", 1 },
|
||||||
{ "fetch.unpackLimit", "1" },
|
{ "fetch.unpackLimit", "1", 1 },
|
||||||
{ "fetch.writeCommitGraph", "false" },
|
{ "fetch.writeCommitGraph", "false", 1 },
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
{ "http.sslBackend", "schannel" },
|
{ "http.sslBackend", "schannel", 1 },
|
||||||
#endif
|
#endif
|
||||||
|
/* Optional */
|
||||||
{ "status.aheadBehind", "false" },
|
{ "status.aheadBehind", "false" },
|
||||||
{ "commitGraph.generationVersion", "1" },
|
{ "commitGraph.generationVersion", "1" },
|
||||||
{ "core.autoCRLF", "false" },
|
{ "core.autoCRLF", "false" },
|
||||||
@ -166,7 +169,8 @@ static int set_recommended_config(void)
|
|||||||
char *value;
|
char *value;
|
||||||
|
|
||||||
for (i = 0; config[i].key; i++) {
|
for (i = 0; config[i].key; i++) {
|
||||||
if (git_config_get_string(config[i].key, &value)) {
|
if ((reconfigure && config[i].overwrite_on_reconfigure) ||
|
||||||
|
git_config_get_string(config[i].key, &value)) {
|
||||||
trace2_data_string("scalar", the_repository, config[i].key, "created");
|
trace2_data_string("scalar", the_repository, config[i].key, "created");
|
||||||
if (git_config_set_gently(config[i].key,
|
if (git_config_set_gently(config[i].key,
|
||||||
config[i].value) < 0)
|
config[i].value) < 0)
|
||||||
@ -231,7 +235,7 @@ static int register_dir(void)
|
|||||||
int res = add_or_remove_enlistment(1);
|
int res = add_or_remove_enlistment(1);
|
||||||
|
|
||||||
if (!res)
|
if (!res)
|
||||||
res = set_recommended_config();
|
res = set_recommended_config(0);
|
||||||
|
|
||||||
if (!res)
|
if (!res)
|
||||||
res = toggle_maintenance(1);
|
res = toggle_maintenance(1);
|
||||||
@ -419,7 +423,7 @@ static int cmd_clone(int argc, const char **argv)
|
|||||||
(res = run_git("sparse-checkout", "init", "--cone", NULL)))
|
(res = run_git("sparse-checkout", "init", "--cone", NULL)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (set_recommended_config())
|
if (set_recommended_config(0))
|
||||||
return error(_("could not configure '%s'"), dir);
|
return error(_("could not configure '%s'"), dir);
|
||||||
|
|
||||||
if ((res = run_git("fetch", "--quiet", "origin", NULL))) {
|
if ((res = run_git("fetch", "--quiet", "origin", NULL))) {
|
||||||
@ -484,6 +488,24 @@ static int cmd_register(int argc, const char **argv)
|
|||||||
return register_dir();
|
return register_dir();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int cmd_reconfigure(int argc, const char **argv)
|
||||||
|
{
|
||||||
|
struct option options[] = {
|
||||||
|
OPT_END(),
|
||||||
|
};
|
||||||
|
const char * const usage[] = {
|
||||||
|
N_("scalar reconfigure [<enlistment>]"),
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
argc = parse_options(argc, argv, NULL, options,
|
||||||
|
usage, 0);
|
||||||
|
|
||||||
|
setup_enlistment_directory(argc, argv, usage, options, NULL);
|
||||||
|
|
||||||
|
return set_recommended_config(1);
|
||||||
|
}
|
||||||
|
|
||||||
static int cmd_run(int argc, const char **argv)
|
static int cmd_run(int argc, const char **argv)
|
||||||
{
|
{
|
||||||
struct option options[] = {
|
struct option options[] = {
|
||||||
@ -620,6 +642,7 @@ static struct {
|
|||||||
{ "register", cmd_register },
|
{ "register", cmd_register },
|
||||||
{ "unregister", cmd_unregister },
|
{ "unregister", cmd_unregister },
|
||||||
{ "run", cmd_run },
|
{ "run", cmd_run },
|
||||||
|
{ "reconfigure", cmd_reconfigure },
|
||||||
{ NULL, NULL},
|
{ NULL, NULL},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ scalar list
|
|||||||
scalar register [<enlistment>]
|
scalar register [<enlistment>]
|
||||||
scalar unregister [<enlistment>]
|
scalar unregister [<enlistment>]
|
||||||
scalar run ( all | config | commit-graph | fetch | loose-objects | pack-files ) [<enlistment>]
|
scalar run ( all | config | commit-graph | fetch | loose-objects | pack-files ) [<enlistment>]
|
||||||
|
scalar reconfigure <enlistment>
|
||||||
|
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
-----------
|
-----------
|
||||||
@ -117,6 +118,13 @@ opinionated default settings that make Git work more efficiently with
|
|||||||
large repositories. As this task is run as part of `scalar clone`
|
large repositories. As this task is run as part of `scalar clone`
|
||||||
automatically, explicit invocations of this task are rarely needed.
|
automatically, explicit invocations of this task are rarely needed.
|
||||||
|
|
||||||
|
Reconfigure
|
||||||
|
~~~~~~~~~~~
|
||||||
|
|
||||||
|
After a Scalar upgrade, or when the configuration of a Scalar enlistment
|
||||||
|
was somehow corrupted or changed by mistake, this subcommand allows to
|
||||||
|
reconfigure the enlistment.
|
||||||
|
|
||||||
SEE ALSO
|
SEE ALSO
|
||||||
--------
|
--------
|
||||||
linkgit:git-clone[1], linkgit:git-maintenance[1].
|
linkgit:git-clone[1], linkgit:git-maintenance[1].
|
||||||
|
@ -65,4 +65,12 @@ test_expect_success 'scalar clone' '
|
|||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'scalar reconfigure' '
|
||||||
|
git init one/src &&
|
||||||
|
scalar register one &&
|
||||||
|
git -C one/src config core.preloadIndex false &&
|
||||||
|
scalar reconfigure one &&
|
||||||
|
test true = "$(git -C one/src config core.preloadIndex)"
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
Reference in New Issue
Block a user