[PATCH 1/5] scalar: annotate config file with "set by scalar"
- From
Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>
- Date
- Nov 26, 2025, 22:18 UTC
- Message-ID
- <a4ad8f80d062cd9fc62db69c21625eb286f4ebb8.1764195516.git.gitgitgadget@gmail.com>
- In-Reply-To
- <pull.2010.git.1764195516.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.
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 | 16 +++++++++++++--- t/t9210-scalar.sh | 3 +++ 2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/scalar.c b/scalar.c index f754311627..431b631585 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, @@ -99,16 +100,20 @@ static int set_scalar_config(const struct scalar_config *config, int reconfigure { char *value = NULL; int res; + char *file = repo_git_path(the_repository, "config"); 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 = repo_config_set_multivar_in_file_gently(the_repository, file, config->key, + config->value, NULL, + " # set by scalar", 0); } else { trace2_data_string("scalar", the_repository, config->key, "exists"); res = 0; } + free(file); free(value); return res; } @@ -195,13 +200,18 @@ static int set_recommended_config(int reconfigure) * for multiple values. */ if (repo_config_get_string(the_repository, "log.excludeDecoration", &value)) { + char *file = repo_git_path(the_repository, "config"); trace2_data_string("scalar", the_repository, "log.excludeDecoration", "created"); - if (repo_config_set_multivar_gently(the_repository, "log.excludeDecoration", + if (repo_config_set_multivar_in_file_gently(the_repository, file, + "log.excludeDecoration", "refs/prefetch/*", - CONFIG_REGEX_NONE, 0)) + CONFIG_REGEX_NONE, + " # set by scalar", + 0)) return error(_("could not configure " "log.excludeDecoration")); + free(file); } else { trace2_data_string("scalar", the_repository, "log.excludeDecoration", "exists"); 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