git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 1/5] scalar: annotate config file with "set by scalar"

From
Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>
Date
Dec 1, 2025, 16:50 UTC
Message-ID
<639ff98c44c45bb570fdde5123127aa099c299f8.1764607847.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.2010.v2.git.1764607847.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          | 18 ++++++++++++++----
 t/t9210-scalar.sh |  3 +++
 2 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/scalar.c b/scalar.c
index f754311627..be3878948d 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,6 +96,16 @@ struct scalar_config {
 	int overwrite_on_reconfigure;
 };
 
+static int set_config_with_comment(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_scalar_config(const struct scalar_config *config, int reconfigure)
 {
 	char *value = NULL;
@@ -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_config_with_comment(config->key, config->value);
 	} else {
 		trace2_data_string("scalar", the_repository, config->key, "exists");
 		res = 0;
@@ -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_config_with_comment("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
Previous: Derrick Stolee via GitGitGadgetNext: Patrick Steinhardt
Message 20 of 48 in “Audit and document Scalar config”
  1. 0/5 Audit and document Scalar configDerrick Stolee via GitGitGadget, Nov 26, 2025
  2. 1/5 scalar: annotate config file with "set by scalar"Derrick Stolee via GitGitGadget, Nov 26, 2025
  3. Junio C HamanoNov 26, 2025
  4. Patrick SteinhardtDec 1, 2025
  5. 2/5 scalar: use index.skipHash=true for performanceDerrick Stolee via GitGitGadget, Nov 26, 2025
  6. Junio C HamanoNov 26, 2025
  7. Derrick StoleeNov 30, 2025
  8. 3/5 scalar: remove stale config valuesDerrick Stolee via GitGitGadget, Nov 26, 2025
  9. Junio C HamanoNov 27, 2025
  10. 4/5 scalar: alphabetize and simplify configDerrick Stolee via GitGitGadget, Nov 26, 2025
  11. Patrick SteinhardtDec 1, 2025
  12. Derrick StoleeDec 1, 2025
  13. 5/5 scalar: document config settingsDerrick Stolee via GitGitGadget, Nov 26, 2025
  14. Junio C HamanoNov 27, 2025
  15. Derrick StoleeNov 30, 2025
  16. Patrick SteinhardtDec 1, 2025
  17. Derrick StoleeDec 1, 2025
  18. Johannes SchindelinDec 1, 2025
  19. 0/5 Audit and document Scalar configDerrick Stolee via GitGitGadget, Dec 1, 2025
  20. 1/5 scalar: annotate config file with "set by scalar"Derrick Stolee via GitGitGadget, Dec 1, 2025
  21. Patrick SteinhardtDec 2, 2025
  22. 2/5 scalar: use index.skipHash=true for performanceDerrick Stolee via GitGitGadget, Dec 1, 2025
  23. 3/5 scalar: remove stale config valuesDerrick Stolee via GitGitGadget, Dec 1, 2025
  24. Matthew HughesDec 1, 2025
  25. Patrick SteinhardtDec 2, 2025
  26. Matthew HughesDec 2, 2025
  27. Patrick SteinhardtDec 2, 2025
  28. Junio C HamanoDec 7, 2025
  29. Patrick SteinhardtDec 8, 2025
  30. Derrick StoleeDec 12, 2025
  31. 4/5 scalar: alphabetize and simplify configDerrick Stolee via GitGitGadget, Dec 1, 2025
  32. 5/5 scalar: document config settingsDerrick Stolee via GitGitGadget, Dec 1, 2025
  33. Matthew HughesDec 1, 2025
  34. Patrick SteinhardtDec 2, 2025
  35. Henrique FerreiroDec 11, 2025
  36. Derrick StoleeDec 12, 2025
  37. Henrique FerreiroDec 15, 2025
  38. Junio C HamanoDec 2, 2025
  39. 0/5 Audit and document Scalar configDerrick Stolee via GitGitGadget, Dec 12, 2025
  40. 1/5 scalar: annotate config file with "set by scalar"Derrick Stolee via GitGitGadget, Dec 12, 2025
  41. 2/5 scalar: use index.skipHash=true for performanceDerrick Stolee via GitGitGadget, Dec 12, 2025
  42. 3/5 scalar: remove stale config valuesDerrick Stolee via GitGitGadget, Dec 12, 2025
  43. 4/5 scalar: alphabetize and simplify configDerrick Stolee via GitGitGadget, Dec 12, 2025
  44. 5/5 scalar: document config settingsDerrick Stolee via GitGitGadget, Dec 12, 2025
  45. Henrique FerreiroDec 15, 2025
  46. Junio C HamanoDec 12, 2025
  47. Derrick StoleeDec 15, 2025
  48. Junio C HamanoDec 16, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.