Skip to contentSkip to conversation

how to find options set by scalar?

QUESTION Matthew Hughes 4 participants 8 messages Sep 16, 2025 – Oct 19, 2025

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw
Quoted 14 lines · Matthew Hughes

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.

Quoted 2 lines

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:

scalar.c +5 -1
index 4a373c133d..c69ec57374 100644
@@ -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

#2 lore raw
Quoted 3 lines

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.

#3 lore raw
Quoted 4 lines · Matthew Hughes

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.

#4 lore raw
Quoted 8 lines · Junio C Hamano
Quoted 4 lines · Matthew Hughes

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

#5 lore raw
Quoted 17 lines · Derrick Stolee
Quoted 8 lines · Junio C Hamano
Quoted 4 lines · Matthew Hughes

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.

Quoted 5 lines

[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

#6 lore raw
Quoted 24 lines · Patrick Steinhardt
Quoted 17 lines · Derrick Stolee
Quoted 8 lines · Junio C Hamano
Quoted 4 lines · Matthew Hughes

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.

Quoted 5 lines

[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.

Quoted 6 lines

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

#7 lore raw
Quoted 1 line · Derrick Stolee

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

Thanks,
Matt