threads / discuss / 64152

[QUESTION] how to find options set by scalar?

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

## tl;dr

8 messages between Sep 16, 2025 and Oct 19, 2025.

replies: 7people: 4as markdown or json

Matthew Hughes· Sep 16, 2025, 06:21 UTC · lore
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?

Thanks, Matt

Patrick Steinhardt· Sep 16, 2025, 07:45 UTC · re: Matthew Hughes · lore

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

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
Matthew Hughes· Sep 18, 2025, 19:32 UTC · re: Patrick Steinhardt · lore

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

> 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:

Agreed, I think this would be very helpful to have! I'd be happy to submit a patch.

I was also looking through the list of config options (within `set_recommended_config`) and thought it might also be useful to comment why each those settings are recommended in the context of working within a large repository. These comments would just be in-line in the code for those curious enough (I think it would be a bit noisy for general use as comments within the config itself) I might dig a bit into the history here, from what I understand it started as a separated project[1] before being added to `git-for-windows`[2] before being merged into `git/git`, are there any other bits I missed?

I see there may be some relics from the history that may not be generally applicable, e.g. setting `credential.https://dev.azure.com.useHttpPath`.

Link: https://github.com/microsoft/scalar [1]
Link: https://github.com/git-for-windows/git [2]
Junio C Hamano· Sep 18, 2025, 20:29 UTC · re: Matthew Hughes · lore

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

Matthew Hughes <matthewhughes934@gmail.com> writes:
> I was also looking through the list of config options (within
> `set_recommended_config`) and thought it might also be useful to comment why
> each those settings are recommended in the context of working within a large
> repository.
That would be ultra useful.
Derrick Stolee· Sep 19, 2025, 15:38 UTC · re: Junio C Hamano · lore

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

On 9/18/2025 4:29 PM, Junio C Hamano wrote:
Show 8 quoted lines
> Matthew Hughes <matthewhughes934@gmail.com> writes:
> 
>> I was also looking through the list of config options (within
>> `set_recommended_config`) and thought it might also be useful to comment why
>> each those settings are recommended in the context of working within a large
>> repository.
> 
> That would be ultra useful.

I think all of these ideas are good ones. Adding the comment as Patrick described is good, for sure.

Instead of commenting the _reason_ in code or in the config, it would be good to list the reasons for each recommended config in the Scalar docs so they would be visible in web docs [1] for easy discovery.

[1] https://git-scm.com/docs/scalar

It seems like Patrick is already 80% of the way to a patch for the comment in the config. I'll see if I can carve out some time next week for the commentary on the config options in the Documentation.

Thanks, -Stolee

Patrick Steinhardt· Sep 22, 2025, 06:20 UTC · re: Derrick Stolee · lore

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

On Fri, Sep 19, 2025 at 11:38:50AM -0400, Derrick Stolee wrote:
Show 22 quoted lines
> On 9/18/2025 4:29 PM, Junio C Hamano wrote:
> > Matthew Hughes <matthewhughes934@gmail.com> writes:
> > 
> >> I was also looking through the list of config options (within
> >> `set_recommended_config`) and thought it might also be useful to comment why
> >> each those settings are recommended in the context of working within a large
> >> repository.
> > 
> > That would be ultra useful.
> 
> I think all of these ideas are good ones. Adding the comment as Patrick
> described is good, for sure.
> 
> Instead of commenting the _reason_ in code or in the config, it would be
> good to list the reasons for each recommended config in the Scalar docs
> so they would be visible in web docs [1] for easy discovery.
> 
> [1] https://git-scm.com/docs/scalar
> 
> It seems like Patrick is already 80% of the way to a patch for the
> comment in the config. I'll see if I can carve out some time next week
> for the commentary on the config options in the Documentation.

Agreed, that seems like a good compromise: we note in the config the values that were set by scalar(1), but the more verbose justification would be part of the docs.

I'm a bit stretched right now, so if you want to work on this please feel free to just pick my patch and iterate on it.

Thanks!
Patrick
Derrick Stolee· Sep 22, 2025, 13:36 UTC · re: Patrick Steinhardt · lore

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

On 9/22/2025 2:20 AM, Patrick Steinhardt wrote:
Show 30 quoted lines
> On Fri, Sep 19, 2025 at 11:38:50AM -0400, Derrick Stolee wrote:
>> On 9/18/2025 4:29 PM, Junio C Hamano wrote:
>>> Matthew Hughes <matthewhughes934@gmail.com> writes:
>>>
>>>> I was also looking through the list of config options (within
>>>> `set_recommended_config`) and thought it might also be useful to comment why
>>>> each those settings are recommended in the context of working within a large
>>>> repository.
>>>
>>> That would be ultra useful.
>>
>> I think all of these ideas are good ones. Adding the comment as Patrick
>> described is good, for sure.
>>
>> Instead of commenting the _reason_ in code or in the config, it would be
>> good to list the reasons for each recommended config in the Scalar docs
>> so they would be visible in web docs [1] for easy discovery.
>>
>> [1] https://git-scm.com/docs/scalar
>>
>> It seems like Patrick is already 80% of the way to a patch for the
>> comment in the config. I'll see if I can carve out some time next week
>> for the commentary on the config options in the Documentation.
> 
> Agreed, that seems like a good compromise: we note in the config the
> values that were set by scalar(1), but the more verbose justification
> would be part of the docs.
> 
> I'm a bit stretched right now, so if you want to work on this please
> feel free to just pick my patch and iterate on it.
Makes sense. I'll pick up your patch into my series as I prepare it.

Thanks, -Stolee

Matthew Hughes· Oct 19, 2025, 17:43 UTC · re: Derrick Stolee · lore

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

On Mon, Sep 22, 2025 at 09:36:00AM -0400, Derrick Stolee wrote:
> Makes sense. I'll pick up your patch into my series as I prepare it.

I'm not sure if you had a chance to start working on this (I didn't see any other activity around this on the mailing list, but shout-out if I missed something!). But I got curious and started looking into some of the options and had some questions (I haven't do much archaeology on the original Scalar repo[1], so if I should just go dig around there for more answers let me know).

Firstly, there are a couple of options specific to things outside this repo:
* core.FSCache: specific for git-for-windows[2]
* credential.validate: specific to Git-Credential-Manager-for-Windows[3]

Could these possibly be removed from here (I understand scalar started as an external project, so these are perhaps a relic of that)?

Secondly, I was curious around some of the CRLF options, in particular, setting:
* am.keepCR=true
* core.autoCRLF=false
* core.safeCRLF=false

Is there a non-trival cost to doing conversions over a large enough number of files?

GC bits: I there is some GC automation disabled:
* gc.auto=0
* gui.GCWwarning=false
* receive.autoGC=false

What's the reason for this? Is garbage collection expected to be unreasonably slow in a large repo? Is it worth the GC still being run at least occasionally in a large repo?

Index bits: scalar will set index.threads=true, index.version=4: I assume these are expected to just speed up most read operations on in the index in general? It also disable index.skipHash: the docs tells me this speeds up commands that manipulate the index, but I was wondering if having this trailing hash can make future _reads_ more efficient?

And more generally, I'm not sure I understand the reasons for the following settings in the context of a large repo:

* pack.useBitmaps=false
* fetch.writeCommitGraph=false
* status.aheadBehind=false
* merge.stat=false
* commitGraph.generationVersion=false 
* fetch.showForcedUpdates=false
Link: https://github.com/microsoft/scalar [1]
Link: https://github.com/git-for-windows [2]
Link: https://github.com/microsoft/Git-Credential-Manager-for-Windows [3]

Thanks, Matt

← back to recent threads