mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-08 03:15:46 +00:00
Merge branch 'pull-req' of https://github.com/chris-y/libgit2 into amigaos
This commit is contained in:
commit
2ae052d1b1
@ -21,13 +21,30 @@ STRING(REGEX REPLACE "^.*LIBGIT2_VERSION \"[0-9]+\\.([0-9]+).*$" "\\1" LIBGIT2_V
|
|||||||
STRING(REGEX REPLACE "^.*LIBGIT2_VERSION \"[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" LIBGIT2_VERSION_REV "${GIT2_HEADER}")
|
STRING(REGEX REPLACE "^.*LIBGIT2_VERSION \"[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" LIBGIT2_VERSION_REV "${GIT2_HEADER}")
|
||||||
SET(LIBGIT2_VERSION_STRING "${LIBGIT2_VERSION_MAJOR}.${LIBGIT2_VERSION_MINOR}.${LIBGIT2_VERSION_REV}")
|
SET(LIBGIT2_VERSION_STRING "${LIBGIT2_VERSION_MAJOR}.${LIBGIT2_VERSION_MINOR}.${LIBGIT2_VERSION_REV}")
|
||||||
|
|
||||||
|
IF (AMIGA)
|
||||||
|
# Default AmigaOS to use the PowerPC SHA1
|
||||||
|
SET(SHA1_TYPE "ppc")
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
# Find required dependencies
|
# Find required dependencies
|
||||||
INCLUDE_DIRECTORIES(src include deps/http-parser)
|
INCLUDE_DIRECTORIES(src include deps/http-parser)
|
||||||
|
|
||||||
FILE(GLOB SRC_HTTP deps/http-parser/*.c)
|
FILE(GLOB SRC_HTTP deps/http-parser/*.c)
|
||||||
|
|
||||||
|
# Specify sha1 implementation
|
||||||
|
IF (SHA1_TYPE STREQUAL "ppc")
|
||||||
|
ADD_DEFINITIONS(-DPPC_SHA1)
|
||||||
|
FILE(GLOB SRC_SHA1 src/ppc/*.c src/ppc/*.S)
|
||||||
|
ELSE ()
|
||||||
|
SET (SRC_SHA1)
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
IF (NOT WIN32)
|
IF (NOT WIN32)
|
||||||
FIND_PACKAGE(ZLIB)
|
FIND_PACKAGE(ZLIB)
|
||||||
|
IF (CMAKE_SYSTEM_NAME STREQUAL "AmigaOS")
|
||||||
|
INCLUDE_DIRECTORIES(deps/regex)
|
||||||
|
SET(SRC_REGEX deps/regex/regex.c)
|
||||||
|
ENDIF()
|
||||||
ELSE()
|
ELSE()
|
||||||
# Windows doesn't understand POSIX regex on its own
|
# Windows doesn't understand POSIX regex on its own
|
||||||
INCLUDE_DIRECTORIES(deps/regex)
|
INCLUDE_DIRECTORIES(deps/regex)
|
||||||
@ -115,12 +132,15 @@ IF (WIN32 AND NOT CYGWIN)
|
|||||||
FILE(GLOB SRC src/*.c src/transports/*.c src/xdiff/*.c src/win32/*.c src/compat/*.c)
|
FILE(GLOB SRC src/*.c src/transports/*.c src/xdiff/*.c src/win32/*.c src/compat/*.c)
|
||||||
ELSEIF (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
|
ELSEIF (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
|
||||||
FILE(GLOB SRC src/*.c src/transports/*.c src/xdiff/*.c src/unix/*.c src/compat/*.c)
|
FILE(GLOB SRC src/*.c src/transports/*.c src/xdiff/*.c src/unix/*.c src/compat/*.c)
|
||||||
|
ELSEIF (AMIGA)
|
||||||
|
ADD_DEFINITIONS(-DNO_ADDRINFO -DNO_READDIR_R)
|
||||||
|
FILE(GLOB SRC src/*.c src/transports/*.c src/xdiff/*.c src/amiga/*.c src/compat/*.c)
|
||||||
ELSE()
|
ELSE()
|
||||||
FILE(GLOB SRC src/*.c src/transports/*.c src/xdiff/*.c src/unix/*.c)
|
FILE(GLOB SRC src/*.c src/transports/*.c src/xdiff/*.c src/unix/*.c)
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
# Compile and link libgit2
|
# Compile and link libgit2
|
||||||
ADD_LIBRARY(git2 ${SRC} ${SRC_ZLIB} ${SRC_HTTP} ${SRC_REGEX} ${WIN_RC})
|
ADD_LIBRARY(git2 ${SRC} ${SRC_ZLIB} ${SRC_HTTP} ${SRC_REGEX} ${SRC_SHA1} ${WIN_RC})
|
||||||
|
|
||||||
IF (WIN32)
|
IF (WIN32)
|
||||||
TARGET_LINK_LIBRARIES(git2 ws2_32)
|
TARGET_LINK_LIBRARIES(git2 ws2_32)
|
||||||
|
@ -2,7 +2,7 @@ default: all
|
|||||||
|
|
||||||
CC = gcc
|
CC = gcc
|
||||||
CFLAGS += -g
|
CFLAGS += -g
|
||||||
CFLAGS += -I../../include -L../../ -lgit2 -lpthread
|
CFLAGS += -I../../include -L../../build -lgit2 -lpthread
|
||||||
|
|
||||||
OBJECTS = \
|
OBJECTS = \
|
||||||
git2.o \
|
git2.o \
|
||||||
|
@ -91,6 +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);
|
||||||
|
|
||||||
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.
|
||||||
|
@ -55,6 +55,10 @@
|
|||||||
#define GIT_WIN32 1
|
#define GIT_WIN32 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __amigaos4__
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file git2/common.h
|
* @file git2/common.h
|
||||||
* @brief Git common platform definitions
|
* @brief Git common platform definitions
|
||||||
|
@ -20,6 +20,7 @@ GIT_BEGIN_DECL
|
|||||||
#ifdef GIT_OLD_ERRORS
|
#ifdef GIT_OLD_ERRORS
|
||||||
enum {
|
enum {
|
||||||
GIT_SUCCESS = 0,
|
GIT_SUCCESS = 0,
|
||||||
|
GIT_ERROR = -1,
|
||||||
GIT_ENOTOID = -2,
|
GIT_ENOTOID = -2,
|
||||||
GIT_ENOTFOUND = -3,
|
GIT_ENOTFOUND = -3,
|
||||||
GIT_ENOMEM = -4,
|
GIT_ENOMEM = -4,
|
||||||
@ -52,7 +53,7 @@ enum {
|
|||||||
GIT_ENOMATCH = -31,
|
GIT_ENOMATCH = -31,
|
||||||
GIT_ESHORTBUFFER = -32,
|
GIT_ESHORTBUFFER = -32,
|
||||||
};
|
};
|
||||||
#endif
|
#else
|
||||||
|
|
||||||
/** Generic return codes */
|
/** Generic return codes */
|
||||||
enum {
|
enum {
|
||||||
@ -66,6 +67,7 @@ enum {
|
|||||||
GIT_PASSTHROUGH = -30,
|
GIT_PASSTHROUGH = -30,
|
||||||
GIT_REVWALKOVER = -31,
|
GIT_REVWALKOVER = -31,
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *message;
|
char *message;
|
||||||
|
@ -32,6 +32,9 @@ GIT_BEGIN_DECL
|
|||||||
* stat() functions, for all platforms.
|
* stat() functions, for all platforms.
|
||||||
*/
|
*/
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#ifdef __amigaos4__
|
||||||
|
#include <stdint.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
|
|
||||||
|
51
src/amiga/map.c
Executable file
51
src/amiga/map.c
Executable file
@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2009-2012 the libgit2 contributors
|
||||||
|
*
|
||||||
|
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||||
|
* a Linking Exception. For full terms see the included COPYING file.
|
||||||
|
*/
|
||||||
|
#include <git2/common.h>
|
||||||
|
|
||||||
|
#ifndef GIT_WIN32
|
||||||
|
|
||||||
|
#include "posix.h"
|
||||||
|
#include "map.h"
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offset)
|
||||||
|
{
|
||||||
|
GIT_MMAP_VALIDATE(out, len, prot, flags);
|
||||||
|
|
||||||
|
out->data = NULL;
|
||||||
|
out->len = 0;
|
||||||
|
|
||||||
|
if ((prot & GIT_PROT_WRITE) && ((flags & GIT_MAP_TYPE) == GIT_MAP_SHARED)) {
|
||||||
|
giterr_set(GITERR_OS, "Trying to map shared-writeable");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if((out->data = malloc(len))) {
|
||||||
|
p_lseek(fd, offset, SEEK_SET);
|
||||||
|
p_read(fd, out->data, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!out->data || (out->data == MAP_FAILED)) {
|
||||||
|
giterr_set(GITERR_OS, "Failed to mmap. Could not write data");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
out->len = len;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int p_munmap(git_map *map)
|
||||||
|
{
|
||||||
|
assert(map != NULL);
|
||||||
|
free(map->data);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -365,11 +365,11 @@ int git_indexer_stream_add(git_indexer_stream *idx, const void *data, size_t siz
|
|||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
idx->off = entry_start;
|
idx->off = entry_start;
|
||||||
error = store_delta(idx);
|
error = store_delta(idx);
|
||||||
|
|
||||||
if (error == GIT_EBUFS)
|
if (error == GIT_EBUFS)
|
||||||
return 0;
|
return 0;
|
||||||
if (error < 0)
|
if (error < 0)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,10 @@
|
|||||||
#define GIT_MAP_TYPE 0xf
|
#define GIT_MAP_TYPE 0xf
|
||||||
#define GIT_MAP_FIXED 0x10
|
#define GIT_MAP_FIXED 0x10
|
||||||
|
|
||||||
|
#ifdef __amigaos4__
|
||||||
|
#define MAP_FAILED 0
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct { /* memory mapped buffer */
|
typedef struct { /* memory mapped buffer */
|
||||||
void *data; /* data bytes */
|
void *data; /* data bytes */
|
||||||
size_t len; /* data length */
|
size_t len; /* data length */
|
||||||
|
@ -158,6 +158,7 @@ static git_mwindow *new_window(
|
|||||||
git_mwindow *w;
|
git_mwindow *w;
|
||||||
|
|
||||||
w = git__malloc(sizeof(*w));
|
w = git__malloc(sizeof(*w));
|
||||||
|
|
||||||
if (w == NULL)
|
if (w == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
96
src/netops.c
96
src/netops.c
@ -32,6 +32,99 @@
|
|||||||
#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_in;
|
||||||
|
struct sockaddr *ai_addr;
|
||||||
|
size_t ai_addrlen;
|
||||||
|
int ai_family;
|
||||||
|
int ai_socktype;
|
||||||
|
int ai_protocol;
|
||||||
|
long ai_port;
|
||||||
|
struct addrinfo *ai_next;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int getaddrinfo(const char *host, const char *port, struct addrinfo *hints, struct addrinfo **info) {
|
||||||
|
GIT_UNUSED(hints);
|
||||||
|
|
||||||
|
struct addrinfo *ainfo, *ai;
|
||||||
|
int p = 0;
|
||||||
|
|
||||||
|
if((ainfo = malloc(sizeof(struct addrinfo))) == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if((ainfo->ai_hostent = gethostbyname(host)) == NULL)
|
||||||
|
return -2;
|
||||||
|
|
||||||
|
ainfo->ai_servent = getservbyname(port, 0);
|
||||||
|
|
||||||
|
if(ainfo->ai_servent)
|
||||||
|
ainfo->ai_port = ainfo->ai_servent->s_port;
|
||||||
|
else
|
||||||
|
ainfo->ai_port = atol(port);
|
||||||
|
|
||||||
|
|
||||||
|
memcpy(&ainfo->ai_addr_in.sin_addr, ainfo->ai_hostent->h_addr_list[0], ainfo->ai_hostent->h_length);
|
||||||
|
ainfo->ai_protocol = 0;
|
||||||
|
ainfo->ai_socktype = hints->ai_socktype;
|
||||||
|
ainfo->ai_family = ainfo->ai_hostent->h_addrtype;
|
||||||
|
ainfo->ai_addr_in.sin_family = ainfo->ai_family;
|
||||||
|
ainfo->ai_addr_in.sin_port = ainfo->ai_port;
|
||||||
|
ainfo->ai_addr = (struct addrinfo *)&ainfo->ai_addr_in;
|
||||||
|
ainfo->ai_addrlen = sizeof(struct sockaddr_in);
|
||||||
|
|
||||||
|
*info = ainfo;
|
||||||
|
|
||||||
|
if(ainfo->ai_hostent->h_addr_list[1] == NULL) {
|
||||||
|
ainfo->ai_next = NULL;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ai = ainfo;
|
||||||
|
|
||||||
|
for (p = 1; ainfo->ai_hostent->h_addr_list[p] != NULL; p++) {
|
||||||
|
ai->ai_next = malloc(sizeof(struct addrinfo));
|
||||||
|
memcpy(&ai->ai_next, ainfo, sizeof(struct addrinfo));
|
||||||
|
memcpy(&ai->ai_next->ai_addr_in.sin_addr, ainfo->ai_hostent->h_addr_list[p], ainfo->ai_hostent->h_length);
|
||||||
|
ai->ai_next->ai_addr = (struct addrinfo *)&ai->ai_next->ai_addr_in;
|
||||||
|
ai = ai->ai_next;
|
||||||
|
}
|
||||||
|
|
||||||
|
ai->ai_next = NULL;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void freeaddrinfo(struct addrinfo *info) {
|
||||||
|
struct addrinfo *p, *next;
|
||||||
|
|
||||||
|
p = info;
|
||||||
|
|
||||||
|
while(p != NULL) {
|
||||||
|
next = p->ai_next;
|
||||||
|
free(p);
|
||||||
|
p = next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char *gai_strerror(int ret) {
|
||||||
|
switch(ret) {
|
||||||
|
case -1:
|
||||||
|
return "Out of memory";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case -2:
|
||||||
|
return "Address lookup failed";
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return "Unknown error";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef GIT_WIN32
|
#ifdef GIT_WIN32
|
||||||
static void net_set_error(const char *str)
|
static void net_set_error(const char *str)
|
||||||
{
|
{
|
||||||
@ -381,8 +474,8 @@ int gitno_connect(git_transport *t, const char *host, const char *port)
|
|||||||
GIT_SOCKET s = INVALID_SOCKET;
|
GIT_SOCKET s = INVALID_SOCKET;
|
||||||
|
|
||||||
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;
|
||||||
|
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));
|
||||||
@ -391,6 +484,7 @@ int gitno_connect(git_transport *t, const char *host, const char *port)
|
|||||||
|
|
||||||
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);
|
||||||
|
|
||||||
if (s == INVALID_SOCKET) {
|
if (s == INVALID_SOCKET) {
|
||||||
net_set_error("error creating socket");
|
net_set_error("error creating socket");
|
||||||
break;
|
break;
|
||||||
|
@ -262,7 +262,7 @@ int git_packfile_unpack_header(
|
|||||||
if (base == NULL)
|
if (base == NULL)
|
||||||
return GIT_EBUFS;
|
return GIT_EBUFS;
|
||||||
|
|
||||||
ret = packfile_unpack_header1(&used, size_p, type_p, base, left);
|
ret = packfile_unpack_header1(&used, size_p, type_p, base, left);
|
||||||
git_mwindow_close(w_curs);
|
git_mwindow_close(w_curs);
|
||||||
if (ret == GIT_EBUFS)
|
if (ret == GIT_EBUFS)
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -275,6 +275,8 @@ uint32_t git_pool__system_page_size(void)
|
|||||||
SYSTEM_INFO info;
|
SYSTEM_INFO info;
|
||||||
GetSystemInfo(&info);
|
GetSystemInfo(&info);
|
||||||
size = (uint32_t)info.dwPageSize;
|
size = (uint32_t)info.dwPageSize;
|
||||||
|
#elif defined(__amigaos4__)
|
||||||
|
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
@ -83,6 +83,16 @@ extern int p_gettimeofday(struct timeval *tv, struct timezone *tz);
|
|||||||
# include "unix/posix.h"
|
# include "unix/posix.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#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
|
||||||
|
#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
|
||||||
|
@ -33,6 +33,7 @@ int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offs
|
|||||||
mflag = MAP_PRIVATE;
|
mflag = MAP_PRIVATE;
|
||||||
|
|
||||||
out->data = mmap(NULL, len, mprot, mflag, fd, offset);
|
out->data = mmap(NULL, len, mprot, mflag, fd, offset);
|
||||||
|
|
||||||
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;
|
||||||
@ -47,6 +48,7 @@ int p_munmap(git_map *map)
|
|||||||
{
|
{
|
||||||
assert(map != NULL);
|
assert(map != NULL);
|
||||||
munmap(map->data, map->len);
|
munmap(map->data, map->len);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#ifndef INCLUDE_posix__w32_h__
|
#ifndef INCLUDE_posix__w32_h__
|
||||||
#define INCLUDE_posix__w32_h__
|
#define INCLUDE_posix__w32_h__
|
||||||
|
|
||||||
#ifndef __sun
|
#if !defined(__sun) && !defined(__amigaos4__)
|
||||||
# include <fnmatch.h>
|
# include <fnmatch.h>
|
||||||
# define p_fnmatch(p, s, f) fnmatch(p, s, f)
|
# define p_fnmatch(p, s, f) fnmatch(p, s, f)
|
||||||
#else
|
#else
|
||||||
|
Loading…
Reference in New Issue
Block a user