From patchwork Tue Nov 30 11:54:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin X-Patchwork-Id: 12647041 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77E56C433FE for ; Tue, 30 Nov 2021 11:55:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241153AbhK3L7K (ORCPT ); Tue, 30 Nov 2021 06:59:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236368AbhK3L60 (ORCPT ); Tue, 30 Nov 2021 06:58:26 -0500 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52A23C061574 for ; Tue, 30 Nov 2021 03:55:02 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id p27-20020a05600c1d9b00b0033bf8532855so14566611wms.3 for ; Tue, 30 Nov 2021 03:55:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=Zl2vUbDhqmmWJ8RnUA4Mik2HNxETj5S1M012xd3a9wU=; b=pXQUBFPN+/jWlnSmoZD8f5guPLuow+8HxYcZ5FBY+jNa1aJfGJRyauHumFisAiS222 XREd9usEAhKG8oajpH2GgJ8Ga1FeIKNUMr+wAFDQQfOKoi3jCEZ+6dlBKBKfpMcRf6QJ 0GXvKBT5/JlizloThNJGrpnolPoe+OaepXBij9gl5aYB9eXg+fBfCKXs5ioOEHUiX7Qr 1QBSL3Y0b+w6OCeznlFabzEsKDfZdmyNgNtiAXK7V0Q4bJYM7fBjrYNoJNqUEBNUmAXy 4+nDmSWQxe4Z5RXPgOJTddJaOdlsiQIcLZOME18N03Q4NSAWoTmEnPpOS+FzMlZThdCC xW6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=Zl2vUbDhqmmWJ8RnUA4Mik2HNxETj5S1M012xd3a9wU=; b=6FwQ4sh19qfMZ9sJB8iRctLX/TIv/caR+48NVEj3hXj87ddZeTQitQx9dztHi51V+r mVloQBF8oQ9MV3aaCgmL7oZ0LwxU2SLangMz1B4XhwO4OOOwuf9uT9ZWZU/lgRNjXX6F ShXTiWgFGzzI/JwYrqyIjR/HSiEmZpJVmG22HxYVTXGbniBXuPvfZKxlgcWNSsANol01 Rmle8wicj1vwzUZ5Y01RD47ufTcBocvYgqrOLrivl4XwS/Zk6DCcR2cPSiF3kPFelncV oeLIdZVG0g0mt+t4IZA9B2yyZq1z5KRE0CGWY1hmfSXhVfqvVTLsTYe9haxyWJbxUbnH GMxw== X-Gm-Message-State: AOAM532nVJ+s3X9/zxt+2E/DQtW02nLWqVTf4w15kJZyx3I6ZQlua5Si MA9Z8HCZTZqWd1kHU60OAM8SYkCZTPo= X-Google-Smtp-Source: ABdhPJwP4WCsRyD/dQ0wn5flBJaQZvkk9XUG6b8jsYB15ImmDc0R2fiHy4W82tXBNJaoRJ3UcRUUsQ== X-Received: by 2002:a7b:c94e:: with SMTP id i14mr4364816wml.85.1638273300783; Tue, 30 Nov 2021 03:55:00 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id k187sm1788497wme.0.2021.11.30.03.55.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Nov 2021 03:55:00 -0800 (PST) Message-Id: <08e4f548aa83bd636bffb51e19f58a7cc0f9967d.1638273289.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 30 Nov 2021 11:54:46 +0000 Subject: [PATCH v9 14/17] scalar: allow reconfiguring an existing enlistment Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Derrick Stolee , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Elijah Newren , Bagas Sanjaya , Theodore Ts'o , Matt Rogers , Johannes Schindelin , Johannes Schindelin Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin From: Johannes Schindelin This comes in handy during Scalar upgrades, or when config settings were messed up by mistake. Signed-off-by: Johannes Schindelin --- contrib/scalar/scalar.c | 79 +++++++++++++++++++++----------- contrib/scalar/scalar.txt | 8 ++++ contrib/scalar/t/t9099-scalar.sh | 8 ++++ 3 files changed, 67 insertions(+), 28 deletions(-) diff --git a/contrib/scalar/scalar.c b/contrib/scalar/scalar.c index fa900e4373f..d7306b43cae 100644 --- a/contrib/scalar/scalar.c +++ b/contrib/scalar/scalar.c @@ -108,18 +108,20 @@ static int run_git(const char *arg, ...) return res; } -static int set_recommended_config(void) +static int set_recommended_config(int reconfigure) { struct { const char *key; const char *value; + int overwrite_on_reconfigure; } config[] = { - { "am.keepCR", "true" }, - { "core.FSCache", "true" }, - { "core.multiPackIndex", "true" }, - { "core.preloadIndex", "true" }, + /* Required */ + { "am.keepCR", "true", 1 }, + { "core.FSCache", "true", 1 }, + { "core.multiPackIndex", "true", 1 }, + { "core.preloadIndex", "true", 1 }, #ifndef WIN32 - { "core.untrackedCache", "true" }, + { "core.untrackedCache", "true", 1 }, #else /* * 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 * feature on Windows. */ - { "core.untrackedCache", "false" }, + { "core.untrackedCache", "false", 1 }, #endif - { "core.logAllRefUpdates", "true" }, - { "credential.https://dev.azure.com.useHttpPath", "true" }, - { "credential.validate", "false" }, /* GCM4W-only */ - { "gc.auto", "0" }, - { "gui.GCWarning", "false" }, - { "index.threads", "true" }, - { "index.version", "4" }, - { "merge.stat", "false" }, - { "merge.renames", "true" }, - { "pack.useBitmaps", "false" }, - { "pack.useSparse", "true" }, - { "receive.autoGC", "false" }, - { "reset.quiet", "true" }, - { "feature.manyFiles", "false" }, - { "feature.experimental", "false" }, - { "fetch.unpackLimit", "1" }, - { "fetch.writeCommitGraph", "false" }, + { "core.logAllRefUpdates", "true", 1 }, + { "credential.https://dev.azure.com.useHttpPath", "true", 1 }, + { "credential.validate", "false", 1 }, /* GCM4W-only */ + { "gc.auto", "0", 1 }, + { "gui.GCWarning", "false", 1 }, + { "index.threads", "true", 1 }, + { "index.version", "4", 1 }, + { "merge.stat", "false", 1 }, + { "merge.renames", "true", 1 }, + { "pack.useBitmaps", "false", 1 }, + { "pack.useSparse", "true", 1 }, + { "receive.autoGC", "false", 1 }, + { "reset.quiet", "true", 1 }, + { "feature.manyFiles", "false", 1 }, + { "feature.experimental", "false", 1 }, + { "fetch.unpackLimit", "1", 1 }, + { "fetch.writeCommitGraph", "false", 1 }, #ifdef WIN32 - { "http.sslBackend", "schannel" }, + { "http.sslBackend", "schannel", 1 }, #endif + /* Optional */ { "status.aheadBehind", "false" }, { "commitGraph.generationVersion", "1" }, { "core.autoCRLF", "false" }, @@ -166,7 +169,8 @@ static int set_recommended_config(void) char *value; 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"); if (git_config_set_gently(config[i].key, config[i].value) < 0) @@ -231,7 +235,7 @@ static int register_dir(void) int res = add_or_remove_enlistment(1); if (!res) - res = set_recommended_config(); + res = set_recommended_config(0); if (!res) 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))) goto cleanup; - if (set_recommended_config()) + if (set_recommended_config(0)) return error(_("could not configure '%s'"), dir); if ((res = run_git("fetch", "--quiet", "origin", NULL))) { @@ -484,6 +488,24 @@ static int cmd_register(int argc, const char **argv) return register_dir(); } +static int cmd_reconfigure(int argc, const char **argv) +{ + struct option options[] = { + OPT_END(), + }; + const char * const usage[] = { + N_("scalar reconfigure []"), + 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) { struct option options[] = { @@ -620,6 +642,7 @@ static struct { { "register", cmd_register }, { "unregister", cmd_unregister }, { "run", cmd_run }, + { "reconfigure", cmd_reconfigure }, { NULL, NULL}, }; diff --git a/contrib/scalar/scalar.txt b/contrib/scalar/scalar.txt index 39143b08324..89fd7901585 100644 --- a/contrib/scalar/scalar.txt +++ b/contrib/scalar/scalar.txt @@ -13,6 +13,7 @@ scalar list scalar register [] scalar unregister [] scalar run ( all | config | commit-graph | fetch | loose-objects | pack-files ) [] +scalar reconfigure 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` 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 -------- linkgit:git-clone[1], linkgit:git-maintenance[1]. diff --git a/contrib/scalar/t/t9099-scalar.sh b/contrib/scalar/t/t9099-scalar.sh index f60e086d6f9..fb5e2efee0a 100755 --- a/contrib/scalar/t/t9099-scalar.sh +++ b/contrib/scalar/t/t9099-scalar.sh @@ -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