summaryrefslogtreecommitdiff
path: root/src/netops.c
diff options
context:
space:
mode:
authorBen Straub <bs@github.com>2013-01-30 19:03:58 -0800
committerBen Straub <bs@github.com>2013-01-30 19:03:58 -0800
commit2234b2b03153c03fc6d502dd61ae55e659be4b8b (patch)
treef3ebc65392fa5c94c3c11c809688454f51f64c48 /src/netops.c
parent5f10853e90014ea9929a976f647f2a2d32a2c129 (diff)
downloadlibgit2-2234b2b03153c03fc6d502dd61ae55e659be4b8b.tar.gz
Stash username from url (but don't use it yet)
Diffstat (limited to 'src/netops.c')
-rw-r--r--src/netops.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/netops.c b/src/netops.c
index 5623ca9bf..12738141f 100644
--- a/src/netops.c
+++ b/src/netops.c
@@ -578,7 +578,7 @@ int gitno_select_in(gitno_buffer *buf, long int sec, long int usec)
return select((int)buf->socket->socket + 1, &fds, NULL, NULL, &tv);
}
-int gitno_extract_host_and_port(char **host, char **port, const char *url, const char *default_port)
+int gitno_extract_host_and_port(char **host, char **port, char **username, const char *url, const char *default_port)
{
char *colon, *slash, *at, *delim;
const char *start;
@@ -600,7 +600,12 @@ int gitno_extract_host_and_port(char **host, char **port, const char *url, const
GITERR_CHECK_ALLOC(*port);
delim = colon == NULL ? slash : colon;
- start = at == NULL && at < slash ? url : at+1;
+
+ start = url;
+ if (at && at < slash) {
+ start = at+1;
+ *username = git__strndup(url, at - url);
+ }
*host = git__strndup(start, delim - start);
GITERR_CHECK_ALLOC(*host);