]> git.ipfire.org Git - thirdparty/git.git/commitdiff
bundle-uri client: add boolean transfer.bundleURI setting
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Thu, 22 Dec 2022 15:14:10 +0000 (15:14 +0000)
committerJunio C Hamano <gitster@pobox.com>
Sun, 25 Dec 2022 07:24:23 +0000 (16:24 +0900)
The yet-to-be introduced client support for bundle-uri will always
fall back on a full clone, but we'd still like to be able to ignore a
server's bundle-uri advertisement entirely.

The new transfer.bundleURI config option defaults to 'false', but a user
can set it to 'true' to enable checking for bundle URIs from the origin
Git server using protocol v2.

Co-authored-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/config/transfer.txt
t/lib-bundle-uri-protocol.sh
transport.c

index 264812cca4db9a0a7b70be3eed7703d3439c9f46..c3ac767d1e4de152865ec82de6a995a9b4934834 100644 (file)
@@ -115,3 +115,9 @@ transfer.unpackLimit::
 transfer.advertiseSID::
        Boolean. When true, client and server processes will advertise their
        unique session IDs to their remote counterpart. Defaults to false.
+
+transfer.bundleURI::
+       When `true`, local `git clone` commands will request bundle
+       information from the remote server (if advertised) and download
+       bundles before continuing the clone through the Git protocol.
+       Defaults to `false`.
index d44c6e10f9ea242c2f39cc0e4651c5b6dbea6fb0..75ea8c4418f026e657269eb5f056a1105ef265e3 100644 (file)
@@ -85,10 +85,11 @@ test_expect_success "connect with $BUNDLE_URI_PROTOCOL:// using protocol v2: hav
 '
 
 test_expect_success "clone with $BUNDLE_URI_PROTOCOL:// using protocol v2: request bundle-uris" '
-       test_when_finished "rm -rf log cloned" &&
+       test_when_finished "rm -rf log cloned cloned2" &&
 
        GIT_TRACE_PACKET="$PWD/log" \
        git \
+               -c transfer.bundleURI=false \
                -c protocol.version=2 \
                clone "$BUNDLE_URI_REPO_URI" cloned \
                >actual 2>err &&
@@ -99,6 +100,22 @@ test_expect_success "clone with $BUNDLE_URI_PROTOCOL:// using protocol v2: reque
        # Server advertised bundle-uri capability
        grep "< bundle-uri" log &&
 
+       # Client did not issue bundle-uri command
+       ! grep "> command=bundle-uri" log &&
+
+       GIT_TRACE_PACKET="$PWD/log" \
+       git \
+               -c transfer.bundleURI=true \
+               -c protocol.version=2 \
+               clone "$BUNDLE_URI_REPO_URI" cloned2 \
+               >actual 2>err &&
+
+       # Server responded using protocol v2
+       grep "< version 2" log &&
+
+       # Server advertised bundle-uri capability
+       grep "< bundle-uri" log &&
+
        # Client issued bundle-uri command
        grep "> command=bundle-uri" log
 '
index b6f279e92cb01bc204b1a242593a5ad670fc2e23..b4cf2c0252eeb05b2206951f0086433a0a31cb85 100644 (file)
@@ -1516,6 +1516,7 @@ int transport_fetch_refs(struct transport *transport, struct ref *refs)
 
 int transport_get_remote_bundle_uri(struct transport *transport)
 {
+       int value = 0;
        const struct transport_vtable *vtable = transport->vtable;
 
        /* Check config only once. */
@@ -1523,6 +1524,13 @@ int transport_get_remote_bundle_uri(struct transport *transport)
                return 0;
        transport->got_remote_bundle_uri = 1;
 
+       /*
+        * Don't request bundle-uri from the server unless configured to
+        * do so by the transfer.bundleURI=true config option.
+        */
+       if (git_config_get_bool("transfer.bundleuri", &value) || !value)
+               return 0;
+
        if (!vtable->get_bundle_uri)
                return error(_("bundle-uri operation not supported by protocol"));