44
return 0;
45
}
46
47
-static const struct transport_ops rsync_transport;
48
-
47
static int curl_transport_push(struct transport *transport, int refspec_nr, const char **refspec, int flags) {
48
const char **argv;
49
int argc;
197
198
#endif
199
202
-static const struct transport_ops curl_transport = {
203
- /* set_option */ NULL,
204
- /* get_refs_list */ get_refs_via_curl,
205
- /* fetch */ fetch_objs_via_curl,
206
- /* push */ curl_transport_push,
207
- /* disconnect */ disconnect_walker
208
-};
209
-
200
struct bundle_transport_data {
201
int fd;
202
struct bundle_header header;
239
return 0;
240
}
241
252
-static const struct transport_ops bundle_transport = {
253
- /* set_option */ NULL,
254
- /* get_refs_list */ get_refs_from_bundle,
255
- /* fetch */ fetch_refs_from_bundle,
256
- /* push */ NULL,
257
- /* disconnect */ close_bundle
258
-};
259
-
242
struct git_transport_data {
243
unsigned thin : 1;
244
unsigned keep : 1;
383
return !!err;
384
}
385
404
-static const struct transport_ops git_transport = {
405
- /* set_option */ set_git_option,
406
- /* get_refs_list */ get_refs_via_connect,
407
- /* fetch */ fetch_refs_via_pack,
408
- /* push */ git_transport_push
409
-};
410
-
386
static int is_local(const char *url)
387
{
388
const char *colon = strchr(url, ':');
406
ret->url = url;
407
408
if (!prefixcmp(url, "rsync://")) {
434
- ret->ops = &rsync_transport;
409
+ /* not supported; don't populate any ops */
410
+
411
} else if (!prefixcmp(url, "http://")
412
|| !prefixcmp(url, "https://")
413
|| !prefixcmp(url, "ftp://")) {
438
- ret->ops = &curl_transport;
414
+ ret->get_refs_list = get_refs_via_curl;
415
+ ret->fetch = fetch_objs_via_curl;
416
+ ret->push = curl_transport_push;
417
+ ret->disconnect = disconnect_walker;
418
+
419
} else if (is_local(url) && is_file(url)) {
420
struct bundle_transport_data *data = xcalloc(1, sizeof(*data));
421
ret->data = data;
442
- ret->ops = &bundle_transport;
422
+ ret->get_refs_list = get_refs_from_bundle;
423
+ ret->fetch = fetch_refs_from_bundle;
424
+ ret->disconnect = close_bundle;
425
+
426
} else {
427
struct git_transport_data *data = xcalloc(1, sizeof(*data));
428
ret->data = data;
429
+ ret->set_option = set_git_option;
430
+ ret->get_refs_list = get_refs_via_connect;
431
+ ret->fetch = fetch_refs_via_pack;
432
+ ret->push = git_transport_push;
433
+
434
data->thin = 1;
435
data->uploadpack = "git-upload-pack";
436
if (remote && remote->uploadpack)
439
if (remote && remote->receivepack)
440
data->receivepack = remote->receivepack;
441
data->unpacklimit = -1;
454
- ret->ops = &git_transport;
442
}
443
444
return ret;
447
int transport_set_option(struct transport *transport,
448
const char *name, const char *value)
449
{
463
- if (transport->ops->set_option)
464
- return transport->ops->set_option(transport, name, value);
450
+ if (transport->set_option)
451
+ return transport->set_option(transport, name, value);
452
return 1;
453
}
454
455
int transport_push(struct transport *transport,
456
int refspec_nr, const char **refspec, int flags)
457
{
471
- if (!transport->ops->push)
458
+ if (!transport->push)
459
return 1;
473
- return transport->ops->push(transport, refspec_nr, refspec, flags);
460
+ return transport->push(transport, refspec_nr, refspec, flags);
461
}
462
463
struct ref *transport_get_remote_refs(struct transport *transport)
464
{
465
if (!transport->remote_refs)
479
- transport->remote_refs =
480
- transport->ops->get_refs_list(transport);
466
+ transport->remote_refs = transport->get_refs_list(transport);
467
return transport->remote_refs;
468
}
469
482
heads[nr_heads++] = rm;
483
}
484
499
- rc = transport->ops->fetch(transport, nr_heads, heads);
485
+ rc = transport->fetch(transport, nr_heads, heads);
486
free(heads);
487
return rc;
488
}
499
int transport_disconnect(struct transport *transport)
500
{
501
int ret = 0;
516
- if (transport->ops->disconnect)
517
- ret = transport->ops->disconnect(transport);
502
+ if (transport->disconnect)
503
+ ret = transport->disconnect(transport);
504
free(transport);
505
return ret;
506
}