summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2021-11-07 09:24:38 -0500
committerEdward Thomson <ethomson@edwardthomson.com>2021-11-10 21:37:54 -0500
commit40ec0e7df8e6299d7e27b2088ce79295e5db74f4 (patch)
tree0e25026a836d3a8b17ae933827928213174f960a
parentfae9f00b69c4ba0cdb39bdc1810524ac9be0958a (diff)
downloadlibgit2-40ec0e7df8e6299d7e27b2088ce79295e5db74f4.tar.gz
refactor: move utility functions into util directory
-rw-r--r--cmake/SelectHashes.cmake94
-rw-r--r--src/CMakeLists.txt435
-rw-r--r--src/libgit2/CMakeLists.txt430
-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)0
-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)0
-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)0
-rw-r--r--src/util/array.h (renamed from src/libgit2/array.h)0
-rw-r--r--src/util/assert_safe.h (renamed from src/libgit2/assert_safe.h)0
-rw-r--r--src/util/cc-compat.h (renamed from src/libgit2/cc-compat.h)0
-rw-r--r--src/util/fs_path.c (renamed from src/libgit2/fs_path.c)0
-rw-r--r--src/util/fs_path.h (renamed from src/libgit2/fs_path.h)0
-rw-r--r--src/util/futils.c (renamed from src/libgit2/futils.c)0
-rw-r--r--src/util/futils.h (renamed from src/libgit2/futils.h)0
-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)0
-rw-r--r--src/util/hash/sha1.h (renamed from src/libgit2/hash/sha1.h)0
-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)0
-rw-r--r--src/util/net.c (renamed from src/libgit2/net.c)0
-rw-r--r--src/util/net.h (renamed from src/libgit2/net.h)0
-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)0
-rw-r--r--src/util/posix.h (renamed from src/libgit2/posix.h)0
-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)0
-rw-r--r--src/util/runtime.c (renamed from src/libgit2/runtime.c)0
-rw-r--r--src/util/runtime.h (renamed from src/libgit2/runtime.h)0
-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)0
-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)0
-rw-r--r--src/util/thread.c (renamed from src/libgit2/thread.c)0
-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)0
-rw-r--r--src/util/unix/map.c (renamed from src/libgit2/unix/map.c)0
-rw-r--r--src/util/unix/posix.h (renamed from src/libgit2/unix/posix.h)0
-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)0
-rw-r--r--src/util/utf8.c (renamed from src/libgit2/utf8.c)0
-rw-r--r--src/util/utf8.h (renamed from src/libgit2/utf8.h)0
-rw-r--r--src/util/util.c (renamed from src/libgit2/util.c)0
-rw-r--r--src/util/util.h (renamed from src/libgit2/util.h)0
-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)0
-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)0
-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)0
-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)0
-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)0
-rw-r--r--src/util/win32/git2.rc (renamed from src/libgit2/win32/git2.rc)0
-rw-r--r--src/util/win32/map.c (renamed from src/libgit2/win32/map.c)0
-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)0
-rw-r--r--src/util/win32/posix.h (renamed from src/libgit2/win32/posix.h)0
-rw-r--r--src/util/win32/posix_w32.c (renamed from src/libgit2/win32/posix_w32.c)0
-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)0
-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)0
-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)0
-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)0
-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)0
-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)0
-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)0
100 files changed, 481 insertions, 478 deletions
diff --git a/cmake/SelectHashes.cmake b/cmake/SelectHashes.cmake
index 092cdfd05..a5e3e22aa 100644
--- a/cmake/SelectHashes.cmake
+++ b/cmake/SelectHashes.cmake
@@ -1,62 +1,62 @@
# Select a hash backend
-INCLUDE(SanitizeBool)
+include(SanitizeBool)
# USE_SHA1=CollisionDetection(ON)/HTTPS/Generic/OFF
+sanitizebool(USE_SHA1)
-SanitizeBool(USE_SHA1)
-IF(USE_SHA1 STREQUAL ON)
+if(USE_SHA1 STREQUAL ON)
SET(USE_SHA1 "CollisionDetection")
-ELSEIF(USE_SHA1 STREQUAL "HTTPS")
- IF(USE_HTTPS STREQUAL "SecureTransport")
- SET(USE_SHA1 "CommonCrypto")
- ELSEIF(USE_HTTPS STREQUAL "WinHTTP")
- SET(USE_SHA1 "Win32")
- ELSEIF(USE_HTTPS)
- SET(USE_SHA1 ${USE_HTTPS})
- ELSE()
- SET(USE_SHA1 "CollisionDetection")
- ENDIF()
-ENDIF()
+elseif(USE_SHA1 STREQUAL "HTTPS")
+ if(USE_HTTPS STREQUAL "SecureTransport")
+ set(USE_SHA1 "CommonCrypto")
+ elseif(USE_HTTPS STREQUAL "WinHTTP")
+ set(USE_SHA1 "Win32")
+ elseif(USE_HTTPS)
+ set(USE_SHA1 ${USE_HTTPS})
+ else()
+ set(USE_SHA1 "CollisionDetection")
+ endif()
+endif()
-IF(USE_SHA1 STREQUAL "CollisionDetection")
- SET(GIT_SHA1_COLLISIONDETECT 1)
- ADD_DEFINITIONS(-DSHA1DC_NO_STANDARD_INCLUDES=1)
- ADD_DEFINITIONS(-DSHA1DC_CUSTOM_INCLUDE_SHA1_C=\"common.h\")
- ADD_DEFINITIONS(-DSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C=\"common.h\")
- FILE(GLOB SRC_SHA1 hash/sha1/collisiondetect.* hash/sha1/sha1dc/*)
-ELSEIF(USE_SHA1 STREQUAL "OpenSSL")
+if(USE_SHA1 STREQUAL "CollisionDetection")
+ set(GIT_SHA1_COLLISIONDETECT 1)
+ add_definitions(-DSHA1DC_NO_STANDARD_INCLUDES=1)
+ add_definitions(-DSHA1DC_CUSTOM_INCLUDE_SHA1_C=\"common.h\")
+ add_definitions(-DSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C=\"common.h\")
+ file(GLOB SRC_SHA1 util/hash/sha1/collisiondetect.* util/hash/sha1/sha1dc/*)
+elseif(USE_SHA1 STREQUAL "OpenSSL")
# OPENSSL_FOUND should already be set, we're checking USE_HTTPS
- SET(GIT_SHA1_OPENSSL 1)
- IF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
- LIST(APPEND LIBGIT2_PC_LIBS "-lssl")
- ELSE()
- LIST(APPEND LIBGIT2_PC_REQUIRES "openssl")
- ENDIF()
- FILE(GLOB SRC_SHA1 hash/sha1/openssl.*)
-ELSEIF(USE_SHA1 STREQUAL "CommonCrypto")
- SET(GIT_SHA1_COMMON_CRYPTO 1)
- FILE(GLOB SRC_SHA1 hash/sha1/common_crypto.*)
-ELSEIF(USE_SHA1 STREQUAL "mbedTLS")
- SET(GIT_SHA1_MBEDTLS 1)
- FILE(GLOB SRC_SHA1 hash/sha1/mbedtls.*)
- LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${MBEDTLS_INCLUDE_DIR})
- LIST(APPEND LIBGIT2_LIBS ${MBEDTLS_LIBRARIES})
+ set(GIT_SHA1_OPENSSL 1)
+ if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
+ list(APPEND LIBGIT2_PC_LIBS "-lssl")
+ else()
+ list(APPEND LIBGIT2_PC_REQUIRES "openssl")
+ endif()
+ file(GLOB SRC_SHA1 util/hash/sha1/openssl.*)
+elseif(USE_SHA1 STREQUAL "CommonCrypto")
+ set(GIT_SHA1_COMMON_CRYPTO 1)
+ file(GLOB SRC_SHA1 util/hash/sha1/common_crypto.*)
+elseif(USE_SHA1 STREQUAL "mbedTLS")
+ set(GIT_SHA1_MBEDTLS 1)
+ file(GLOB SRC_SHA1 util/hash/sha1/mbedtls.*)
+ list(APPEND LIBGIT2_SYSTEM_INCLUDES ${MBEDTLS_INCLUDE_DIR})
+ list(APPEND LIBGIT2_LIBS ${MBEDTLS_LIBRARIES})
# mbedTLS has no pkgconfig file, hence we can't require it
# https://github.com/ARMmbed/mbedtls/issues/228
# For now, pass its link flags as our own
- LIST(APPEND LIBGIT2_PC_LIBS ${MBEDTLS_LIBRARIES})
-ELSEIF(USE_SHA1 STREQUAL "Win32")
- SET(GIT_SHA1_WIN32 1)
- FILE(GLOB SRC_SHA1 hash/sha1/win32.*)
-ELSEIF(USE_SHA1 STREQUAL "Generic")
- FILE(GLOB SRC_SHA1 hash/sha1/generic.*)
-ELSE()
- MESSAGE(FATAL_ERROR "Asked for unknown SHA1 backend: ${USE_SHA1}")
-ENDIF()
+ list(APPEND LIBGIT2_PC_LIBS ${MBEDTLS_LIBRARIES})
+elseif(USE_SHA1 STREQUAL "Win32")
+ set(GIT_SHA1_WIN32 1)
+ file(GLOB SRC_SHA1 util/hash/sha1/win32.*)
+elseif(USE_SHA1 STREQUAL "Generic")
+ file(GLOB SRC_SHA1 util/hash/sha1/generic.*)
+else()
+ message(FATAL_ERROR "Asked for unknown SHA1 backend: ${USE_SHA1}")
+endif()
-list(APPEND SRC_SHA1 "hash/sha1.h")
+list(APPEND SRC_SHA1 "util/hash/sha1.h")
list(SORT SRC_SHA1)
-ADD_FEATURE_INFO(SHA ON "using ${USE_SHA1}")
+add_feature_info(SHA ON "using ${USE_SHA1}")
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 1b31354e5..e254329f4 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1 +1,434 @@
-add_subdirectory(libgit2)
+add_library(git2internal OBJECT)
+set_target_properties(git2internal PROPERTIES C_STANDARD 90)
+
+
+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}"
+ "${libgit2_SOURCE_DIR}/src/libgit2"
+ "${libgit2_SOURCE_DIR}/src/util"
+ "${libgit2_SOURCE_DIR}/include")
+set(LIBGIT2_SYSTEM_INCLUDES "")
+set(LIBGIT2_LIBS "")
+
+if(HAVE_FUTIMENS)
+ set(GIT_USE_FUTIMENS 1)
+endif ()
+add_feature_info(futimens GIT_USE_FUTIMENS "futimens support")
+
+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)
+
+# Find required dependencies
+
+if(WIN32)
+ list(APPEND LIBGIT2_LIBS ws2_32)
+elseif(CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
+ list(APPEND LIBGIT2_LIBS socket nsl)
+ list(APPEND LIBGIT2_PC_LIBS "-lsocket" "-lnsl")
+elseif(CMAKE_SYSTEM_NAME MATCHES "Haiku")
+ list(APPEND LIBGIT2_LIBS network)
+ list(APPEND LIBGIT2_PC_LIBS "-lnetwork")
+endif()
+
+check_library_exists(rt clock_gettime "time.h" NEED_LIBRT)
+if(NEED_LIBRT)
+ list(APPEND LIBGIT2_LIBS rt)
+ list(APPEND LIBGIT2_PC_LIBS "-lrt")
+endif()
+
+if(USE_THREADS)
+ list(APPEND LIBGIT2_LIBS ${CMAKE_THREAD_LIBS_INIT})
+ list(APPEND LIBGIT2_PC_LIBS ${CMAKE_THREAD_LIBS_INIT})
+endif()
+add_feature_info(threadsafe USE_THREADS "threadsafe 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})
+
+ 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()
+
+if(WIN32 AND USE_WINHTTP)
+ set(GIT_WINHTTP 1)
+
+ # Since MinGW does not come with headers or an import library for winhttp,
+ # we have to include a private header and generate our own import library
+ if(MINGW)
+ add_subdirectory("${libgit2_SOURCE_DIR}/deps/winhttp" "${libgit2_BINARY_DIR}/deps/winhttp")
+ list(APPEND LIBGIT2_LIBS winhttp)
+ list(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/winhttp")
+ else()
+ list(APPEND LIBGIT2_LIBS "winhttp")
+ list(APPEND LIBGIT2_PC_LIBS "-lwinhttp")
+ endif()
+
+ list(APPEND LIBGIT2_LIBS "rpcrt4" "crypt32" "ole32")
+ list(APPEND LIBGIT2_PC_LIBS "-lrpcrt4" "-lcrypt32" "-lole32")
+endif()
+
+include(SelectHTTPSBackend)
+include(SelectHashes)
+target_sources(git2internal PRIVATE ${SRC_SHA1})
+
+# Specify regular expression implementation
+find_package(PCRE)
+
+if(REGEX_BACKEND STREQUAL "")
+ check_symbol_exists(regcomp_l "regex.h;xlocale.h" HAVE_REGCOMP_L)
+
+ if(HAVE_REGCOMP_L)
+ set(REGEX_BACKEND "regcomp_l")
+ elseif(PCRE_FOUND)
+ set(REGEX_BACKEND "pcre")
+ else()
+ set(REGEX_BACKEND "builtin")
+ endif()
+endif()
+
+if(REGEX_BACKEND STREQUAL "regcomp_l")
+ add_feature_info(regex ON "using system regcomp_l")
+ set(GIT_REGEX_REGCOMP_L 1)
+elseif(REGEX_BACKEND STREQUAL "pcre2")
+ find_package(PCRE2)
+
+ if(NOT PCRE2_FOUND)
+ MESSAGE(FATAL_ERROR "PCRE2 support was requested but not found")
+ endif()
+
+ add_feature_info(regex ON "using system PCRE2")
+ set(GIT_REGEX_PCRE2 1)
+
+ list(APPEND LIBGIT2_SYSTEM_INCLUDES ${PCRE2_INCLUDE_DIRS})
+ list(APPEND LIBGIT2_LIBS ${PCRE2_LIBRARIES})
+ list(APPEND LIBGIT2_PC_REQUIRES "libpcre2-8")
+elseif(REGEX_BACKEND STREQUAL "pcre")
+ add_feature_info(regex ON "using system PCRE")
+ set(GIT_REGEX_PCRE 1)
+
+ list(APPEND LIBGIT2_SYSTEM_INCLUDES ${PCRE_INCLUDE_DIRS})
+ list(APPEND LIBGIT2_LIBS ${PCRE_LIBRARIES})
+ list(APPEND LIBGIT2_PC_REQUIRES "libpcre")
+elseif(REGEX_BACKEND STREQUAL "regcomp")
+ add_feature_info(regex ON "using system regcomp")
+ set(GIT_REGEX_REGCOMP 1)
+elseif(REGEX_BACKEND STREQUAL "builtin")
+ add_feature_info(regex ON "using bundled PCRE")
+ set(GIT_REGEX_BUILTIN 1)
+
+ add_subdirectory("${libgit2_SOURCE_DIR}/deps/pcre" "${libgit2_BINARY_DIR}/deps/pcre")
+ list(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/pcre")
+ list(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:pcre>)
+else()
+ message(FATAL_ERROR "The REGEX_BACKEND option provided is not supported")
+endif()
+
+# Optional external dependency: http-parser
+if(USE_HTTP_PARSER STREQUAL "system")
+ find_package(HTTPParser)
+
+ if(HTTP_PARSER_FOUND AND HTTP_PARSER_VERSION_MAJOR EQUAL 2)
+ list(APPEND LIBGIT2_SYSTEM_INCLUDES ${HTTP_PARSER_INCLUDE_DIRS})
+ list(APPEND LIBGIT2_LIBS ${HTTP_PARSER_LIBRARIES})
+ list(APPEND LIBGIT2_PC_LIBS "-lhttp_parser")
+ add_feature_info(http-parser ON "http-parser support (system)")
+ else()
+ message(FATAL_ERROR "http-parser support was requested but not found")
+ endif()
+else()
+ message(STATUS "http-parser version 2 was not found or disabled; using bundled 3rd-party sources.")
+ add_subdirectory("${libgit2_SOURCE_DIR}/deps/http-parser" "${libgit2_BINARY_DIR}/deps/http-parser")
+ list(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/http-parser")
+ list(APPEND LIBGIT2_OBJECTS "$<TARGET_OBJECTS:http-parser>")
+ add_feature_info(http-parser ON "http-parser support (bundled)")
+endif()
+
+# Optional external dependency: zlib
+SanitizeBool(USE_BUNDLED_ZLIB)
+if(USE_BUNDLED_ZLIB STREQUAL ON)
+ set(USE_BUNDLED_ZLIB "Bundled")
+endif()
+
+if(USE_BUNDLED_ZLIB STREQUAL "OFF")
+ find_package(ZLIB)
+ if(ZLIB_FOUND)
+ list(APPEND LIBGIT2_SYSTEM_INCLUDES ${ZLIB_INCLUDE_DIRS})
+ list(APPEND LIBGIT2_LIBS ${ZLIB_LIBRARIES})
+ if(APPLE OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
+ list(APPEND LIBGIT2_PC_LIBS "-lz")
+ else()
+ list(APPEND LIBGIT2_PC_REQUIRES "zlib")
+ endif()
+ add_feature_info(zlib ON "using system zlib")
+ else()
+ message(STATUS "zlib was not found; using bundled 3rd-party sources." )
+ endif()
+endif()
+if(USE_BUNDLED_ZLIB STREQUAL "Chromium")
+ add_subdirectory("${libgit2_SOURCE_DIR}/deps/chromium-zlib" "${libgit2_BINARY_DIR}/deps/chromium-zlib")
+ list(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/chromium-zlib")
+ list(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:chromium_zlib>)
+ add_feature_info(zlib ON "using (Chromium) bundled zlib")
+elseif(USE_BUNDLED_ZLIB OR NOT ZLIB_FOUND)
+ add_subdirectory("${libgit2_SOURCE_DIR}/deps/zlib" "${libgit2_BINARY_DIR}/deps/zlib")
+ list(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/zlib")
+ list(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:zlib>)
+ add_feature_info(zlib ON "using bundled zlib")
+endif()
+
+# Optional external dependency: libssh2
+if(USE_SSH)
+ find_pkglibraries(LIBSSH2 libssh2)
+ if(NOT LIBSSH2_FOUND)
+ find_package(LibSSH2)
+ set(LIBSSH2_INCLUDE_DIRS ${LIBSSH2_INCLUDE_DIR})
+ get_filename_component(LIBSSH2_LIBRARY_DIRS "${LIBSSH2_LIBRARY}" DIRECTORY)
+ set(LIBSSH2_LIBRARIES ${LIBSSH2_LIBRARY})
+ set(LIBSSH2_LDFLAGS "-lssh2")
+ endif()
+endif()
+if(LIBSSH2_FOUND)
+ set(GIT_SSH 1)
+ list(APPEND LIBGIT2_SYSTEM_INCLUDES ${LIBSSH2_INCLUDE_DIRS})
+ list(APPEND LIBGIT2_LIBS ${LIBSSH2_LIBRARIES})
+ list(APPEND LIBGIT2_PC_LIBS ${LIBSSH2_LDFLAGS})
+
+ check_library_exists("${LIBSSH2_LIBRARIES}" libssh2_userauth_publickey_frommemory "${LIBSSH2_LIBRARY_DIRS}" HAVE_LIBSSH2_MEMORY_CREDENTIALS)
+ if(HAVE_LIBSSH2_MEMORY_CREDENTIALS)
+ set(GIT_SSH_MEMORY_CREDENTIALS 1)
+ endif()
+else()
+ message(STATUS "LIBSSH2 not found. Set CMAKE_PREFIX_PATH if it is installed outside of the default search path.")
+endif()
+add_feature_info(SSH GIT_SSH "SSH transport support")
+
+# Optional external dependency: ntlmclient
+if(USE_NTLMCLIENT)
+ set(GIT_NTLM 1)
+ add_subdirectory("${libgit2_SOURCE_DIR}/deps/ntlmclient" "${libgit2_BINARY_DIR}/deps/ntlmclient")
+ list(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/ntlmclient")
+ list(APPEND LIBGIT2_OBJECTS "$<TARGET_OBJECTS:ntlmclient>")
+endif()
+add_feature_info(ntlmclient GIT_NTLM "NTLM authentication support for Unix")
+
+# 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_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)
+ if(NOT WIN32)
+ find_package(Threads REQUIRED)
+ endif()
+
+ set(GIT_THREADS 1)
+endif()
+
+if(USE_NSEC)
+ set(GIT_USE_NSEC 1)
+endif()
+
+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)
+
+# Collect sourcefiles
+file(GLOB SRC_H
+ "${libgit2_SOURCE_DIR}/include/git2.h"
+ "${libgit2_SOURCE_DIR}/include/git2/*.h"
+ "${libgit2_SOURCE_DIR}/include/git2/sys/*.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 "util/win32/git2.rc")
+
+ file(GLOB SRC_OS util/win32/*.c util/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 util/unix/*.c util/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 libgit2/*.c libgit2/*.h
+ libgit2/streams/*.c libgit2/streams/*.h
+ libgit2/transports/*.c libgit2/transports/*.h
+ libgit2/xdiff/*.c libgit2/xdiff/*.h)
+list(SORT SRC_GIT2)
+target_sources(git2internal PRIVATE ${SRC_GIT2})
+
+file(GLOB SRC_UTIL util/*.c util/*.h util/allocators/*.c util/allocators/*.h)
+list(SORT SRC_UTIL)
+target_sources(git2internal PRIVATE ${SRC_UTIL})
+
+if(APPLE)
+ # The old Secure Transport API has been deprecated in macOS 10.15.
+ set_source_files_properties(libgit2/streams/stransport.c PROPERTIES COMPILE_FLAGS -Wno-deprecated)
+endif()
+
+# the xdiff dependency is not (yet) warning-free, disable warnings as
+# errors for the xdiff sources until we've sorted them out
+if(MSVC)
+ set_source_files_properties(libgit2/xdiff/xdiffi.c PROPERTIES COMPILE_FLAGS -WX-)
+ set_source_files_properties(libgit2/xdiff/xutils.c PROPERTIES COMPILE_FLAGS -WX-)
+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(libgit2/features.h.in git2/sys/features.h)
+
+ide_split_sources(git2internal)
+list(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:git2internal>)
+
+target_include_directories(git2internal PRIVATE ${LIBGIT2_INCLUDES} PUBLIC ${libgit2_SOURCE_DIR}/include)
+target_include_directories(git2internal SYSTEM PRIVATE ${LIBGIT2_SYSTEM_INCLUDES})
+
+set(LIBGIT2_OBJECTS ${LIBGIT2_OBJECTS} PARENT_SCOPE)
+set(LIBGIT2_INCLUDES ${LIBGIT2_INCLUDES} PARENT_SCOPE)
+set(LIBGIT2_SYSTEM_INCLUDES ${LIBGIT2_SYSTEM_INCLUDES} PARENT_SCOPE)
+set(LIBGIT2_LIBS ${LIBGIT2_LIBS} PARENT_SCOPE)
+
+if(XCODE_VERSION)
+ # This is required for Xcode to actually link the libgit2 library
+ # when using only object libraries.
+ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dummy.c "")
+ list(APPEND LIBGIT2_OBJECTS ${CMAKE_CURRENT_BINARY_DIR}/dummy.c)
+endif()
+
+# Compile and link libgit2
+add_library(git2 ${WIN_RC} ${LIBGIT2_OBJECTS})
+target_link_libraries(git2 ${LIBGIT2_LIBS})
+
+set_target_properties(git2 PROPERTIES C_STANDARD 90)
+set_target_properties(git2 PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR})
+set_target_properties(git2 PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR})
+set_target_properties(git2 PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR})
+
+# Workaround for Cmake bug #0011240 (see http://public.kitware.com/Bug/view.php?id=11240)
+# Win64+MSVC+static libs = linker error
+if(MSVC AND GIT_ARCH_64 AND NOT BUILD_SHARED_LIBS)
+ set_target_properties(git2 PROPERTIES STATIC_LIBRARY_FLAGS "/MACHINE:x64")
+endif()
+
+ide_split_sources(git2)
+
+if(SONAME)
+ set_target_properties(git2 PROPERTIES VERSION ${libgit2_VERSION})
+ set_target_properties(git2 PROPERTIES SOVERSION "${libgit2_VERSION_MAJOR}.${libgit2_VERSION_MINOR}")
+ if(LIBGIT2_FILENAME)
+ target_compile_definitions(git2 PRIVATE LIBGIT2_FILENAME=\"${LIBGIT2_FILENAME}\")
+ set_target_properties(git2 PROPERTIES OUTPUT_NAME ${LIBGIT2_FILENAME})
+ elseif(DEFINED LIBGIT2_PREFIX)
+ set_target_properties(git2 PROPERTIES PREFIX "${LIBGIT2_PREFIX}")
+ endif()
+endif()
+
+pkg_build_config(NAME libgit2
+ VERSION ${libgit2_VERSION}
+ DESCRIPTION "The git library, take 2"
+ LIBS_SELF git2
+ PRIVATE_LIBS ${LIBGIT2_PC_LIBS}
+ REQUIRES ${LIBGIT2_PC_REQUIRES}
+)
+
+if(MSVC_IDE)
+ # Precompiled headers
+ set_target_properties(git2 PROPERTIES COMPILE_FLAGS "/Yuprecompiled.h /FIprecompiled.h")
+ set_source_files_properties(libgit2/win32/precompiled.c COMPILE_FLAGS "/Ycprecompiled.h")
+endif()
+
+# Install
+install(TARGETS git2
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+install(DIRECTORY ${libgit2_SOURCE_DIR}/include/git2 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
+install(FILES ${libgit2_SOURCE_DIR}/include/git2.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
+
+# export these variables for the test framework; it links our object
+# files directly (instead of linking to libgit2.so) so that it can
+# test private and internal functions.
+set_property(GLOBAL PROPERTY libgit2_objects ${LIBGIT2_OBJECTS})
+set_property(GLOBAL PROPERTY libgit2_includes ${LIBGIT2_INCLUDES})
+set_property(GLOBAL PROPERTY libgit2_system_includes ${LIBGIT2_SYSTEM_INCLUDES})
+set_property(GLOBAL PROPERTY libgit2_libs ${LIBGIT2_LIBS})
diff --git a/src/libgit2/CMakeLists.txt b/src/libgit2/CMakeLists.txt
deleted file mode 100644
index f39df4864..000000000
--- a/src/libgit2/CMakeLists.txt
+++ /dev/null
@@ -1,430 +0,0 @@
-add_library(git2internal OBJECT)
-set_target_properties(git2internal PROPERTIES C_STANDARD 90)
-
-
-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}"
- "${libgit2_SOURCE_DIR}/src/libgit2"
- "${libgit2_SOURCE_DIR}/include")
-set(LIBGIT2_SYSTEM_INCLUDES "")
-set(LIBGIT2_LIBS "")
-
-if(HAVE_FUTIMENS)
- set(GIT_USE_FUTIMENS 1)
-endif ()
-add_feature_info(futimens GIT_USE_FUTIMENS "futimens support")
-
-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)
-
-# Find required dependencies
-
-if(WIN32)
- list(APPEND LIBGIT2_LIBS ws2_32)
-elseif(CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
- list(APPEND LIBGIT2_LIBS socket nsl)
- list(APPEND LIBGIT2_PC_LIBS "-lsocket" "-lnsl")
-elseif(CMAKE_SYSTEM_NAME MATCHES "Haiku")
- list(APPEND LIBGIT2_LIBS network)
- list(APPEND LIBGIT2_PC_LIBS "-lnetwork")
-endif()
-
-check_library_exists(rt clock_gettime "time.h" NEED_LIBRT)
-if(NEED_LIBRT)
- list(APPEND LIBGIT2_LIBS rt)
- list(APPEND LIBGIT2_PC_LIBS "-lrt")
-endif()
-
-if(USE_THREADS)
- list(APPEND LIBGIT2_LIBS ${CMAKE_THREAD_LIBS_INIT})
- list(APPEND LIBGIT2_PC_LIBS ${CMAKE_THREAD_LIBS_INIT})
-endif()
-add_feature_info(threadsafe USE_THREADS "threadsafe 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})
-
- 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()
-
-if(WIN32 AND USE_WINHTTP)
- set(GIT_WINHTTP 1)
-
- # Since MinGW does not come with headers or an import library for winhttp,
- # we have to include a private header and generate our own import library
- if(MINGW)
- add_subdirectory("${libgit2_SOURCE_DIR}/deps/winhttp" "${libgit2_BINARY_DIR}/deps/winhttp")
- list(APPEND LIBGIT2_LIBS winhttp)
- list(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/winhttp")
- else()
- list(APPEND LIBGIT2_LIBS "winhttp")
- list(APPEND LIBGIT2_PC_LIBS "-lwinhttp")
- endif()
-
- list(APPEND LIBGIT2_LIBS "rpcrt4" "crypt32" "ole32")
- list(APPEND LIBGIT2_PC_LIBS "-lrpcrt4" "-lcrypt32" "-lole32")
-endif()
-
-include(SelectHTTPSBackend)
-include(SelectHashes)
-target_sources(git2internal PRIVATE ${SRC_SHA1})
-
-# Specify regular expression implementation
-find_package(PCRE)
-
-if(REGEX_BACKEND STREQUAL "")
- check_symbol_exists(regcomp_l "regex.h;xlocale.h" HAVE_REGCOMP_L)
-
- if(HAVE_REGCOMP_L)
- set(REGEX_BACKEND "regcomp_l")
- elseif(PCRE_FOUND)
- set(REGEX_BACKEND "pcre")
- else()
- set(REGEX_BACKEND "builtin")
- endif()
-endif()
-
-if(REGEX_BACKEND STREQUAL "regcomp_l")
- add_feature_info(regex ON "using system regcomp_l")
- set(GIT_REGEX_REGCOMP_L 1)
-elseif(REGEX_BACKEND STREQUAL "pcre2")
- find_package(PCRE2)
-
- if(NOT PCRE2_FOUND)
- MESSAGE(FATAL_ERROR "PCRE2 support was requested but not found")
- endif()
-
- add_feature_info(regex ON "using system PCRE2")
- set(GIT_REGEX_PCRE2 1)
-
- list(APPEND LIBGIT2_SYSTEM_INCLUDES ${PCRE2_INCLUDE_DIRS})
- list(APPEND LIBGIT2_LIBS ${PCRE2_LIBRARIES})
- list(APPEND LIBGIT2_PC_REQUIRES "libpcre2-8")
-elseif(REGEX_BACKEND STREQUAL "pcre")
- add_feature_info(regex ON "using system PCRE")
- set(GIT_REGEX_PCRE 1)
-
- list(APPEND LIBGIT2_SYSTEM_INCLUDES ${PCRE_INCLUDE_DIRS})
- list(APPEND LIBGIT2_LIBS ${PCRE_LIBRARIES})
- list(APPEND LIBGIT2_PC_REQUIRES "libpcre")
-elseif(REGEX_BACKEND STREQUAL "regcomp")
- add_feature_info(regex ON "using system regcomp")
- set(GIT_REGEX_REGCOMP 1)
-elseif(REGEX_BACKEND STREQUAL "builtin")
- add_feature_info(regex ON "using bundled PCRE")
- set(GIT_REGEX_BUILTIN 1)
-
- add_subdirectory("${libgit2_SOURCE_DIR}/deps/pcre" "${libgit2_BINARY_DIR}/deps/pcre")
- list(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/pcre")
- list(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:pcre>)
-else()
- message(FATAL_ERROR "The REGEX_BACKEND option provided is not supported")
-endif()
-
-# Optional external dependency: http-parser
-if(USE_HTTP_PARSER STREQUAL "system")
- find_package(HTTPParser)
-
- if(HTTP_PARSER_FOUND AND HTTP_PARSER_VERSION_MAJOR EQUAL 2)
- list(APPEND LIBGIT2_SYSTEM_INCLUDES ${HTTP_PARSER_INCLUDE_DIRS})
- list(APPEND LIBGIT2_LIBS ${HTTP_PARSER_LIBRARIES})
- list(APPEND LIBGIT2_PC_LIBS "-lhttp_parser")
- add_feature_info(http-parser ON "http-parser support (system)")
- else()
- message(FATAL_ERROR "http-parser support was requested but not found")
- endif()
-else()
- message(STATUS "http-parser version 2 was not found or disabled; using bundled 3rd-party sources.")
- add_subdirectory("${libgit2_SOURCE_DIR}/deps/http-parser" "${libgit2_BINARY_DIR}/deps/http-parser")
- list(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/http-parser")
- list(APPEND LIBGIT2_OBJECTS "$<TARGET_OBJECTS:http-parser>")
- add_feature_info(http-parser ON "http-parser support (bundled)")
-endif()
-
-# Optional external dependency: zlib
-SanitizeBool(USE_BUNDLED_ZLIB)
-if(USE_BUNDLED_ZLIB STREQUAL ON)
- set(USE_BUNDLED_ZLIB "Bundled")
-endif()
-
-if(USE_BUNDLED_ZLIB STREQUAL "OFF")
- find_package(ZLIB)
- if(ZLIB_FOUND)
- list(APPEND LIBGIT2_SYSTEM_INCLUDES ${ZLIB_INCLUDE_DIRS})
- list(APPEND LIBGIT2_LIBS ${ZLIB_LIBRARIES})
- if(APPLE OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
- list(APPEND LIBGIT2_PC_LIBS "-lz")
- else()
- list(APPEND LIBGIT2_PC_REQUIRES "zlib")
- endif()
- add_feature_info(zlib ON "using system zlib")
- else()
- message(STATUS "zlib was not found; using bundled 3rd-party sources." )
- endif()
-endif()
-if(USE_BUNDLED_ZLIB STREQUAL "Chromium")
- add_subdirectory("${libgit2_SOURCE_DIR}/deps/chromium-zlib" "${libgit2_BINARY_DIR}/deps/chromium-zlib")
- list(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/chromium-zlib")
- list(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:chromium_zlib>)
- add_feature_info(zlib ON "using (Chromium) bundled zlib")
-elseif(USE_BUNDLED_ZLIB OR NOT ZLIB_FOUND)
- add_subdirectory("${libgit2_SOURCE_DIR}/deps/zlib" "${libgit2_BINARY_DIR}/deps/zlib")
- list(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/zlib")
- list(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:zlib>)
- add_feature_info(zlib ON "using bundled zlib")
-endif()
-
-# Optional external dependency: libssh2
-if(USE_SSH)
- find_pkglibraries(LIBSSH2 libssh2)
- if(NOT LIBSSH2_FOUND)
- find_package(LibSSH2)
- set(LIBSSH2_INCLUDE_DIRS ${LIBSSH2_INCLUDE_DIR})
- get_filename_component(LIBSSH2_LIBRARY_DIRS "${LIBSSH2_LIBRARY}" DIRECTORY)
- set(LIBSSH2_LIBRARIES ${LIBSSH2_LIBRARY})
- set(LIBSSH2_LDFLAGS "-lssh2")
- endif()
-endif()
-if(LIBSSH2_FOUND)
- set(GIT_SSH 1)
- list(APPEND LIBGIT2_SYSTEM_INCLUDES ${LIBSSH2_INCLUDE_DIRS})
- list(APPEND LIBGIT2_LIBS ${LIBSSH2_LIBRARIES})
- list(APPEND LIBGIT2_PC_LIBS ${LIBSSH2_LDFLAGS})
-
- check_library_exists("${LIBSSH2_LIBRARIES}" libssh2_userauth_publickey_frommemory "${LIBSSH2_LIBRARY_DIRS}" HAVE_LIBSSH2_MEMORY_CREDENTIALS)
- if(HAVE_LIBSSH2_MEMORY_CREDENTIALS)
- set(GIT_SSH_MEMORY_CREDENTIALS 1)
- endif()
-else()
- message(STATUS "LIBSSH2 not found. Set CMAKE_PREFIX_PATH if it is installed outside of the default search path.")
-endif()
-add_feature_info(SSH GIT_SSH "SSH transport support")
-
-# Optional external dependency: ntlmclient
-if(USE_NTLMCLIENT)
- set(GIT_NTLM 1)
- add_subdirectory("${libgit2_SOURCE_DIR}/deps/ntlmclient" "${libgit2_BINARY_DIR}/deps/ntlmclient")
- list(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/ntlmclient")
- list(APPEND LIBGIT2_OBJECTS "$<TARGET_OBJECTS:ntlmclient>")
-endif()
-add_feature_info(ntlmclient GIT_NTLM "NTLM authentication support for Unix")
-
-# 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_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)
- if(NOT WIN32)
- find_package(Threads REQUIRED)
- endif()
-
- set(GIT_THREADS 1)
-endif()
-
-if(USE_NSEC)
- set(GIT_USE_NSEC 1)
-endif()
-
-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)
-
-# Collect sourcefiles
-file(GLOB SRC_H
- "${libgit2_SOURCE_DIR}/include/git2.h"
- "${libgit2_SOURCE_DIR}/include/git2/*.h"
- "${libgit2_SOURCE_DIR}/include/git2/sys/*.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(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)
-endif()
-
-# the xdiff dependency is not (yet) warning-free, disable warnings as
-# errors for the xdiff sources until we've sorted them out
-if(MSVC)
- set_source_files_properties(xdiff/xdiffi.c PROPERTIES COMPILE_FLAGS -WX-)
- set_source_files_properties(xdiff/xutils.c PROPERTIES COMPILE_FLAGS -WX-)
-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>)
-
-target_include_directories(git2internal PRIVATE ${LIBGIT2_INCLUDES} PUBLIC ${libgit2_SOURCE_DIR}/include)
-target_include_directories(git2internal SYSTEM PRIVATE ${LIBGIT2_SYSTEM_INCLUDES})
-
-set(LIBGIT2_OBJECTS ${LIBGIT2_OBJECTS} PARENT_SCOPE)
-set(LIBGIT2_INCLUDES ${LIBGIT2_INCLUDES} PARENT_SCOPE)
-set(LIBGIT2_SYSTEM_INCLUDES ${LIBGIT2_SYSTEM_INCLUDES} PARENT_SCOPE)
-set(LIBGIT2_LIBS ${LIBGIT2_LIBS} PARENT_SCOPE)
-
-if(XCODE_VERSION)
- # This is required for Xcode to actually link the libgit2 library
- # when using only object libraries.
- file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dummy.c "")
- list(APPEND LIBGIT2_OBJECTS ${CMAKE_CURRENT_BINARY_DIR}/dummy.c)
-endif()
-
-# Compile and link libgit2
-add_library(git2 ${WIN_RC} ${LIBGIT2_OBJECTS})
-target_link_libraries(git2 ${LIBGIT2_LIBS})
-
-set_target_properties(git2 PROPERTIES C_STANDARD 90)
-set_target_properties(git2 PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR})
-set_target_properties(git2 PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR})
-set_target_properties(git2 PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR})
-
-# Workaround for Cmake bug #0011240 (see http://public.kitware.com/Bug/view.php?id=11240)
-# Win64+MSVC+static libs = linker error
-if(MSVC AND GIT_ARCH_64 AND NOT BUILD_SHARED_LIBS)
- set_target_properties(git2 PROPERTIES STATIC_LIBRARY_FLAGS "/MACHINE:x64")
-endif()
-
-ide_split_sources(git2)
-
-if(SONAME)
- set_target_properties(git2 PROPERTIES VERSION ${libgit2_VERSION})
- set_target_properties(git2 PROPERTIES SOVERSION "${libgit2_VERSION_MAJOR}.${libgit2_VERSION_MINOR}")
- if(LIBGIT2_FILENAME)
- target_compile_definitions(git2 PRIVATE LIBGIT2_FILENAME=\"${LIBGIT2_FILENAME}\")
- set_target_properties(git2 PROPERTIES OUTPUT_NAME ${LIBGIT2_FILENAME})
- elseif(DEFINED LIBGIT2_PREFIX)
- set_target_properties(git2 PROPERTIES PREFIX "${LIBGIT2_PREFIX}")
- endif()
-endif()
-
-pkg_build_config(NAME libgit2
- VERSION ${libgit2_VERSION}
- DESCRIPTION "The git library, take 2"
- LIBS_SELF git2
- PRIVATE_LIBS ${LIBGIT2_PC_LIBS}
- REQUIRES ${LIBGIT2_PC_REQUIRES}
-)
-
-if(MSVC_IDE)
- # Precompiled headers
- set_target_properties(git2 PROPERTIES COMPILE_FLAGS "/Yuprecompiled.h /FIprecompiled.h")
- set_source_files_properties(win32/precompiled.c COMPILE_FLAGS "/Ycprecompiled.h")
-endif()
-
-# Install
-install(TARGETS git2
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
-)
-install(DIRECTORY ${libgit2_SOURCE_DIR}/include/git2 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
-install(FILES ${libgit2_SOURCE_DIR}/include/git2.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
-
-# export these variables for the test framework; it links our object
-# files directly (instead of linking to libgit2.so) so that it can
-# test private and internal functions.
-set_property(GLOBAL PROPERTY libgit2_objects ${LIBGIT2_OBJECTS})
-set_property(GLOBAL PROPERTY libgit2_includes ${LIBGIT2_INCLUDES})
-set_property(GLOBAL PROPERTY libgit2_system_includes ${LIBGIT2_SYSTEM_INCLUDES})
-set_property(GLOBAL PROPERTY libgit2_libs ${LIBGIT2_LIBS})
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..6115e51e7 100644
--- a/src/libgit2/allocators/failalloc.h
+++ b/src/util/allocators/failalloc.h
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..fa23fe6e3 100644
--- a/src/libgit2/allocators/stdalloc.h
+++ b/src/util/allocators/stdalloc.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..089690f90 100644
--- a/src/libgit2/allocators/win32_leakcheck.h
+++ b/src/util/allocators/win32_leakcheck.h
diff --git a/src/libgit2/array.h b/src/util/array.h
index e97688b36..e97688b36 100644
--- a/src/libgit2/array.h
+++ b/src/util/array.h
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/cc-compat.h b/src/util/cc-compat.h
index f701b2d93..f701b2d93 100644
--- a/src/libgit2/cc-compat.h
+++ b/src/util/cc-compat.h
diff --git a/src/libgit2/fs_path.c b/src/util/fs_path.c
index 957f389cc..957f389cc 100644
--- a/src/libgit2/fs_path.c
+++ b/src/util/fs_path.c
diff --git a/src/libgit2/fs_path.h b/src/util/fs_path.h
index 188dcf303..188dcf303 100644
--- a/src/libgit2/fs_path.h
+++ b/src/util/fs_path.h
diff --git a/src/libgit2/futils.c b/src/util/futils.c
index 7ec1009bd..7ec1009bd 100644
--- a/src/libgit2/futils.c
+++ b/src/util/futils.c
diff --git a/src/libgit2/futils.h b/src/util/futils.h
index 22098addf..22098addf 100644
--- a/src/libgit2/futils.h
+++ b/src/util/futils.h
diff --git a/src/libgit2/hash.c b/src/util/hash.c
index 92e7ff219..92e7ff219 100644
--- a/src/libgit2/hash.c
+++ b/src/util/hash.c
diff --git a/src/libgit2/hash.h b/src/util/hash.h
index 10b14a904..10b14a904 100644
--- a/src/libgit2/hash.h
+++ b/src/util/hash.h
diff --git a/src/libgit2/hash/sha1.h b/src/util/hash/sha1.h
index 4b4dae3f8..4b4dae3f8 100644
--- a/src/libgit2/hash/sha1.h
+++ b/src/util/hash/sha1.h
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 4d03c75d8..4d03c75d8 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 7adccdb00..7adccdb00 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..01931d199 100644
--- a/src/libgit2/map.h
+++ b/src/util/map.h
diff --git a/src/libgit2/net.c b/src/util/net.c
index 58792ee7d..58792ee7d 100644
--- a/src/libgit2/net.c
+++ b/src/util/net.c
diff --git a/src/libgit2/net.h b/src/util/net.h
index 728add3d0..728add3d0 100644
--- a/src/libgit2/net.h
+++ b/src/util/net.h
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..cecb84665 100644
--- a/src/libgit2/pool.h
+++ b/src/util/pool.h
diff --git a/src/libgit2/posix.h b/src/util/posix.h
index d98bc82ca..d98bc82ca 100644
--- a/src/libgit2/posix.h
+++ b/src/util/posix.h
diff --git a/src/libgit2/regexp.c b/src/util/regexp.c
index c1b9ef4cd..c1b9ef4cd 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..2592ef383 100644
--- a/src/libgit2/regexp.h
+++ b/src/util/regexp.h
diff --git a/src/libgit2/runtime.c b/src/util/runtime.c
index c05dee8b9..c05dee8b9 100644
--- a/src/libgit2/runtime.c
+++ b/src/util/runtime.c
diff --git a/src/libgit2/runtime.h b/src/util/runtime.h
index 24ac58ee9..24ac58ee9 100644
--- a/src/libgit2/runtime.h
+++ b/src/util/runtime.h
diff --git a/src/libgit2/str.c b/src/util/str.c
index 7b50800c1..7b50800c1 100644
--- a/src/libgit2/str.c
+++ b/src/util/str.c
diff --git a/src/libgit2/str.h b/src/util/str.h
index af7acc21f..af7acc21f 100644
--- a/src/libgit2/str.h
+++ b/src/util/str.h
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..9f5e4cc8b 100644
--- a/src/libgit2/strmap.h
+++ b/src/util/strmap.h
diff --git a/src/libgit2/thread.c b/src/util/thread.c
index 3171771d7..3171771d7 100644
--- a/src/libgit2/thread.c
+++ b/src/util/thread.c
diff --git a/src/libgit2/thread.h b/src/util/thread.h
index 82eb7fcab..82eb7fcab 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..045efad23 100644
--- a/src/libgit2/tsort.c
+++ b/src/util/tsort.c
diff --git a/src/libgit2/unix/map.c b/src/util/unix/map.c
index 88f283ce8..88f283ce8 100644
--- a/src/libgit2/unix/map.c
+++ b/src/util/unix/map.c
diff --git a/src/libgit2/unix/posix.h b/src/util/unix/posix.h
index 7b3325e78..7b3325e78 100644
--- a/src/libgit2/unix/posix.h
+++ b/src/util/unix/posix.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 893bac87b..893bac87b 100644
--- a/src/libgit2/unix/realpath.c
+++ b/src/util/unix/realpath.c
diff --git a/src/libgit2/utf8.c b/src/util/utf8.c
index 77065cb71..77065cb71 100644
--- a/src/libgit2/utf8.c
+++ b/src/util/utf8.c
diff --git a/src/libgit2/utf8.h b/src/util/utf8.h
index dff91b294..dff91b294 100644
--- a/src/libgit2/utf8.h
+++ b/src/util/utf8.h
diff --git a/src/libgit2/util.c b/src/util/util.c
index e06d4ca09..e06d4ca09 100644
--- a/src/libgit2/util.c
+++ b/src/util/util.c
diff --git a/src/libgit2/util.h b/src/util/util.h
index 30cdd0ddf..30cdd0ddf 100644
--- a/src/libgit2/util.h
+++ b/src/util/util.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..652e22486 100644
--- a/src/libgit2/varint.h
+++ b/src/util/varint.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 3dcec3d13..3dcec3d13 100644
--- a/src/libgit2/vector.h
+++ b/src/util/vector.h
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..acd64729e 100644
--- a/src/libgit2/win32/dir.h
+++ b/src/util/win32/dir.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..9e81141ce 100644
--- a/src/libgit2/win32/error.h
+++ b/src/util/win32/error.h
diff --git a/src/libgit2/win32/findfile.c b/src/util/win32/findfile.c
index d4afc4acc..d4afc4acc 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 e11ccebc5..e11ccebc5 100644
--- a/src/libgit2/win32/findfile.h
+++ b/src/util/win32/findfile.h
diff --git a/src/libgit2/win32/git2.rc b/src/util/win32/git2.rc
index d273afd70..d273afd70 100644
--- a/src/libgit2/win32/git2.rc
+++ b/src/util/win32/git2.rc
diff --git a/src/libgit2/win32/map.c b/src/util/win32/map.c
index 2aabc9b15..2aabc9b15 100644
--- a/src/libgit2/win32/map.c
+++ b/src/util/win32/map.c
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 5d7ad11f6..5d7ad11f6 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 4fadf8d08..4fadf8d08 100644
--- a/src/libgit2/win32/path_w32.h
+++ b/src/util/win32/path_w32.h
diff --git a/src/libgit2/win32/posix.h b/src/util/win32/posix.h
index 87c6b436a..87c6b436a 100644
--- a/src/libgit2/win32/posix.h
+++ b/src/util/win32/posix.h
diff --git a/src/libgit2/win32/posix_w32.c b/src/util/win32/posix_w32.c
index ba46b5ea9..ba46b5ea9 100644
--- a/src/libgit2/win32/posix_w32.c
+++ b/src/util/win32/posix_w32.c
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..806b1698a 100644
--- a/src/libgit2/win32/precompiled.h
+++ b/src/util/win32/precompiled.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..8305036b4 100644
--- a/src/libgit2/win32/thread.h
+++ b/src/util/win32/thread.h
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..6090a4b35 100644
--- a/src/libgit2/win32/utf-conv.h
+++ b/src/util/win32/utf-conv.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..4227296d8 100644
--- a/src/libgit2/win32/w32_buffer.h
+++ b/src/util/win32/w32_buffer.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 5c8425be3..5c8425be3 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..cb45e3675 100644
--- a/src/libgit2/win32/w32_leakcheck.h
+++ b/src/util/win32/w32_leakcheck.h
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..1321d30e6 100644
--- a/src/libgit2/win32/w32_util.h
+++ b/src/util/win32/w32_util.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 3a59d9a36..3a59d9a36 100644
--- a/src/libgit2/zstream.h
+++ b/src/util/zstream.h