git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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 otherwise

certainly 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.
Previous: Elijah Newren via GitGitGadget
Message 23 of 23 in “repo-settings: fix checking for fetch.negotiationAlgorithm=default”
  1. repo-settings: fix checking for fetch.negotiationAlgorithm=defaultElijah Newren via GitGitGadget, Jan 28, 2022
  2. Ævar Arnfjörð BjarmasonJan 28, 2022
  3. Elijah NewrenJan 29, 2022
  4. Ævar Arnfjörð BjarmasonJan 29, 2022
  5. Junio C HamanoJan 31, 2022
  6. Elijah NewrenJan 31, 2022
  7. Ævar Arnfjörð BjarmasonJan 31, 2022
  8. Elijah NewrenJan 31, 2022
  9. Jonathan TanFeb 1, 2022
  10. Junio C HamanoJan 31, 2022
  11. repo-settings: fix checking for fetch.negotiationAlgorithm=defaultElijah Newren via GitGitGadget, Jan 29, 2022
  12. 0/3 repo-settings: fix checking for fetch.negotiationAlgorithm=defaultElijah Newren via GitGitGadget, Feb 1, 2022
  13. 1/3 repo-settings: fix checking for fetch.negotiationAlgorithm=defaultElijah Newren via GitGitGadget, Feb 1, 2022
  14. Junio C HamanoFeb 1, 2022
  15. 2/3 repo-settings: fix error handling for unknown valuesElijah Newren via GitGitGadget, Feb 1, 2022
  16. Junio C HamanoFeb 1, 2022
  17. 3/3 repo-settings: name the default fetch.negotiationAlgorithm 'consecutive'Elijah Newren via GitGitGadget, Feb 1, 2022
  18. Junio C HamanoFeb 1, 2022
  19. 0/3 repo-settings: fix checking for fetch.negotiationAlgorithm=defaultElijah Newren via GitGitGadget, Feb 2, 2022
  20. 1/3 repo-settings: fix checking for fetch.negotiationAlgorithm=defaultElijah Newren via GitGitGadget, Feb 2, 2022
  21. 2/3 repo-settings: fix error handling for unknown valuesElijah Newren via GitGitGadget, Feb 2, 2022
  22. 3/3 repo-settings: rename the traditional default fetch.negotiationAlgorithmElijah Newren via GitGitGadget, Feb 2, 2022
  23. Junio C HamanoFeb 2, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.