diff options
| author | Edward Thomson <ethomson@edwardthomson.com> | 2022-01-10 21:12:13 -0500 |
|---|---|---|
| committer | Edward Thomson <ethomson@edwardthomson.com> | 2022-01-17 21:06:06 -0500 |
| commit | e2bda60a524fef857763ce8605b0be277ef12f37 (patch) | |
| tree | 20d326eba28a649559fa54ccb2a75f97ae6b5fd0 /src/transports/ssh.c | |
| parent | 3db53eb1a2e9116c7566913fa6384e73c9ba4967 (diff) | |
| download | libgit2-e2bda60a524fef857763ce8605b0be277ef12f37.tar.gz | |
url: introduce git_net_url_parse_scp
Provide a mechanism for parsing scp-style paths (eg
`git@github.com:libgit2/libgit2` into the url form
`ssh://git@github.com/libgit2/libgit2`.)
Diffstat (limited to 'src/transports/ssh.c')
| -rw-r--r-- | src/transports/ssh.c | 38 |
1 files changed, 1 insertions, 37 deletions
diff --git a/src/transports/ssh.c b/src/transports/ssh.c index f37bf70bb..0f4a0fcc5 100644 --- a/src/transports/ssh.c +++ b/src/transports/ssh.c @@ -258,37 +258,6 @@ static int ssh_stream_alloc( return 0; } -static int git_ssh_extract_url_parts( - git_net_url *urldata, - const char *url) -{ - char *colon, *at; - const char *start; - - colon = strchr(url, ':'); - - - at = strchr(url, '@'); - if (at) { - start = at + 1; - urldata->username = git__substrdup(url, at - url); - GIT_ERROR_CHECK_ALLOC(urldata->username); - } else { - start = url; - urldata->username = NULL; - } - - if (colon == NULL || (colon < start)) { - git_error_set(GIT_ERROR_NET, "malformed URL"); - return -1; - } - - urldata->host = git__substrdup(start, colon - start); - GIT_ERROR_CHECK_ALLOC(urldata->host); - - return 0; -} - static int ssh_agent_auth(LIBSSH2_SESSION *session, git_credential_ssh_key *c) { int rc = LIBSSH2_ERROR_NONE; @@ -546,14 +515,9 @@ static int _git_ssh_setup_conn( goto post_extract; } } - if ((error = git_ssh_extract_url_parts(&urldata, url)) < 0) + if ((error = git_net_url_parse_scp(&urldata, url)) < 0) goto done; - if (urldata.port == NULL) - urldata.port = git__strdup(SSH_DEFAULT_PORT); - - GIT_ERROR_CHECK_ALLOC(urldata.port); - post_extract: if ((error = git_socket_stream_new(&s->io, urldata.host, urldata.port)) < 0 || (error = git_stream_connect(s->io)) < 0) |
