]> git.ipfire.org Git - thirdparty/git.git/commitdiff
repo-settings: fix checking for fetch.negotiationAlgorithm=default
authorElijah Newren <newren@gmail.com>
Wed, 2 Feb 2022 03:42:38 +0000 (03:42 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 2 Feb 2022 17:36:17 +0000 (09:36 -0800)
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>
repo-settings.c
t/t5500-fetch-pack.sh

index b93e91a212eb98aae494acc544edcd71b77a4761..27f230681f0d149bada1cbc83600077798933b72 100644 (file)
@@ -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;
        }
 
        /*
index 8a5d3492c713b8ca5eceef13ed55f7bd49edcae9..bc29f03ce4b9968a61420bbfb3ed00a627527878 100755 (executable)
@@ -927,7 +927,8 @@ test_expect_success 'fetching deepen' '
        )
 '
 
-test_expect_success 'use ref advertisement to prune "have" lines sent' '
+test_negotiation_algorithm_default () {
+       test_when_finished rm -rf clientv0 clientv2 &&
        rm -rf server client &&
        git init server &&
        test_commit -C server both_have_1 &&
@@ -946,7 +947,7 @@ test_expect_success 'use ref advertisement to prune "have" lines sent' '
        rm -f trace &&
        cp -r client clientv0 &&
        GIT_TRACE_PACKET="$(pwd)/trace" git -C clientv0 \
-               fetch origin server_has both_have_2 &&
+               "$@" fetch origin server_has both_have_2 &&
        grep "have $(git -C client rev-parse client_has)" trace &&
        grep "have $(git -C client rev-parse both_have_2)" trace &&
        ! 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' '
        rm -f trace &&
        cp -r client clientv2 &&
        GIT_TRACE_PACKET="$(pwd)/trace" git -C clientv2 -c protocol.version=2 \
-               fetch origin server_has both_have_2 &&
+               "$@" fetch origin server_has both_have_2 &&
        grep "have $(git -C client rev-parse client_has)" trace &&
        grep "have $(git -C client rev-parse both_have_2)" trace &&
        ! grep "have $(git -C client rev-parse both_have_2^)" trace
+}
+
+test_expect_success 'use ref advertisement to prune "have" lines sent' '
+       test_negotiation_algorithm_default
+'
+
+test_expect_success 'same as last but with config overrides' '
+       test_negotiation_algorithm_default \
+               -c feature.experimental=true \
+               -c fetch.negotiationAlgorithm=default
 '
 
 test_expect_success 'filtering by size' '