Commit cd58c15c by Vicent Martí

Merge remote-tracking branch 'scottjg/fix-mingw32' into development

Conflicts:
	src/netops.c
	src/netops.h
	src/transports/http.c
	tests-clar/clar
parents 48ecd122 35cdd261
......@@ -93,7 +93,7 @@ void gitno_consume_n(gitno_buffer *buf, size_t cons)
buf->offset -= cons;
}
GIT_SOCKET gitno_connect(const char *host, const char *port)
int gitno_connect(GIT_SOCKET *sock, const char *host, const char *port)
{
struct addrinfo *info = NULL, *p;
struct addrinfo hints;
......@@ -106,7 +106,7 @@ GIT_SOCKET gitno_connect(const char *host, const char *port)
if ((ret = getaddrinfo(host, port, &hints, &info)) < 0) {
giterr_set(GITERR_NET, "Failed to resolve address for %s: %s", host, gai_strerror(ret));
return INVALID_SOCKET;
return -1;
}
for (p = info; p != NULL; p = p->ai_next) {
......@@ -125,11 +125,14 @@ GIT_SOCKET gitno_connect(const char *host, const char *port)
}
/* Oops, we couldn't connect to any address */
if (s == INVALID_SOCKET && p == NULL)
if (s == INVALID_SOCKET && p == NULL) {
giterr_set(GITERR_OS, "Failed to connect to %s", host);
return -1;
}
freeaddrinfo(info);
return s;
*sock = s;
return 0;
}
int gitno_send(GIT_SOCKET s, const char *msg, size_t len, int flags)
......
......@@ -21,7 +21,7 @@ int gitno_recv(gitno_buffer *buf);
void gitno_consume(gitno_buffer *buf, const char *ptr);
void gitno_consume_n(gitno_buffer *buf, size_t cons);
GIT_SOCKET gitno_connect(const char *host, const char *port);
int gitno_connect(GIT_SOCKET *s, const char *host, const char *port);
int gitno_send(GIT_SOCKET s, const char *msg, size_t len, int flags);
int gitno_close(GIT_SOCKET s);
int gitno_send_chunk_size(int s, size_t len);
......
......@@ -100,10 +100,11 @@ cleanup:
*/
static int do_connect(transport_git *t, const char *url)
{
GIT_SOCKET s;
char *host, *port;
const char prefix[] = "git://";
int error, connected = 0;
int error;
t->socket = INVALID_SOCKET;
if (!git__prefixcmp(url, prefix))
url += strlen(prefix);
......@@ -111,22 +112,24 @@ static int do_connect(transport_git *t, const char *url)
if (gitno_extract_host_and_port(&host, &port, url, GIT_DEFAULT_PORT) < 0)
return -1;
s = gitno_connect(host, port);
connected = 1;
error = send_request(s, NULL, url);
t->socket = s;
if (gitno_connect(&t->socket, host, port) == 0) {
error = send_request(t->socket, NULL, url);
}
git__free(host);
git__free(port);
if (error < GIT_SUCCESS && s > 0)
gitno_close(s);
if (!connected) {
if (error < 0 && t->socket != INVALID_SOCKET) {
gitno_close(t->socket);
t->socket = INVALID_SOCKET;
}
if (t->socket == INVALID_SOCKET) {
giterr_set(GITERR_NET, "Failed to connect to the host");
return -1;
}
return error;
return 0;
}
/*
......
......@@ -85,12 +85,12 @@ static int gen_request(git_buf *buf, const char *url, const char *host, const ch
static int do_connect(transport_http *t, const char *host, const char *port)
{
GIT_SOCKET s = -1;
GIT_SOCKET s;
if (t->parent.connected && http_should_keep_alive(&t->parser))
return 0;
if ((s = gitno_connect(host, port)) < 0)
if (gitno_connect(&s, host, port) < 0)
return -1;
t->socket = s;
......
......@@ -7,6 +7,7 @@
#include "common.h"
#include "utf-conv.h"
#include "git2/windows.h"
/*
* Default codepage value
......
......@@ -83,8 +83,16 @@ void test_object_commit_commitstagedfile__generate_predictable_object_ids(void)
struct stat st;
cl_must_pass(p_lstat("treebuilder/test.txt", &st));
cl_assert(entry->file_size == st.st_size);
#ifndef _WIN32
/*
* Windows doesn't populate these fields, and the signage is
* wrong in the Windows version of the struct, so lets avoid
* the "comparing signed and unsigned" compilation warning in
* that case.
*/
cl_assert(entry->uid == st.st_uid);
cl_assert(entry->gid == st.st_gid);
#endif
}
/*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment