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 <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Elijah Newren committed
Feb 2, 2022 at 03:42 UTC
a9a136c23223bf6b211db0746f3c9f6769deb833
2 files changed
+9
repo-settings.c
+2
@@ -84,6 +84,8 @@ void prepare_repo_settings(struct repository *r)
84
r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_NOOP;
85
else if (!strcasecmp(strval, "default"))
86
r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_DEFAULT;
87
+ else
88
+ die("unknown fetch negotiation algorithm '%s'", strval);
89
}
90
91
/*
t/t5500-fetch-pack.sh
+7
@@ -971,6 +971,13 @@ test_expect_success 'same as last but with config overrides' '
971
-c fetch.negotiationAlgorithm=default
972
'
973
974
+test_expect_success 'ensure bogus fetch.negotiationAlgorithm yields error' '
975
+ test_when_finished rm -rf clientv0 &&
976
+ cp -r client clientv0 &&
977
+ test_must_fail git -C clientv0 --fetch.negotiationAlgorithm=bogus \
978
+ fetch origin server_has both_have_2
979
+'
980
+
981
test_expect_success 'filtering by size' '
982
rm -rf server client &&
983
test_create_repo server &&