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 <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elijah Newren committed Feb 2, 2022 at 03:42 UTC a68c5b9eba0e62af19a84e1f8945fcdef06c96d1
2 files changed +16 -3
repo-settings.c
+2
@@ -82,6 +82,8 @@ void prepare_repo_settings(struct repository *r)
82 r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_SKIPPING;
83 else if (!strcasecmp(strval, "noop"))
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 }
88
89 /*
t/t5500-fetch-pack.sh
+14 -3
@@ -927,7 +927,8 @@ test_expect_success 'fetching deepen' '
927 )
928 '
929
930 -test_expect_success 'use ref advertisement to prune "have" lines sent' '
930 +test_negotiation_algorithm_default () {
931 + test_when_finished rm -rf clientv0 clientv2 &&
932 rm -rf server client &&
933 git init server &&
934 test_commit -C server both_have_1 &&
@@ -946,7 +947,7 @@ test_expect_success 'use ref advertisement to prune "have" lines sent' '
947 rm -f trace &&
948 cp -r client clientv0 &&
949 GIT_TRACE_PACKET="$(pwd)/trace" git -C clientv0 \
949 - fetch origin server_has both_have_2 &&
950 + "$@" fetch origin server_has both_have_2 &&
951 grep "have $(git -C client rev-parse client_has)" trace &&
952 grep "have $(git -C client rev-parse both_have_2)" trace &&
953 ! grep "have $(git -C client rev-parse both_have_2^)" trace &&
@@ -954,10 +955,20 @@ test_expect_success 'use ref advertisement to prune "have" lines sent' '
955 rm -f trace &&
956 cp -r client clientv2 &&
957 GIT_TRACE_PACKET="$(pwd)/trace" git -C clientv2 -c protocol.version=2 \
957 - fetch origin server_has both_have_2 &&
958 + "$@" fetch origin server_has both_have_2 &&
959 grep "have $(git -C client rev-parse client_has)" trace &&
960 grep "have $(git -C client rev-parse both_have_2)" trace &&
961 ! grep "have $(git -C client rev-parse both_have_2^)" trace
962 +}
963 +
964 +test_expect_success 'use ref advertisement to prune "have" lines sent' '
965 + test_negotiation_algorithm_default
966 +'
967 +
968 +test_expect_success 'same as last but with config overrides' '
969 + test_negotiation_algorithm_default \
970 + -c feature.experimental=true \
971 + -c fetch.negotiationAlgorithm=default
972 '
973
974 test_expect_success 'filtering by size' '