Re: [PATCH 1/5] scalar: annotate config file with "set by scalar"
From: Junio C Hamano <hidden>
Date: 2025-11-26 23:55:13
"Derrick Stolee via GitGitGadget" [off-list ref] writes:
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.
The implementation is quite straight-forward, inlining expansion of
repo_config_set_gently() in the places that we want to add comment to.
If we had (a lot) more than two callsites, I would have suggested to
add a simple helper function, something like
static int scalar_config_set(struct repository *r, const char *key, const char *value)
{
char *file = repo_git_path(r, "config");
int res = repo_config_set_multivar_in_file_gently(r, file,
key, value, NULL, " # set by scalar", 0);
free(file);
return res;
}
and then the updates to the callers would have been absolute minimum.
Well, even with only two callsites, perhaps such a refactoring may
still have value in reducing the risk of typo in the comment.
quoted hunk
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 &&
Looks good.