git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [QUESTION] how to find options set by scalar?
@ 2025-09-16  6:21 Matthew Hughes
  2025-09-16  7:45 ` Patrick Steinhardt
  0 siblings, 1 reply; 8+ messages in thread
From: Matthew Hughes @ 2025-09-16  6:21 UTC (permalink / raw)
  To: git

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [QUESTION] how to find options set by scalar?
  2025-09-16  6:21 [QUESTION] how to find options set by scalar? Matthew Hughes
@ 2025-09-16  7:45 ` Patrick Steinhardt
  2025-09-18 19:32   ` Matthew Hughes
  0 siblings, 1 reply; 8+ messages in thread
From: Patrick Steinhardt @ 2025-09-16  7:45 UTC (permalink / raw)
  To: Matthew Hughes; +Cc: git, Derrick Stolee

On Tue, Sep 16, 2025 at 07:21:21AM +0100, Matthew Hughes wrote:
> 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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [QUESTION] how to find options set by scalar?
  2025-09-16  7:45 ` Patrick Steinhardt
@ 2025-09-18 19:32   ` Matthew Hughes
  2025-09-18 20:29     ` Junio C Hamano
  0 siblings, 1 reply; 8+ messages in thread
From: Matthew Hughes @ 2025-09-18 19:32 UTC (permalink / raw)
  To: Patrick Steinhardt; +Cc: git, Derrick Stolee

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [QUESTION] how to find options set by scalar?
  2025-09-18 19:32   ` Matthew Hughes
@ 2025-09-18 20:29     ` Junio C Hamano
  2025-09-19 15:38       ` Derrick Stolee
  0 siblings, 1 reply; 8+ messages in thread
From: Junio C Hamano @ 2025-09-18 20:29 UTC (permalink / raw)
  To: Matthew Hughes; +Cc: Patrick Steinhardt, git, Derrick Stolee

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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [QUESTION] how to find options set by scalar?
  2025-09-18 20:29     ` Junio C Hamano
@ 2025-09-19 15:38       ` Derrick Stolee
  2025-09-22  6:20         ` Patrick Steinhardt
  0 siblings, 1 reply; 8+ messages in thread
From: Derrick Stolee @ 2025-09-19 15:38 UTC (permalink / raw)
  To: Junio C Hamano, Matthew Hughes; +Cc: Patrick Steinhardt, git

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.

Thanks,
-Stolee


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [QUESTION] how to find options set by scalar?
  2025-09-19 15:38       ` Derrick Stolee
@ 2025-09-22  6:20         ` Patrick Steinhardt
  2025-09-22 13:36           ` Derrick Stolee
  0 siblings, 1 reply; 8+ messages in thread
From: Patrick Steinhardt @ 2025-09-22  6:20 UTC (permalink / raw)
  To: Derrick Stolee; +Cc: Junio C Hamano, Matthew Hughes, git

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.

Thanks!

Patrick

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [QUESTION] how to find options set by scalar?
  2025-09-22  6:20         ` Patrick Steinhardt
@ 2025-09-22 13:36           ` Derrick Stolee
  2025-10-19 17:43             ` Matthew Hughes
  0 siblings, 1 reply; 8+ messages in thread
From: Derrick Stolee @ 2025-09-22 13:36 UTC (permalink / raw)
  To: Patrick Steinhardt; +Cc: Junio C Hamano, Matthew Hughes, git

On 9/22/2025 2:20 AM, Patrick Steinhardt wrote:
> 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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [QUESTION] how to find options set by scalar?
  2025-09-22 13:36           ` Derrick Stolee
@ 2025-10-19 17:43             ` Matthew Hughes
  0 siblings, 0 replies; 8+ messages in thread
From: Matthew Hughes @ 2025-10-19 17:43 UTC (permalink / raw)
  To: Derrick Stolee, Patrick Steinhardt; +Cc: Junio C Hamano, git

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-10-19 17:43 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-16  6:21 [QUESTION] how to find options set by scalar? Matthew Hughes
2025-09-16  7:45 ` Patrick Steinhardt
2025-09-18 19:32   ` Matthew Hughes
2025-09-18 20:29     ` Junio C Hamano
2025-09-19 15:38       ` Derrick Stolee
2025-09-22  6:20         ` Patrick Steinhardt
2025-09-22 13:36           ` Derrick Stolee
2025-10-19 17:43             ` Matthew Hughes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).