diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 178 | ||||
-rw-r--r-- | src/README.md | 10 | ||||
-rw-r--r-- | src/features.h.in (renamed from src/libgit2/features.h.in) | 0 | ||||
-rw-r--r-- | src/libgit2/CMakeLists.txt | 183 | ||||
-rw-r--r-- | src/libgit2/blob.c | 2 | ||||
-rw-r--r-- | src/libgit2/common.h | 189 | ||||
-rw-r--r-- | src/libgit2/diff_xdiff.c | 1 | ||||
-rw-r--r-- | src/libgit2/filter.c | 2 | ||||
-rw-r--r-- | src/libgit2/git2.rc (renamed from src/libgit2/win32/git2.rc) | 2 | ||||
-rw-r--r-- | src/libgit2/netops.c | 1 | ||||
-rw-r--r-- | src/libgit2/odb.c | 2 | ||||
-rw-r--r-- | src/libgit2/path.c | 1 | ||||
-rw-r--r-- | src/libgit2/util/platform.h.in | 34 | ||||
-rw-r--r-- | src/util/CMakeLists.txt | 59 | ||||
-rw-r--r-- | src/util/alloc.c (renamed from src/libgit2/alloc.c) | 0 | ||||
-rw-r--r-- | src/util/alloc.h (renamed from src/libgit2/alloc.h) | 0 | ||||
-rw-r--r-- | src/util/allocators/failalloc.c (renamed from src/libgit2/allocators/failalloc.c) | 0 | ||||
-rw-r--r-- | src/util/allocators/failalloc.h (renamed from src/libgit2/allocators/failalloc.h) | 2 | ||||
-rw-r--r-- | src/util/allocators/stdalloc.c (renamed from src/libgit2/allocators/stdalloc.c) | 0 | ||||
-rw-r--r-- | src/util/allocators/stdalloc.h (renamed from src/libgit2/allocators/stdalloc.h) | 2 | ||||
-rw-r--r-- | src/util/allocators/win32_leakcheck.c (renamed from src/libgit2/allocators/win32_leakcheck.c) | 0 | ||||
-rw-r--r-- | src/util/allocators/win32_leakcheck.h (renamed from src/libgit2/allocators/win32_leakcheck.h) | 2 | ||||
-rw-r--r-- | src/util/array.h (renamed from src/libgit2/array.h) | 2 | ||||
-rw-r--r-- | src/util/assert_safe.h (renamed from src/libgit2/assert_safe.h) | 0 | ||||
-rw-r--r-- | src/util/bitvec.h (renamed from src/libgit2/bitvec.h) | 0 | ||||
-rw-r--r-- | src/util/cc-compat.h (renamed from src/libgit2/cc-compat.h) | 0 | ||||
-rw-r--r-- | src/util/date.c (renamed from src/libgit2/date.c) | 7 | ||||
-rw-r--r-- | src/util/date.h (renamed from src/libgit2/date.h) | 0 | ||||
-rw-r--r-- | src/util/filebuf.c (renamed from src/libgit2/filebuf.c) | 2 | ||||
-rw-r--r-- | src/util/filebuf.h (renamed from src/libgit2/filebuf.h) | 2 | ||||
-rw-r--r-- | src/util/fs_path.c (renamed from src/libgit2/fs_path.c) | 18 | ||||
-rw-r--r-- | src/util/fs_path.h (renamed from src/libgit2/fs_path.h) | 2 | ||||
-rw-r--r-- | src/util/futils.c (renamed from src/libgit2/futils.c) | 2 | ||||
-rw-r--r-- | src/util/futils.h (renamed from src/libgit2/futils.h) | 2 | ||||
-rw-r--r-- | src/util/git2_util.h | 168 | ||||
-rw-r--r-- | src/util/hash.c (renamed from src/libgit2/hash.c) | 0 | ||||
-rw-r--r-- | src/util/hash.h (renamed from src/libgit2/hash.h) | 2 | ||||
-rw-r--r-- | src/util/hash/sha1.h (renamed from src/libgit2/hash/sha1.h) | 2 | ||||
-rw-r--r-- | src/util/hash/sha1/collisiondetect.c (renamed from src/libgit2/hash/sha1/collisiondetect.c) | 0 | ||||
-rw-r--r-- | src/util/hash/sha1/collisiondetect.h (renamed from src/libgit2/hash/sha1/collisiondetect.h) | 0 | ||||
-rw-r--r-- | src/util/hash/sha1/common_crypto.c (renamed from src/libgit2/hash/sha1/common_crypto.c) | 0 | ||||
-rw-r--r-- | src/util/hash/sha1/common_crypto.h (renamed from src/libgit2/hash/sha1/common_crypto.h) | 0 | ||||
-rw-r--r-- | src/util/hash/sha1/generic.c (renamed from src/libgit2/hash/sha1/generic.c) | 0 | ||||
-rw-r--r-- | src/util/hash/sha1/generic.h (renamed from src/libgit2/hash/sha1/generic.h) | 0 | ||||
-rw-r--r-- | src/util/hash/sha1/mbedtls.c (renamed from src/libgit2/hash/sha1/mbedtls.c) | 0 | ||||
-rw-r--r-- | src/util/hash/sha1/mbedtls.h (renamed from src/libgit2/hash/sha1/mbedtls.h) | 0 | ||||
-rw-r--r-- | src/util/hash/sha1/openssl.c (renamed from src/libgit2/hash/sha1/openssl.c) | 0 | ||||
-rw-r--r-- | src/util/hash/sha1/openssl.h (renamed from src/libgit2/hash/sha1/openssl.h) | 0 | ||||
-rw-r--r-- | src/util/hash/sha1/sha1dc/sha1.c (renamed from src/libgit2/hash/sha1/sha1dc/sha1.c) | 0 | ||||
-rw-r--r-- | src/util/hash/sha1/sha1dc/sha1.h (renamed from src/libgit2/hash/sha1/sha1dc/sha1.h) | 0 | ||||
-rw-r--r-- | src/util/hash/sha1/sha1dc/ubc_check.c (renamed from src/libgit2/hash/sha1/sha1dc/ubc_check.c) | 0 | ||||
-rw-r--r-- | src/util/hash/sha1/sha1dc/ubc_check.h (renamed from src/libgit2/hash/sha1/sha1dc/ubc_check.h) | 0 | ||||
-rw-r--r-- | src/util/hash/sha1/win32.c (renamed from src/libgit2/hash/sha1/win32.c) | 0 | ||||
-rw-r--r-- | src/util/hash/sha1/win32.h (renamed from src/libgit2/hash/sha1/win32.h) | 0 | ||||
-rw-r--r-- | src/util/integer.h (renamed from src/libgit2/integer.h) | 0 | ||||
-rw-r--r-- | src/util/khash.h (renamed from src/libgit2/khash.h) | 0 | ||||
-rw-r--r-- | src/util/map.h (renamed from src/libgit2/map.h) | 2 | ||||
-rw-r--r-- | src/util/net.c (renamed from src/libgit2/net.c) | 1 | ||||
-rw-r--r-- | src/util/net.h (renamed from src/libgit2/net.h) | 2 | ||||
-rw-r--r-- | src/util/pool.c (renamed from src/libgit2/pool.c) | 0 | ||||
-rw-r--r-- | src/util/pool.h (renamed from src/libgit2/pool.h) | 2 | ||||
-rw-r--r-- | src/util/posix.c (renamed from src/libgit2/posix.c) | 0 | ||||
-rw-r--r-- | src/util/posix.h (renamed from src/libgit2/posix.h) | 2 | ||||
-rw-r--r-- | src/util/pqueue.c (renamed from src/libgit2/pqueue.c) | 0 | ||||
-rw-r--r-- | src/util/pqueue.h (renamed from src/libgit2/pqueue.h) | 2 | ||||
-rw-r--r-- | src/util/rand.c (renamed from src/rand.c) | 2 | ||||
-rw-r--r-- | src/util/rand.h (renamed from src/rand.h) | 2 | ||||
-rw-r--r-- | src/util/regexp.c (renamed from src/libgit2/regexp.c) | 0 | ||||
-rw-r--r-- | src/util/regexp.h (renamed from src/libgit2/regexp.h) | 2 | ||||
-rw-r--r-- | src/util/runtime.c (renamed from src/libgit2/runtime.c) | 2 | ||||
-rw-r--r-- | src/util/runtime.h (renamed from src/libgit2/runtime.h) | 2 | ||||
-rw-r--r-- | src/util/sortedcache.c (renamed from src/libgit2/sortedcache.c) | 0 | ||||
-rw-r--r-- | src/util/sortedcache.h (renamed from src/libgit2/sortedcache.h) | 2 | ||||
-rw-r--r-- | src/util/str.c (renamed from src/libgit2/str.c) | 0 | ||||
-rw-r--r-- | src/util/str.h (renamed from src/libgit2/str.h) | 2 | ||||
-rw-r--r-- | src/util/strmap.c (renamed from src/libgit2/strmap.c) | 0 | ||||
-rw-r--r-- | src/util/strmap.h (renamed from src/libgit2/strmap.h) | 2 | ||||
-rw-r--r-- | src/util/strnlen.h (renamed from src/libgit2/strnlen.h) | 0 | ||||
-rw-r--r-- | src/util/thread.c (renamed from src/libgit2/thread.c) | 2 | ||||
-rw-r--r-- | src/util/thread.h (renamed from src/libgit2/thread.h) | 0 | ||||
-rw-r--r-- | src/util/tsort.c (renamed from src/libgit2/tsort.c) | 2 | ||||
-rw-r--r-- | src/util/unix/map.c (renamed from src/libgit2/unix/map.c) | 2 | ||||
-rw-r--r-- | src/util/unix/posix.h (renamed from src/libgit2/unix/posix.h) | 2 | ||||
-rw-r--r-- | src/util/unix/pthread.h (renamed from src/libgit2/unix/pthread.h) | 0 | ||||
-rw-r--r-- | src/util/unix/realpath.c (renamed from src/libgit2/unix/realpath.c) | 2 | ||||
-rw-r--r-- | src/util/utf8.c (renamed from src/libgit2/utf8.c) | 2 | ||||
-rw-r--r-- | src/util/utf8.h (renamed from src/libgit2/utf8.h) | 2 | ||||
-rw-r--r-- | src/util/util.c (renamed from src/libgit2/util.c) | 2 | ||||
-rw-r--r-- | src/util/util.h (renamed from src/libgit2/util.h) | 2 | ||||
-rw-r--r-- | src/util/varint.c (renamed from src/libgit2/varint.c) | 0 | ||||
-rw-r--r-- | src/util/varint.h (renamed from src/libgit2/varint.h) | 2 | ||||
-rw-r--r-- | src/util/vector.c (renamed from src/libgit2/vector.c) | 0 | ||||
-rw-r--r-- | src/util/vector.h (renamed from src/libgit2/vector.h) | 2 | ||||
-rw-r--r-- | src/util/wildmatch.c (renamed from src/libgit2/wildmatch.c) | 0 | ||||
-rw-r--r-- | src/util/wildmatch.h (renamed from src/libgit2/wildmatch.h) | 2 | ||||
-rw-r--r-- | src/util/win32/dir.c (renamed from src/libgit2/win32/dir.c) | 0 | ||||
-rw-r--r-- | src/util/win32/dir.h (renamed from src/libgit2/win32/dir.h) | 2 | ||||
-rw-r--r-- | src/util/win32/error.c (renamed from src/libgit2/win32/error.c) | 0 | ||||
-rw-r--r-- | src/util/win32/error.h (renamed from src/libgit2/win32/error.h) | 2 | ||||
-rw-r--r-- | src/util/win32/findfile.c (renamed from src/libgit2/win32/findfile.c) | 0 | ||||
-rw-r--r-- | src/util/win32/findfile.h (renamed from src/libgit2/win32/findfile.h) | 2 | ||||
-rw-r--r-- | src/util/win32/map.c (renamed from src/libgit2/win32/map.c) | 2 | ||||
-rw-r--r-- | src/util/win32/mingw-compat.h (renamed from src/libgit2/win32/mingw-compat.h) | 0 | ||||
-rw-r--r-- | src/util/win32/msvc-compat.h (renamed from src/libgit2/win32/msvc-compat.h) | 0 | ||||
-rw-r--r-- | src/util/win32/path_w32.c (renamed from src/libgit2/win32/path_w32.c) | 0 | ||||
-rw-r--r-- | src/util/win32/path_w32.h (renamed from src/libgit2/win32/path_w32.h) | 2 | ||||
-rw-r--r-- | src/util/win32/posix.h (renamed from src/libgit2/win32/posix.h) | 2 | ||||
-rw-r--r-- | src/util/win32/posix_w32.c (renamed from src/libgit2/win32/posix_w32.c) | 2 | ||||
-rw-r--r-- | src/util/win32/precompiled.c (renamed from src/libgit2/win32/precompiled.c) | 0 | ||||
-rw-r--r-- | src/util/win32/precompiled.h (renamed from src/libgit2/win32/precompiled.h) | 2 | ||||
-rw-r--r-- | src/util/win32/reparse.h (renamed from src/libgit2/win32/reparse.h) | 0 | ||||
-rw-r--r-- | src/util/win32/thread.c (renamed from src/libgit2/win32/thread.c) | 0 | ||||
-rw-r--r-- | src/util/win32/thread.h (renamed from src/libgit2/win32/thread.h) | 2 | ||||
-rw-r--r-- | src/util/win32/utf-conv.c (renamed from src/libgit2/win32/utf-conv.c) | 0 | ||||
-rw-r--r-- | src/util/win32/utf-conv.h (renamed from src/libgit2/win32/utf-conv.h) | 2 | ||||
-rw-r--r-- | src/util/win32/version.h (renamed from src/libgit2/win32/version.h) | 0 | ||||
-rw-r--r-- | src/util/win32/w32_buffer.c (renamed from src/libgit2/win32/w32_buffer.c) | 0 | ||||
-rw-r--r-- | src/util/win32/w32_buffer.h (renamed from src/libgit2/win32/w32_buffer.h) | 2 | ||||
-rw-r--r-- | src/util/win32/w32_common.h (renamed from src/libgit2/win32/w32_common.h) | 0 | ||||
-rw-r--r-- | src/util/win32/w32_leakcheck.c (renamed from src/libgit2/win32/w32_leakcheck.c) | 0 | ||||
-rw-r--r-- | src/util/win32/w32_leakcheck.h (renamed from src/libgit2/win32/w32_leakcheck.h) | 2 | ||||
-rw-r--r-- | src/util/win32/w32_util.c (renamed from src/libgit2/win32/w32_util.c) | 0 | ||||
-rw-r--r-- | src/util/win32/w32_util.h (renamed from src/libgit2/win32/w32_util.h) | 2 | ||||
-rw-r--r-- | src/util/win32/win32-compat.h (renamed from src/libgit2/win32/win32-compat.h) | 0 | ||||
-rw-r--r-- | src/util/zstream.c (renamed from src/libgit2/zstream.c) | 0 | ||||
-rw-r--r-- | src/util/zstream.h (renamed from src/libgit2/zstream.h) | 2 |
126 files changed, 584 insertions, 374 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f6924eff5..bbb724057 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,182 @@ +# The main libgit2 source tree: this CMakeLists.txt identifies platform +# support and includes the subprojects that make up core libgit2 support. + +# +# Optional build configuration settings +# + +if(DEPRECATE_HARD) + add_definitions(-DGIT_DEPRECATE_HARD) +endif() + +if(USE_LEAK_CHECKER STREQUAL "valgrind") + add_definitions(-DVALGRIND) +endif() + +# +# Optional debugging functionality +# + +if(DEBUG_POOL) + set(GIT_DEBUG_POOL 1) +endif() +add_feature_info(debugpool GIT_DEBUG_POOL "debug pool allocator") + +if(DEBUG_STRICT_ALLOC) + set(GIT_DEBUG_STRICT_ALLOC 1) +endif() +add_feature_info(debugalloc GIT_DEBUG_STRICT_ALLOC "debug strict allocators") + +if(DEBUG_STRICT_OPEN) + set(GIT_DEBUG_STRICT_OPEN 1) +endif() +add_feature_info(debugopen GIT_DEBUG_STRICT_OPEN "path validation in open") + +# +# Optional feature enablement +# + +include(SelectGSSAPI) +include(SelectHTTPSBackend) +include(SelectHashes) +include(SelectHTTPParser) +include(SelectRegex) +include(SelectSSH) +include(SelectWinHTTP) +include(SelectZlib) + +# +# Platform support +# + +# futimes/futimens + +if(HAVE_FUTIMENS) + set(GIT_USE_FUTIMENS 1) +endif () +add_feature_info(futimens GIT_USE_FUTIMENS "futimens support") + +# qsort + +check_prototype_definition(qsort_r + "void qsort_r(void *base, size_t nmemb, size_t size, void *thunk, int (*compar)(void *, const void *, const void *))" + "" "stdlib.h" GIT_QSORT_R_BSD) + +check_prototype_definition(qsort_r + "void qsort_r(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *, void *), void *arg)" + "" "stdlib.h" GIT_QSORT_R_GNU) + +check_function_exists(qsort_s GIT_QSORT_S) + +# determine architecture of the machine + +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(GIT_ARCH_64 1) +elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) + set(GIT_ARCH_32 1) +elseif(CMAKE_SIZEOF_VOID_P) + message(FATAL_ERROR "Unsupported architecture (pointer size is ${CMAKE_SIZEOF_VOID_P} bytes)") +else() + message(FATAL_ERROR "Unsupported architecture (CMAKE_SIZEOF_VOID_P is unset)") +endif() + +# nanosecond mtime/ctime support + +if(USE_NSEC) + set(GIT_USE_NSEC 1) +endif() + +# high-resolution stat support + +if(HAVE_STRUCT_STAT_ST_MTIM) + set(GIT_USE_STAT_MTIM 1) +elseif(HAVE_STRUCT_STAT_ST_MTIMESPEC) + set(GIT_USE_STAT_MTIMESPEC 1) +elseif(HAVE_STRUCT_STAT_ST_MTIME_NSEC) + set(GIT_USE_STAT_MTIME_NSEC 1) +endif() + +# realtime support + +check_library_exists(rt clock_gettime "time.h" NEED_LIBRT) +if(NEED_LIBRT) + list(APPEND LIBGIT2_SYSTEM_LIBS rt) + list(APPEND LIBGIT2_PC_LIBS "-lrt") +endif() + +# platform libraries + +if(WIN32) + list(APPEND LIBGIT2_SYSTEM_LIBS ws2_32) +endif() + +if(CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)") + list(APPEND LIBGIT2_SYSTEM_LIBS socket nsl) + list(APPEND LIBGIT2_PC_LIBS "-lsocket" "-lnsl") +endif() + +if(CMAKE_SYSTEM_NAME MATCHES "Haiku") + list(APPEND LIBGIT2_SYSTEM_LIBS network) + list(APPEND LIBGIT2_PC_LIBS "-lnetwork") +endif() + +if(AMIGA) + add_definitions(-DNO_ADDRINFO -DNO_READDIR_R -DNO_MMAP) +endif() + +# threads + +if(USE_THREADS) + if(NOT WIN32) + find_package(Threads REQUIRED) + list(APPEND LIBGIT2_SYSTEM_LIBS ${CMAKE_THREAD_LIBS_INIT}) + list(APPEND LIBGIT2_PC_LIBS ${CMAKE_THREAD_LIBS_INIT}) + endif() + + set(GIT_THREADS 1) +endif() +add_feature_info(threadsafe USE_THREADS "threadsafe support") + +# +# Optional bundled features +# + +# ntlmclient +if(USE_NTLMCLIENT) + set(GIT_NTLM 1) + add_subdirectory("${libgit2_SOURCE_DIR}/deps/ntlmclient" "${libgit2_BINARY_DIR}/deps/ntlmclient") + list(APPEND LIBGIT2_DEPENDENCY_INCLUDES "${libgit2_SOURCE_DIR}/deps/ntlmclient") + list(APPEND LIBGIT2_DEPENDENCY_OBJECTS "$<TARGET_OBJECTS:ntlmclient>") +endif() +add_feature_info(ntlmclient GIT_NTLM "NTLM authentication support for Unix") + +# +# Optional external dependencies + +# iconv +if(USE_ICONV) + find_package(Iconv) +endif() +if(ICONV_FOUND) + set(GIT_USE_ICONV 1) + list(APPEND LIBGIT2_SYSTEM_INCLUDES ${ICONV_INCLUDE_DIR}) + list(APPEND LIBGIT2_SYSTEM_LIBS ${ICONV_LIBRARIES}) + list(APPEND LIBGIT2_PC_LIBS ${ICONV_LIBRARIES}) +endif() +add_feature_info(iconv GIT_USE_ICONV "iconv encoding conversion support") + +# +# Configure support +# + +configure_file(features.h.in git2/sys/features.h) + +# +# Include child projects +# + add_subdirectory(libgit2) +add_subdirectory(util) # re-export these to the root so that peer projects (tests, fuzzers, # examples) can use them diff --git a/src/README.md b/src/README.md new file mode 100644 index 000000000..12e0d0e43 --- /dev/null +++ b/src/README.md @@ -0,0 +1,10 @@ +# libgit2 sources + +This is the source that makes up the core of libgit2 and its related +projects. + +* `libgit2` + This is the libgit2 project, a cross-platform, linkable library + implementation of Git that you can use in your application. +* `util` + A shared utility library for these projects. diff --git a/src/libgit2/features.h.in b/src/features.h.in index f920135da..f920135da 100644 --- a/src/libgit2/features.h.in +++ b/src/features.h.in diff --git a/src/libgit2/CMakeLists.txt b/src/libgit2/CMakeLists.txt index e6cdddd49..3dac83d7a 100644 --- a/src/libgit2/CMakeLists.txt +++ b/src/libgit2/CMakeLists.txt @@ -2,94 +2,99 @@ add_library(git2internal OBJECT) set_target_properties(git2internal PROPERTIES C_STANDARD 90) set_target_properties(git2internal PROPERTIES C_EXTENSIONS OFF) - -if(DEPRECATE_HARD) - add_definitions(-DGIT_DEPRECATE_HARD) -endif() - -if(DEBUG_POOL) - set(GIT_DEBUG_POOL 1) -endif() -add_feature_info(debugpool GIT_DEBUG_POOL "debug pool allocator") - -if(DEBUG_STRICT_ALLOC) - set(GIT_DEBUG_STRICT_ALLOC 1) -endif() -add_feature_info(debugalloc GIT_DEBUG_STRICT_ALLOC "debug strict allocators") - -if(DEBUG_STRICT_OPEN) - set(GIT_DEBUG_STRICT_OPEN 1) -endif() -add_feature_info(debugopen GIT_DEBUG_STRICT_OPEN "path validation in open") - - include(PkgBuildConfig) -include(SanitizeBool) - -# This variable will contain the libraries we need to put into -# libgit2.pc's Requires.private. That is, what we're linking to or -# what someone who's statically linking us needs to link to. -set(LIBGIT2_PC_REQUIRES "") -# This will be set later if we use the system's http-parser library or -# use iconv (OSX) and will be written to the Libs.private field in the -# pc file. -set(LIBGIT2_PC_LIBS "") set(LIBGIT2_INCLUDES - "${CMAKE_CURRENT_BINARY_DIR}" + "${PROJECT_BINARY_DIR}/src" "${PROJECT_SOURCE_DIR}/src/libgit2" + "${PROJECT_SOURCE_DIR}/src/util" "${PROJECT_SOURCE_DIR}/include") -if(HAVE_FUTIMENS) - set(GIT_USE_FUTIMENS 1) -endif () -add_feature_info(futimens GIT_USE_FUTIMENS "futimens support") +if(WIN32 AND EMBED_SSH_PATH) + file(GLOB SRC_SSH "${EMBED_SSH_PATH}/src/*.c") + list(SORT SRC_SSH) + target_sources(git2internal PRIVATE ${SRC_SSH}) -check_prototype_definition(qsort_r - "void qsort_r(void *base, size_t nmemb, size_t size, void *thunk, int (*compar)(void *, const void *, const void *))" - "" "stdlib.h" GIT_QSORT_R_BSD) + list(APPEND LIBGIT2_SYSTEM_INCLUDES "${EMBED_SSH_PATH}/include") + file(WRITE "${EMBED_SSH_PATH}/src/libssh2_config.h" "#define HAVE_WINCNG\n#define LIBSSH2_WINCNG\n#include \"../win32/libssh2_config.h\"") + set(GIT_SSH 1) +endif() -check_prototype_definition(qsort_r - "void qsort_r(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *, void *), void *arg)" - "" "stdlib.h" GIT_QSORT_R_GNU) +<<<<<<< HEAD +include(SelectHTTPSBackend) +include(SelectHashes) +include(SelectHTTPParser) +include(SelectRegex) +include(SelectSSH) +include(SelectWinHTTP) +include(SelectZlib) -check_function_exists(qsort_s GIT_QSORT_S) -# Find required dependencies +if(USE_SHA1 STREQUAL "CollisionDetection") + file(GLOB SRC_SHA1 hash/sha1/collisiondetect.* hash/sha1/sha1dc/*) +elseif(USE_SHA1 STREQUAL "OpenSSL") + file(GLOB SRC_SHA1 hash/sha1/openssl.*) +elseif(USE_SHA1 STREQUAL "CommonCrypto") + file(GLOB SRC_SHA1 hash/sha1/common_crypto.*) +elseif(USE_SHA1 STREQUAL "mbedTLS") + file(GLOB SRC_SHA1 hash/sha1/mbedtls.*) +elseif(USE_SHA1 STREQUAL "Win32") + file(GLOB SRC_SHA1 hash/sha1/win32.*) +elseif(USE_SHA1 STREQUAL "Generic") + file(GLOB SRC_SHA1 hash/sha1/generic.*) +endif() +list(APPEND SRC_SHA1 "hash/sha1.h") +target_sources(git2internal PRIVATE ${SRC_SHA1}) -if(WIN32) - list(APPEND LIBGIT2_SYSTEM_LIBS ws2_32) -elseif(CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)") - list(APPEND LIBGIT2_SYSTEM_LIBS socket nsl) - list(APPEND LIBGIT2_PC_LIBS "-lsocket" "-lnsl") -elseif(CMAKE_SYSTEM_NAME MATCHES "Haiku") - list(APPEND LIBGIT2_SYSTEM_LIBS network) - list(APPEND LIBGIT2_PC_LIBS "-lnetwork") +# Optional external dependency: ntlmclient +if(USE_NTLMCLIENT) + set(GIT_NTLM 1) + add_subdirectory("${PROJECT_SOURCE_DIR}/deps/ntlmclient" "${PROJECT_BINARY_DIR}/deps/ntlmclient") + list(APPEND LIBGIT2_DEPENDENCY_INCLUDES "${PROJECT_SOURCE_DIR}/deps/ntlmclient") + list(APPEND LIBGIT2_DEPENDENCY_OBJECTS "$<TARGET_OBJECTS:ntlmclient>") endif() +add_feature_info(ntlmclient GIT_NTLM "NTLM authentication support for Unix") -check_library_exists(rt clock_gettime "time.h" NEED_LIBRT) -if(NEED_LIBRT) - list(APPEND LIBGIT2_SYSTEM_LIBS rt) - list(APPEND LIBGIT2_PC_LIBS "-lrt") +# Optional external dependency: GSSAPI + +include(SelectGSSAPI) + +# Optional external dependency: iconv +if(USE_ICONV) + find_package(Iconv) endif() +if(ICONV_FOUND) + set(GIT_USE_ICONV 1) + list(APPEND LIBGIT2_SYSTEM_INCLUDES ${ICONV_INCLUDE_DIR}) + list(APPEND LIBGIT2_SYSTEM_LIBS ${ICONV_LIBRARIES}) + list(APPEND LIBGIT2_PC_LIBS ${ICONV_LIBRARIES}) +endif() +add_feature_info(iconv GIT_USE_ICONV "iconv encoding conversion support") + if(USE_THREADS) - list(APPEND LIBGIT2_SYSTEM_LIBS ${CMAKE_THREAD_LIBS_INIT}) - list(APPEND LIBGIT2_PC_LIBS ${CMAKE_THREAD_LIBS_INIT}) -endif() -add_feature_info(threadsafe USE_THREADS "threadsafe support") + if(NOT WIN32) + find_package(Threads REQUIRED) + endif() + set(GIT_THREADS 1) +endif() -if(WIN32 AND EMBED_SSH_PATH) - file(GLOB SRC_SSH "${EMBED_SSH_PATH}/src/*.c") - list(SORT SRC_SSH) - target_sources(git2internal PRIVATE ${SRC_SSH}) +if(USE_NSEC) + set(GIT_USE_NSEC 1) +endif() - list(APPEND LIBGIT2_SYSTEM_INCLUDES "${EMBED_SSH_PATH}/include") - file(WRITE "${EMBED_SSH_PATH}/src/libssh2_config.h" "#define HAVE_WINCNG\n#define LIBSSH2_WINCNG\n#include \"../win32/libssh2_config.h\"") - set(GIT_SSH 1) +if(HAVE_STRUCT_STAT_ST_MTIM) + set(GIT_USE_STAT_MTIM 1) +elseif(HAVE_STRUCT_STAT_ST_MTIMESPEC) + set(GIT_USE_STAT_MTIMESPEC 1) +elseif(HAVE_STRUCT_STAT_ST_MTIME_NSEC) + set(GIT_USE_STAT_MTIME_NSEC 1) endif() +target_compile_definitions(git2internal PRIVATE _FILE_OFFSET_BITS=64) + +||||||| parent of a930dafb4 (refactor: make util an object library) include(SelectHTTPSBackend) include(SelectHashes) include(SelectHTTPParser) @@ -163,6 +168,8 @@ endif() target_compile_definitions(git2internal PRIVATE _FILE_OFFSET_BITS=64) +======= +>>>>>>> a930dafb4 (refactor: make util an object library) # Collect sourcefiles file(GLOB SRC_H "${PROJECT_SOURCE_DIR}/include/git2.h" @@ -171,33 +178,18 @@ file(GLOB SRC_H list(SORT SRC_H) target_sources(git2internal PRIVATE ${SRC_H}) -# On Windows use specific platform sources -if(WIN32 AND NOT CYGWIN) - set(WIN_RC "win32/git2.rc") - - file(GLOB SRC_OS win32/*.c win32/*.h) - list(SORT SRC_OS) - target_sources(git2internal PRIVATE ${SRC_OS}) -elseif(AMIGA) - target_compile_definitions(git2internal PRIVATE NO_ADDRINFO NO_READDIR_R NO_MMAP) -else() - file(GLOB SRC_OS unix/*.c unix/*.h) - list(SORT SRC_OS) - target_sources(git2internal PRIVATE ${SRC_OS}) -endif() - -if(USE_LEAK_CHECKER STREQUAL "valgrind") - target_compile_definitions(git2internal PRIVATE VALGRIND) -endif() - file(GLOB SRC_GIT2 *.c *.h - allocators/*.c allocators/*.h streams/*.c streams/*.h transports/*.c transports/*.h xdiff/*.c xdiff/*.h) list(SORT SRC_GIT2) target_sources(git2internal PRIVATE ${SRC_GIT2}) +if(WIN32 AND NOT CYGWIN) + # Add resource information on Windows + set(SRC_RC "git2.rc") +endif() + if(APPLE) # The old Secure Transport API has been deprecated in macOS 10.15. set_source_files_properties(streams/stransport.c PROPERTIES COMPILE_FLAGS -Wno-deprecated) @@ -220,21 +212,8 @@ else() set_source_files_properties(xdiff/xpatience.c PROPERTIES COMPILE_FLAGS "-Wno-sign-compare") endif() -# Determine architecture of the machine -if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(GIT_ARCH_64 1) -elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) - set(GIT_ARCH_32 1) -elseif(CMAKE_SIZEOF_VOID_P) - message(FATAL_ERROR "Unsupported architecture (pointer size is ${CMAKE_SIZEOF_VOID_P} bytes)") -else() - message(FATAL_ERROR "Unsupported architecture (CMAKE_SIZEOF_VOID_P is unset)") -endif() - -configure_file(features.h.in git2/sys/features.h) - ide_split_sources(git2internal) -list(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:git2internal> ${LIBGIT2_DEPENDENCY_OBJECTS}) +list(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:util> $<TARGET_OBJECTS:git2internal> ${LIBGIT2_DEPENDENCY_OBJECTS}) target_include_directories(git2internal PRIVATE ${LIBGIT2_INCLUDES} ${LIBGIT2_DEPENDENCY_INCLUDES} PUBLIC ${PROJECT_SOURCE_DIR}/include) target_include_directories(git2internal SYSTEM PRIVATE ${LIBGIT2_SYSTEM_INCLUDES}) @@ -254,7 +233,7 @@ if(XCODE_VERSION) endif() # Compile and link libgit2 -add_library(git2 ${WIN_RC} ${LIBGIT2_OBJECTS}) +add_library(git2 ${SRC_RC} ${LIBGIT2_OBJECTS}) target_link_libraries(git2 ${LIBGIT2_SYSTEM_LIBS}) set_target_properties(git2 PROPERTIES C_STANDARD 90) diff --git a/src/libgit2/blob.c b/src/libgit2/blob.c index 19ce8b3b5..b1680d3a8 100644 --- a/src/libgit2/blob.c +++ b/src/libgit2/blob.c @@ -101,7 +101,7 @@ static int write_file_stream( git_oid *id, git_odb *odb, const char *path, git_object_size_t file_size) { int fd, error; - char buffer[FILEIO_BUFSIZE]; + char buffer[GIT_BUFSIZE_FILEIO]; git_odb_stream *stream = NULL; ssize_t read_len = -1; git_object_size_t written = 0; diff --git a/src/libgit2/common.h b/src/libgit2/common.h index 549bddb59..bb9ec5ac1 100644 --- a/src/libgit2/common.h +++ b/src/libgit2/common.h @@ -7,136 +7,31 @@ #ifndef INCLUDE_common_h__ #define INCLUDE_common_h__ -#ifndef LIBGIT2_NO_FEATURES_H -# include "git2/sys/features.h" -#endif - -#include "git2/common.h" -#include "cc-compat.h" - -/** Declare a function as always inlined. */ -#if defined(_MSC_VER) -# define GIT_INLINE(type) static __inline type -#elif defined(__GNUC__) -# define GIT_INLINE(type) static __inline__ type -#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) -# define GIT_INLINE(type) static inline type -#else -# define GIT_INLINE(type) static type -#endif - -/** Support for gcc/clang __has_builtin intrinsic */ -#ifndef __has_builtin -# define __has_builtin(x) 0 -#endif - -/** - * Declare that a function's return value must be used. - * - * Used mostly to guard against potential silent bugs at runtime. This is - * recommended to be added to functions that: - * - * - Allocate / reallocate memory. This prevents memory leaks or errors where - * buffers are expected to have grown to a certain size, but could not be - * resized. - * - Acquire locks. When a lock cannot be acquired, that will almost certainly - * cause a data race / undefined behavior. - */ -#if defined(__GNUC__) -# define GIT_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) -#else -# define GIT_WARN_UNUSED_RESULT -#endif - -#include <assert.h> -#include <errno.h> -#include <limits.h> -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -#include <sys/types.h> -#include <sys/stat.h> - -#ifdef GIT_WIN32 - -# include <io.h> -# include <direct.h> -# include <winsock2.h> -# include <windows.h> -# include <ws2tcpip.h> -# include "win32/msvc-compat.h" -# include "win32/mingw-compat.h" -# include "win32/w32_common.h" -# include "win32/win32-compat.h" -# include "win32/error.h" -# include "win32/version.h" -# ifdef GIT_THREADS -# include "win32/thread.h" -# endif - -#else - -# include <unistd.h> -# include <strings.h> -# ifdef GIT_THREADS -# include <pthread.h> -# include <sched.h> -# endif - -#define GIT_LIBGIT2_CALL -#define GIT_SYSTEM_CALL - -#ifdef GIT_USE_STAT_ATIMESPEC -# define st_atim st_atimespec -# define st_ctim st_ctimespec -# define st_mtim st_mtimespec -#endif - -# include <arpa/inet.h> - -#endif - -#include "git2/types.h" -#include "git2/errors.h" +#include "git2_util.h" #include "errors.h" -#include "thread.h" -#include "integer.h" -#include "assert_safe.h" -#include "utf8.h" /* - * Include the declarations for deprecated functions; this ensures - * that they're decorated with the proper extern/visibility attributes. - */ +* Include the declarations for deprecated functions; this ensures +* that they're decorated with the proper extern/visibility attributes. +*/ #include "git2/deprecated.h" #include "posix.h" -#define DEFAULT_BUFSIZE 65536 -#define FILEIO_BUFSIZE DEFAULT_BUFSIZE -#define FILTERIO_BUFSIZE DEFAULT_BUFSIZE -#define NETIO_BUFSIZE DEFAULT_BUFSIZE - -/** - * Check a pointer allocation result, returning -1 if it failed. - */ -#define GIT_ERROR_CHECK_ALLOC(ptr) do { \ - if ((ptr) == NULL) { return -1; } \ - } while(0) - /** - * Check a string buffer allocation result, returning -1 if it failed. + * Initialize a structure with a version. */ -#define GIT_ERROR_CHECK_ALLOC_STR(buf) do { \ - if ((void *)(buf) == NULL || git_str_oom(buf)) { return -1; } \ - } while(0) +GIT_INLINE(void) git__init_structure(void *structure, size_t len, unsigned int version) +{ + memset(structure, 0, len); + *((int*)structure) = version; +} +#define GIT_INIT_STRUCTURE(S,V) git__init_structure(S, sizeof(*S), V) -/** - * Check a return value and propagate result if non-zero. - */ -#define GIT_ERROR_CHECK_ERROR(code) \ - do { int _err = (code); if (_err) return _err; } while (0) +#define GIT_INIT_STRUCTURE_FROM_TEMPLATE(PTR,VERSION,TYPE,TPL) do { \ + TYPE _tmpl = TPL; \ + GIT_ERROR_CHECK_VERSION(&(VERSION), _tmpl.version, #TYPE); \ + memcpy((PTR), &_tmpl, sizeof(_tmpl)); } while (0) /** * Check a versioned structure for validity @@ -157,58 +52,4 @@ GIT_INLINE(int) git_error__check_version(const void *structure, unsigned int exp } #define GIT_ERROR_CHECK_VERSION(S,V,N) if (git_error__check_version(S,V,N) < 0) return -1 -/** - * Initialize a structure with a version. - */ -GIT_INLINE(void) git__init_structure(void *structure, size_t len, unsigned int version) -{ - memset(structure, 0, len); - *((int*)structure) = version; -} -#define GIT_INIT_STRUCTURE(S,V) git__init_structure(S, sizeof(*S), V) - -#define GIT_INIT_STRUCTURE_FROM_TEMPLATE(PTR,VERSION,TYPE,TPL) do { \ - TYPE _tmpl = TPL; \ - GIT_ERROR_CHECK_VERSION(&(VERSION), _tmpl.version, #TYPE); \ - memcpy((PTR), &_tmpl, sizeof(_tmpl)); } while (0) - - -/** Check for additive overflow, setting an error if would occur. */ -#define GIT_ADD_SIZET_OVERFLOW(out, one, two) \ - (git__add_sizet_overflow(out, one, two) ? (git_error_set_oom(), 1) : 0) - -/** Check for additive overflow, setting an error if would occur. */ -#define GIT_MULTIPLY_SIZET_OVERFLOW(out, nelem, elsize) \ - (git__multiply_sizet_overflow(out, nelem, elsize) ? (git_error_set_oom(), 1) : 0) - -/** Check for additive overflow, failing if it would occur. */ -#define GIT_ERROR_CHECK_ALLOC_ADD(out, one, two) \ - if (GIT_ADD_SIZET_OVERFLOW(out, one, two)) { return -1; } - -#define GIT_ERROR_CHECK_ALLOC_ADD3(out, one, two, three) \ - if (GIT_ADD_SIZET_OVERFLOW(out, one, two) || \ - GIT_ADD_SIZET_OVERFLOW(out, *(out), three)) { return -1; } - -#define GIT_ERROR_CHECK_ALLOC_ADD4(out, one, two, three, four) \ - if (GIT_ADD_SIZET_OVERFLOW(out, one, two) || \ - GIT_ADD_SIZET_OVERFLOW(out, *(out), three) || \ - GIT_ADD_SIZET_OVERFLOW(out, *(out), four)) { return -1; } - -#define GIT_ERROR_CHECK_ALLOC_ADD5(out, one, two, three, four, five) \ - if (GIT_ADD_SIZET_OVERFLOW(out, one, two) || \ - GIT_ADD_SIZET_OVERFLOW(out, *(out), three) || \ - GIT_ADD_SIZET_OVERFLOW(out, *(out), four) || \ - GIT_ADD_SIZET_OVERFLOW(out, *(out), five)) { return -1; } - -/** Check for multiplicative overflow, failing if it would occur. */ -#define GIT_ERROR_CHECK_ALLOC_MULTIPLY(out, nelem, elsize) \ - if (GIT_MULTIPLY_SIZET_OVERFLOW(out, nelem, elsize)) { return -1; } - -/* NOTE: other git_error functions are in the public errors.h header file */ - -/* Forward declare git_str */ -typedef struct git_str git_str; - -#include "util.h" - #endif diff --git a/src/libgit2/diff_xdiff.c b/src/libgit2/diff_xdiff.c index 3f6eccac1..5f56c5209 100644 --- a/src/libgit2/diff_xdiff.c +++ b/src/libgit2/diff_xdiff.c @@ -11,6 +11,7 @@ #include "diff.h" #include "diff_driver.h" #include "patch_generate.h" +#include "utf8.h" static int git_xdiff_scan_int(const char **str, int *value) { diff --git a/src/libgit2/filter.c b/src/libgit2/filter.c index 2712e8c60..20b215729 100644 --- a/src/libgit2/filter.c +++ b/src/libgit2/filter.c @@ -1085,7 +1085,7 @@ int git_filter_list_stream_file( const char *path, git_writestream *target) { - char buf[FILTERIO_BUFSIZE]; + char buf[GIT_BUFSIZE_FILTERIO]; git_str abspath = GIT_STR_INIT; const char *base = repo ? git_repository_workdir(repo) : NULL; git_vector filter_streams = GIT_VECTOR_INIT; diff --git a/src/libgit2/win32/git2.rc b/src/libgit2/git2.rc index 3f97239da..d273afd70 100644 --- a/src/libgit2/win32/git2.rc +++ b/src/libgit2/git2.rc @@ -1,5 +1,5 @@ #include <winver.h> -#include "../../../include/git2/version.h" +#include "../../include/git2/version.h" #ifndef LIBGIT2_FILENAME # ifdef __GNUC__ diff --git a/src/libgit2/netops.c b/src/libgit2/netops.c index 0a27365b8..00640c600 100644 --- a/src/libgit2/netops.c +++ b/src/libgit2/netops.c @@ -12,7 +12,6 @@ #include "posix.h" #include "str.h" -#include "http_parser.h" #include "runtime.h" int gitno_recv(gitno_buffer *buf) diff --git a/src/libgit2/odb.c b/src/libgit2/odb.c index 6d714ba54..7b98c72ee 100644 --- a/src/libgit2/odb.c +++ b/src/libgit2/odb.c @@ -198,7 +198,7 @@ void git_odb_object_free(git_odb_object *object) int git_odb__hashfd(git_oid *out, git_file fd, size_t size, git_object_t type) { size_t hdr_len; - char hdr[64], buffer[FILEIO_BUFSIZE]; + char hdr[64], buffer[GIT_BUFSIZE_FILEIO]; git_hash_ctx ctx; ssize_t read_len = 0; int error = 0; diff --git a/src/libgit2/path.c b/src/libgit2/path.c index 05a3dc2cf..a19340efe 100644 --- a/src/libgit2/path.c +++ b/src/libgit2/path.c @@ -9,6 +9,7 @@ #include "repository.h" #include "fs_path.h" +#include "utf8.h" typedef struct { git_repository *repo; diff --git a/src/libgit2/util/platform.h.in b/src/libgit2/util/platform.h.in deleted file mode 100644 index e511fe331..000000000 --- a/src/libgit2/util/platform.h.in +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef INCLUDE_platform_h__ -#define INCLUDE_platform_h__ - -#cmakedefine GIT_DEBUG_POOL 1 -#cmakedefine GIT_DEBUG_STRICT_ALLOC 1 -#cmakedefine GIT_DEBUG_STRICT_OPEN 1 - -#cmakedefine GIT_WIN32_LEAKCHECK 1 - -#cmakedefine GIT_ARCH_64 1 -#cmakedefine GIT_ARCH_32 1 - -#cmakedefine GIT_USE_STAT_MTIM 1 -#cmakedefine GIT_USE_STAT_MTIMESPEC 1 -#cmakedefine GIT_USE_STAT_MTIME_NSEC 1 -#cmakedefine GIT_USE_FUTIMENS 1 - -#cmakedefine GIT_USE_QSORT_R_BSD 1 -#cmakedefine GIT_USE_QSORT_R_GNU 1 -#cmakedefine GIT_USE_QSORT_S 1 - -#cmakedefine GIT_REGEX_REGCOMP_L 1 -#cmakedefine GIT_REGEX_REGCOMP 1 -#cmakedefine GIT_REGEX_PCRE 1 -#cmakedefine GIT_REGEX_PCRE2 1 -#cmakedefine GIT_REGEX_BUILTIN 1 - -#cmakedefine GIT_SHA1_COLLISIONDETECT 1 -#cmakedefine GIT_SHA1_WIN32 1 -#cmakedefine GIT_SHA1_COMMON_CRYPTO 1 -#cmakedefine GIT_SHA1_OPENSSL 1 -#cmakedefine GIT_SHA1_MBEDTLS 1 - -#endif diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt new file mode 100644 index 000000000..ea2df0a56 --- /dev/null +++ b/src/util/CMakeLists.txt @@ -0,0 +1,59 @@ +# util: a shared library for common utility functions for libgit2 projects + +add_library(util OBJECT) +set_target_properties(util PROPERTIES C_STANDARD 90) +set_target_properties(util PROPERTIES C_EXTENSIONS OFF) + +set(UTIL_INCLUDES + "${PROJECT_BINARY_DIR}/src" + "${PROJECT_SOURCE_DIR}/src/util" + "${PROJECT_SOURCE_DIR}/include") + +file(GLOB UTIL_SRC *.c *.h allocators/*.c allocators/*.h hash/sha1.h) +list(SORT UTIL_SRC) + +# +# Platform specific sources +# + +if(WIN32 AND NOT CYGWIN) + file(GLOB UTIL_SRC_OS win32/*.c win32/*.h) + list(SORT UTIL_SRC_OS) +elseif(NOT AMIGA) + file(GLOB UTIL_SRC_OS unix/*.c unix/*.h) + list(SORT UTIL_SRC_OS) +endif() + +# +# Hash backend selection +# + +if(USE_SHA1 STREQUAL "CollisionDetection") + file(GLOB UTIL_SRC_HASH hash/sha1/collisiondetect.* hash/sha1/sha1dc/*) + target_compile_definitions(util PRIVATE SHA1DC_NO_STANDARD_INCLUDES=1) + target_compile_definitions(util PRIVATE SHA1DC_CUSTOM_INCLUDE_SHA1_C=\"git2_util.h\") + target_compile_definitions(util PRIVATE SHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C=\"git2_util.h\") +elseif(USE_SHA1 STREQUAL "OpenSSL") + file(GLOB UTIL_SRC_HASH hash/sha1/openssl.*) +elseif(USE_SHA1 STREQUAL "CommonCrypto") + file(GLOB UTIL_SRC_HASH hash/sha1/common_crypto.*) +elseif(USE_SHA1 STREQUAL "mbedTLS") + file(GLOB UTIL_SRC_HASH hash/sha1/mbedtls.*) +elseif(USE_SHA1 STREQUAL "Win32") + file(GLOB UTIL_SRC_HASH hash/sha1/win32.*) +elseif(USE_SHA1 STREQUAL "Generic") + file(GLOB UTIL_SRC_HASH hash/sha1/generic.*) +else() + message(FATAL_ERROR "Asked for unknown SHA1 backend: ${USE_SHA1}") +endif() + +list(SORT UTIL_SRC_HASH) + +# +# Build the library +# + +target_sources(util PRIVATE ${UTIL_SRC} ${UTIL_SRC_OS} ${UTIL_SRC_HASH}) + +target_include_directories(util PRIVATE ${UTIL_INCLUDES} ${LIBGIT2_DEPENDENCY_INCLUDES} PUBLIC ${libgit2_SOURCE_DIR}/include) +target_include_directories(util SYSTEM PRIVATE ${LIBGIT2_SYSTEM_INCLUDES}) diff --git a/src/libgit2/alloc.c b/src/util/alloc.c index 2820d84a2..2820d84a2 100644 --- a/src/libgit2/alloc.c +++ b/src/util/alloc.c diff --git a/src/libgit2/alloc.h b/src/util/alloc.h index 04fb7e101..04fb7e101 100644 --- a/src/libgit2/alloc.h +++ b/src/util/alloc.h diff --git a/src/libgit2/allocators/failalloc.c b/src/util/allocators/failalloc.c index 5257d1dec..5257d1dec 100644 --- a/src/libgit2/allocators/failalloc.c +++ b/src/util/allocators/failalloc.c diff --git a/src/libgit2/allocators/failalloc.h b/src/util/allocators/failalloc.h index 6115e51e7..91264a0bb 100644 --- a/src/libgit2/allocators/failalloc.h +++ b/src/util/allocators/failalloc.h @@ -8,7 +8,7 @@ #ifndef INCLUDE_allocators_failalloc_h__ #define INCLUDE_allocators_failalloc_h__ -#include "common.h" +#include "git2_util.h" extern void *git_failalloc_malloc(size_t len, const char *file, int line); extern void *git_failalloc_calloc(size_t nelem, size_t elsize, const char *file, int line); diff --git a/src/libgit2/allocators/stdalloc.c b/src/util/allocators/stdalloc.c index 2b36d9f3d..2b36d9f3d 100644 --- a/src/libgit2/allocators/stdalloc.c +++ b/src/util/allocators/stdalloc.c diff --git a/src/libgit2/allocators/stdalloc.h b/src/util/allocators/stdalloc.h index fa23fe6e3..955038cb0 100644 --- a/src/libgit2/allocators/stdalloc.h +++ b/src/util/allocators/stdalloc.h @@ -8,7 +8,7 @@ #ifndef INCLUDE_allocators_stdalloc_h__ #define INCLUDE_allocators_stdalloc_h__ -#include "common.h" +#include "git2_util.h" #include "alloc.h" diff --git a/src/libgit2/allocators/win32_leakcheck.c b/src/util/allocators/win32_leakcheck.c index fe06a14af..fe06a14af 100644 --- a/src/libgit2/allocators/win32_leakcheck.c +++ b/src/util/allocators/win32_leakcheck.c diff --git a/src/libgit2/allocators/win32_leakcheck.h b/src/util/allocators/win32_leakcheck.h index 089690f90..edcd9307f 100644 --- a/src/libgit2/allocators/win32_leakcheck.h +++ b/src/util/allocators/win32_leakcheck.h @@ -8,7 +8,7 @@ #ifndef INCLUDE_allocators_win32_leakcheck_h #define INCLUDE_allocators_win32_leakcheck_h -#include "common.h" +#include "git2_util.h" #include "alloc.h" diff --git a/src/libgit2/array.h b/src/util/array.h index e97688b36..cbab52ad1 100644 --- a/src/libgit2/array.h +++ b/src/util/array.h @@ -7,7 +7,7 @@ #ifndef INCLUDE_array_h__ #define INCLUDE_array_h__ -#include "common.h" +#include "git2_util.h" /* * Use this to declare a typesafe resizable array of items, a la: diff --git a/src/libgit2/assert_safe.h b/src/util/assert_safe.h index 8c261100f..8c261100f 100644 --- a/src/libgit2/assert_safe.h +++ b/src/util/assert_safe.h diff --git a/src/libgit2/bitvec.h b/src/util/bitvec.h index 544832d95..544832d95 100644 --- a/src/libgit2/bitvec.h +++ b/src/util/bitvec.h diff --git a/src/libgit2/cc-compat.h b/src/util/cc-compat.h index a0971e86c..a0971e86c 100644 --- a/src/libgit2/cc-compat.h +++ b/src/util/cc-compat.h diff --git a/src/libgit2/date.c b/src/util/date.c index 0e5ffc96b..4d757e21a 100644 --- a/src/libgit2/date.c +++ b/src/util/date.c @@ -1,10 +1,11 @@ /* - * GIT - The information manager from hell + * Copyright (C) the libgit2 contributors. All rights reserved. * - * Copyright (C) Linus Torvalds, 2005 + * 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 "common.h" +#include "git2_util.h" #ifndef GIT_WIN32 #include <sys/time.h> diff --git a/src/libgit2/date.h b/src/util/date.h index 7ebd3c30e..7ebd3c30e 100644 --- a/src/libgit2/date.h +++ b/src/util/date.h diff --git a/src/libgit2/filebuf.c b/src/util/filebuf.c index eafcba3bd..e014d43b2 100644 --- a/src/libgit2/filebuf.c +++ b/src/util/filebuf.c @@ -65,7 +65,7 @@ static int lock_file(git_filebuf *file, int flags, mode_t mode) if ((flags & GIT_FILEBUF_APPEND) && git_fs_path_exists(file->path_original) == true) { git_file source; - char buffer[FILEIO_BUFSIZE]; + char buffer[GIT_BUFSIZE_FILEIO]; ssize_t read_bytes; int error = 0; diff --git a/src/libgit2/filebuf.h b/src/util/filebuf.h index adbb19936..4a61ae4e3 100644 --- a/src/libgit2/filebuf.h +++ b/src/util/filebuf.h @@ -7,7 +7,7 @@ #ifndef INCLUDE_filebuf_h__ #define INCLUDE_filebuf_h__ -#include "common.h" +#include "git2_util.h" #include "futils.h" #include "hash.h" diff --git a/src/libgit2/fs_path.c b/src/util/fs_path.c index 7a657778a..920c39073 100644 --- a/src/libgit2/fs_path.c +++ b/src/util/fs_path.c @@ -7,8 +7,9 @@ #include "fs_path.h" +#include "git2_util.h" +#include "futils.h" #include "posix.h" -#include "repository.h" #ifdef GIT_WIN32 #include "win32/posix.h" #include "win32/w32_buffer.h" @@ -21,6 +22,13 @@ #include <stdio.h> #include <ctype.h> +#define ensure_error_set(code) do { \ + const git_error *e = git_error_last(); \ + if (!e || !e->message) \ + git_error_set(e ? e->klass : GIT_ERROR_CALLBACK, \ + "filesystem callback returned %d", code); \ + } while(0) + static int dos_drive_prefix_length(const char *path) { int i; @@ -530,7 +538,7 @@ int git_fs_path_walk_up( if (!scan) { error = cb(data, ""); if (error) - git_error_set_after_callback(error); + ensure_error_set(error); return error; } @@ -543,7 +551,7 @@ int git_fs_path_walk_up( iter.ptr[scan] = oldc; if (error) { - git_error_set_after_callback(error); + ensure_error_set(error); break; } @@ -563,7 +571,7 @@ int git_fs_path_walk_up( if (!error && stop == 0 && iter.ptr[0] != '/') { error = cb(data, ""); if (error) - git_error_set_after_callback(error); + ensure_error_set(error); } return error; @@ -1167,7 +1175,7 @@ int git_fs_path_direach( /* Only set our own error if the callback did not set one already */ if (error != 0) { if (!git_error_last()) - git_error_set_after_callback(error); + ensure_error_set(error); break; } diff --git a/src/libgit2/fs_path.h b/src/util/fs_path.h index 222c44abc..bb840c43c 100644 --- a/src/libgit2/fs_path.h +++ b/src/util/fs_path.h @@ -7,7 +7,7 @@ #ifndef INCLUDE_fs_path_h__ #define INCLUDE_fs_path_h__ -#include "common.h" +#include "git2_util.h" #include "posix.h" #include "str.h" diff --git a/src/libgit2/futils.c b/src/util/futils.c index 42c35955e..2b0dbf362 100644 --- a/src/libgit2/futils.c +++ b/src/util/futils.c @@ -856,7 +856,7 @@ int git_futils_fake_symlink(const char *target, const char *path) static int cp_by_fd(int ifd, int ofd, bool close_fd_when_done) { int error = 0; - char buffer[FILEIO_BUFSIZE]; + char buffer[GIT_BUFSIZE_FILEIO]; ssize_t len = 0; while (!error && (len = p_read(ifd, buffer, sizeof(buffer))) > 0) diff --git a/src/libgit2/futils.h b/src/util/futils.h index a82ec41cc..fb1afcbd5 100644 --- a/src/libgit2/futils.h +++ b/src/util/futils.h @@ -7,7 +7,7 @@ #ifndef INCLUDE_futils_h__ #define INCLUDE_futils_h__ -#include "common.h" +#include "git2_util.h" #include "map.h" #include "posix.h" diff --git a/src/util/git2_util.h b/src/util/git2_util.h new file mode 100644 index 000000000..ad3f1c71f --- /dev/null +++ b/src/util/git2_util.h @@ -0,0 +1,168 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git2_util_h__ +#define INCLUDE_git2_util_h__ + +#ifndef LIBGIT2_NO_FEATURES_H +# include "git2/sys/features.h" +#endif + +#include "git2/common.h" +#include "cc-compat.h" + +typedef struct git_str git_str; + +/** Declare a function as always inlined. */ +#if defined(_MSC_VER) +# define GIT_INLINE(type) static __inline type +#elif defined(__GNUC__) +# define GIT_INLINE(type) static __inline__ type +#else +# define GIT_INLINE(type) static type +#endif + +/** Support for gcc/clang __has_builtin intrinsic */ +#ifndef __has_builtin +# define __has_builtin(x) 0 +#endif + +/** + * Declare that a function's return value must be used. + * + * Used mostly to guard against potential silent bugs at runtime. This is + * recommended to be added to functions that: + * + * - Allocate / reallocate memory. This prevents memory leaks or errors where + * buffers are expected to have grown to a certain size, but could not be + * resized. + * - Acquire locks. When a lock cannot be acquired, that will almost certainly + * cause a data race / undefined behavior. + */ +#if defined(__GNUC__) +# define GIT_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) +#else +# define GIT_WARN_UNUSED_RESULT +#endif + +#include <assert.h> +#include <errno.h> +#include <limits.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +#include <sys/types.h> +#include <sys/stat.h> + +#ifdef GIT_WIN32 + +# include <io.h> +# include <direct.h> +# include <winsock2.h> +# include <windows.h> +# include <ws2tcpip.h> +# include "win32/msvc-compat.h" +# include "win32/mingw-compat.h" +# include "win32/win32-compat.h" +# include "win32/w32_common.h" +# include "win32/version.h" +# include "win32/error.h" +# ifdef GIT_THREADS +# include "win32/thread.h" +# endif + +#else + +# include <unistd.h> +# include <strings.h> +# ifdef GIT_THREADS +# include <pthread.h> +# include <sched.h> +# endif + +#define GIT_LIBGIT2_CALL +#define GIT_SYSTEM_CALL + +#ifdef GIT_USE_STAT_ATIMESPEC +# define st_atim st_atimespec +# define st_ctim st_ctimespec +# define st_mtim st_mtimespec +#endif + +# include <arpa/inet.h> + +#endif + +#include "git2/types.h" +#include "git2/errors.h" +#include "thread.h" +#include "integer.h" +#include "assert_safe.h" + +#include "posix.h" + +#define GIT_BUFSIZE_DEFAULT 65536 +#define GIT_BUFSIZE_FILEIO GIT_BUFSIZE_DEFAULT +#define GIT_BUFSIZE_FILTERIO GIT_BUFSIZE_DEFAULT +#define GIT_BUFSIZE_NETIO GIT_BUFSIZE_DEFAULT + + +/** + * Check a pointer allocation result, returning -1 if it failed. + */ +#define GIT_ERROR_CHECK_ALLOC(ptr) do { \ + if ((ptr) == NULL) { return -1; } \ + } while(0) + +/** + * Check a buffer allocation result, returning -1 if it failed. + */ +#define GIT_ERROR_CHECK_ALLOC_STR(buf) do { \ + if ((void *)(buf) == NULL || git_str_oom(buf)) { return -1; } \ + } while(0) + +/** + * Check a return value and propagate result if non-zero. + */ +#define GIT_ERROR_CHECK_ERROR(code) \ + do { int _err = (code); if (_err) return _err; } while (0) + + +/** Check for additive overflow, setting an error if would occur. */ +#define GIT_ADD_SIZET_OVERFLOW(out, one, two) \ + (git__add_sizet_overflow(out, one, two) ? (git_error_set_oom(), 1) : 0) + +/** Check for additive overflow, setting an error if would occur. */ +#define GIT_MULTIPLY_SIZET_OVERFLOW(out, nelem, elsize) \ + (git__multiply_sizet_overflow(out, nelem, elsize) ? (git_error_set_oom(), 1) : 0) + +/** Check for additive overflow, failing if it would occur. */ +#define GIT_ERROR_CHECK_ALLOC_ADD(out, one, two) \ + if (GIT_ADD_SIZET_OVERFLOW(out, one, two)) { return -1; } + +#define GIT_ERROR_CHECK_ALLOC_ADD3(out, one, two, three) \ + if (GIT_ADD_SIZET_OVERFLOW(out, one, two) || \ + GIT_ADD_SIZET_OVERFLOW(out, *(out), three)) { return -1; } + +#define GIT_ERROR_CHECK_ALLOC_ADD4(out, one, two, three, four) \ + if (GIT_ADD_SIZET_OVERFLOW(out, one, two) || \ + GIT_ADD_SIZET_OVERFLOW(out, *(out), three) || \ + GIT_ADD_SIZET_OVERFLOW(out, *(out), four)) { return -1; } + +#define GIT_ERROR_CHECK_ALLOC_ADD5(out, one, two, three, four, five) \ + if (GIT_ADD_SIZET_OVERFLOW(out, one, two) || \ + GIT_ADD_SIZET_OVERFLOW(out, *(out), three) || \ + GIT_ADD_SIZET_OVERFLOW(out, *(out), four) || \ + GIT_ADD_SIZET_OVERFLOW(out, *(out), five)) { return -1; } + +/** Check for multiplicative overflow, failing if it would occur. */ +#define GIT_ERROR_CHECK_ALLOC_MULTIPLY(out, nelem, elsize) \ + if (GIT_MULTIPLY_SIZET_OVERFLOW(out, nelem, elsize)) { return -1; } + +#include "util.h" + +#endif diff --git a/src/libgit2/hash.c b/src/util/hash.c index 98ceb05d2..98ceb05d2 100644 --- a/src/libgit2/hash.c +++ b/src/util/hash.c diff --git a/src/libgit2/hash.h b/src/util/hash.h index 507c1cb25..5f1386563 100644 --- a/src/libgit2/hash.h +++ b/src/util/hash.h @@ -8,7 +8,7 @@ #ifndef INCLUDE_hash_h__ #define INCLUDE_hash_h__ -#include "common.h" +#include "git2_util.h" #include "hash/sha1.h" diff --git a/src/libgit2/hash/sha1.h b/src/util/hash/sha1.h index 4b4dae3f8..9d32bce42 100644 --- a/src/libgit2/hash/sha1.h +++ b/src/util/hash/sha1.h @@ -8,7 +8,7 @@ #ifndef INCLUDE_hash_sha1_h__ #define INCLUDE_hash_sha1_h__ -#include "common.h" +#include "git2_util.h" typedef struct git_hash_sha1_ctx git_hash_sha1_ctx; diff --git a/src/libgit2/hash/sha1/collisiondetect.c b/src/util/hash/sha1/collisiondetect.c index ec7059c4c..ec7059c4c 100644 --- a/src/libgit2/hash/sha1/collisiondetect.c +++ b/src/util/hash/sha1/collisiondetect.c diff --git a/src/libgit2/hash/sha1/collisiondetect.h b/src/util/hash/sha1/collisiondetect.h index eb88e86c1..eb88e86c1 100644 --- a/src/libgit2/hash/sha1/collisiondetect.h +++ b/src/util/hash/sha1/collisiondetect.h diff --git a/src/libgit2/hash/sha1/common_crypto.c b/src/util/hash/sha1/common_crypto.c index 9d608f449..9d608f449 100644 --- a/src/libgit2/hash/sha1/common_crypto.c +++ b/src/util/hash/sha1/common_crypto.c diff --git a/src/libgit2/hash/sha1/common_crypto.h b/src/util/hash/sha1/common_crypto.h index a5fcfb33e..a5fcfb33e 100644 --- a/src/libgit2/hash/sha1/common_crypto.h +++ b/src/util/hash/sha1/common_crypto.h diff --git a/src/libgit2/hash/sha1/generic.c b/src/util/hash/sha1/generic.c index 85b34c578..85b34c578 100644 --- a/src/libgit2/hash/sha1/generic.c +++ b/src/util/hash/sha1/generic.c diff --git a/src/libgit2/hash/sha1/generic.h b/src/util/hash/sha1/generic.h index 53fc0823e..53fc0823e 100644 --- a/src/libgit2/hash/sha1/generic.h +++ b/src/util/hash/sha1/generic.h diff --git a/src/libgit2/hash/sha1/mbedtls.c b/src/util/hash/sha1/mbedtls.c index 56016bec8..56016bec8 100644 --- a/src/libgit2/hash/sha1/mbedtls.c +++ b/src/util/hash/sha1/mbedtls.c diff --git a/src/libgit2/hash/sha1/mbedtls.h b/src/util/hash/sha1/mbedtls.h index 15f7462a4..15f7462a4 100644 --- a/src/libgit2/hash/sha1/mbedtls.h +++ b/src/util/hash/sha1/mbedtls.h diff --git a/src/libgit2/hash/sha1/openssl.c b/src/util/hash/sha1/openssl.c index 64bf99b3c..64bf99b3c 100644 --- a/src/libgit2/hash/sha1/openssl.c +++ b/src/util/hash/sha1/openssl.c diff --git a/src/libgit2/hash/sha1/openssl.h b/src/util/hash/sha1/openssl.h index a223ca03e..a223ca03e 100644 --- a/src/libgit2/hash/sha1/openssl.h +++ b/src/util/hash/sha1/openssl.h diff --git a/src/libgit2/hash/sha1/sha1dc/sha1.c b/src/util/hash/sha1/sha1dc/sha1.c index 929822728..929822728 100644 --- a/src/libgit2/hash/sha1/sha1dc/sha1.c +++ b/src/util/hash/sha1/sha1dc/sha1.c diff --git a/src/libgit2/hash/sha1/sha1dc/sha1.h b/src/util/hash/sha1/sha1dc/sha1.h index 1e4e94be5..1e4e94be5 100644 --- a/src/libgit2/hash/sha1/sha1dc/sha1.h +++ b/src/util/hash/sha1/sha1dc/sha1.h diff --git a/src/libgit2/hash/sha1/sha1dc/ubc_check.c b/src/util/hash/sha1/sha1dc/ubc_check.c index b3beff2af..b3beff2af 100644 --- a/src/libgit2/hash/sha1/sha1dc/ubc_check.c +++ b/src/util/hash/sha1/sha1dc/ubc_check.c diff --git a/src/libgit2/hash/sha1/sha1dc/ubc_check.h b/src/util/hash/sha1/sha1dc/ubc_check.h index d7e17dc73..d7e17dc73 100644 --- a/src/libgit2/hash/sha1/sha1dc/ubc_check.h +++ b/src/util/hash/sha1/sha1dc/ubc_check.h diff --git a/src/libgit2/hash/sha1/win32.c b/src/util/hash/sha1/win32.c index b89dfbad8..b89dfbad8 100644 --- a/src/libgit2/hash/sha1/win32.c +++ b/src/util/hash/sha1/win32.c diff --git a/src/libgit2/hash/sha1/win32.h b/src/util/hash/sha1/win32.h index 791d20a42..791d20a42 100644 --- a/src/libgit2/hash/sha1/win32.h +++ b/src/util/hash/sha1/win32.h diff --git a/src/libgit2/integer.h b/src/util/integer.h index 63277177b..63277177b 100644 --- a/src/libgit2/integer.h +++ b/src/util/integer.h diff --git a/src/libgit2/khash.h b/src/util/khash.h index c9b7f131f..c9b7f131f 100644 --- a/src/libgit2/khash.h +++ b/src/util/khash.h diff --git a/src/libgit2/map.h b/src/util/map.h index 01931d199..c101e46f6 100644 --- a/src/libgit2/map.h +++ b/src/util/map.h @@ -7,7 +7,7 @@ #ifndef INCLUDE_map_h__ #define INCLUDE_map_h__ -#include "common.h" +#include "git2_util.h" /* p_mmap() prot values */ diff --git a/src/libgit2/net.c b/src/util/net.c index a76fd1d7c..b2236daf8 100644 --- a/src/libgit2/net.c +++ b/src/util/net.c @@ -6,7 +6,6 @@ */ #include "net.h" -#include "netops.h" #include <ctype.h> diff --git a/src/libgit2/net.h b/src/util/net.h index 499315e6c..88030a952 100644 --- a/src/libgit2/net.h +++ b/src/util/net.h @@ -7,7 +7,7 @@ #ifndef INCLUDE_net_h__ #define INCLUDE_net_h__ -#include "common.h" +#include "git2_util.h" typedef struct git_net_url { char *scheme; diff --git a/src/libgit2/pool.c b/src/util/pool.c index 16ffa398d..16ffa398d 100644 --- a/src/libgit2/pool.c +++ b/src/util/pool.c diff --git a/src/libgit2/pool.h b/src/util/pool.h index cecb84665..0238431b0 100644 --- a/src/libgit2/pool.h +++ b/src/util/pool.h @@ -7,7 +7,7 @@ #ifndef INCLUDE_pool_h__ #define INCLUDE_pool_h__ -#include "common.h" +#include "git2_util.h" #include "vector.h" diff --git a/src/libgit2/posix.c b/src/util/posix.c index b1f85dc94..b1f85dc94 100644 --- a/src/libgit2/posix.c +++ b/src/util/posix.c diff --git a/src/libgit2/posix.h b/src/util/posix.h index e6f603078..c8f8cd9d2 100644 --- a/src/libgit2/posix.h +++ b/src/util/posix.h @@ -7,7 +7,7 @@ #ifndef INCLUDE_posix_h__ #define INCLUDE_posix_h__ -#include "common.h" +#include "git2_util.h" #include <stdlib.h> #include <fcntl.h> diff --git a/src/libgit2/pqueue.c b/src/util/pqueue.c index 3820e999c..3820e999c 100644 --- a/src/libgit2/pqueue.c +++ b/src/util/pqueue.c diff --git a/src/libgit2/pqueue.h b/src/util/pqueue.h index 4db74ea03..97232b4a9 100644 --- a/src/libgit2/pqueue.h +++ b/src/util/pqueue.h @@ -7,7 +7,7 @@ #ifndef INCLUDE_pqueue_h__ #define INCLUDE_pqueue_h__ -#include "common.h" +#include "git2_util.h" #include "vector.h" diff --git a/src/rand.c b/src/util/rand.c index 0a208134e..432494902 100644 --- a/src/rand.c +++ b/src/util/rand.c @@ -6,7 +6,7 @@ worldwide. This software is distributed without any warranty. See <http://creativecommons.org/publicdomain/zero/1.0/>. */ -#include "common.h" +#include "git2_util.h" #include "rand.h" #include "runtime.h" diff --git a/src/rand.h b/src/util/rand.h index 2e60561e5..fa0619aa2 100644 --- a/src/rand.h +++ b/src/util/rand.h @@ -7,7 +7,7 @@ #ifndef INCLUDE_rand_h__ #define INCLUDE_rand_h__ -#include "common.h" +#include "git2_util.h" /** * Initialize the random number generation subsystem. This will diff --git a/src/libgit2/regexp.c b/src/util/regexp.c index 2569dea0a..2569dea0a 100644 --- a/src/libgit2/regexp.c +++ b/src/util/regexp.c diff --git a/src/libgit2/regexp.h b/src/util/regexp.h index 2592ef383..d0862b107 100644 --- a/src/libgit2/regexp.h +++ b/src/util/regexp.h @@ -8,7 +8,7 @@ #ifndef INCLUDE_regexp_h__ #define INCLUDE_regexp_h__ -#include "common.h" +#include "git2_util.h" #if defined(GIT_REGEX_BUILTIN) || defined(GIT_REGEX_PCRE) # include "pcre.h" diff --git a/src/libgit2/runtime.c b/src/util/runtime.c index c05dee8b9..a7711ffc4 100644 --- a/src/libgit2/runtime.c +++ b/src/util/runtime.c @@ -5,7 +5,7 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" +#include "git2_util.h" #include "runtime.h" static git_runtime_shutdown_fn shutdown_callback[32]; diff --git a/src/libgit2/runtime.h b/src/util/runtime.h index 24ac58ee9..6cbfd6043 100644 --- a/src/libgit2/runtime.h +++ b/src/util/runtime.h @@ -7,7 +7,7 @@ #ifndef INCLUDE_runtime_h__ #define INCLUDE_runtime_h__ -#include "common.h" +#include "git2_util.h" typedef int (*git_runtime_init_fn)(void); typedef void (*git_runtime_shutdown_fn)(void); diff --git a/src/libgit2/sortedcache.c b/src/util/sortedcache.c index 7ff900efe..7ff900efe 100644 --- a/src/libgit2/sortedcache.c +++ b/src/util/sortedcache.c diff --git a/src/libgit2/sortedcache.h b/src/util/sortedcache.h index ef260a093..3eee4659f 100644 --- a/src/libgit2/sortedcache.h +++ b/src/util/sortedcache.h @@ -7,7 +7,7 @@ #ifndef INCLUDE_sorted_cache_h__ #define INCLUDE_sorted_cache_h__ -#include "common.h" +#include "git2_util.h" #include "util.h" #include "futils.h" diff --git a/src/libgit2/str.c b/src/util/str.c index 0d405bfda..0d405bfda 100644 --- a/src/libgit2/str.c +++ b/src/util/str.c diff --git a/src/libgit2/str.h b/src/util/str.h index ef769ce2f..588e6fc22 100644 --- a/src/libgit2/str.h +++ b/src/util/str.h @@ -7,7 +7,7 @@ #ifndef INCLUDE_str_h__ #define INCLUDE_str_h__ -#include "common.h" +#include "git2_util.h" struct git_str { char *ptr; diff --git a/src/libgit2/strmap.c b/src/util/strmap.c index c6e5b6dc7..c6e5b6dc7 100644 --- a/src/libgit2/strmap.c +++ b/src/util/strmap.c diff --git a/src/libgit2/strmap.h b/src/util/strmap.h index 9f5e4cc8b..b64d3dcb5 100644 --- a/src/libgit2/strmap.h +++ b/src/util/strmap.h @@ -7,7 +7,7 @@ #ifndef INCLUDE_strmap_h__ #define INCLUDE_strmap_h__ -#include "common.h" +#include "git2_util.h" /** A map with C strings as key. */ typedef struct kh_str_s git_strmap; diff --git a/src/libgit2/strnlen.h b/src/util/strnlen.h index eecfe3c02..eecfe3c02 100644 --- a/src/libgit2/strnlen.h +++ b/src/util/strnlen.h diff --git a/src/libgit2/thread.c b/src/util/thread.c index 3171771d7..bc7364f8c 100644 --- a/src/libgit2/thread.c +++ b/src/util/thread.c @@ -5,7 +5,7 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" +#include "git2_util.h" #if !defined(GIT_THREADS) diff --git a/src/libgit2/thread.h b/src/util/thread.h index 4bbac9fd8..4bbac9fd8 100644 --- a/src/libgit2/thread.h +++ b/src/util/thread.h diff --git a/src/libgit2/tsort.c b/src/util/tsort.c index 045efad23..2ef03d03a 100644 --- a/src/libgit2/tsort.c +++ b/src/util/tsort.c @@ -5,7 +5,7 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" +#include "git2_util.h" /** * An array-of-pointers implementation of Python's Timsort diff --git a/src/libgit2/unix/map.c b/src/util/unix/map.c index 23fcb786e..933077689 100644 --- a/src/libgit2/unix/map.c +++ b/src/util/unix/map.c @@ -5,7 +5,7 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" +#include "git2_util.h" #if !defined(GIT_WIN32) && !defined(NO_MMAP) diff --git a/src/libgit2/unix/posix.h b/src/util/unix/posix.h index 49065e533..778477e8e 100644 --- a/src/libgit2/unix/posix.h +++ b/src/util/unix/posix.h @@ -7,7 +7,7 @@ #ifndef INCLUDE_unix_posix_h__ #define INCLUDE_unix_posix_h__ -#include "common.h" +#include "git2_util.h" #include <stdio.h> #include <dirent.h> diff --git a/src/libgit2/unix/pthread.h b/src/util/unix/pthread.h index 55f4ae227..55f4ae227 100644 --- a/src/libgit2/unix/pthread.h +++ b/src/util/unix/pthread.h diff --git a/src/libgit2/unix/realpath.c b/src/util/unix/realpath.c index f1ca669f7..9e31a63b9 100644 --- a/src/libgit2/unix/realpath.c +++ b/src/util/unix/realpath.c @@ -5,7 +5,7 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" +#include "git2_util.h" #ifndef GIT_WIN32 diff --git a/src/libgit2/utf8.c b/src/util/utf8.c index 77065cb71..c566fdf20 100644 --- a/src/libgit2/utf8.c +++ b/src/util/utf8.c @@ -7,7 +7,7 @@ #include "utf8.h" -#include "common.h" +#include "git2_util.h" /* * git_utf8_iterate is taken from the utf8proc project, diff --git a/src/libgit2/utf8.h b/src/util/utf8.h index dff91b294..753ab07e2 100644 --- a/src/libgit2/utf8.h +++ b/src/util/utf8.h @@ -7,7 +7,7 @@ #ifndef INCLUDE_utf8_h__ #define INCLUDE_utf8_h__ -#include "common.h" +#include "git2_util.h" /* * Iterate through an UTF-8 string, yielding one codepoint at a time. diff --git a/src/libgit2/util.c b/src/util/util.c index e06d4ca09..aee95fddf 100644 --- a/src/libgit2/util.c +++ b/src/util/util.c @@ -7,7 +7,7 @@ #include "util.h" -#include "common.h" +#include "git2_util.h" #ifdef GIT_WIN32 # include "win32/utf-conv.h" diff --git a/src/libgit2/util.h b/src/util/util.h index 141779ade..8d6d1d6b6 100644 --- a/src/libgit2/util.h +++ b/src/util/util.h @@ -12,7 +12,7 @@ #endif #include "str.h" -#include "common.h" +#include "git2_util.h" #include "strnlen.h" #include "thread.h" diff --git a/src/libgit2/varint.c b/src/util/varint.c index 9ffc1d744..9ffc1d744 100644 --- a/src/libgit2/varint.c +++ b/src/util/varint.c diff --git a/src/libgit2/varint.h b/src/util/varint.h index 652e22486..79b8f5548 100644 --- a/src/libgit2/varint.h +++ b/src/util/varint.h @@ -7,7 +7,7 @@ #ifndef INCLUDE_varint_h__ #define INCLUDE_varint_h__ -#include "common.h" +#include "git2_util.h" #include <stdint.h> diff --git a/src/libgit2/vector.c b/src/util/vector.c index 4a4bc8c0e..4a4bc8c0e 100644 --- a/src/libgit2/vector.c +++ b/src/util/vector.c diff --git a/src/libgit2/vector.h b/src/util/vector.h index ae3c79a4c..e50cdfefc 100644 --- a/src/libgit2/vector.h +++ b/src/util/vector.h @@ -7,7 +7,7 @@ #ifndef INCLUDE_vector_h__ #define INCLUDE_vector_h__ -#include "common.h" +#include "git2_util.h" typedef int (*git_vector_cmp)(const void *, const void *); diff --git a/src/libgit2/wildmatch.c b/src/util/wildmatch.c index a894e4841..a894e4841 100644 --- a/src/libgit2/wildmatch.c +++ b/src/util/wildmatch.c diff --git a/src/libgit2/wildmatch.h b/src/util/wildmatch.h index 44bb575a6..f20640500 100644 --- a/src/libgit2/wildmatch.h +++ b/src/util/wildmatch.h @@ -8,7 +8,7 @@ #ifndef INCLUDE_wildmatch_h__ #define INCLUDE_wildmatch_h__ -#include "common.h" +#include "git2_util.h" #define WM_CASEFOLD 1 #define WM_PATHNAME 2 diff --git a/src/libgit2/win32/dir.c b/src/util/win32/dir.c index 44052caf0..44052caf0 100644 --- a/src/libgit2/win32/dir.c +++ b/src/util/win32/dir.c diff --git a/src/libgit2/win32/dir.h b/src/util/win32/dir.h index acd64729e..810111534 100644 --- a/src/libgit2/win32/dir.h +++ b/src/util/win32/dir.h @@ -7,7 +7,7 @@ #ifndef INCLUDE_win32_dir_h__ #define INCLUDE_win32_dir_h__ -#include "common.h" +#include "git2_util.h" #include "w32_util.h" diff --git a/src/libgit2/win32/error.c b/src/util/win32/error.c index 3a52fb5a9..3a52fb5a9 100644 --- a/src/libgit2/win32/error.c +++ b/src/util/win32/error.c diff --git a/src/libgit2/win32/error.h b/src/util/win32/error.h index 9e81141ce..fd53b7f99 100644 --- a/src/libgit2/win32/error.h +++ b/src/util/win32/error.h @@ -8,7 +8,7 @@ #ifndef INCLUDE_win32_error_h__ #define INCLUDE_win32_error_h__ -#include "common.h" +#include "git2_util.h" extern char *git_win32_get_error_message(DWORD error_code); diff --git a/src/libgit2/win32/findfile.c b/src/util/win32/findfile.c index 725a90167..725a90167 100644 --- a/src/libgit2/win32/findfile.c +++ b/src/util/win32/findfile.c diff --git a/src/libgit2/win32/findfile.h b/src/util/win32/findfile.h index 61fb7dbad..7b191d1fe 100644 --- a/src/libgit2/win32/findfile.h +++ b/src/util/win32/findfile.h @@ -8,7 +8,7 @@ #ifndef INCLUDE_win32_findfile_h__ #define INCLUDE_win32_findfile_h__ -#include "common.h" +#include "git2_util.h" /** Sets the mock registry root for Git for Windows for testing. */ extern int git_win32__set_registry_system_dir(const wchar_t *mock_sysdir); diff --git a/src/libgit2/win32/map.c b/src/util/win32/map.c index 2aabc9b15..52e1363ea 100644 --- a/src/libgit2/win32/map.c +++ b/src/util/win32/map.c @@ -5,7 +5,7 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" +#include "git2_util.h" #include "map.h" #include <errno.h> diff --git a/src/libgit2/win32/mingw-compat.h b/src/util/win32/mingw-compat.h index aa2bef98d..aa2bef98d 100644 --- a/src/libgit2/win32/mingw-compat.h +++ b/src/util/win32/mingw-compat.h diff --git a/src/libgit2/win32/msvc-compat.h b/src/util/win32/msvc-compat.h index 03f9f36dc..03f9f36dc 100644 --- a/src/libgit2/win32/msvc-compat.h +++ b/src/util/win32/msvc-compat.h diff --git a/src/libgit2/win32/path_w32.c b/src/util/win32/path_w32.c index d9fc8292b..d9fc8292b 100644 --- a/src/libgit2/win32/path_w32.c +++ b/src/util/win32/path_w32.c diff --git a/src/libgit2/win32/path_w32.h b/src/util/win32/path_w32.h index 837b11ebd..b241d5c8a 100644 --- a/src/libgit2/win32/path_w32.h +++ b/src/util/win32/path_w32.h @@ -7,7 +7,7 @@ #ifndef INCLUDE_win32_path_w32_h__ #define INCLUDE_win32_path_w32_h__ -#include "common.h" +#include "git2_util.h" /** * Create a Win32 path (in UCS-2 format) from a UTF-8 string. If the given diff --git a/src/libgit2/win32/posix.h b/src/util/win32/posix.h index 578347f15..03fa2ac52 100644 --- a/src/libgit2/win32/posix.h +++ b/src/util/win32/posix.h @@ -7,7 +7,7 @@ #ifndef INCLUDE_win32_posix_h__ #define INCLUDE_win32_posix_h__ -#include "common.h" +#include "git2_util.h" #include "../posix.h" #include "win32-compat.h" #include "path_w32.h" diff --git a/src/libgit2/win32/posix_w32.c b/src/util/win32/posix_w32.c index 5f7cd0c26..5862e5c9a 100644 --- a/src/libgit2/win32/posix_w32.c +++ b/src/util/win32/posix_w32.c @@ -5,7 +5,7 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" +#include "git2_util.h" #include "../posix.h" #include "../futils.h" diff --git a/src/libgit2/win32/precompiled.c b/src/util/win32/precompiled.c index 5f656a45d..5f656a45d 100644 --- a/src/libgit2/win32/precompiled.c +++ b/src/util/win32/precompiled.c diff --git a/src/libgit2/win32/precompiled.h b/src/util/win32/precompiled.h index 806b1698a..1163c3d63 100644 --- a/src/libgit2/win32/precompiled.h +++ b/src/util/win32/precompiled.h @@ -1,4 +1,4 @@ -#include "common.h" +#include "git2_util.h" #include <errno.h> #include <limits.h> diff --git a/src/libgit2/win32/reparse.h b/src/util/win32/reparse.h index 23312319f..23312319f 100644 --- a/src/libgit2/win32/reparse.h +++ b/src/util/win32/reparse.h diff --git a/src/libgit2/win32/thread.c b/src/util/win32/thread.c index f5cacd320..f5cacd320 100644 --- a/src/libgit2/win32/thread.c +++ b/src/util/win32/thread.c diff --git a/src/libgit2/win32/thread.h b/src/util/win32/thread.h index 8305036b4..184762e2a 100644 --- a/src/libgit2/win32/thread.h +++ b/src/util/win32/thread.h @@ -8,7 +8,7 @@ #ifndef INCLUDE_win32_thread_h__ #define INCLUDE_win32_thread_h__ -#include "common.h" +#include "git2_util.h" #if defined (_MSC_VER) # define GIT_RESTRICT __restrict diff --git a/src/libgit2/win32/utf-conv.c b/src/util/win32/utf-conv.c index 4bde3023a..4bde3023a 100644 --- a/src/libgit2/win32/utf-conv.c +++ b/src/util/win32/utf-conv.c diff --git a/src/libgit2/win32/utf-conv.h b/src/util/win32/utf-conv.h index 6090a4b35..120d647ef 100644 --- a/src/libgit2/win32/utf-conv.h +++ b/src/util/win32/utf-conv.h @@ -7,7 +7,7 @@ #ifndef INCLUDE_win32_utf_conv_h__ #define INCLUDE_win32_utf_conv_h__ -#include "common.h" +#include "git2_util.h" #include <wchar.h> diff --git a/src/libgit2/win32/version.h b/src/util/win32/version.h index 79667697f..79667697f 100644 --- a/src/libgit2/win32/version.h +++ b/src/util/win32/version.h diff --git a/src/libgit2/win32/w32_buffer.c b/src/util/win32/w32_buffer.c index 6fee8203c..6fee8203c 100644 --- a/src/libgit2/win32/w32_buffer.c +++ b/src/util/win32/w32_buffer.c diff --git a/src/libgit2/win32/w32_buffer.h b/src/util/win32/w32_buffer.h index 4227296d8..68ea96035 100644 --- a/src/libgit2/win32/w32_buffer.h +++ b/src/util/win32/w32_buffer.h @@ -7,7 +7,7 @@ #ifndef INCLUDE_win32_w32_buffer_h__ #define INCLUDE_win32_w32_buffer_h__ -#include "common.h" +#include "git2_util.h" #include "str.h" /** diff --git a/src/libgit2/win32/w32_common.h b/src/util/win32/w32_common.h index c20b3e85e..c20b3e85e 100644 --- a/src/libgit2/win32/w32_common.h +++ b/src/util/win32/w32_common.h diff --git a/src/libgit2/win32/w32_leakcheck.c b/src/util/win32/w32_leakcheck.c index 0f095de12..0f095de12 100644 --- a/src/libgit2/win32/w32_leakcheck.c +++ b/src/util/win32/w32_leakcheck.c diff --git a/src/libgit2/win32/w32_leakcheck.h b/src/util/win32/w32_leakcheck.h index cb45e3675..82d863851 100644 --- a/src/libgit2/win32/w32_leakcheck.h +++ b/src/util/win32/w32_leakcheck.h @@ -8,7 +8,7 @@ #ifndef INCLUDE_win32_leakcheck_h__ #define INCLUDE_win32_leakcheck_h__ -#include "common.h" +#include "git2_util.h" /* Initialize the win32 leak checking system. */ int git_win32_leakcheck_global_init(void); diff --git a/src/libgit2/win32/w32_util.c b/src/util/win32/w32_util.c index fe4b75bae..fe4b75bae 100644 --- a/src/libgit2/win32/w32_util.c +++ b/src/util/win32/w32_util.c diff --git a/src/libgit2/win32/w32_util.h b/src/util/win32/w32_util.h index 1321d30e6..519663720 100644 --- a/src/libgit2/win32/w32_util.h +++ b/src/util/win32/w32_util.h @@ -8,7 +8,7 @@ #ifndef INCLUDE_win32_w32_util_h__ #define INCLUDE_win32_w32_util_h__ -#include "common.h" +#include "git2_util.h" #include "utf-conv.h" #include "posix.h" diff --git a/src/libgit2/win32/win32-compat.h b/src/util/win32/win32-compat.h index dee40a438..dee40a438 100644 --- a/src/libgit2/win32/win32-compat.h +++ b/src/util/win32/win32-compat.h diff --git a/src/libgit2/zstream.c b/src/util/zstream.c index cb8b125ed..cb8b125ed 100644 --- a/src/libgit2/zstream.c +++ b/src/util/zstream.c diff --git a/src/libgit2/zstream.h b/src/util/zstream.h index 3f8b1c72f..d78b11291 100644 --- a/src/libgit2/zstream.h +++ b/src/util/zstream.h @@ -7,7 +7,7 @@ #ifndef INCLUDE_zstream_h__ #define INCLUDE_zstream_h__ -#include "common.h" +#include "git2_util.h" #include <zlib.h> |