Merge branch 'ab/fetch-nego'
authorJunio C Hamano <gitster@pobox.com>
Fri, 17 Aug 2018 20:09:55 +0000 (13:09 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 17 Aug 2018 20:09:55 +0000 (13:09 -0700)
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

Documentation/config.txt
Documentation/fetch-options.txt
fetch-negotiator.c
t/t5552-skipping-fetch-negotiator.sh
index c0eb78e344ec2412e7ad1d5acfcfe64c629451e5..b568bad15ddbc611fb41ed1f681d75c777cce797 100644 (file)
@@ -1550,9 +1550,12 @@ fetch.negotiationAlgorithm::
        sent when negotiating the contents of the packfile to be sent by the
        server. Set to "skipping" to use an algorithm that skips commits in an
        effort to converge faster, but may result in a larger-than-necessary
-       packfile; any other value instructs Git to use the default algorithm
+       packfile; The default is "default" which instructs Git to use the default algorithm
        that never skips commits (unless the server has acknowledged it or one
        of its descendants).
+       Unknown values will cause 'git fetch' to error out.
++
+See also the `--negotiation-tip` option for linkgit:git-fetch[1].
 
 format.attach::
        Enable multipart/mixed attachments as the default for
index 2d09f87b4b38dbb98e0e1e5e341e09e5f84ece17..8bc36af4b1b10375c81c6f700ea300cee2295cc1 100644 (file)
@@ -57,6 +57,9 @@ commits reachable from any of the given commits.
 The argument to this option may be a glob on ref names, a ref, or the (possibly
 abbreviated) SHA-1 of a commit. Specifying a glob is equivalent to specifying
 this option multiple times, one for each matching ref name.
++
+See also the `fetch.negotiationAlgorithm` configuration variable
+documented in linkgit:git-config[1].
 
 ifndef::git-pull[]
 --dry-run::
index 5d283049f4ac0a1282db16dd9d61cffd2b9a53dd..d6d685cba012d6765b3998fde14b5c40fff82a96 100644 (file)
@@ -6,9 +6,15 @@
 void fetch_negotiator_init(struct fetch_negotiator *negotiator,
                           const char *algorithm)
 {
-       if (algorithm && !strcmp(algorithm, "skipping")) {
-               skipping_negotiator_init(negotiator);
-               return;
+       if (algorithm) {
+               if (!strcmp(algorithm, "skipping")) {
+                       skipping_negotiator_init(negotiator);
+                       return;
+               } else if (!strcmp(algorithm, "default")) {
+                       /* Fall through to default initialization */
+               } else {
+                       die("unknown fetch negotiation algorithm '%s'", algorithm);
+               }
        }
        default_negotiator_init(negotiator);
 }
index 0a8e0e42ed3b0992ffa645464eeb33bdf727d6da..3b60bd44e0a925931bc0ccb7c0b67df4809a6773 100755 (executable)
@@ -47,6 +47,29 @@ test_expect_success 'commits with no parents are sent regardless of skip distanc
        have_not_sent c6 c4 c3
 '
 
+test_expect_success 'unknown fetch.negotiationAlgorithm values error out' '
+       rm -rf server client trace &&
+       git init server &&
+       test_commit -C server to_fetch &&
+
+       git init client &&
+       test_commit -C client on_client &&
+       git -C client checkout on_client &&
+
+       test_config -C client fetch.negotiationAlgorithm invalid &&
+       test_must_fail git -C client fetch "$(pwd)/server" 2>err &&
+       test_i18ngrep "unknown fetch negotiation algorithm" err &&
+
+       # Explicit "default" value
+       test_config -C client fetch.negotiationAlgorithm default &&
+       git -C client -c fetch.negotiationAlgorithm=default fetch "$(pwd)/server" &&
+
+       # Implementation detail: If there is nothing to fetch, we will not error out
+       test_config -C client fetch.negotiationAlgorithm invalid &&
+       git -C client fetch "$(pwd)/server" 2>err &&
+       test_i18ngrep ! "unknown fetch negotiation algorithm" err
+'
+
 test_expect_success 'when two skips collide, favor the larger one' '
        rm -rf server client trace &&
        git init server &&