Re: [PATCH v4 3/3] repo-settings: rename the traditional default fetch.negotiationAlgorithm
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Feb 2, 2022, 17:50 UTC
- Message-ID
- <xmqqk0ed17l8.fsf@gitster.g>
- In-Reply-To
- <7500a4d2e44008b1d8df9cc8b24b67ff973a98ae.1643773361.git.gitgitgadget@gmail.com>
"Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 30 quoted lines
> diff --git a/repo-settings.c b/repo-settings.c
> index 41e1c30845f..b4fbd16cdcc 100644
> --- a/repo-settings.c
> +++ b/repo-settings.c
> @@ -26,7 +26,7 @@ void prepare_repo_settings(struct repository *r)
> /* Defaults */
> r->settings.index_version = -1;
> r->settings.core_untracked_cache = UNTRACKED_CACHE_KEEP;
> - r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_DEFAULT;
> + r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_CONSECUTIVE;
>
> /* Booleans config or default, cascades to other settings */
> repo_cfg_bool(r, "feature.manyfiles", &manyfiles, 0);
> @@ -81,12 +81,15 @@ void prepare_repo_settings(struct repository *r)
> }
>
> if (!repo_config_get_string(r, "fetch.negotiationalgorithm", &strval)) {
> + int fetch_default = r->settings.fetch_negotiation_algorithm;
> if (!strcasecmp(strval, "skipping"))
> r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_SKIPPING;
> else if (!strcasecmp(strval, "noop"))
> r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_NOOP;
> + else if (!strcasecmp(strval, "consecutive"))
> + r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_CONSECUTIVE;
> else if (!strcasecmp(strval, "default"))
> - r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_DEFAULT;
> + r->settings.fetch_negotiation_algorithm = fetch_default;
> else
> die("unknown fetch negotiation algorithm '%s'", strval);
> }This
- set the default to whatever experimental says
- parse the configuration and set it
- to the specified value unless it is DEFAULT
- to the value the experimental bit set as the default otherwisecertainly works, even though I find it a bit convoluted and backwards. I have slight preference to "if the user says 'default', hold onto it as a symbolic 'default' setting, and resolve it to a concrete value at the very end" pattern, which tends to handle the "reverting to default" case better.
There is the "manyfiles" precedent that sets index.version and core.untrackedCache irreversibly nearby, and I am sympathetic to whoever added the fetch_negotiation_algorithm support (it probably is not you, I am guessing) by mimicking it, so I am OK with the version posted as-is.
Thanks.