]> Kevux Git Server - rit/commitdiff
repo-settings: fix error handling for unknown values
authorElijah Newren <newren@gmail.com>
Wed, 2 Feb 2022 03:42:39 +0000 (03:42 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 2 Feb 2022 17:36:17 +0000 (09:36 -0800)
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>
repo-settings.c
t/t5500-fetch-pack.sh

index 27f2306..ab896fa 100644 (file)
@@ -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);
        }
 
        /*
index bc29f03..403d4e4 100755 (executable)
@@ -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 &&