Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 28f087c

Browse files
committed
libgit2 v0.21.0
2 parents 4b0a36e + 1589aa0 commit 28f087c

File tree

784 files changed

+31834
-10716
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

784 files changed

+31834
-10716
lines changed

.travis.yml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,48 @@
33

44
language: c
55

6+
os:
7+
- linux
8+
- osx
9+
610
compiler:
711
- gcc
812
- clang
913

1014
# Settings to try
1115
env:
16+
global:
17+
- secure: "YnhS+8n6B+uoyaYfaJ3Lei7cSJqHDPiKJCKFIF2c87YDfmCvAJke8QtE7IzjYDs7UFkTCM4ox+ph2bERUrxZbSCyEkHdjIZpKuMJfYWja/jgMqTMxdyOH9y8JLFbZsSXDIXDwqBlC6vVyl1fP90M35wuWcNTs6tctfVWVofEFbs="
18+
matrix:
1219
- OPTIONS="-DTHREADSAFE=ON -DCMAKE_BUILD_TYPE=Release"
1320
- OPTIONS="-DBUILD_CLAR=ON -DBUILD_EXAMPLES=ON"
1421

1522
matrix:
23+
fast_finish: true
24+
exclude:
25+
- os: osx
26+
compiler: gcc
1627
include:
1728
- compiler: i586-mingw32msvc-gcc
18-
env: OPTIONS="-DBUILD_CLAR=OFF -DWIN32=ON -DMINGW=ON"
29+
env: OPTIONS="-DBUILD_CLAR=OFF -DWIN32=ON -DMINGW=ON -DUSE_SSH=OFF"
30+
os: linux
31+
- compiler: gcc
32+
env: COVERITY=1
33+
os: linux
34+
allow_failures:
35+
- env: COVERITY=1
1936

2037
install:
21-
- sudo apt-get -qq update
22-
- sudo apt-get -qq install cmake libssh2-1-dev openssh-client openssh-server
38+
- ./script/install-deps-${TRAVIS_OS_NAME}.sh
2339

2440
# Run the Build script and tests
2541
script:
2642
- script/cibuild.sh
2743

2844
# Run Tests
2945
after_success:
30-
- sudo apt-get -qq install valgrind
31-
- valgrind --leak-check=full --show-reachable=yes --suppressions=./libgit2_clar.supp _build/libgit2_clar -ionline
46+
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get -qq install valgrind; fi
47+
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then valgrind --leak-check=full --show-reachable=yes --suppressions=./libgit2_clar.supp _build/libgit2_clar -ionline; fi
3248

3349
# Only watch the development branch
3450
branches:

AUTHORS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Alexei Sholik
66
Andreas Ericsson
77
Anton "antong" Gyllenberg
88
Ankur Sethi
9+
Arthur Schreiber
910
Ben Noordhuis
1011
Ben Straub
1112
Benjamin C Meyer
@@ -25,6 +26,7 @@ Florian Forster
2526
Holger Weiss
2627
Ingmar Vanhassel
2728
J. David Ibáñez
29+
Jacques Germishuys
2830
Jakob Pfender
2931
Jason Penny
3032
Jason R. McNeil

CMakeLists.txt

Lines changed: 68 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ PROJECT(libgit2 C)
1515
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
1616

1717
# Add find modules to the path
18-
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
18+
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")
19+
20+
INCLUDE(CheckLibraryExists)
21+
INCLUDE(AddCFlagIfSupported)
1922

2023
# Build options
2124
#
@@ -33,8 +36,9 @@ OPTION( ANDROID "Build for android NDK" OFF )
3336

3437
OPTION( USE_ICONV "Link with and use iconv library" OFF )
3538
OPTION( USE_SSH "Link with libssh to enable SSH support" ON )
39+
OPTION( VALGRIND "Configure build for valgrind" OFF )
3640

37-
IF(APPLE)
41+
IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
3842
SET( USE_ICONV ON )
3943
ENDIF()
4044

@@ -54,6 +58,10 @@ IF(MSVC)
5458
# By default, libgit2 is built with WinHTTP. To use the built-in
5559
# HTTP transport, invoke CMake with the "-DWINHTTP=OFF" argument.
5660
OPTION( WINHTTP "Use Win32 WinHTTP routines" ON )
61+
62+
ADD_DEFINITIONS(-D_SCL_SECURE_NO_WARNINGS)
63+
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
64+
ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE)
5765
ENDIF()
5866

5967
# This variable will contain the libraries we need to put into
@@ -77,17 +85,13 @@ FUNCTION(TARGET_OS_LIBRARIES target)
7785
ELSEIF(CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
7886
TARGET_LINK_LIBRARIES(${target} socket nsl)
7987
SET(LIBGIT2_PC_LIBS "${LIBGIT2_PC_LIBS} -lsocket -lnsl" PARENT_SCOPE)
80-
ELSEIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
88+
ENDIF()
89+
CHECK_LIBRARY_EXISTS(rt clock_gettime "time.h" NEED_LIBRT)
90+
IF(NEED_LIBRT)
8191
TARGET_LINK_LIBRARIES(${target} rt)
8292
SET(LIBGIT2_PC_LIBS "${LIBGIT2_PC_LIBS} -lrt" PARENT_SCOPE)
8393
ENDIF()
8494

85-
IF(USE_ICONV)
86-
TARGET_LINK_LIBRARIES(${target} iconv)
87-
ADD_DEFINITIONS(-DGIT_USE_ICONV)
88-
SET(LIBGIT2_PC_LIBS "${LIBGIT2_PC_LIBS} -liconv" PARENT_SCOPE)
89-
ENDIF()
90-
9195
IF(THREADSAFE)
9296
TARGET_LINK_LIBRARIES(${target} ${CMAKE_THREAD_LIBS_INIT})
9397
ENDIF()
@@ -123,6 +127,9 @@ STRING(REGEX REPLACE "^.*LIBGIT2_VERSION \"[0-9]+\\.([0-9]+).*$" "\\1" LIBGIT2_V
123127
STRING(REGEX REPLACE "^.*LIBGIT2_VERSION \"[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" LIBGIT2_VERSION_REV "${GIT2_HEADER}")
124128
SET(LIBGIT2_VERSION_STRING "${LIBGIT2_VERSION_MAJOR}.${LIBGIT2_VERSION_MINOR}.${LIBGIT2_VERSION_REV}")
125129

130+
FILE(STRINGS "include/git2/version.h" GIT2_HEADER_SOVERSION REGEX "^#define LIBGIT2_SOVERSION [0-9]+$")
131+
STRING(REGEX REPLACE "^.*LIBGIT2_SOVERSION ([0-9]+)$" "\\1" LIBGIT2_SOVERSION "${GIT2_HEADER_SOVERSION}")
132+
126133
# Find required dependencies
127134
INCLUDE_DIRECTORIES(src include)
128135

@@ -135,13 +142,13 @@ ELSE ()
135142
FIND_PACKAGE(OpenSSL)
136143
ENDIF ()
137144

138-
FIND_PACKAGE(HTTP_Parser QUIET)
145+
FIND_PACKAGE(HTTP_Parser)
139146
IF (HTTP_PARSER_FOUND AND HTTP_PARSER_VERSION_MAJOR EQUAL 2)
140147
INCLUDE_DIRECTORIES(${HTTP_PARSER_INCLUDE_DIRS})
141148
LINK_LIBRARIES(${HTTP_PARSER_LIBRARIES})
142149
SET(LIBGIT2_PC_LIBS "${LIBGIT2_PC_LIBS} -lhttp_parser")
143150
ELSE()
144-
MESSAGE("http-parser was not found or is too old; using bundled 3rd-party sources.")
151+
MESSAGE(STATUS "http-parser was not found or is too old; using bundled 3rd-party sources.")
145152
INCLUDE_DIRECTORIES(deps/http-parser)
146153
FILE(GLOB SRC_HTTP deps/http-parser/*.c deps/http-parser/*.h)
147154
ENDIF()
@@ -153,7 +160,11 @@ IF (WIN32 AND NOT MINGW AND NOT SHA1_TYPE STREQUAL "builtin")
153160
FILE(GLOB SRC_SHA1 src/hash/hash_win32.c)
154161
ELSEIF (OPENSSL_FOUND AND NOT SHA1_TYPE STREQUAL "builtin")
155162
ADD_DEFINITIONS(-DOPENSSL_SHA1)
156-
SET(LIBGIT2_PC_REQUIRES "${LIBGIT2_PC_REQUIRES} openssl")
163+
IF (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
164+
SET(LIBGIT2_PC_LIBS "${LIBGIT2_PC_LIBS} -lssl")
165+
ELSE()
166+
SET(LIBGIT2_PC_REQUIRES "${LIBGIT2_PC_REQUIRES} openssl")
167+
ENDIF ()
157168
ELSE()
158169
FILE(GLOB SRC_SHA1 src/hash/hash_generic.c)
159170
ENDIF()
@@ -164,34 +175,31 @@ IF (ENABLE_TRACE STREQUAL "ON")
164175
ENDIF()
165176

166177
# Include POSIX regex when it is required
167-
IF(WIN32 OR AMIGA OR ANDROID)
178+
IF(WIN32 OR AMIGA OR ANDROID OR CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
168179
INCLUDE_DIRECTORIES(deps/regex)
169180
SET(SRC_REGEX deps/regex/regex.c)
170181
ENDIF()
171182

172183
# Optional external dependency: zlib
173-
# It's optional, but FIND_PACKAGE gives a warning that looks more like an
174-
# error.
175-
FIND_PACKAGE(ZLIB QUIET)
184+
FIND_PACKAGE(ZLIB)
176185
IF (ZLIB_FOUND)
177186
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIRS})
178187
LINK_LIBRARIES(${ZLIB_LIBRARIES})
179-
IF(APPLE)
188+
IF(APPLE OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
180189
SET(LIBGIT2_PC_LIBS "${LIBGIT2_PC_LIBS} -lz")
181190
ELSE()
182191
SET(LIBGIT2_PC_REQUIRES "${LIBGIT2_PC_REQUIRES} zlib")
183192
ENDIF()
184-
# Fake the message CMake would have shown
185-
MESSAGE("-- Found zlib: ${ZLIB_LIBRARY}")
186193
ELSE()
187-
MESSAGE( "zlib was not found; using bundled 3rd-party sources." )
194+
MESSAGE(STATUS "zlib was not found; using bundled 3rd-party sources." )
188195
INCLUDE_DIRECTORIES(deps/zlib)
189196
ADD_DEFINITIONS(-DNO_VIZ -DSTDC -DNO_GZIP)
190197
FILE(GLOB SRC_ZLIB deps/zlib/*.c deps/zlib/*.h)
191198
ENDIF()
192199

193-
IF (USE_SSH AND NOT MINGW)
194-
FIND_PACKAGE(LIBSSH2 QUIET)
200+
# Optional external dependency: libssh2
201+
IF (USE_SSH)
202+
FIND_PACKAGE(LIBSSH2)
195203
ENDIF()
196204
IF (LIBSSH2_FOUND)
197205
ADD_DEFINITIONS(-DGIT_SSH)
@@ -200,6 +208,15 @@ IF (LIBSSH2_FOUND)
200208
SET(SSH_LIBRARIES ${LIBSSH2_LIBRARIES})
201209
ENDIF()
202210

211+
# Optional external dependency: iconv
212+
IF (USE_ICONV)
213+
FIND_PACKAGE(Iconv)
214+
ENDIF()
215+
IF (ICONV_FOUND)
216+
ADD_DEFINITIONS(-DGIT_USE_ICONV)
217+
INCLUDE_DIRECTORIES(${ICONV_INCLUDE_DIR})
218+
SET(LIBGIT2_PC_LIBS "${LIBGIT2_PC_LIBS} ${ICONV_LIBRARIES}")
219+
ENDIF()
203220

204221
# Platform specific compilation flags
205222
IF (MSVC)
@@ -274,7 +291,11 @@ IF (MSVC)
274291
# Precompiled headers
275292

276293
ELSE ()
277-
SET(CMAKE_C_FLAGS "-D_GNU_SOURCE -Wall -Wextra -Wno-missing-field-initializers -Wstrict-aliasing=2 -Wstrict-prototypes ${CMAKE_C_FLAGS}")
294+
SET(CMAKE_C_FLAGS "-D_GNU_SOURCE -Wall -Wextra ${CMAKE_C_FLAGS}")
295+
296+
IF (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
297+
SET(CMAKE_C_FLAGS "-std=c99 -D_POSIX_C_SOURCE=200112L -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS ${CMAKE_C_FLAGS}")
298+
ENDIF()
278299

279300
IF (WIN32 AND NOT CYGWIN)
280301
SET(CMAKE_C_FLAGS_DEBUG "-D_DEBUG")
@@ -288,11 +309,22 @@ ELSE ()
288309
ADD_DEFINITIONS(-D__USE_MINGW_ANSI_STDIO=1)
289310

290311
ELSEIF (BUILD_SHARED_LIBS)
291-
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden -fPIC")
312+
ADD_C_FLAG_IF_SUPPORTED(-fvisibility=hidden)
313+
314+
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
292315
ENDIF ()
316+
317+
ADD_C_FLAG_IF_SUPPORTED(-Wno-missing-field-initializers)
318+
ADD_C_FLAG_IF_SUPPORTED(-Wstrict-aliasing=2)
319+
ADD_C_FLAG_IF_SUPPORTED(-Wstrict-prototypes)
320+
ADD_C_FLAG_IF_SUPPORTED(-Wdeclaration-after-statement)
321+
ADD_C_FLAG_IF_SUPPORTED(-Wno-unused-const-variable)
322+
ADD_C_FLAG_IF_SUPPORTED(-Wno-unused-function)
323+
293324
IF (APPLE) # Apple deprecated OpenSSL
294-
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations")
295-
ENDIF ()
325+
ADD_C_FLAG_IF_SUPPORTED(-Wno-deprecated-declarations)
326+
ENDIF()
327+
296328
IF (PROFILE)
297329
SET(CMAKE_C_FLAGS "-pg ${CMAKE_C_FLAGS}")
298330
SET(CMAKE_EXE_LINKER_FLAGS "-pg ${CMAKE_EXE_LINKER_FLAGS}")
@@ -317,7 +349,7 @@ ENDIF()
317349

318350
IF (THREADSAFE)
319351
IF (NOT WIN32)
320-
find_package(Threads REQUIRED)
352+
FIND_PACKAGE(Threads REQUIRED)
321353
ENDIF()
322354

323355
ADD_DEFINITIONS(-DGIT_THREADS)
@@ -333,9 +365,11 @@ IF (WIN32 AND NOT CYGWIN)
333365
ADD_DEFINITIONS(-DWIN32 -D_WIN32_WINNT=0x0501)
334366
FILE(GLOB SRC_OS src/win32/*.c src/win32/*.h)
335367
ELSEIF (AMIGA)
336-
ADD_DEFINITIONS(-DNO_ADDRINFO -DNO_READDIR_R)
337-
FILE(GLOB SRC_OS src/amiga/*.c src/amiga/*.h)
368+
ADD_DEFINITIONS(-DNO_ADDRINFO -DNO_READDIR_R -DNO_MMAP)
338369
ELSE()
370+
IF (VALGRIND)
371+
ADD_DEFINITIONS(-DNO_MMAP)
372+
ENDIF()
339373
FILE(GLOB SRC_OS src/unix/*.c src/unix/*.h)
340374
ENDIF()
341375
FILE(GLOB SRC_GIT2 src/*.c src/*.h src/transports/*.c src/transports/*.h src/xdiff/*.c src/xdiff/*.h)
@@ -346,13 +380,14 @@ IF (CMAKE_SIZEOF_VOID_P EQUAL 8)
346380
ELSEIF (CMAKE_SIZEOF_VOID_P EQUAL 4)
347381
ADD_DEFINITIONS(-DGIT_ARCH_32)
348382
ELSE()
349-
message(FATAL_ERROR "Unsupported architecture")
383+
MESSAGE(FATAL_ERROR "Unsupported architecture")
350384
ENDIF()
351385

352386
# Compile and link libgit2
353387
ADD_LIBRARY(git2 ${SRC_H} ${SRC_GIT2} ${SRC_OS} ${SRC_ZLIB} ${SRC_HTTP} ${SRC_REGEX} ${SRC_SHA1} ${WIN_RC})
354388
TARGET_LINK_LIBRARIES(git2 ${SSL_LIBRARIES})
355389
TARGET_LINK_LIBRARIES(git2 ${SSH_LIBRARIES})
390+
TARGET_LINK_LIBRARIES(git2 ${ICONV_LIBRARIES})
356391
TARGET_OS_LIBRARIES(git2)
357392

358393
# Workaround for Cmake bug #0011240 (see http://public.kitware.com/Bug/view.php?id=11240)
@@ -365,7 +400,7 @@ MSVC_SPLIT_SOURCES(git2)
365400

366401
IF (SONAME)
367402
SET_TARGET_PROPERTIES(git2 PROPERTIES VERSION ${LIBGIT2_VERSION_STRING})
368-
SET_TARGET_PROPERTIES(git2 PROPERTIES SOVERSION ${LIBGIT2_VERSION_MAJOR})
403+
SET_TARGET_PROPERTIES(git2 PROPERTIES SOVERSION ${LIBGIT2_SOVERSION})
369404
IF (LIBGIT2_FILENAME)
370405
ADD_DEFINITIONS(-DLIBGIT2_FILENAME=\"${LIBGIT2_FILENAME}\")
371406
SET_TARGET_PROPERTIES(git2 PROPERTIES OUTPUT_NAME ${LIBGIT2_FILENAME})
@@ -418,6 +453,7 @@ IF (BUILD_CLAR)
418453

419454
TARGET_LINK_LIBRARIES(libgit2_clar ${SSL_LIBRARIES})
420455
TARGET_LINK_LIBRARIES(libgit2_clar ${SSH_LIBRARIES})
456+
TARGET_LINK_LIBRARIES(libgit2_clar ${ICONV_LIBRARIES})
421457
TARGET_OS_LIBRARIES(libgit2_clar)
422458
MSVC_SPLIT_SOURCES(libgit2_clar)
423459

@@ -433,7 +469,7 @@ ENDIF ()
433469
IF (TAGS)
434470
FIND_PROGRAM(CTAGS ctags)
435471
IF (NOT CTAGS)
436-
message(FATAL_ERROR "Could not find ctags command")
472+
MESSAGE(FATAL_ERROR "Could not find ctags command")
437473
ENDIF ()
438474

439475
FILE(GLOB_RECURSE SRC_ALL *.[ch])

CONTRIBUTING.md

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@ your help.
55

66
## Licensing
77

8-
By contributing to libgit2, you agree to release your contribution under the terms of the license.
9-
For code under `examples`, this is governed by the [CC0 Public Domain Dedication](examples/COPYING).
10-
All other code is released under the [GPL v2 with linking exception](COPYING).
8+
By contributing to libgit2, you agree to release your contribution under
9+
the terms of the license. Except for the `examples` directory, all code
10+
is released under the [GPL v2 with linking exception](COPYING).
11+
12+
The `examples` code is governed by the
13+
[CC0 Public Domain Dedication](examples/COPYING), so that you may copy
14+
from them into your own application.
1115

1216
## Discussion & Chat
1317

@@ -76,15 +80,19 @@ you're porting code *from* to see what you need to do. As a general rule,
7680
MIT and BSD (3-clause) licenses are typically no problem. Apache 2.0
7781
license typically doesn't work due to GPL incompatibility.
7882

79-
If you are pulling in code from core Git, another project or code you've pulled from
80-
a forum / Stack Overflow then please flag this in your PR and also make sure you've
81-
given proper credit to the original author in the code snippet.
83+
If you are pulling in code from core Git, another project or code you've
84+
pulled from a forum / Stack Overflow then please flag this in your PR and
85+
also make sure you've given proper credit to the original author in the
86+
code snippet.
8287

8388
## Style Guide
8489

85-
`libgit2` is written in [ANSI C](http://en.wikipedia.org/wiki/ANSI_C)
86-
(a.k.a. C89) with some specific conventions for function and type naming,
87-
code formatting, and testing.
90+
The public API of `libgit2` is [ANSI C](http://en.wikipedia.org/wiki/ANSI_C)
91+
(a.k.a. C89) compatible. Internally, `libgit2` is written using a portable
92+
subset of C99 - in order to compile with GCC, Clang, MSVC, etc., we keep
93+
local variable declarations at the tops of blocks only and avoid `//` style
94+
comments. Additionally, `libgit2` follows some extra conventions for
95+
function and type naming, code formatting, and testing.
8896

8997
We like to keep the source code consistent and easy to read. Maintaining
9098
this takes some discipline, but it's been more than worth it. Take a look
@@ -93,22 +101,4 @@ at the
93101

94102
## Starter Projects
95103

96-
So, you want to start helping out with `libgit2`? That's fantastic? We
97-
welcome contributions and we promise we'll try to be nice.
98-
99-
If you want to jump in, you can look at our issues list to see if there
100-
are any unresolved issues to jump in on. Also, here is a list of some
101-
smaller project ideas that could help you become familiar with the code
102-
base and make a nice first step:
103-
104-
* Convert a `git_*modulename*_foreach()` callback-based iteration API
105-
into a `git_*modulename*_iterator` object with a create/advance style
106-
of API. This helps folks writing language bindings and usually isn't
107-
too complicated.
108-
* Write a new `examples/` program that mirrors a particular core git
109-
command. (See `examples/diff.c` for example.) This lets you (and us)
110-
easily exercise a particular facet of the API and measure compatability
111-
and feature parity with core git.
112-
* Submit a PR to clarify documentation! While we do try to document all of
113-
the APIs, your fresh eyes on the documentation will find areas that are
114-
confusing much more easily.
104+
See our [projects list](https://github.com/libgit2/libgit2/blob/development/PROJECTS.md).

0 commit comments

Comments
 (0)