bundle-uri client: add boolean transfer.bundleURI setting
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>
Ævar Arnfjörð Bjarmason committed
Dec 22, 2022 at 15:14 UTC
7cce9074a728fb32501054577963d8ae31d007be
3 files changed
+32
-1
Documentation/config/transfer.txt
+6
@@ -115,3 +115,9 @@ transfer.unpackLimit::
115
transfer.advertiseSID::
116
Boolean. When true, client and server processes will advertise their
117
unique session IDs to their remote counterpart. Defaults to false.
118
+
119
+transfer.bundleURI::
120
+ When `true`, local `git clone` commands will request bundle
121
+ information from the remote server (if advertised) and download
122
+ bundles before continuing the clone through the Git protocol.
123
+ Defaults to `false`.
t/lib-bundle-uri-protocol.sh
+18
-1
@@ -85,10 +85,11 @@ test_expect_success "connect with $BUNDLE_URI_PROTOCOL:// using protocol v2: hav
85
'
86
87
test_expect_success "clone with $BUNDLE_URI_PROTOCOL:// using protocol v2: request bundle-uris" '
88
- test_when_finished "rm -rf log cloned" &&
88
+ test_when_finished "rm -rf log cloned cloned2" &&
89
90
GIT_TRACE_PACKET="$PWD/log" \
91
git \
92
+ -c transfer.bundleURI=false \
93
-c protocol.version=2 \
94
clone "$BUNDLE_URI_REPO_URI" cloned \
95
>actual 2>err &&
@@ -99,6 +100,22 @@ test_expect_success "clone with $BUNDLE_URI_PROTOCOL:// using protocol v2: reque
100
# Server advertised bundle-uri capability
101
grep "< bundle-uri" log &&
102
103
+ # Client did not issue bundle-uri command
104
+ ! grep "> command=bundle-uri" log &&
105
+
106
+ GIT_TRACE_PACKET="$PWD/log" \
107
+ git \
108
+ -c transfer.bundleURI=true \
109
+ -c protocol.version=2 \
110
+ clone "$BUNDLE_URI_REPO_URI" cloned2 \
111
+ >actual 2>err &&
112
+
113
+ # Server responded using protocol v2
114
+ grep "< version 2" log &&
115
+
116
+ # Server advertised bundle-uri capability
117
+ grep "< bundle-uri" log &&
118
+
119
# Client issued bundle-uri command
120
grep "> command=bundle-uri" log
121
'
transport.c
+8
@@ -1516,6 +1516,7 @@ int transport_fetch_refs(struct transport *transport, struct ref *refs)
1516
1517
int transport_get_remote_bundle_uri(struct transport *transport)
1518
{
1519
+ int value = 0;
1520
const struct transport_vtable *vtable = transport->vtable;
1521
1522
/* Check config only once. */
@@ -1523,6 +1524,13 @@ int transport_get_remote_bundle_uri(struct transport *transport)
1524
return 0;
1525
transport->got_remote_bundle_uri = 1;
1526
1527
+ /*
1528
+ * Don't request bundle-uri from the server unless configured to
1529
+ * do so by the transfer.bundleURI=true config option.
1530
+ */
1531
+ if (git_config_get_bool("transfer.bundleuri", &value) || !value)
1532
+ return 0;
1533
+
1534
if (!vtable->get_bundle_uri)
1535
return error(_("bundle-uri operation not supported by protocol"));
1536