From: "Derrick Stolee via GitGitGadget" <gitgitgadget@gmail•com>
To: git@vger•kernel.org
Cc: gitster@pobox•com, ps@pks•im, atthewhughes934@gmail•com,
johannes.schindelin@gmx•de,
Matthew Hughes <matthewhughes934@gmail•com>,
Henrique Ferreiro <hferreiro@igalia•com>,
Derrick Stolee <stolee@gmail•com>,
Derrick Stolee <stolee@gmail•com>
Subject: [PATCH v3 1/5] scalar: annotate config file with "set by scalar"
Date: Fri, 12 Dec 2025 15:15:24 +0000 [thread overview]
Message-ID: <7a2f919d7c610ce7c9e93682884212ebee34d9b5.1765552528.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.2010.v3.git.1765552528.gitgitgadget@gmail.com>
From: Derrick Stolee <stolee@gmail•com>
A repo may have config options set by 'scalar clone' or 'scalar
register' and then updated by 'scalar reconfigure'. It can be helpful to
point out which of those options were set by the latest scalar
recommendations.
Add "# set by scalar" to the end of each config option to assist users
in identifying why these config options were set in their repo. Use a new
helper method to simplify the two callsites.
Co-authored-by: Patrick Steinhardt <ps@pks•im>
Signed-off-by: Patrick Steinhardt <ps@pks•im>
Signed-off-by: Derrick Stolee <stolee@gmail•com>
---
scalar.c | 24 +++++++++++++++++-------
t/t9210-scalar.sh | 3 +++
2 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/scalar.c b/scalar.c
index f754311627..1c7bd1a8f8 100644
--- a/scalar.c
+++ b/scalar.c
@@ -19,6 +19,7 @@
#include "help.h"
#include "setup.h"
#include "trace2.h"
+#include "path.h"
static void setup_enlistment_directory(int argc, const char **argv,
const char * const *usagestr,
@@ -95,7 +96,17 @@ struct scalar_config {
int overwrite_on_reconfigure;
};
-static int set_scalar_config(const struct scalar_config *config, int reconfigure)
+static int set_scalar_config(const char *key, const char *value)
+{
+ char *file = repo_git_path(the_repository, "config");
+ int res = repo_config_set_multivar_in_file_gently(the_repository, file,
+ key, value, NULL,
+ " # set by scalar", 0);
+ free(file);
+ return res;
+}
+
+static int set_config_if_missing(const struct scalar_config *config, int reconfigure)
{
char *value = NULL;
int res;
@@ -103,7 +114,7 @@ static int set_scalar_config(const struct scalar_config *config, int reconfigure
if ((reconfigure && config->overwrite_on_reconfigure) ||
repo_config_get_string(the_repository, config->key, &value)) {
trace2_data_string("scalar", the_repository, config->key, "created");
- res = repo_config_set_gently(the_repository, config->key, config->value);
+ res = set_scalar_config(config->key, config->value);
} else {
trace2_data_string("scalar", the_repository, config->key, "exists");
res = 0;
@@ -178,14 +189,14 @@ static int set_recommended_config(int reconfigure)
char *value;
for (i = 0; config[i].key; i++) {
- if (set_scalar_config(config + i, reconfigure))
+ if (set_config_if_missing(config + i, reconfigure))
return error(_("could not configure %s=%s"),
config[i].key, config[i].value);
}
if (have_fsmonitor_support()) {
struct scalar_config fsmonitor = { "core.fsmonitor", "true" };
- if (set_scalar_config(&fsmonitor, reconfigure))
+ if (set_config_if_missing(&fsmonitor, reconfigure))
return error(_("could not configure %s=%s"),
fsmonitor.key, fsmonitor.value);
}
@@ -197,9 +208,8 @@ static int set_recommended_config(int reconfigure)
if (repo_config_get_string(the_repository, "log.excludeDecoration", &value)) {
trace2_data_string("scalar", the_repository,
"log.excludeDecoration", "created");
- if (repo_config_set_multivar_gently(the_repository, "log.excludeDecoration",
- "refs/prefetch/*",
- CONFIG_REGEX_NONE, 0))
+ if (set_scalar_config("log.excludeDecoration",
+ "refs/prefetch/*"))
return error(_("could not configure "
"log.excludeDecoration"));
} else {
diff --git a/t/t9210-scalar.sh b/t/t9210-scalar.sh
index bd6f0c40d2..43c210a23d 100755
--- a/t/t9210-scalar.sh
+++ b/t/t9210-scalar.sh
@@ -210,6 +210,9 @@ test_expect_success 'scalar reconfigure' '
GIT_TRACE2_EVENT="$(pwd)/reconfigure" scalar reconfigure -a &&
test_path_is_file one/src/cron.txt &&
test true = "$(git -C one/src config core.preloadIndex)" &&
+ test_grep "preloadIndex = true # set by scalar" one/src/.git/config &&
+ test_grep "excludeDecoration = refs/prefetch/\* # set by scalar" one/src/.git/config &&
+
test_subcommand git maintenance start <reconfigure &&
test_subcommand ! git maintenance unregister --force <reconfigure &&
--
gitgitgadget
next prev parent reply other threads:[~2025-12-12 15:15 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-26 22:18 [PATCH 0/5] Audit and document Scalar config Derrick Stolee via GitGitGadget
2025-11-26 22:18 ` [PATCH 1/5] scalar: annotate config file with "set by scalar" Derrick Stolee via GitGitGadget
2025-11-26 23:55 ` Junio C Hamano
2025-12-01 8:55 ` Patrick Steinhardt
2025-11-26 22:18 ` [PATCH 2/5] scalar: use index.skipHash=true for performance Derrick Stolee via GitGitGadget
2025-11-26 23:57 ` Junio C Hamano
2025-11-30 19:55 ` Derrick Stolee
2025-11-26 22:18 ` [PATCH 3/5] scalar: remove stale config values Derrick Stolee via GitGitGadget
2025-11-27 0:00 ` Junio C Hamano
2025-11-26 22:18 ` [PATCH 4/5] scalar: alphabetize and simplify config Derrick Stolee via GitGitGadget
2025-12-01 8:55 ` Patrick Steinhardt
2025-12-01 12:35 ` Derrick Stolee
2025-11-26 22:18 ` [PATCH 5/5] scalar: document config settings Derrick Stolee via GitGitGadget
2025-11-27 0:09 ` Junio C Hamano
2025-11-30 19:56 ` Derrick Stolee
2025-12-01 8:55 ` Patrick Steinhardt
2025-12-01 12:40 ` Derrick Stolee
2025-12-01 14:04 ` [PATCH 0/5] Audit and document Scalar config Johannes Schindelin
2025-12-01 16:50 ` [PATCH v2 " Derrick Stolee via GitGitGadget
2025-12-01 16:50 ` [PATCH v2 1/5] scalar: annotate config file with "set by scalar" Derrick Stolee via GitGitGadget
2025-12-02 7:53 ` Patrick Steinhardt
2025-12-01 16:50 ` [PATCH v2 2/5] scalar: use index.skipHash=true for performance Derrick Stolee via GitGitGadget
2025-12-01 16:50 ` [PATCH v2 3/5] scalar: remove stale config values Derrick Stolee via GitGitGadget
2025-12-01 17:46 ` Matthew Hughes
2025-12-02 7:53 ` Patrick Steinhardt
2025-12-02 19:04 ` Matthew Hughes
2025-12-02 19:22 ` Patrick Steinhardt
2025-12-07 0:34 ` Junio C Hamano
2025-12-08 6:58 ` Patrick Steinhardt
2025-12-12 13:57 ` Derrick Stolee
2025-12-01 16:50 ` [PATCH v2 4/5] scalar: alphabetize and simplify config Derrick Stolee via GitGitGadget
2025-12-01 16:50 ` [PATCH v2 5/5] scalar: document config settings Derrick Stolee via GitGitGadget
2025-12-01 17:58 ` Matthew Hughes
2025-12-02 7:53 ` Patrick Steinhardt
2025-12-11 14:20 ` Henrique Ferreiro
2025-12-12 14:06 ` Derrick Stolee
2025-12-15 12:14 ` Henrique Ferreiro
2025-12-02 2:05 ` [PATCH v2 0/5] Audit and document Scalar config Junio C Hamano
2025-12-12 15:15 ` [PATCH v3 " Derrick Stolee via GitGitGadget
2025-12-12 15:15 ` Derrick Stolee via GitGitGadget [this message]
2025-12-12 15:15 ` [PATCH v3 2/5] scalar: use index.skipHash=true for performance Derrick Stolee via GitGitGadget
2025-12-12 15:15 ` [PATCH v3 3/5] scalar: remove stale config values Derrick Stolee via GitGitGadget
2025-12-12 15:15 ` [PATCH v3 4/5] scalar: alphabetize and simplify config Derrick Stolee via GitGitGadget
2025-12-12 15:15 ` [PATCH v3 5/5] scalar: document config settings Derrick Stolee via GitGitGadget
2025-12-15 12:33 ` Henrique Ferreiro
2025-12-12 23:49 ` [PATCH v3 0/5] Audit and document Scalar config Junio C Hamano
2025-12-15 14:33 ` Derrick Stolee
2025-12-16 0:39 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7a2f919d7c610ce7c9e93682884212ebee34d9b5.1765552528.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail$(echo .)com \
--cc=atthewhughes934@gmail$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
--cc=gitster@pobox$(echo .)com \
--cc=hferreiro@igalia$(echo .)com \
--cc=johannes.schindelin@gmx$(echo .)de \
--cc=matthewhughes934@gmail$(echo .)com \
--cc=ps@pks$(echo .)im \
--cc=stolee@gmail$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox