Re: [PATCH 1/5] scalar: annotate config file with "set by scalar"
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Dec 1, 2025, 08:55 UTC
- Message-ID
- <aS1X_UohbRkttu0E@pks.im>
- In-Reply-To
- <xmqqqztkl57l.fsf@gitster.g>
On Wed, Nov 26, 2025 at 03:55:10PM -0800, Junio C Hamano wrote:
Show 24 quoted lines
> "Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com> writes:
>
> > 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.
>
> The implementation is quite straight-forward, inlining expansion of
> repo_config_set_gently() in the places that we want to add comment to.
>
> If we had (a lot) more than two callsites, I would have suggested to
> add a simple helper function, something like
>
> static int scalar_config_set(struct repository *r, const char *key, const char *value)
> {
> char *file = repo_git_path(r, "config");
> int res = repo_config_set_multivar_in_file_gently(r, file,
> key, value, NULL, " # set by scalar", 0);
> free(file);
> return res;
> }
>
> and then the updates to the callers would have been absolute minimum.
>
> Well, even with only two callsites, perhaps such a refactoring may
> still have value in reducing the risk of typo in the comment.Agreed, I think it's a good idea to provide such a function. The calls to `repo_config_set_multivar_in_file_gently()` are quite verbose.
Patrick