Skip to content

Commit 70ff41f

Browse files
committed
Merge branch 'en/fetch-negotiation-default-fix'
Interaction between fetch.negotiationAlgorithm and feature.experimental configuration variables has been corrected. * en/fetch-negotiation-default-fix: repo-settings: rename the traditional default fetch.negotiationAlgorithm repo-settings: fix error handling for unknown values repo-settings: fix checking for fetch.negotiationAlgorithm=default
2 parents 00e38ba + 714edc6 commit 70ff41f

File tree

5 files changed

+44
-18
lines changed

5 files changed

+44
-18
lines changed

Documentation/config/fetch.txt

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,19 @@ fetch.output::
5656
OUTPUT in linkgit:git-fetch[1] for detail.
5757

5858
fetch.negotiationAlgorithm::
59-
Control how information about the commits in the local repository is
60-
sent when negotiating the contents of the packfile to be sent by the
61-
server. Set to "skipping" to use an algorithm that skips commits in an
62-
effort to converge faster, but may result in a larger-than-necessary
63-
packfile; or set to "noop" to not send any information at all, which
64-
will almost certainly result in a larger-than-necessary packfile, but
65-
will skip the negotiation step.
66-
The default is "default" which instructs Git to use the default algorithm
67-
that never skips commits (unless the server has acknowledged it or one
68-
of its descendants). If `feature.experimental` is enabled, then this
69-
setting defaults to "skipping".
70-
Unknown values will cause 'git fetch' to error out.
59+
Control how information about the commits in the local repository
60+
is sent when negotiating the contents of the packfile to be sent by
61+
the server. Set to "consecutive" to use an algorithm that walks
62+
over consecutive commits checking each one. Set to "skipping" to
63+
use an algorithm that skips commits in an effort to converge
64+
faster, but may result in a larger-than-necessary packfile; or set
65+
to "noop" to not send any information at all, which will almost
66+
certainly result in a larger-than-necessary packfile, but will skip
67+
the negotiation step. Set to "default" to override settings made
68+
previously and use the default behaviour. The default is normally
69+
"consecutive", but if `feature.experimental` is true, then the
70+
default is "skipping". Unknown values will cause 'git fetch' to
71+
error out.
7172
+
7273
See also the `--negotiate-only` and `--negotiation-tip` options to
7374
linkgit:git-fetch[1].

fetch-negotiator.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ void fetch_negotiator_init(struct repository *r,
1818
noop_negotiator_init(negotiator);
1919
return;
2020

21-
case FETCH_NEGOTIATION_DEFAULT:
21+
case FETCH_NEGOTIATION_CONSECUTIVE:
2222
default_negotiator_init(negotiator);
2323
return;
2424
}

repo-settings.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ void prepare_repo_settings(struct repository *r)
2626
/* Defaults */
2727
r->settings.index_version = -1;
2828
r->settings.core_untracked_cache = UNTRACKED_CACHE_KEEP;
29-
r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_DEFAULT;
29+
r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_CONSECUTIVE;
3030

3131
/* Booleans config or default, cascades to other settings */
3232
repo_cfg_bool(r, "feature.manyfiles", &manyfiles, 0);
@@ -81,10 +81,17 @@ void prepare_repo_settings(struct repository *r)
8181
}
8282

8383
if (!repo_config_get_string(r, "fetch.negotiationalgorithm", &strval)) {
84+
int fetch_default = r->settings.fetch_negotiation_algorithm;
8485
if (!strcasecmp(strval, "skipping"))
8586
r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_SKIPPING;
8687
else if (!strcasecmp(strval, "noop"))
8788
r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_NOOP;
89+
else if (!strcasecmp(strval, "consecutive"))
90+
r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_CONSECUTIVE;
91+
else if (!strcasecmp(strval, "default"))
92+
r->settings.fetch_negotiation_algorithm = fetch_default;
93+
else
94+
die("unknown fetch negotiation algorithm '%s'", strval);
8895
}
8996

9097
/*

repository.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ enum untracked_cache_setting {
2020
};
2121

2222
enum fetch_negotiation_setting {
23-
FETCH_NEGOTIATION_DEFAULT,
23+
FETCH_NEGOTIATION_CONSECUTIVE,
2424
FETCH_NEGOTIATION_SKIPPING,
2525
FETCH_NEGOTIATION_NOOP,
2626
};

t/t5500-fetch-pack.sh

Lines changed: 21 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,35 @@ 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=consecutive
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
961979
'
962980

963981
test_expect_success 'filtering by size' '

0 commit comments

Comments
 (0)