repo-settings: rename the traditional default fetch.negotiationAlgorithm

Give the traditional default fetch.negotiationAlgorithm the name 'consecutive'. Also allow a choice of 'default' to have Git decide between the choices (currently, picking 'skipping' if feature.experimental is true and 'consecutive' otherwise). Update the documentation accordingly. 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 714edc620c7ddca5d54ff148ac27da6b67217012
5 files changed +21 -17
Documentation/config/fetch.txt
+13 -12
@@ -56,18 +56,19 @@ fetch.output::
56 OUTPUT in linkgit:git-fetch[1] for detail.
57
58 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.
72 +
73 See also the `--negotiate-only` and `--negotiation-tip` options to
74 linkgit:git-fetch[1].
fetch-negotiator.c
+1 -1
@@ -18,7 +18,7 @@ void fetch_negotiator_init(struct repository *r,
18 noop_negotiator_init(negotiator);
19 return;
20
21 - case FETCH_NEGOTIATION_DEFAULT:
21 + case FETCH_NEGOTIATION_CONSECUTIVE:
22 default_negotiator_init(negotiator);
23 return;
24 }
repo-settings.c
+5 -2
@@ -23,7 +23,7 @@ void prepare_repo_settings(struct repository *r)
23 /* Defaults */
24 r->settings.index_version = -1;
25 r->settings.core_untracked_cache = UNTRACKED_CACHE_KEEP;
26 - r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_DEFAULT;
26 + r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_CONSECUTIVE;
27
28 /* Booleans config or default, cascades to other settings */
29 repo_cfg_bool(r, "feature.manyfiles", &manyfiles, 0);
@@ -78,12 +78,15 @@ void prepare_repo_settings(struct repository *r)
78 }
79
80 if (!repo_config_get_string(r, "fetch.negotiationalgorithm", &strval)) {
81 + int fetch_default = r->settings.fetch_negotiation_algorithm;
82 if (!strcasecmp(strval, "skipping"))
83 r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_SKIPPING;
84 else if (!strcasecmp(strval, "noop"))
85 r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_NOOP;
86 + else if (!strcasecmp(strval, "consecutive"))
87 + r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_CONSECUTIVE;
88 else if (!strcasecmp(strval, "default"))
86 - r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_DEFAULT;
89 + r->settings.fetch_negotiation_algorithm = fetch_default;
90 else
91 die("unknown fetch negotiation algorithm '%s'", strval);
92 }
repository.h
+1 -1
@@ -19,7 +19,7 @@ enum untracked_cache_setting {
19 };
20
21 enum fetch_negotiation_setting {
22 - FETCH_NEGOTIATION_DEFAULT,
22 + FETCH_NEGOTIATION_CONSECUTIVE,
23 FETCH_NEGOTIATION_SKIPPING,
24 FETCH_NEGOTIATION_NOOP,
25 };
t/t5500-fetch-pack.sh
+1 -1
@@ -968,7 +968,7 @@ test_expect_success 'use ref advertisement to prune "have" lines sent' '
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
971 + -c fetch.negotiationAlgorithm=consecutive
972 '
973
974 test_expect_success 'ensure bogus fetch.negotiationAlgorithm yields error' '