Skip to content

Commit a68c5b9

Browse files
newrengitster
authored andcommitted
repo-settings: fix checking for fetch.negotiationAlgorithm=default
In commit 3050b6d (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 3050b6d, 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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e9d7761 commit a68c5b9

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

repo-settings.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ void prepare_repo_settings(struct repository *r)
8282
r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_SKIPPING;
8383
else if (!strcasecmp(strval, "noop"))
8484
r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_NOOP;
85+
else if (!strcasecmp(strval, "default"))
86+
r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_DEFAULT;
8587
}
8688

8789
/*

t/t5500-fetch-pack.sh

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,8 @@ test_expect_success 'fetching deepen' '
927927
)
928928
'
929929

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 &&
931932
rm -rf server client &&
932933
git init server &&
933934
test_commit -C server both_have_1 &&
@@ -946,18 +947,28 @@ test_expect_success 'use ref advertisement to prune "have" lines sent' '
946947
rm -f trace &&
947948
cp -r client clientv0 &&
948949
GIT_TRACE_PACKET="$(pwd)/trace" git -C clientv0 \
949-
fetch origin server_has both_have_2 &&
950+
"$@" fetch origin server_has both_have_2 &&
950951
grep "have $(git -C client rev-parse client_has)" trace &&
951952
grep "have $(git -C client rev-parse both_have_2)" trace &&
952953
! grep "have $(git -C client rev-parse both_have_2^)" trace &&
953954

954955
rm -f trace &&
955956
cp -r client clientv2 &&
956957
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 &&
958959
grep "have $(git -C client rev-parse client_has)" trace &&
959960
grep "have $(git -C client rev-parse both_have_2)" trace &&
960961
! 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
961972
'
962973

963974
test_expect_success 'filtering by size' '

0 commit comments

Comments
 (0)