Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
2ae052d1
Commit
2ae052d1
authored
Jun 22, 2012
by
Vicent Marti
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'pull-req' of
https://github.com/chris-y/libgit2
into amigaos
parents
430af731
db5a6ec7
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
201 additions
and
7 deletions
+201
-7
CMakeLists.txt
+21
-1
examples/network/Makefile
+1
-1
examples/network/fetch.c
+1
-0
include/git2/common.h
+4
-0
include/git2/errors.h
+3
-1
include/git2/types.h
+3
-0
src/amiga/map.c
+51
-0
src/indexer.c
+1
-1
src/map.h
+4
-0
src/mwindow.c
+1
-0
src/netops.c
+95
-1
src/pack.c
+1
-1
src/pool.c
+2
-0
src/posix.h
+10
-0
src/unix/map.c
+2
-0
src/unix/posix.h
+1
-1
No files found.
CMakeLists.txt
View file @
2ae052d1
...
...
@@ -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
}
"
)
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
INCLUDE_DIRECTORIES
(
src include deps/http-parser
)
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
)
FIND_PACKAGE
(
ZLIB
)
IF
(
CMAKE_SYSTEM_NAME STREQUAL
"AmigaOS"
)
INCLUDE_DIRECTORIES
(
deps/regex
)
SET
(
SRC_REGEX deps/regex/regex.c
)
ENDIF
()
ELSE
()
# Windows doesn't understand POSIX regex on its own
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
)
ELSEIF
(
CMAKE_SYSTEM_NAME MATCHES
"(Solaris|SunOS)"
)
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
()
FILE
(
GLOB SRC src/*.c src/transports/*.c src/xdiff/*.c src/unix/*.c
)
ENDIF
()
# 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
)
TARGET_LINK_LIBRARIES
(
git2 ws2_32
)
...
...
examples/network/Makefile
View file @
2ae052d1
...
...
@@ -2,7 +2,7 @@ default: all
CC
=
gcc
CFLAGS
+=
-g
CFLAGS
+=
-I
../../include
-L
../../
-lgit2
-lpthread
CFLAGS
+=
-I
../../include
-L
../../
build
-lgit2
-lpthread
OBJECTS
=
\
git2.o
\
...
...
examples/network/fetch.c
View file @
2ae052d1
...
...
@@ -91,6 +91,7 @@ int fetch(git_repository *repo, int argc, char **argv)
usleep
(
10000
);
printf
(
"
\r
Received %d/%d objects in %d bytes"
,
stats
.
processed
,
stats
.
total
,
bytes
);
}
while
(
!
data
.
finished
);
printf
(
"
\r
Received %d/%d objects in %d bytes
\n
"
,
stats
.
processed
,
stats
.
total
,
bytes
);
// Disconnect the underlying connection to prevent from idling.
...
...
include/git2/common.h
View file @
2ae052d1
...
...
@@ -55,6 +55,10 @@
#define GIT_WIN32 1
#endif
#ifdef __amigaos4__
#include <netinet/in.h>
#endif
/**
* @file git2/common.h
* @brief Git common platform definitions
...
...
include/git2/errors.h
View file @
2ae052d1
...
...
@@ -20,6 +20,7 @@ GIT_BEGIN_DECL
#ifdef GIT_OLD_ERRORS
enum
{
GIT_SUCCESS
=
0
,
GIT_ERROR
=
-
1
,
GIT_ENOTOID
=
-
2
,
GIT_ENOTFOUND
=
-
3
,
GIT_ENOMEM
=
-
4
,
...
...
@@ -52,7 +53,7 @@ enum {
GIT_ENOMATCH
=
-
31
,
GIT_ESHORTBUFFER
=
-
32
,
};
#e
ndif
#e
lse
/** Generic return codes */
enum
{
...
...
@@ -66,6 +67,7 @@ enum {
GIT_PASSTHROUGH
=
-
30
,
GIT_REVWALKOVER
=
-
31
,
};
#endif
typedef
struct
{
char
*
message
;
...
...
include/git2/types.h
View file @
2ae052d1
...
...
@@ -32,6 +32,9 @@ GIT_BEGIN_DECL
* stat() functions, for all platforms.
*/
#include <sys/types.h>
#ifdef __amigaos4__
#include <stdint.h>
#endif
#if defined(_MSC_VER)
...
...
src/amiga/map.c
0 → 100755
View file @
2ae052d1
/*
* 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
src/indexer.c
View file @
2ae052d1
...
...
@@ -365,11 +365,11 @@ int git_indexer_stream_add(git_indexer_stream *idx, const void *data, size_t siz
if
(
error
<
0
)
{
idx
->
off
=
entry_start
;
error
=
store_delta
(
idx
);
if
(
error
==
GIT_EBUFS
)
return
0
;
if
(
error
<
0
)
return
error
;
continue
;
}
...
...
src/map.h
View file @
2ae052d1
...
...
@@ -23,6 +23,10 @@
#define GIT_MAP_TYPE 0xf
#define GIT_MAP_FIXED 0x10
#ifdef __amigaos4__
#define MAP_FAILED 0
#endif
typedef
struct
{
/* memory mapped buffer */
void
*
data
;
/* data bytes */
size_t
len
;
/* data length */
...
...
src/mwindow.c
View file @
2ae052d1
...
...
@@ -158,6 +158,7 @@ static git_mwindow *new_window(
git_mwindow
*
w
;
w
=
git__malloc
(
sizeof
(
*
w
));
if
(
w
==
NULL
)
return
NULL
;
...
...
src/netops.c
View file @
2ae052d1
...
...
@@ -32,6 +32,99 @@
#include "buffer.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
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
;
memset
(
&
hints
,
0x0
,
sizeof
(
struct
addrinfo
));
hints
.
ai_family
=
AF_UNSPEC
;
hints
.
ai_socktype
=
SOCK_STREAM
;
hints
.
ai_family
=
AF_UNSPEC
;
if
((
ret
=
getaddrinfo
(
host
,
port
,
&
hints
,
&
info
))
<
0
)
{
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
)
{
s
=
socket
(
p
->
ai_family
,
p
->
ai_socktype
,
p
->
ai_protocol
);
if
(
s
==
INVALID_SOCKET
)
{
net_set_error
(
"error creating socket"
);
break
;
...
...
src/pack.c
View file @
2ae052d1
...
...
@@ -262,7 +262,7 @@ int git_packfile_unpack_header(
if
(
base
==
NULL
)
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
);
if
(
ret
==
GIT_EBUFS
)
return
ret
;
...
...
src/pool.c
View file @
2ae052d1
...
...
@@ -275,6 +275,8 @@ uint32_t git_pool__system_page_size(void)
SYSTEM_INFO
info
;
GetSystemInfo
(
&
info
);
size
=
(
uint32_t
)
info
.
dwPageSize
;
#elif defined(__amigaos4__)
size
=
(
uint32_t
)
4096
;
/* 4K as there is no global value we can query */
#else
size
=
(
uint32_t
)
sysconf
(
_SC_PAGE_SIZE
);
#endif
...
...
src/posix.h
View file @
2ae052d1
...
...
@@ -83,6 +83,16 @@ extern int p_gettimeofday(struct timeval *tv, struct timezone *tz);
# include "unix/posix.h"
#endif
#ifndef NO_READDIR_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
src/unix/map.c
View file @
2ae052d1
...
...
@@ -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
;
out
->
data
=
mmap
(
NULL
,
len
,
mprot
,
mflag
,
fd
,
offset
);
if
(
!
out
->
data
||
out
->
data
==
MAP_FAILED
)
{
giterr_set
(
GITERR_OS
,
"Failed to mmap. Could not write data"
);
return
-
1
;
...
...
@@ -47,6 +48,7 @@ int p_munmap(git_map *map)
{
assert
(
map
!=
NULL
);
munmap
(
map
->
data
,
map
->
len
);
return
0
;
}
...
...
src/unix/posix.h
View file @
2ae052d1
...
...
@@ -7,7 +7,7 @@
#ifndef INCLUDE_posix__w32_h__
#define INCLUDE_posix__w32_h__
#if
ndef __sun
#if
!defined(__sun) && !defined(__amigaos4__)
# include <fnmatch.h>
# define p_fnmatch(p, s, f) fnmatch(p, s, f)
#else
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment