diff options
| author | Vicent Marti <vicent@github.com> | 2014-08-27 18:02:10 +0200 |
|---|---|---|
| committer | Vicent Marti <vicent@github.com> | 2014-08-27 18:02:10 +0200 |
| commit | 1485c6833a6142d03ac79ff976055797d68151b8 (patch) | |
| tree | c80d99b8cfe7b1d0007527c4d5532c548bf623dd /src | |
| parent | c13b68442fa92c19fb8e92f0c1da4704fe14174f (diff) | |
| parent | 0e5bb61992cce41cc45ba9ad352297cbb8432a6d (diff) | |
| download | libgit2-1485c6833a6142d03ac79ff976055797d68151b8.tar.gz | |
Merge pull request #2490 from csware/ssh-wintunnel
Allow to override default ssh transport_cb - in order to allow third party ssh transports
Diffstat (limited to 'src')
| -rw-r--r-- | src/transport.c | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/src/transport.c b/src/transport.c index c0311fa90..d390e1422 100644 --- a/src/transport.c +++ b/src/transport.c @@ -46,34 +46,37 @@ static git_vector custom_transports = GIT_VECTOR_INIT; #define GIT_TRANSPORT_COUNT (sizeof(transports)/sizeof(transports[0])) - 1 -static int transport_find_fn( - git_transport_cb *out, - const char *url, - void **param) +static transport_definition * transport_find_by_url(const char *url) { size_t i = 0; - transport_definition *d, *definition = NULL; + transport_definition *d; /* Find a user transport who wants to deal with this URI */ git_vector_foreach(&custom_transports, i, d) { if (strncasecmp(url, d->prefix, strlen(d->prefix)) == 0) { - definition = d; - break; + return d; } } /* Find a system transport for this URI */ - if (!definition) { - for (i = 0; i < GIT_TRANSPORT_COUNT; ++i) { - d = &transports[i]; - - if (strncasecmp(url, d->prefix, strlen(d->prefix)) == 0) { - definition = d; - break; - } + for (i = 0; i < GIT_TRANSPORT_COUNT; ++i) { + d = &transports[i]; + + if (strncasecmp(url, d->prefix, strlen(d->prefix)) == 0) { + return d; } } + return NULL; +} + +static int transport_find_fn( + git_transport_cb *out, + const char *url, + void **param) +{ + transport_definition *definition = transport_find_by_url(url); + #ifdef GIT_WIN32 /* On Windows, it might not be possible to discern between absolute local * and ssh paths - first check if this is a valid local path that points @@ -89,12 +92,15 @@ static int transport_find_fn( /* It could be a SSH remote path. Check to see if there's a : * SSH is an unsupported transport mechanism in this version of libgit2 */ - if (!definition && strrchr(url, ':')) -#ifdef GIT_SSH - definition = &ssh_transport_definition; -#else - definition = &dummy_transport_definition; + if (!definition && strrchr(url, ':')) { + // re-search transports again with ssh:// as url so that we can find a third party ssh transport + definition = transport_find_by_url("ssh://"); +#ifndef GIT_SSH + if (!definition) { + definition = &dummy_transport_definition; + } #endif + } #ifndef GIT_WIN32 /* Check to see if the path points to a file on the local file system */ |
