示例#1
0
/*
 * Since this is a network connection, we need to parse and store the
 * pkt-lines at this stage and keep them there.
 */
static int git_connect(git_transport *transport, int direction)
{
	transport_git *t = (transport_git *) transport;

	if (direction == GIT_DIR_PUSH) {
		giterr_set(GITERR_NET, "Pushing over git:// is not supported");
		return -1;
	}

	t->parent.direction = direction;

	/* Connect and ask for the refs */
	if (do_connect(t, transport->url) < 0)
		return -1;

	gitno_buffer_setup(transport, &transport->buffer, t->buff, sizeof(t->buff));

	t->parent.connected = 1;
	if (git_protocol_store_refs(transport, 1) < 0)
		return -1;

	if (git_protocol_detect_caps(git_vector_get(&transport->refs, 0), &transport->caps) < 0)
		return -1;

	return 0;
}
示例#2
0
文件: git.c 项目: Asquera/libgit2
/*
 * Read from the socket and store the references in the vector
 */
static int store_refs(transport_git *t)
{
	gitno_buffer *buf = &t->buf;
	int ret = 0;

	while (1) {
		if ((ret = gitno_recv(buf)) < 0)
			return -1;
		if (ret == 0) /* Orderly shutdown, so exit */
			return 0;

		ret = git_protocol_store_refs(&t->proto, buf->data, buf->offset);
		if (ret == GIT_EBUFS) {
			gitno_consume_n(buf, buf->len);
			continue;
		}

		if (ret < 0)
			return ret;

		gitno_consume_n(buf, buf->offset);

		if (t->proto.flush) { /* No more refs */
			t->proto.flush = 0;
			return 0;
		}
	}
}
示例#3
0
文件: http.c 项目: ileitch/meanie
static int on_body_store_refs(http_parser *parser, const char *str, size_t len)
{
	transport_http *t = (transport_http *) parser->data;

	if (parser->status_code == 404) {
		return git_buf_put(&t->buf, str, len);
	}

	return git_protocol_store_refs(&t->proto, str, len);
}