summaryrefslogtreecommitdiff
path: root/src/transport_git.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <carlos@cmartin.tk>2011-09-04 15:32:11 +0200
committerCarlos Martín Nieto <carlos@cmartin.tk>2011-09-04 16:07:52 +0200
commitdb84b7988bfbc9caf4fa584d775b4b43154261db (patch)
tree42d62103e0b10314b77626c60ee8ee26bdd12858 /src/transport_git.c
parent3d975abcb8b1dfe538b20d64598f85c94c34df61 (diff)
downloadlibgit2-db84b7988bfbc9caf4fa584d775b4b43154261db.tar.gz
Move extract_host_and_port to netops and add default port argument
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
Diffstat (limited to 'src/transport_git.c')
-rw-r--r--src/transport_git.c34
1 files changed, 2 insertions, 32 deletions
diff --git a/src/transport_git.c b/src/transport_git.c
index 7b0edcfef..fceece3e5 100644
--- a/src/transport_git.c
+++ b/src/transport_git.c
@@ -102,37 +102,6 @@ cleanup:
return error;
}
-/* The URL should already have been stripped of the protocol */
-static int extract_host_and_port(char **host, char **port, const char *url)
-{
- char *colon, *slash, *delim;
- int error = GIT_SUCCESS;
-
- colon = strchr(url, ':');
- slash = strchr(url, '/');
-
- if (slash == NULL)
- return git__throw(GIT_EOBJCORRUPTED, "Malformed URL: missing /");
-
- if (colon == NULL) {
- *port = git__strdup(GIT_DEFAULT_PORT);
- } else {
- *port = git__strndup(colon + 1, slash - colon - 1);
- }
- if (*port == NULL)
- return GIT_ENOMEM;;
-
-
- delim = colon == NULL ? slash : colon;
- *host = git__strndup(url, delim - url);
- if (*host == NULL) {
- free(*port);
- error = GIT_ENOMEM;
- }
-
- return error;
-}
-
/*
* Parse the URL and connect to a server, storing the socket in
* out. For convenience this also takes care of asking for the remote
@@ -148,9 +117,10 @@ static int do_connect(transport_git *t, const char *url)
if (!git__prefixcmp(url, prefix))
url += strlen(prefix);
- error = extract_host_and_port(&host, &port, url);
+ error = gitno_extract_host_and_port(&host, &port, url, GIT_DEFAULT_PORT);
if (error < GIT_SUCCESS)
return error;
+
s = gitno_connect(host, port);
connected = 1;
error = send_request(s, NULL, url);