22
#include "protocol.h"
23
#include "object-store.h"
24
#include "color.h"
25
+#include "bundle-uri.h"
26
27
static int transport_use_color = -1;
28
static char transport_colors[][COLOR_MAXLEN] = {
360
return handshake(transport, for_push, options, 1);
361
}
362
363
+static int get_bundle_uri(struct transport *transport)
364
+{
365
+ struct git_transport_data *data = transport->data;
366
+ struct packet_reader reader;
367
+ int stateless_rpc = transport->stateless_rpc;
368
+
369
+ if (!transport->bundles) {
370
+ CALLOC_ARRAY(transport->bundles, 1);
371
+ init_bundle_list(transport->bundles);
372
+ }
373
+
374
+ /*
375
+ * "Support" protocol v0 and v2 without bundle-uri support by
376
+ * silently degrading to a NOOP.
377
+ */
378
+ if (!server_supports_v2("bundle-uri", 0))
379
+ return 0;
380
+
381
+ packet_reader_init(&reader, data->fd[0], NULL, 0,
382
+ PACKET_READ_CHOMP_NEWLINE |
383
+ PACKET_READ_GENTLE_ON_EOF);
384
+
385
+ return get_remote_bundle_uri(data->fd[1], &reader,
386
+ transport->bundles, stateless_rpc);
387
+}
388
+
389
static int fetch_refs_via_pack(struct transport *transport,
390
int nr_heads, struct ref **to_fetch)
391
{
929
930
static struct transport_vtable taken_over_vtable = {
931
.get_refs_list = get_refs_via_connect,
932
+ .get_bundle_uri = get_bundle_uri,
933
.fetch_refs = fetch_refs_via_pack,
934
.push_refs = git_transport_push,
935
.disconnect = disconnect_git
1082
1083
static struct transport_vtable builtin_smart_vtable = {
1084
.get_refs_list = get_refs_via_connect,
1085
+ .get_bundle_uri = get_bundle_uri,
1086
.fetch_refs = fetch_refs_via_pack,
1087
.push_refs = git_transport_push,
1088
.connect = connect_git,
1097
ret->progress = isatty(2);
1098
string_list_init_dup(&ret->pack_lockfiles);
1099
1100
+ CALLOC_ARRAY(ret->bundles, 1);
1101
+ init_bundle_list(ret->bundles);
1102
+
1103
if (!remote)
1104
BUG("No remote provided to transport_get()");
1105
1514
return rc;
1515
}
1516
1517
+int transport_get_remote_bundle_uri(struct transport *transport)
1518
+{
1519
+ const struct transport_vtable *vtable = transport->vtable;
1520
+
1521
+ /* Check config only once. */
1522
+ if (transport->got_remote_bundle_uri)
1523
+ return 0;
1524
+ transport->got_remote_bundle_uri = 1;
1525
+
1526
+ if (!vtable->get_bundle_uri)
1527
+ return error(_("bundle-uri operation not supported by protocol"));
1528
+
1529
+ if (vtable->get_bundle_uri(transport) < 0)
1530
+ return error(_("could not retrieve server-advertised bundle-uri list"));
1531
+ return 0;
1532
+}
1533
+
1534
void transport_unlock_pack(struct transport *transport, unsigned int flags)
1535
{
1536
int in_signal_handler = !!(flags & TRANSPORT_UNLOCK_PACK_IN_SIGNAL_HANDLER);
1561
ret = transport->vtable->disconnect(transport);
1562
if (transport->got_remote_refs)
1563
free_refs((void *)transport->remote_refs);
1564
+ clear_bundle_list(transport->bundles);
1565
+ free(transport->bundles);
1566
free(transport);
1567
return ret;
1568
}