Skip to content

Commit 7cce907

Browse files
avarderrickstolee
authored andcommitted
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 <[email protected]> Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0cfde74 commit 7cce907

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

Documentation/config/transfer.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,9 @@ transfer.unpackLimit::
115115
transfer.advertiseSID::
116116
Boolean. When true, client and server processes will advertise their
117117
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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,11 @@ test_expect_success "connect with $BUNDLE_URI_PROTOCOL:// using protocol v2: hav
8585
'
8686

8787
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" &&
8989
9090
GIT_TRACE_PACKET="$PWD/log" \
9191
git \
92+
-c transfer.bundleURI=false \
9293
-c protocol.version=2 \
9394
clone "$BUNDLE_URI_REPO_URI" cloned \
9495
>actual 2>err &&
@@ -99,6 +100,22 @@ test_expect_success "clone with $BUNDLE_URI_PROTOCOL:// using protocol v2: reque
99100
# Server advertised bundle-uri capability
100101
grep "< bundle-uri" log &&
101102
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+
102119
# Client issued bundle-uri command
103120
grep "> command=bundle-uri" log
104121
'

transport.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,13 +1516,21 @@ int transport_fetch_refs(struct transport *transport, struct ref *refs)
15161516

15171517
int transport_get_remote_bundle_uri(struct transport *transport)
15181518
{
1519+
int value = 0;
15191520
const struct transport_vtable *vtable = transport->vtable;
15201521

15211522
/* Check config only once. */
15221523
if (transport->got_remote_bundle_uri)
15231524
return 0;
15241525
transport->got_remote_bundle_uri = 1;
15251526

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+
15261534
if (!vtable->get_bundle_uri)
15271535
return error(_("bundle-uri operation not supported by protocol"));
15281536

0 commit comments

Comments
 (0)