Skip to content

Commit 28dbabb

Browse files
committed
Merge branch 'ab/fetch-nego'
Update to a few other topics around 'git fetch'. * ab/fetch-nego: fetch doc: cross-link two new negotiation options negotiator: unknown fetch.negotiationAlgorithm should error out
2 parents 72c11b7 + 5266082 commit 28dbabb

File tree

4 files changed

+39
-4
lines changed

4 files changed

+39
-4
lines changed

Documentation/config.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1550,9 +1550,12 @@ fetch.negotiationAlgorithm::
15501550
sent when negotiating the contents of the packfile to be sent by the
15511551
server. Set to "skipping" to use an algorithm that skips commits in an
15521552
effort to converge faster, but may result in a larger-than-necessary
1553-
packfile; any other value instructs Git to use the default algorithm
1553+
packfile; The default is "default" which instructs Git to use the default algorithm
15541554
that never skips commits (unless the server has acknowledged it or one
15551555
of its descendants).
1556+
Unknown values will cause 'git fetch' to error out.
1557+
+
1558+
See also the `--negotiation-tip` option for linkgit:git-fetch[1].
15561559

15571560
format.attach::
15581561
Enable multipart/mixed attachments as the default for

Documentation/fetch-options.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ commits reachable from any of the given commits.
5757
The argument to this option may be a glob on ref names, a ref, or the (possibly
5858
abbreviated) SHA-1 of a commit. Specifying a glob is equivalent to specifying
5959
this option multiple times, one for each matching ref name.
60+
+
61+
See also the `fetch.negotiationAlgorithm` configuration variable
62+
documented in linkgit:git-config[1].
6063

6164
ifndef::git-pull[]
6265
--dry-run::

fetch-negotiator.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,15 @@
66
void fetch_negotiator_init(struct fetch_negotiator *negotiator,
77
const char *algorithm)
88
{
9-
if (algorithm && !strcmp(algorithm, "skipping")) {
10-
skipping_negotiator_init(negotiator);
11-
return;
9+
if (algorithm) {
10+
if (!strcmp(algorithm, "skipping")) {
11+
skipping_negotiator_init(negotiator);
12+
return;
13+
} else if (!strcmp(algorithm, "default")) {
14+
/* Fall through to default initialization */
15+
} else {
16+
die("unknown fetch negotiation algorithm '%s'", algorithm);
17+
}
1218
}
1319
default_negotiator_init(negotiator);
1420
}

t/t5552-skipping-fetch-negotiator.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,29 @@ test_expect_success 'commits with no parents are sent regardless of skip distanc
4747
have_not_sent c6 c4 c3
4848
'
4949

50+
test_expect_success 'unknown fetch.negotiationAlgorithm values error out' '
51+
rm -rf server client trace &&
52+
git init server &&
53+
test_commit -C server to_fetch &&
54+
55+
git init client &&
56+
test_commit -C client on_client &&
57+
git -C client checkout on_client &&
58+
59+
test_config -C client fetch.negotiationAlgorithm invalid &&
60+
test_must_fail git -C client fetch "$(pwd)/server" 2>err &&
61+
test_i18ngrep "unknown fetch negotiation algorithm" err &&
62+
63+
# Explicit "default" value
64+
test_config -C client fetch.negotiationAlgorithm default &&
65+
git -C client -c fetch.negotiationAlgorithm=default fetch "$(pwd)/server" &&
66+
67+
# Implementation detail: If there is nothing to fetch, we will not error out
68+
test_config -C client fetch.negotiationAlgorithm invalid &&
69+
git -C client fetch "$(pwd)/server" 2>err &&
70+
test_i18ngrep ! "unknown fetch negotiation algorithm" err
71+
'
72+
5073
test_expect_success 'when two skips collide, favor the larger one' '
5174
rm -rf server client trace &&
5275
git init server &&

0 commit comments

Comments
 (0)