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

Re: [QUESTION] how to find options set by scalar?

From
Patrick Steinhardt <ps@pks.im>
Date
Sep 16, 2025, 07:45 UTC
Message-ID
<aMkVqNbdgxqBJ9K4@pks.im>
In-Reply-To
<vppjutjcdglp44qvsk4qozphycyg663yrq5775zztim2oe7ty5@uttjrshb52bd>
On Tue, Sep 16, 2025 at 07:21:21AM +0100, Matthew Hughes wrote:
Show 16 quoted lines
> Hi,
> 
> I'm wondering about making the config options set by `scalar register` a bit
> more discoverable.
> 
> Background: I was recently working in a large repo that recommended I run
> `scalar register` to help make git run a bit more smoothly, and I did (and
> didn't think much of it and forgot about it). It was a couple of weeks later I
> was again working in this repo and wanted to update my config, but was a bit
> confused when I saw a bunch of things set that I didn't remember setting, e.g.
> 'status.aheadBehind false'. It took me remembering that I had run `scalar
> register` and some poking around the code to discover where these options had
> come from.
> 
> I'm not sure if this is something best addressed by documentation, or maybe by
> `scalar register` adding comments to the config lines it changes?

I think documentation wouldn't help much -- the config entries we set may change over time, so at the point in time where the user reads the documentation it may already list entries that we either don't set at all anymore or that we started setting now. So these config entries that scalar(1) did set and the config entries that its man page claims to set will diverge over time.

But doing this via comments may be viable indeed. A start for such a change could be the following patch, which causes us to write a comment "# set by scalar" after every config that we set in the repository:

diff --git a/scalar.c b/scalar.c
index 4a373c133d..c69ec57374 100644
--- a/scalar.c
+++ b/scalar.c
@@ -8,6 +8,7 @@
 #include "abspath.h"
 #include "gettext.h"
 #include "parse-options.h"
+#include "path.h"
 #include "config.h"
 #include "run-command.h"
 #include "simple-ipc.h"
@@ -102,8 +103,11 @@ 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)) {
+		char *file = repo_git_path(the_repository, "config");
 		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);
+		free(file);
 	} else {
 		trace2_data_string("scalar", the_repository, config->key, "exists");
 		res = 0;

With that change in place, a (subset of) ".git/config" file would look
like this:

    [extensions]
        refstorage = reftable
    [core]
        repositoryformatversion = 1
        filemode = true
        bare = false
        logallrefupdates = true
        FSCache = true # set by scalar
        multiPackIndex = true # set by scalar
        preloadIndex = true # set by scalar
        untrackedCache = true # set by scalar
        autoCRLF = false # set by scalar
        safeCRLF = false # set by scalar
    [am]
        keepCR = true # set by scalar

Which I think is quite helpful overall. This cannot grow stale over time
and it's immediately obvious which entries have been set up by scalar in
case the user wants to drop them again.

Cc'ing Stolee, the primary author of scalar(1).

Patrick
Previous: Matthew HughesNext: Matthew Hughes
Message 2 of 8 in “[QUESTION] how to find options set by scalar?”
  1. Matthew HughesSep 16, 2025
  2. Patrick SteinhardtSep 16, 2025
  3. Matthew HughesSep 18, 2025
  4. Junio C HamanoSep 18, 2025
  5. Derrick StoleeSep 19, 2025
  6. Patrick SteinhardtSep 22, 2025
  7. Derrick StoleeSep 22, 2025
  8. Matthew HughesOct 19, 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.