From a68c5b9eba0e62af19a84e1f8945fcdef06c96d1 Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Wed, 2 Feb 2022 03:42:38 +0000 Subject: repo-settings: fix checking for fetch.negotiationAlgorithm=default In commit 3050b6dfc75d (repo-settings.c: simplify the setup, 2021-09-21), the branch for handling fetch.negotiationAlgorithm=default was deleted. Since this value is documented in Documentation/config/fetch.txt, restore the check for this value. Note that this change caused an observable bug: if someone sets feature.experimental=true in config, and then passes "-c fetch.negotiationAlgorithm=default" on the command line in an attempt to override the config, then the override is ignored. Fix the bug by not ignoring the value of "default". Technically, before commit 3050b6dfc75d, repo-settings would treat any fetch.negotiationAlgorithm value other than "skipping" or "noop" as a request for "default", but I think it probably makes more sense to ignore such broken requests and leave fetch.negotiationAlgorithm with the default value rather than the value of "default". (If that sounds confusing, note that "default" is usually the default value, but when feature.experimental=true, "skipping" is the default value.) Signed-off-by: Elijah Newren Signed-off-by: Junio C Hamano --- repo-settings.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'repo-settings.c') diff --git a/repo-settings.c b/repo-settings.c index b93e91a212..27f230681f 100644 --- a/repo-settings.c +++ b/repo-settings.c @@ -82,6 +82,8 @@ void prepare_repo_settings(struct repository *r) 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, "default")) + r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_DEFAULT; } /* -- cgit v1.2.3 From a9a136c23223bf6b211db0746f3c9f6769deb833 Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Wed, 2 Feb 2022 03:42:39 +0000 Subject: repo-settings: fix error handling for unknown values In commit af3a67de01 ("negotiator: unknown fetch.negotiationAlgorithm should error out", 2018-08-01), error handling for an unknown fetch.negotiationAlgorithm was added with the code die()ing. This was also added to the documentation for the fetch.negotiationAlgorithm option, to make it explicit that the code would die on unknown values. This behavior was lost with commit aaf633c2ad ("repo-settings: create feature.experimental setting", 2019-08-13). Restore it so that the behavior again matches the documentation. Signed-off-by: Elijah Newren Signed-off-by: Junio C Hamano --- repo-settings.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'repo-settings.c') diff --git a/repo-settings.c b/repo-settings.c index 27f230681f..ab896fa84b 100644 --- a/repo-settings.c +++ b/repo-settings.c @@ -84,6 +84,8 @@ void prepare_repo_settings(struct repository *r) r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_NOOP; else if (!strcasecmp(strval, "default")) r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_DEFAULT; + else + die("unknown fetch negotiation algorithm '%s'", strval); } /* -- cgit v1.2.3 From 714edc620c7ddca5d54ff148ac27da6b67217012 Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Wed, 2 Feb 2022 03:42:40 +0000 Subject: repo-settings: rename the traditional default fetch.negotiationAlgorithm Give the traditional default fetch.negotiationAlgorithm the name 'consecutive'. Also allow a choice of 'default' to have Git decide between the choices (currently, picking 'skipping' if feature.experimental is true and 'consecutive' otherwise). Update the documentation accordingly. Signed-off-by: Elijah Newren Signed-off-by: Junio C Hamano --- repo-settings.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'repo-settings.c') diff --git a/repo-settings.c b/repo-settings.c index ab896fa84b..c9ca1fd427 100644 --- a/repo-settings.c +++ b/repo-settings.c @@ -23,7 +23,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); @@ -78,12 +78,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); } -- cgit v1.2.3