mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-29 20:42:23 +00:00
Merge branch 'development' into pull-req
This commit is contained in:
commit
a47cfd2211
@ -1,4 +0,0 @@
|
|||||||
Nasty build hack:
|
|
||||||
When setting SHA1 to ppc in CMakeLists.txt, after running initial CMake,
|
|
||||||
copy src/ppc/sha1ppc.S.obj to build/CMakeFiles/git2.dir/src/ppc/
|
|
||||||
Add CMakeFiles/git2.dir/src/ppc/sha1ppc.S.obj to the list in build/CMakeFiles/git2.dir/link.txt
|
|
@ -3,7 +3,6 @@ default: all
|
|||||||
CC = gcc
|
CC = gcc
|
||||||
CFLAGS += -g
|
CFLAGS += -g
|
||||||
CFLAGS += -I../../include -L../../build
|
CFLAGS += -I../../include -L../../build
|
||||||
LIBS += -lgit2 -lpthread #-lregex
|
|
||||||
|
|
||||||
OBJECTS = \
|
OBJECTS = \
|
||||||
git2.o \
|
git2.o \
|
||||||
@ -12,4 +11,4 @@ OBJECTS = \
|
|||||||
index-pack.o
|
index-pack.o
|
||||||
|
|
||||||
all: $(OBJECTS)
|
all: $(OBJECTS)
|
||||||
$(CC) $(CFLAGS) -o git2 $(OBJECTS) $(LIBS)
|
$(CC) $(CFLAGS) -o git2 $(OBJECTS)
|
||||||
|
@ -36,9 +36,7 @@ static void *download(void *ptr)
|
|||||||
|
|
||||||
exit:
|
exit:
|
||||||
data->finished = 1;
|
data->finished = 1;
|
||||||
#ifndef NO_PTHREADS
|
|
||||||
pthread_exit(&data->ret);
|
pthread_exit(&data->ret);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int update_cb(const char *refname, const git_oid *a, const git_oid *b)
|
int update_cb(const char *refname, const git_oid *a, const git_oid *b)
|
||||||
@ -83,9 +81,6 @@ int fetch(git_repository *repo, int argc, char **argv)
|
|||||||
data.finished = 0;
|
data.finished = 0;
|
||||||
memset(&stats, 0, sizeof(stats));
|
memset(&stats, 0, sizeof(stats));
|
||||||
|
|
||||||
#ifdef NO_PTHREADS
|
|
||||||
download(&data);
|
|
||||||
#else
|
|
||||||
pthread_create(&worker, NULL, download, &data);
|
pthread_create(&worker, NULL, download, &data);
|
||||||
|
|
||||||
// Loop while the worker thread is still running. Here we show processed
|
// Loop while the worker thread is still running. Here we show processed
|
||||||
@ -96,7 +91,7 @@ int fetch(git_repository *repo, int argc, char **argv)
|
|||||||
usleep(10000);
|
usleep(10000);
|
||||||
printf("\rReceived %d/%d objects in %d bytes", stats.processed, stats.total, bytes);
|
printf("\rReceived %d/%d objects in %d bytes", stats.processed, stats.total, bytes);
|
||||||
} while (!data.finished);
|
} while (!data.finished);
|
||||||
#endif
|
|
||||||
printf("\rReceived %d/%d objects in %d bytes\n", stats.processed, stats.total, bytes);
|
printf("\rReceived %d/%d objects in %d bytes\n", stats.processed, stats.total, bytes);
|
||||||
|
|
||||||
// Disconnect the underlying connection to prevent from idling.
|
// Disconnect the underlying connection to prevent from idling.
|
||||||
|
@ -103,8 +103,6 @@ GIT_EXTERN(int) git_strarray_copy(git_strarray *tgt, const git_strarray *src);
|
|||||||
*/
|
*/
|
||||||
GIT_EXTERN(void) git_libgit2_version(int *major, int *minor, int *rev);
|
GIT_EXTERN(void) git_libgit2_version(int *major, int *minor, int *rev);
|
||||||
|
|
||||||
/* GIT_EXTERN(int) p_fnmatch(const char *pattern, const char *string, int flags); */
|
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
GIT_END_DECL
|
GIT_END_DECL
|
||||||
#endif
|
#endif
|
||||||
|
@ -14,24 +14,22 @@
|
|||||||
|
|
||||||
int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offset)
|
int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offset)
|
||||||
{
|
{
|
||||||
int mprot = 0;
|
|
||||||
int mflag = 0;
|
|
||||||
|
|
||||||
GIT_MMAP_VALIDATE(out, len, prot, flags);
|
GIT_MMAP_VALIDATE(out, len, prot, flags);
|
||||||
|
|
||||||
out->data = NULL;
|
out->data = NULL;
|
||||||
out->len = 0;
|
out->len = 0;
|
||||||
|
|
||||||
if ((prot & GIT_PROT_WRITE) && ((flags & GIT_MAP_TYPE) == GIT_MAP_SHARED)) {
|
if ((prot & GIT_PROT_WRITE) && ((flags & GIT_MAP_TYPE) == GIT_MAP_SHARED)) {
|
||||||
printf("Trying to map shared-writeable file!!!\n");
|
giterr_set(GITERR_OS, "Trying to map shared-writeable");
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(out->data = malloc(len)) {
|
if((out->data = malloc(len))) {
|
||||||
p_lseek(fd, offset, SEEK_SET);
|
p_lseek(fd, offset, SEEK_SET);
|
||||||
p_read(fd, out->data, len);
|
p_read(fd, out->data, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!out->data || out->data == MAP_FAILED) {
|
if (!out->data || (out->data == MAP_FAILED)) {
|
||||||
giterr_set(GITERR_OS, "Failed to mmap. Could not write data");
|
giterr_set(GITERR_OS, "Failed to mmap. Could not write data");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
45
src/netops.c
45
src/netops.c
@ -33,6 +33,16 @@
|
|||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
#include "transport.h"
|
#include "transport.h"
|
||||||
|
|
||||||
|
#ifdef NO_ADDRINFO
|
||||||
|
struct addrinfo {
|
||||||
|
struct hostent *ai_hostent;
|
||||||
|
struct servent *ai_servent;
|
||||||
|
struct sockaddr_in ai_addr;
|
||||||
|
int ai_socktype;
|
||||||
|
long ai_port;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef GIT_WIN32
|
#ifdef GIT_WIN32
|
||||||
static void net_set_error(const char *str)
|
static void net_set_error(const char *str)
|
||||||
{
|
{
|
||||||
@ -378,41 +388,38 @@ int gitno_connect(git_transport *t, const char *host, const char *port)
|
|||||||
{
|
{
|
||||||
#ifndef NO_ADDRINFO
|
#ifndef NO_ADDRINFO
|
||||||
struct addrinfo *info = NULL, *p;
|
struct addrinfo *info = NULL, *p;
|
||||||
struct addrinfo hints;
|
|
||||||
#else
|
#else
|
||||||
int p;
|
int p;
|
||||||
struct hostent *hent;
|
|
||||||
struct servent *sent;
|
|
||||||
struct sockaddr_in saddr;
|
|
||||||
long port_num = 0;
|
|
||||||
#endif
|
#endif
|
||||||
|
struct addrinfo hints;
|
||||||
int ret;
|
int ret;
|
||||||
GIT_SOCKET s = INVALID_SOCKET;
|
GIT_SOCKET s = INVALID_SOCKET;
|
||||||
#ifndef NO_ADDRINFO
|
|
||||||
memset(&hints, 0x0, sizeof(struct addrinfo));
|
memset(&hints, 0x0, sizeof(struct addrinfo));
|
||||||
hints.ai_family = AF_UNSPEC;
|
|
||||||
hints.ai_socktype = SOCK_STREAM;
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
|
#ifndef NO_ADDRINFO
|
||||||
|
hints.ai_family = AF_UNSPEC;
|
||||||
|
|
||||||
if ((ret = getaddrinfo(host, port, &hints, &info)) < 0) {
|
if ((ret = getaddrinfo(host, port, &hints, &info)) < 0) {
|
||||||
giterr_set(GITERR_NET, "Failed to resolve address for %s: %s", host, gai_strerror(ret));
|
giterr_set(GITERR_NET, "Failed to resolve address for %s: %s", host, gai_strerror(ret));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
hent = gethostbyname(host);
|
hints.ai_hostent = gethostbyname(host);
|
||||||
sent = getservbyname(port, 0);
|
hints.ai_servent = getservbyname(port, 0);
|
||||||
|
|
||||||
if(sent)
|
if(hints.ai_servent)
|
||||||
port_num = sent->s_port;
|
hints.ai_port = hints.ai_servent->s_port;
|
||||||
else
|
else
|
||||||
port_num = atol(port);
|
hints.ai_port = atol(port);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef NO_ADDRINFO
|
#ifndef NO_ADDRINFO
|
||||||
for (p = info; p != NULL; p = p->ai_next) {
|
for (p = info; p != NULL; p = p->ai_next) {
|
||||||
s = socket(p->ai_family, p->ai_socktype, p->ai_protocol);
|
s = socket(p->ai_family, p->ai_socktype, p->ai_protocol);
|
||||||
#else
|
#else
|
||||||
for (p = 0; hent->h_addr_list[p] != NULL; p++) {
|
for (p = 0; hints.ai_hostent->h_addr_list[p] != NULL; p++) {
|
||||||
s = socket(hent->h_addrtype, SOCK_STREAM, 0);
|
s = socket(hints.ai_hostent->h_addrtype, hints.ai_socktype, 0);
|
||||||
#endif
|
#endif
|
||||||
if (s == INVALID_SOCKET) {
|
if (s == INVALID_SOCKET) {
|
||||||
net_set_error("error creating socket");
|
net_set_error("error creating socket");
|
||||||
@ -421,10 +428,10 @@ int gitno_connect(git_transport *t, const char *host, const char *port)
|
|||||||
#ifndef NO_ADDRINFO
|
#ifndef NO_ADDRINFO
|
||||||
if (connect(s, p->ai_addr, (socklen_t)p->ai_addrlen) == 0)
|
if (connect(s, p->ai_addr, (socklen_t)p->ai_addrlen) == 0)
|
||||||
#else
|
#else
|
||||||
memcpy(&saddr.sin_addr, hent->h_addr_list[p], hent->h_length);
|
memcpy(&hints.ai_addr.sin_addr, hints.ai_hostent->h_addr_list[p], hints.ai_hostent->h_length);
|
||||||
saddr.sin_family = hent->h_addrtype;
|
hints.ai_addr.sin_family = hints.ai_hostent->h_addrtype;
|
||||||
saddr.sin_port = port_num;
|
hints.ai_addr.sin_port = hints.ai_port;
|
||||||
if (connect(s, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in)) == 0)
|
if (connect(s, (struct sockaddr *)&hints.ai_addr, sizeof(struct sockaddr_in)) == 0)
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -438,7 +445,7 @@ int gitno_connect(git_transport *t, const char *host, const char *port)
|
|||||||
#ifndef NO_ADDRINFO
|
#ifndef NO_ADDRINFO
|
||||||
p == NULL) {
|
p == NULL) {
|
||||||
#else
|
#else
|
||||||
hent->h_addr_list[p] == NULL) {
|
hints.ai_hostent->h_addr_list[p] == NULL) {
|
||||||
#endif
|
#endif
|
||||||
giterr_set(GITERR_OS, "Failed to connect to %s", host);
|
giterr_set(GITERR_OS, "Failed to connect to %s", host);
|
||||||
return -1;
|
return -1;
|
||||||
|
13
src/path.c
13
src/path.c
@ -486,14 +486,9 @@ int git_path_cmp(
|
|||||||
/* Taken from git.git */
|
/* Taken from git.git */
|
||||||
GIT_INLINE(int) is_dot_or_dotdot(const char *name)
|
GIT_INLINE(int) is_dot_or_dotdot(const char *name)
|
||||||
{
|
{
|
||||||
#ifdef __amigaos4__
|
|
||||||
/* This is irrelevant on AmigaOS */
|
|
||||||
return 0;
|
|
||||||
#else
|
|
||||||
return (name[0] == '.' &&
|
return (name[0] == '.' &&
|
||||||
(name[1] == '\0' ||
|
(name[1] == '\0' ||
|
||||||
(name[1] == '.' && name[2] == '\0')));
|
(name[1] == '.' && name[2] == '\0')));
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int git_path_direach(
|
int git_path_direach(
|
||||||
@ -521,11 +516,7 @@ int git_path_direach(
|
|||||||
de_buf = git__malloc(sizeof(struct dirent));
|
de_buf = git__malloc(sizeof(struct dirent));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef NO_READDIR_R
|
while (p_readdir_r(dir, de_buf, &de) == 0 && de != NULL) {
|
||||||
while (de = readdir(dir)) {
|
|
||||||
#else
|
|
||||||
while (p_readdir_r(dir, de_buf, de) == 0 && de != NULL) {
|
|
||||||
#endif
|
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
if (is_dot_or_dotdot(de->d_name))
|
if (is_dot_or_dotdot(de->d_name))
|
||||||
@ -583,7 +574,7 @@ int git_path_dirload(
|
|||||||
path_len -= prefix_len;
|
path_len -= prefix_len;
|
||||||
need_slash = (path_len > 0 && path[path_len-1] != '/') ? 1 : 0;
|
need_slash = (path_len > 0 && path[path_len-1] != '/') ? 1 : 0;
|
||||||
|
|
||||||
while ((error = p_readdir_r(dir, de_buf, de)) == 0 && de != NULL) {
|
while ((error = p_readdir_r(dir, de_buf, &de)) == 0 && de != NULL) {
|
||||||
char *entry_path;
|
char *entry_path;
|
||||||
size_t entry_len;
|
size_t entry_len;
|
||||||
|
|
||||||
|
@ -276,7 +276,7 @@ uint32_t git_pool__system_page_size(void)
|
|||||||
GetSystemInfo(&info);
|
GetSystemInfo(&info);
|
||||||
size = (uint32_t)info.dwPageSize;
|
size = (uint32_t)info.dwPageSize;
|
||||||
#elif defined(__amigaos4__)
|
#elif defined(__amigaos4__)
|
||||||
size = (uint32_t)1000000; // random value
|
size = (uint32_t)4096; /* 4K as there is no global value we can query */
|
||||||
#else
|
#else
|
||||||
size = (uint32_t)sysconf(_SC_PAGE_SIZE);
|
size = (uint32_t)sysconf(_SC_PAGE_SIZE);
|
||||||
#endif
|
#endif
|
||||||
|
10
src/posix.h
10
src/posix.h
@ -84,9 +84,15 @@ extern int p_gettimeofday(struct timeval *tv, struct timezone *tz);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef NO_READDIR_R
|
#ifndef NO_READDIR_R
|
||||||
#define p_readdir_r(d,e,r) readdir_r(d,e,&r)
|
#define p_readdir_r(d,e,r) readdir_r(d,e,r)
|
||||||
#else
|
#else
|
||||||
#define p_readdir_r(d,e,r) r = readdir(d)
|
#include <dirent.h>
|
||||||
|
GIT_INLINE(int) p_readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result)
|
||||||
|
{
|
||||||
|
GIT_UNUSED(entry);
|
||||||
|
*result = readdir(dirp);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user