forked from git/git
-
Notifications
You must be signed in to change notification settings - Fork 160
Audit and document Scalar config #2010
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
derrickstolee
wants to merge
5
commits into
gitgitgadget:master
Choose a base branch
from
derrickstolee:scalar-config
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+218
−48
Open
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
639ff98
scalar: annotate config file with "set by scalar"
derrickstolee 10e9548
scalar: use index.skipHash=true for performance
derrickstolee 8783db6
scalar: remove stale config values
derrickstolee edc0254
scalar: alphabetize and simplify config
derrickstolee ac1627d
scalar: document config settings
derrickstolee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ | |
| #include "help.h" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Patrick Steinhardt wrote (reply to this): On Mon, Dec 01, 2025 at 04:50:43PM +0000, Derrick Stolee via GitGitGadget wrote:
> diff --git a/t/t9210-scalar.sh b/t/t9210-scalar.sh
> index bd6f0c40d2..43c210a23d 100755
> --- a/t/t9210-scalar.sh
> +++ b/t/t9210-scalar.sh
> @@ -210,6 +210,9 @@ test_expect_success 'scalar reconfigure' '
> GIT_TRACE2_EVENT="$(pwd)/reconfigure" scalar reconfigure -a &&
> test_path_is_file one/src/cron.txt &&
> test true = "$(git -C one/src config core.preloadIndex)" &&
> + test_grep "preloadIndex = true # set by scalar" one/src/.git/config &&
> + test_grep "excludeDecoration = refs/prefetch/\* # set by scalar" one/src/.git/config &&
> +
> test_subcommand git maintenance start <reconfigure &&
> test_subcommand ! git maintenance unregister --force <reconfigure &&
We _could_ make this a bit more solid by adding a test that:
1. Initializes a new repository.
2. Saves the configuration.
3. Performs `scalar reconfigure`.
4. Asserts that all new non-section-header lines in the configuration
have a trailing "#set by scalar" comment.
This would ensure that there is no callsite we forgot to add the new
annotation to, and that there are new future callsites where somebody
isn't aware of the comments.
I don't insist on such a test though, so please feel free to ignore this
suggestion.
Patrick |
||
| #include "setup.h" | ||
| #include "trace2.h" | ||
| #include "path.h" | ||
|
|
||
| static void setup_enlistment_directory(int argc, const char **argv, | ||
| const char * const *usagestr, | ||
|
|
@@ -95,6 +96,16 @@ struct scalar_config { | |
| int overwrite_on_reconfigure; | ||
| }; | ||
|
|
||
| static int set_config_with_comment(const char *key, const char *value) | ||
| { | ||
| char *file = repo_git_path(the_repository, "config"); | ||
| int res = repo_config_set_multivar_in_file_gently(the_repository, file, | ||
| key, value, NULL, | ||
| " # set by scalar", 0); | ||
| free(file); | ||
| return res; | ||
| } | ||
|
|
||
| static int set_scalar_config(const struct scalar_config *config, int reconfigure) | ||
| { | ||
| char *value = NULL; | ||
|
|
@@ -103,7 +114,7 @@ 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)) { | ||
| trace2_data_string("scalar", the_repository, config->key, "created"); | ||
| res = repo_config_set_gently(the_repository, config->key, config->value); | ||
| res = set_config_with_comment(config->key, config->value); | ||
| } else { | ||
| trace2_data_string("scalar", the_repository, config->key, "exists"); | ||
| res = 0; | ||
|
|
@@ -197,9 +208,8 @@ static int set_recommended_config(int reconfigure) | |
| if (repo_config_get_string(the_repository, "log.excludeDecoration", &value)) { | ||
| trace2_data_string("scalar", the_repository, | ||
| "log.excludeDecoration", "created"); | ||
| if (repo_config_set_multivar_gently(the_repository, "log.excludeDecoration", | ||
| "refs/prefetch/*", | ||
| CONFIG_REGEX_NONE, 0)) | ||
| if (set_config_with_comment("log.excludeDecoration", | ||
| "refs/prefetch/*")) | ||
| return error(_("could not configure " | ||
| "log.excludeDecoration")); | ||
| } else { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the Git mailing list, Junio C Hamano wrote (reply to this):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the Git mailing list, Patrick Steinhardt wrote (reply to this):