Пример #1
0
static int _git_receivepack_ls(
	git_subtransport *t,
	const char *url,
	git_smart_subtransport_stream **stream)
{
	char *host=NULL, *port=NULL, *path=NULL, *user=NULL, *pass=NULL;
	const char *stream_url = url;
	git_stream *s;
	int error;

	*stream = NULL;
	if (!git__prefixcmp(url, prefix_git))
		stream_url += strlen(prefix_git);

	if (git_stream_alloc(t, stream_url, cmd_receivepack, stream) < 0)
		return -1;

	s = (git_stream *)*stream;

	if (!(error = gitno_extract_url_parts(&host, &port, &path, &user, &pass, url, GIT_DEFAULT_PORT))) {
		if (!(error = gitno_connect(&s->socket, host, port, 0)))
			t->current_stream = s;

		git__free(host);
		git__free(port);
		git__free(path);
		git__free(user);
		git__free(pass);
	} else if (*stream)
		git_stream_free(*stream);

	return error;
}
Пример #2
0
Файл: git.c Проект: da-x/gitlib
static int _git_receivepack_ls(
    git_subtransport *t,
    const char *url,
    git_smart_subtransport_stream **stream)
{
    char *host, *port, *user=NULL, *pass=NULL;
    git_stream *s;

    *stream = NULL;

    if (!git__prefixcmp(url, prefix_git))
        url += strlen(prefix_git);

    if (git_stream_alloc(t, url, cmd_receivepack, stream) < 0)
        return -1;

    s = (git_stream *)*stream;

    if (gitno_extract_url_parts(&host, &port, &user, &pass, url, GIT_DEFAULT_PORT) < 0)
        goto on_error;

    if (gitno_connect(&s->socket, host, port, 0) < 0)
        goto on_error;

    t->current_stream = s;
    git__free(host);
    git__free(port);
    git__free(user);
    git__free(pass);
    return 0;

on_error:
    if (*stream)
        git_stream_free(*stream);

    git__free(host);
    git__free(port);
    return -1;
}