From: Elijah Newren Date: Wed, 2 Feb 2022 03:42:39 +0000 (+0000) Subject: repo-settings: fix error handling for unknown values X-Git-Tag: v2.36.0-rc0~150^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a9a136c23223bf6b211db0746f3c9f6769deb833;p=thirdparty%2Fgit.git 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 --- 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); } /* diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh index bc29f03ce4..403d4e40a2 100755 --- a/t/t5500-fetch-pack.sh +++ b/t/t5500-fetch-pack.sh @@ -971,6 +971,13 @@ test_expect_success 'same as last but with config overrides' ' -c fetch.negotiationAlgorithm=default ' +test_expect_success 'ensure bogus fetch.negotiationAlgorithm yields error' ' + test_when_finished rm -rf clientv0 && + cp -r client clientv0 && + test_must_fail git -C clientv0 --fetch.negotiationAlgorithm=bogus \ + fetch origin server_has both_have_2 +' + test_expect_success 'filtering by size' ' rm -rf server client && test_create_repo server &&