Commit 7bb206a7 by Yoichi Nakayama

Merge branch 'main' into better-compatiblity-for-at-time-notation

Conflicts:
	src/revparse.c
parents 540b02f3 f9c4dc10
......@@ -91,7 +91,7 @@ jobs:
env:
CC: gcc
CMAKE_GENERATOR: Ninja
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DREGEX_BACKEND=builtin -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DDEBUG_STRICT_ALLOC=ON -DDEBUG_STRICT_OPEN=ON
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DREGEX_BACKEND=builtin -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON -DDEBUG_STRICT_ALLOC=ON -DDEBUG_STRICT_OPEN=ON
os: ubuntu-latest
- # Xenial, GCC, mbedTLS
container:
......@@ -99,7 +99,7 @@ jobs:
env:
CC: gcc
CMAKE_GENERATOR: Ninja
CMAKE_OPTIONS: -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
CMAKE_OPTIONS: -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON
os: ubuntu-latest
- # Xenial, Clang, OpenSSL
container:
......@@ -107,14 +107,14 @@ jobs:
env:
CC: clang
CMAKE_GENERATOR: Ninja
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON
os: ubuntu-latest
- # Xenial, Clang, mbedTLS
container:
name: xenial
env:
CC: clang
CMAKE_OPTIONS: -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
CMAKE_OPTIONS: -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON
CMAKE_GENERATOR: Ninja
os: ubuntu-latest
- # Focal, Clang 10, mbedTLS, MemorySanitizer
......@@ -123,7 +123,7 @@ jobs:
env:
CC: clang-10
CFLAGS: -fsanitize=memory -fsanitize-memory-track-origins=2 -fsanitize-blacklist=/home/libgit2/source/script/sanitizers.supp -fno-optimize-sibling-calls -fno-omit-frame-pointer
CMAKE_OPTIONS: -DCMAKE_PREFIX_PATH=/usr/local/msan -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_BUNDLED_ZLIB=ON
CMAKE_OPTIONS: -DCMAKE_PREFIX_PATH=/usr/local/msan -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_BUNDLED_ZLIB=ON -DUSE_SSH=ON
CMAKE_GENERATOR: Ninja
SKIP_SSH_TESTS: true
SKIP_NEGOTIATE_TESTS: true
......@@ -136,7 +136,7 @@ jobs:
env:
CC: clang-10
CFLAGS: -fsanitize=undefined,nullability -fno-sanitize-recover=undefined,nullability -fsanitize-blacklist=/home/libgit2/source/script/sanitizers.supp -fno-optimize-sibling-calls -fno-omit-frame-pointer
CMAKE_OPTIONS: -DCMAKE_PREFIX_PATH=/usr/local -DUSE_HTTPS=OpenSSL -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_BUNDLED_ZLIB=ON
CMAKE_OPTIONS: -DCMAKE_PREFIX_PATH=/usr/local -DUSE_HTTPS=OpenSSL -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_BUNDLED_ZLIB=ON -DUSE_SSH=ON
CMAKE_GENERATOR: Ninja
SKIP_SSH_TESTS: true
SKIP_NEGOTIATE_TESTS: true
......@@ -149,7 +149,7 @@ jobs:
env:
CC: clang-10
CFLAGS: -fsanitize=thread -fno-optimize-sibling-calls -fno-omit-frame-pointer
CMAKE_OPTIONS: -DCMAKE_PREFIX_PATH=/usr/local -DUSE_HTTPS=OpenSSL -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_BUNDLED_ZLIB=ON
CMAKE_OPTIONS: -DCMAKE_PREFIX_PATH=/usr/local -DUSE_HTTPS=OpenSSL -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_BUNDLED_ZLIB=ON -DUSE_SSH=ON
CMAKE_GENERATOR: Ninja
SKIP_SSH_TESTS: true
SKIP_NEGOTIATE_TESTS: true
......@@ -300,4 +300,4 @@ jobs:
- name: Push documentation branch
working-directory: source
run: git push origin gh-pages
if: github.event_name != 'pull_request' && github.repository == 'libgit2/libgit2'
if: github.event_name == 'push' && github.repository == 'libgit2/libgit2'
......@@ -25,7 +25,7 @@ jobs:
env:
CC: gcc
CMAKE_GENERATOR: Ninja
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DREGEX_BACKEND=builtin -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DREGEX_BACKEND=builtin -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON
os: ubuntu-latest
- # Xenial, GCC, mbedTLS
container:
......@@ -33,7 +33,7 @@ jobs:
env:
CC: gcc
CMAKE_GENERATOR: Ninja
CMAKE_OPTIONS: -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
CMAKE_OPTIONS: -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON
os: ubuntu-latest
- # Xenial, Clang, OpenSSL
container:
......@@ -41,14 +41,14 @@ jobs:
env:
CC: clang
CMAKE_GENERATOR: Ninja
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON
os: ubuntu-latest
- # Xenial, Clang, mbedTLS
container:
name: xenial
env:
CC: clang
CMAKE_OPTIONS: -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
CMAKE_OPTIONS: -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON
CMAKE_GENERATOR: Ninja
os: ubuntu-latest
- # Xenial, GCC, thread-free
......@@ -56,7 +56,7 @@ jobs:
name: xenial
env:
CC: gcc
CMAKE_OPTIONS: -DTHREADSAFE=OFF -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
CMAKE_OPTIONS: -DTHREADSAFE=OFF -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON
CMAKE_GENERATOR: Ninja
os: ubuntu-latest
- # Xenial, Clang, OpenSSL (dynamically loaded)
......@@ -64,7 +64,7 @@ jobs:
name: xenial
env:
CC: clang
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL-Dynamic -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL-Dynamic -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON
CMAKE_GENERATOR: Ninja
os: ubuntu-latest
- # Focal, Clang 10, mbedTLS, MemorySanitizer
......@@ -119,7 +119,7 @@ jobs:
container:
name: centos7
env:
CMAKE_OPTIONS: -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
CMAKE_OPTIONS: -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON
PKG_CONFIG_PATH: /usr/local/lib/pkgconfig
SKIP_NEGOTIATE_TESTS: true
os: ubuntu-latest
......@@ -127,7 +127,7 @@ jobs:
container:
name: centos7
env:
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL-Dynamic -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL-Dynamic -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON
PKG_CONFIG_PATH: /usr/local/lib/pkgconfig
SKIP_NEGOTIATE_TESTS: true
os: ubuntu-latest
......@@ -212,7 +212,7 @@ jobs:
env:
CC: gcc
CMAKE_GENERATOR: Ninja
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL-Dynamic -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL-Dynamic -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON
RUN_INVASIVE_TESTS: true
os: ubuntu-latest
- # Bionic, x86, Clang, OpenSSL
......@@ -223,7 +223,7 @@ jobs:
env:
CC: clang
CMAKE_GENERATOR: Ninja
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON
RUN_INVASIVE_TESTS: true
os: ubuntu-latest
- # Bionic, x86, GCC, OpenSSL
......@@ -233,7 +233,7 @@ jobs:
env:
CC: gcc
CMAKE_GENERATOR: Ninja
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON
RUN_INVASIVE_TESTS: true
os: ubuntu-latest
- # Bionic, arm32, GCC, OpenSSL
......@@ -244,7 +244,7 @@ jobs:
env:
CC: gcc
CMAKE_GENERATOR: Ninja
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_GSSAPI=ON
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_GSSAPI=ON -DUSE_SSH=ON
RUN_INVASIVE_TESTS: true
SKIP_PROXY_TESTS: true
os: ubuntu-latest
......@@ -256,7 +256,7 @@ jobs:
env:
CC: gcc
CMAKE_GENERATOR: Ninja
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_GSSAPI=ON
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_GSSAPI=ON -DUSE_SSH=ON
RUN_INVASIVE_TESTS: true
SKIP_PROXY_TESTS: true
os: ubuntu-latest
......
......@@ -8,7 +8,7 @@
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/libgit2_clar",
"program": "${workspaceFolder}/build/libgit2_tests",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
......
......@@ -16,7 +16,7 @@
{
"label": "Run Tests",
"type": "shell",
"command": "build/libgit2_clar -v",
"command": "build/libgit2_tests -v",
"group": "test",
"presentation": {
"reveal": "always",
......
......@@ -236,18 +236,18 @@ Once built, you can run the tests from the `build` directory with the command
Alternatively you can run the test suite directly using,
$ ./libgit2_clar
$ ./libgit2_tests
Invoking the test suite directly is useful because it allows you to execute
individual tests, or groups of tests using the `-s` flag. For example, to
run the index tests:
$ ./libgit2_clar -sindex
$ ./libgit2_tests -sindex
To run a single test named `index::racy::diff`, which corresponds to the test
function [`test_index_racy__diff`](https://github.com/libgit2/libgit2/blob/main/tests/index/racy.c#L23):
$ ./libgit2_clar -sindex::racy::diff
$ ./libgit2_tests -sindex::racy::diff
The test suite will print a `.` for every passing test, and an `F` for any
failing test. An `S` indicates that a test was skipped because it is not
......@@ -279,7 +279,7 @@ The following CMake variables are declared:
- `CMAKE_INSTALL_INCLUDEDIR`: Where to install headers to.
- `BUILD_SHARED_LIBS`: Build libgit2 as a Shared Library (defaults to ON)
- `BUILD_TESTS`: Build the unit and integration test suites (defaults to ON)
- `THREADSAFE`: Build libgit2 with threading support (defaults to ON)
- `USE_THREADS`: Build libgit2 with threading support (defaults to ON)
To list all build options and their current value, you can do the
following:
......
......@@ -3,28 +3,28 @@
# <flag> - the compiler flag to test
# This internally calls the CHECK_C_COMPILER_FLAG macro.
INCLUDE(CheckCCompilerFlag)
include(CheckCCompilerFlag)
MACRO(ADD_C_FLAG _FLAG)
STRING(TOUPPER ${_FLAG} UPCASE)
STRING(REGEX REPLACE "[-=]" "_" UPCASE_PRETTY ${UPCASE})
STRING(REGEX REPLACE "^_+" "" UPCASE_PRETTY ${UPCASE_PRETTY})
CHECK_C_COMPILER_FLAG(${_FLAG} IS_${UPCASE_PRETTY}_SUPPORTED)
macro(ADD_C_FLAG _FLAG)
string(TOUPPER ${_FLAG} UPCASE)
string(REGEX REPLACE "[-=]" "_" UPCASE_PRETTY ${UPCASE})
string(REGEX REPLACE "^_+" "" UPCASE_PRETTY ${UPCASE_PRETTY})
check_c_compiler_flag(${_FLAG} IS_${UPCASE_PRETTY}_SUPPORTED)
IF(IS_${UPCASE_PRETTY}_SUPPORTED)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_FLAG}")
ELSE()
MESSAGE(FATAL_ERROR "Required flag ${_FLAG} is not supported")
ENDIF()
ENDMACRO()
if(IS_${UPCASE_PRETTY}_SUPPORTED)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_FLAG}")
else()
message(FATAL_ERROR "Required flag ${_FLAG} is not supported")
endif()
endmacro()
MACRO(ADD_C_FLAG_IF_SUPPORTED _FLAG)
STRING(TOUPPER ${_FLAG} UPCASE)
STRING(REGEX REPLACE "[-=]" "_" UPCASE_PRETTY ${UPCASE})
STRING(REGEX REPLACE "^_+" "" UPCASE_PRETTY ${UPCASE_PRETTY})
CHECK_C_COMPILER_FLAG(${_FLAG} IS_${UPCASE_PRETTY}_SUPPORTED)
macro(ADD_C_FLAG_IF_SUPPORTED _FLAG)
string(TOUPPER ${_FLAG} UPCASE)
string(REGEX REPLACE "[-=]" "_" UPCASE_PRETTY ${UPCASE})
string(REGEX REPLACE "^_+" "" UPCASE_PRETTY ${UPCASE_PRETTY})
check_c_compiler_flag(${_FLAG} IS_${UPCASE_PRETTY}_SUPPORTED)
IF(IS_${UPCASE_PRETTY}_SUPPORTED)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_FLAG}")
ENDIF()
ENDMACRO()
if(IS_${UPCASE_PRETTY}_SUPPORTED)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_FLAG}")
endif()
endmacro()
# Platform specific compilation flags
if(MSVC)
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
string(REPLACE "/Zm1000" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
# /GF - String pooling
# /MP - Parallel build
set(CMAKE_C_FLAGS "/GF /MP /nologo ${CMAKE_C_FLAGS}")
# /Gd - explicitly set cdecl calling convention
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Gd")
if(NOT (MSVC_VERSION LESS 1900))
# /guard:cf - Enable Control Flow Guard
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /guard:cf")
endif()
if(STATIC_CRT)
set(CRT_FLAG_DEBUG "/MTd")
set(CRT_FLAG_RELEASE "/MT")
else()
set(CRT_FLAG_DEBUG "/MDd")
set(CRT_FLAG_RELEASE "/MD")
endif()
if(WIN32_LEAKCHECK)
set(GIT_WIN32_LEAKCHECK 1)
set(CRT_FLAG_DEBUG "${CRT_FLAG_DEBUG}")
set(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES} Dbghelp.lib")
endif()
# /Zi - Create debugging information
# /Od - Disable optimization
# /D_DEBUG - #define _DEBUG
# /MTd - Statically link the multithreaded debug version of the CRT
# /MDd - Dynamically link the multithreaded debug version of the CRT
# /RTC1 - Run time checks
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Zi /Od /D_DEBUG /RTC1 ${CRT_FLAG_DEBUG}")
# /DNDEBUG - Disables asserts
# /MT - Statically link the multithreaded release version of the CRT
# /MD - Dynamically link the multithreaded release version of the CRT
# /O2 - Optimize for speed
# /Oy - Enable frame pointer omission (FPO) (otherwise CMake will automatically turn it off)
# /GL - Link time code generation (whole program optimization)
# /Gy - Function-level linking
set(CMAKE_C_FLAGS_RELEASE "/DNDEBUG /O2 /Oy /GL /Gy ${CRT_FLAG_RELEASE}")
# /Oy- - Disable frame pointer omission (FPO)
set(CMAKE_C_FLAGS_RELWITHDEBINFO "/DNDEBUG /Zi /O2 /Oy- /GL /Gy ${CRT_FLAG_RELEASE}")
# /O1 - Optimize for size
set(CMAKE_C_FLAGS_MINSIZEREL "/DNDEBUG /O1 /Oy /GL /Gy ${CRT_FLAG_RELEASE}")
# /IGNORE:4221 - Ignore empty compilation units
set(CMAKE_STATIC_LINKER_FLAGS "/IGNORE:4221")
# /DYNAMICBASE - Address space load randomization (ASLR)
# /NXCOMPAT - Data execution prevention (DEP)
# /LARGEADDRESSAWARE - >2GB user address space on x86
# /VERSION - Embed version information in PE header
set(CMAKE_EXE_LINKER_FLAGS "/DYNAMICBASE /NXCOMPAT /LARGEADDRESSAWARE /VERSION:${libgit2_VERSION_MAJOR}.${libgit2_VERSION_MINOR}")
if(NOT (MSVC_VERSION LESS 1900))
# /GUARD:CF - Enable Control Flow Guard
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /GUARD:CF")
endif()
# /DEBUG - Create a PDB
# /LTCG - Link time code generation (whole program optimization)
# /OPT:REF /OPT:ICF - Fold out duplicate code at link step
# /INCREMENTAL:NO - Required to use /LTCG
# /DEBUGTYPE:cv,fixup - Additional data embedded in the PDB (requires /INCREMENTAL:NO, so not on for Debug)
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "/DEBUG")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/RELEASE /LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO")
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "/DEBUG /RELEASE /LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO /DEBUGTYPE:cv,fixup")
set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "/RELEASE /LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO")
# Same linker settings for DLL as EXE
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO}")
set(CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL}")
else()
if(ENABLE_REPRODUCIBLE_BUILDS)
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Dqc <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> Dq <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -D <TARGET>")
endif()
if(NOT BUILD_SHARED_LIBS)
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
endif()
set(CMAKE_C_FLAGS "-D_GNU_SOURCE ${CMAKE_C_FLAGS}")
enable_warnings(all)
enable_warnings(extra)
if(CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
set(CMAKE_C_FLAGS "-D_POSIX_C_SOURCE=200112L -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS ${CMAKE_C_FLAGS}")
endif()
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG -O0")
if(MINGW OR MSYS) # MinGW and MSYS always do PIC and complain if we tell them to
string(REGEX REPLACE "-fPIC" "" CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS}")
elseif(BUILD_SHARED_LIBS)
add_c_flag_IF_SUPPORTED(-fvisibility=hidden)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
endif()
if(MINGW)
# MinGW >= 3.14 uses the C99-style stdio functions
# automatically, but forks like mingw-w64 still want
# us to define this in order to use them
add_definitions(-D__USE_MINGW_ANSI_STDIO=1)
endif()
enable_warnings(documentation)
disable_warnings(documentation-deprecated-sync)
disable_warnings(missing-field-initializers)
enable_warnings(missing-declarations)
enable_warnings(strict-aliasing)
enable_warnings(strict-prototypes)
enable_warnings(declaration-after-statement)
enable_warnings(shift-count-overflow)
enable_warnings(unused-const-variable)
enable_warnings(unused-function)
enable_warnings(int-conversion)
enable_warnings(c11-extensions)
enable_warnings(c99-c11-compat)
# MinGW uses gcc, which expects POSIX formatting for printf, but
# uses the Windows C library, which uses its own format specifiers.
# Disable format specifier warnings.
if(MINGW)
disable_warnings(format)
disable_warnings(format-security)
else()
enable_warnings(format)
enable_warnings(format-security)
endif()
endif()
# Ensure that MinGW provides the correct header files.
if(WIN32 AND NOT CYGWIN)
add_definitions(-DWIN32 -D_WIN32_WINNT=0x0600)
endif()
MACRO(ENABLE_WARNINGS flag)
ADD_C_FLAG_IF_SUPPORTED(-W${flag})
ENDMACRO()
macro(ENABLE_WARNINGS flag)
add_c_flag_if_supported(-W${flag})
endmacro()
MACRO(DISABLE_WARNINGS flag)
ADD_C_FLAG_IF_SUPPORTED(-Wno-${flag})
ENDMACRO()
macro(DISABLE_WARNINGS flag)
add_c_flag_if_supported(-Wno-${flag})
endmacro()
IF(ENABLE_WERROR)
IF(MSVC)
ADD_COMPILE_OPTIONS(-WX)
ELSE()
ADD_C_FLAG_IF_SUPPORTED(-Werror)
ENDIF()
ENDIF()
if(ENABLE_WERROR)
if(MSVC)
add_compile_options(-WX)
else()
add_c_flag_if_supported(-Werror)
endif()
endif()
......@@ -6,21 +6,21 @@
# COREFOUNDATION_LDFLAGS
#
FIND_PATH(COREFOUNDATION_INCLUDE_DIR NAMES CoreFoundation.h)
FIND_LIBRARY(COREFOUNDATION_LIBRARIES NAMES CoreFoundation)
IF (COREFOUNDATION_INCLUDE_DIR AND COREFOUNDATION_LIBRARIES)
IF (NOT CoreFoundation_FIND_QUIETLY)
MESSAGE(STATUS "Found CoreFoundation ${COREFOUNDATION_LIBRARIES}")
ENDIF()
SET(COREFOUNDATION_FOUND TRUE)
SET(COREFOUNDATION_LDFLAGS "-framework CoreFoundation")
ENDIF ()
find_path(COREFOUNDATION_INCLUDE_DIR NAMES CoreFoundation.h)
find_library(COREFOUNDATION_LIBRARIES NAMES CoreFoundation)
if(COREFOUNDATION_INCLUDE_DIR AND COREFOUNDATION_LIBRARIES)
if(NOT CoreFoundation_FIND_QUIETLY)
message(STATUS "Found CoreFoundation ${COREFOUNDATION_LIBRARIES}")
endif()
set(COREFOUNDATION_FOUND TRUE)
set(COREFOUNDATION_LDFLAGS "-framework CoreFoundation")
endif()
IF (CoreFoundation_FIND_REQUIRED AND NOT COREFOUNDATION_FOUND)
MESSAGE(FATAL_ERROR "CoreFoundation not found")
ENDIF()
if(CoreFoundation_FIND_REQUIRED AND NOT COREFOUNDATION_FOUND)
message(FATAL_ERROR "CoreFoundation not found")
endif()
MARK_AS_ADVANCED(
mark_as_advanced(
COREFOUNDATION_INCLUDE_DIR
COREFOUNDATION_LIBRARIES
)
......@@ -7,21 +7,21 @@
# GSSFRAMEWORK_LDFLAGS
#
FIND_PATH(GSSFRAMEWORK_INCLUDE_DIR NAMES GSS.h)
FIND_LIBRARY(GSSFRAMEWORK_LIBRARIES NAMES GSS)
IF (GSSFRAMEWORK_INCLUDE_DIR AND GSSFRAMEWORK_LIBRARIES)
IF (NOT CoreFoundation_FIND_QUIETLY)
MESSAGE(STATUS "Found GSS.framework ${GSSFRAMEWORK_LIBRARIES}")
ENDIF()
SET(GSSFRAMEWORK_FOUND TRUE)
SET(GSSFRAMEWORK_LDFLAGS "-framework GSS")
ENDIF ()
find_path(GSSFRAMEWORK_INCLUDE_DIR NAMES GSS.h)
find_library(GSSFRAMEWORK_LIBRARIES NAMES GSS)
if(GSSFRAMEWORK_INCLUDE_DIR AND GSSFRAMEWORK_LIBRARIES)
if(NOT CoreFoundation_FIND_QUIETLY)
message(STATUS "Found GSS.framework ${GSSFRAMEWORK_LIBRARIES}")
endif()
set(GSSFRAMEWORK_FOUND TRUE)
set(GSSFRAMEWORK_LDFLAGS "-framework GSS")
endif()
IF (GSS_FIND_REQUIRED AND NOT GSSFRAMEWORK_FOUND)
MESSAGE(FATAL_ERROR "CoreFoundation not found")
ENDIF()
if(GSS_FIND_REQUIRED AND NOT GSSFRAMEWORK_FOUND)
message(FATAL_ERROR "CoreFoundation not found")
endif()
MARK_AS_ADVANCED(
mark_as_advanced(
GSSFRAMEWORK_INCLUDE_DIR
GSSFRAMEWORK_LIBRARIES
GSSFRAMEWORK_LDFLAGS
......
......@@ -10,30 +10,30 @@
# HTTP_PARSER_VERSION_STRING - the version of http-parser found
# Find the header and library
FIND_PATH(HTTP_PARSER_INCLUDE_DIR NAMES http_parser.h)
FIND_LIBRARY(HTTP_PARSER_LIBRARY NAMES http_parser libhttp_parser)
find_path(HTTP_PARSER_INCLUDE_DIR NAMES http_parser.h)
find_library(HTTP_PARSER_LIBRARY NAMES http_parser libhttp_parser)
# Found the header, read version
if (HTTP_PARSER_INCLUDE_DIR AND EXISTS "${HTTP_PARSER_INCLUDE_DIR}/http_parser.h")
FILE(READ "${HTTP_PARSER_INCLUDE_DIR}/http_parser.h" HTTP_PARSER_H)
IF (HTTP_PARSER_H)
STRING(REGEX REPLACE ".*#define[\t ]+HTTP_PARSER_VERSION_MAJOR[\t ]+([0-9]+).*" "\\1" HTTP_PARSER_VERSION_MAJOR "${HTTP_PARSER_H}")
STRING(REGEX REPLACE ".*#define[\t ]+HTTP_PARSER_VERSION_MINOR[\t ]+([0-9]+).*" "\\1" HTTP_PARSER_VERSION_MINOR "${HTTP_PARSER_H}")
SET(HTTP_PARSER_VERSION_STRING "${HTTP_PARSER_VERSION_MAJOR}.${HTTP_PARSER_VERSION_MINOR}")
ENDIF()
UNSET(HTTP_PARSER_H)
ENDIF()
if(HTTP_PARSER_INCLUDE_DIR AND EXISTS "${HTTP_PARSER_INCLUDE_DIR}/http_parser.h")
file(READ "${HTTP_PARSER_INCLUDE_DIR}/http_parser.h" HTTP_PARSER_H)
if(HTTP_PARSER_H)
string(REGEX REPLACE ".*#define[\t ]+HTTP_PARSER_VERSION_MAJOR[\t ]+([0-9]+).*" "\\1" HTTP_PARSER_VERSION_MAJOR "${HTTP_PARSER_H}")
string(REGEX REPLACE ".*#define[\t ]+HTTP_PARSER_VERSION_MINOR[\t ]+([0-9]+).*" "\\1" HTTP_PARSER_VERSION_MINOR "${HTTP_PARSER_H}")
set(HTTP_PARSER_VERSION_STRING "${HTTP_PARSER_VERSION_MAJOR}.${HTTP_PARSER_VERSION_MINOR}")
endif()
unset(HTTP_PARSER_H)
endif()
# Handle the QUIETLY and REQUIRED arguments and set HTTP_PARSER_FOUND
# to TRUE if all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(HTTP_Parser REQUIRED_VARS HTTP_PARSER_INCLUDE_DIR HTTP_PARSER_LIBRARY)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(HTTP_Parser REQUIRED_VARS HTTP_PARSER_INCLUDE_DIR HTTP_PARSER_LIBRARY)
# Hide advanced variables
MARK_AS_ADVANCED(HTTP_PARSER_INCLUDE_DIR HTTP_PARSER_LIBRARY)
mark_as_advanced(HTTP_PARSER_INCLUDE_DIR HTTP_PARSER_LIBRARY)
# Set standard variables
IF (HTTP_PARSER_FOUND)
SET(HTTP_PARSER_LIBRARIES ${HTTP_PARSER_LIBRARY})
if(HTTP_PARSER_FOUND)
set(HTTP_PARSER_LIBRARIES ${HTTP_PARSER_LIBRARY})
set(HTTP_PARSER_INCLUDE_DIRS ${HTTP_PARSER_INCLUDE_DIR})
ENDIF()
endif()
......@@ -6,40 +6,40 @@
# ICONV_LIBRARIES - Link these to use Iconv
#
IF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
if(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
# Already in cache, be silent
SET(ICONV_FIND_QUIETLY TRUE)
ENDIF()
set(ICONV_FIND_QUIETLY TRUE)
endif()
FIND_PATH(ICONV_INCLUDE_DIR iconv.h)
CHECK_FUNCTION_EXISTS(iconv_open libc_has_iconv)
FIND_LIBRARY(iconv_lib NAMES iconv libiconv libiconv-2 c)
find_path(ICONV_INCLUDE_DIR iconv.h)
check_function_exists(iconv_open libc_has_iconv)
find_library(iconv_lib NAMES iconv libiconv libiconv-2 c)
IF(ICONV_INCLUDE_DIR AND libc_has_iconv)
SET(ICONV_FOUND TRUE)
SET(ICONV_LIBRARIES "")
IF(NOT ICONV_FIND_QUIETLY)
MESSAGE(STATUS "Found Iconv: provided by libc")
ENDIF(NOT ICONV_FIND_QUIETLY)
ELSEIF(ICONV_INCLUDE_DIR AND iconv_lib)
SET(ICONV_FOUND TRUE)
if(ICONV_INCLUDE_DIR AND libc_has_iconv)
set(ICONV_FOUND TRUE)
set(ICONV_LIBRARIES "")
if(NOT ICONV_FIND_QUIETLY)
message(STATUS "Found Iconv: provided by libc")
endif(NOT ICONV_FIND_QUIETLY)
elseif(ICONV_INCLUDE_DIR AND iconv_lib)
set(ICONV_FOUND TRUE)
# split iconv into -L and -l linker options, so we can
# set them for pkg-config
GET_FILENAME_COMPONENT(iconv_path ${iconv_lib} PATH)
GET_FILENAME_COMPONENT(iconv_name ${iconv_lib} NAME_WE)
STRING(REGEX REPLACE "^lib" "" iconv_name ${iconv_name})
SET(ICONV_LIBRARIES "-L${iconv_path} -l${iconv_name}")
get_filename_component(iconv_path ${iconv_lib} PATH)
get_filename_component(iconv_name ${iconv_lib} NAME_WE)
string(REGEX REPLACE "^lib" "" iconv_name ${iconv_name})
set(ICONV_LIBRARIES "-L${iconv_path} -l${iconv_name}")
IF(NOT ICONV_FIND_QUIETLY)
MESSAGE(STATUS "Found Iconv: ${ICONV_LIBRARIES}")
ENDIF(NOT ICONV_FIND_QUIETLY)
ELSE()
IF(Iconv_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find Iconv")
ENDIF(Iconv_FIND_REQUIRED)
ENDIF()
if(NOT ICONV_FIND_QUIETLY)
message(STATUS "Found Iconv: ${ICONV_LIBRARIES}")
endif()
else()
if(Iconv_FIND_REQUIRED)
message(FATAL_ERROR "Could not find Iconv")
endif(Iconv_FIND_REQUIRED)
endif()
MARK_AS_ADVANCED(
mark_as_advanced(
ICONV_INCLUDE_DIR
ICONV_LIBRARIES
)
......@@ -2,12 +2,12 @@
# LIBSSH2_INCLUDE_DIR - the libssh2 include directory
# LIBSSH2_LIBRARY - the libssh2 library name
FIND_PATH(LIBSSH2_INCLUDE_DIR libssh2.h)
find_path(LIBSSH2_INCLUDE_DIR libssh2.h)
FIND_LIBRARY(LIBSSH2_LIBRARY NAMES ssh2 libssh2)
find_library(LIBSSH2_LIBRARY NAMES ssh2 libssh2)
INCLUDE(FindPackageHandleStandardArgs)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LibSSH2
REQUIRED_VARS LIBSSH2_LIBRARY LIBSSH2_INCLUDE_DIR)
MARK_AS_ADVANCED(LIBSSH2_INCLUDE_DIR LIBSSH2_LIBRARY)
mark_as_advanced(LIBSSH2_INCLUDE_DIR LIBSSH2_LIBRARY)
......@@ -16,23 +16,23 @@
# PCRE_FOUND - True if pcre found.
# Look for the header file.
FIND_PATH(PCRE_INCLUDE_DIR NAMES pcreposix.h)
find_path(PCRE_INCLUDE_DIR NAMES pcreposix.h)
# Look for the library.
FIND_LIBRARY(PCRE_LIBRARY NAMES pcre)
FIND_LIBRARY(PCRE_POSIX_LIBRARY NAMES pcreposix)
find_library(PCRE_LIBRARY NAMES pcre)
find_library(PCRE_POSIX_LIBRARY NAMES pcreposix)
# Handle the QUIETLY and REQUIRED arguments and set PCRE_FOUND to TRUE if all listed variables are TRUE.
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCRE DEFAULT_MSG PCRE_LIBRARY PCRE_POSIX_LIBRARY PCRE_INCLUDE_DIR)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(PCRE DEFAULT_MSG PCRE_LIBRARY PCRE_POSIX_LIBRARY PCRE_INCLUDE_DIR)
# Copy the results to the output variables.
IF(PCRE_FOUND)
SET(PCRE_LIBRARIES ${PCRE_LIBRARY} ${PCRE_POSIX_LIBRARY})
SET(PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIR})
ELSE(PCRE_FOUND)
SET(PCRE_LIBRARIES)
SET(PCRE_INCLUDE_DIRS)
ENDIF(PCRE_FOUND)
if(PCRE_FOUND)
set(PCRE_LIBRARIES ${PCRE_LIBRARY} ${PCRE_POSIX_LIBRARY})
set(PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIR})
else(PCRE_FOUND)
set(PCRE_LIBRARIES)
set(PCRE_INCLUDE_DIRS)
endif()
MARK_AS_ADVANCED(PCRE_INCLUDE_DIRS PCRE_LIBRARIES)
mark_as_advanced(PCRE_INCLUDE_DIRS PCRE_LIBRARIES)
......@@ -16,22 +16,22 @@
# PCRE2_FOUND - True if pcre found.
# Look for the header file.
FIND_PATH(PCRE2_INCLUDE_DIR NAMES pcre2posix.h)
find_path(PCRE2_INCLUDE_DIR NAMES pcre2posix.h)
# Look for the library.
FIND_LIBRARY(PCRE2_LIBRARY NAMES pcre2-8)
find_library(PCRE2_LIBRARY NAMES pcre2-8)
# Handle the QUIETLY and REQUIRED arguments and set PCRE2_FOUND to TRUE if all listed variables are TRUE.
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCRE2 DEFAULT_MSG PCRE2_LIBRARY PCRE2_INCLUDE_DIR)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(PCRE2 DEFAULT_MSG PCRE2_LIBRARY PCRE2_INCLUDE_DIR)
# Copy the results to the output variables.
IF(PCRE2_FOUND)
SET(PCRE2_LIBRARIES ${PCRE2_LIBRARY})
SET(PCRE2_INCLUDE_DIRS ${PCRE2_INCLUDE_DIR})
ELSE(PCRE2_FOUND)
SET(PCRE2_LIBRARIES)
SET(PCRE2_INCLUDE_DIRS)
ENDIF(PCRE2_FOUND)
if(PCRE2_FOUND)
set(PCRE2_LIBRARIES ${PCRE2_LIBRARY})
set(PCRE2_INCLUDE_DIRS ${PCRE2_INCLUDE_DIR})
else(PCRE2_FOUND)
set(PCRE2_LIBRARIES)
set(PCRE2_INCLUDE_DIRS)
endif()
MARK_AS_ADVANCED(PCRE2_INCLUDE_DIRS PCRE2_LIBRARIES)
mark_as_advanced(PCRE2_INCLUDE_DIRS PCRE2_LIBRARIES)
INCLUDE(FindPkgConfig)
include(FindPkgConfig)
# This function will find and set up a pkg-config based module.
# If a pc-file was found, it will resolve library paths to
# absolute paths. Furthermore, the function will automatically
# fall back to use static libraries in case no dynamic libraries
# were found.
FUNCTION(FIND_PKGLIBRARIES prefix package)
PKG_CHECK_MODULES(${prefix} ${package})
IF(NOT ${prefix}_FOUND)
RETURN()
ENDIF()
function(FIND_PKGLIBRARIES prefix package)
pkg_check_modules(${prefix} ${package})
if(NOT ${prefix}_FOUND)
return()
endif()
FOREACH(LIBRARY ${${prefix}_LIBRARIES})
FIND_LIBRARY(${LIBRARY}_RESOLVED ${LIBRARY} PATHS ${${prefix}_LIBRARY_DIRS})
IF(${${LIBRARY}_RESOLVED} STREQUAL "${LIBRARY}_RESOLVED-NOTFOUND")
MESSAGE(FATAL_ERROR "could not resolve ${LIBRARY}")
ENDIF()
LIST(APPEND RESOLVED_LIBRARIES ${${LIBRARY}_RESOLVED})
ENDFOREACH(LIBRARY)
foreach(LIBRARY ${${prefix}_LIBRARIES})
find_library(${LIBRARY}_RESOLVED ${LIBRARY} PATHS ${${prefix}_LIBRARY_DIRS})
if(${${LIBRARY}_RESOLVED} STREQUAL "${LIBRARY}_RESOLVED-NOTFOUND")
message(FATAL_ERROR "could not resolve ${LIBRARY}")
endif()
list(APPEND RESOLVED_LIBRARIES ${${LIBRARY}_RESOLVED})
endforeach()
SET(${prefix}_FOUND 1 PARENT_SCOPE)
SET(${prefix}_LIBRARIES ${RESOLVED_LIBRARIES} PARENT_SCOPE)
SET(${prefix}_INCLUDE_DIRS ${${prefix}_INCLUDE_DIRS} PARENT_SCOPE)
SET(${prefix}_LDFLAGS ${${prefix}_LDFLAGS} PARENT_SCOPE)
set(${prefix}_FOUND 1 PARENT_SCOPE)
set(${prefix}_LIBRARIES ${RESOLVED_LIBRARIES} PARENT_SCOPE)
set(${prefix}_INCLUDE_DIRS ${${prefix}_INCLUDE_DIRS} PARENT_SCOPE)
set(${prefix}_LDFLAGS ${${prefix}_LDFLAGS} PARENT_SCOPE)
MESSAGE(STATUS " Resolved libraries: ${RESOLVED_LIBRARIES}")
ENDFUNCTION()
message(STATUS " Resolved libraries: ${RESOLVED_LIBRARIES}")
endfunction()
......@@ -7,22 +7,22 @@
# SECURITY_HAS_SSLCREATECONTEXT
#
FIND_PATH(SECURITY_INCLUDE_DIR NAMES Security/Security.h)
FIND_LIBRARY(SECURITY_LIBRARIES NAMES Security)
IF (SECURITY_INCLUDE_DIR AND SECURITY_LIBRARIES)
IF (NOT Security_FIND_QUIETLY)
MESSAGE(STATUS "Found Security ${SECURITY_LIBRARIES}")
ENDIF()
SET(SECURITY_FOUND TRUE)
SET(SECURITY_LDFLAGS "-framework Security")
CHECK_LIBRARY_EXISTS("${SECURITY_LIBRARIES}" SSLCreateContext "Security/SecureTransport.h" SECURITY_HAS_SSLCREATECONTEXT)
ENDIF ()
find_path(SECURITY_INCLUDE_DIR NAMES Security/Security.h)
find_library(SECURITY_LIBRARIES NAMES Security)
if(SECURITY_INCLUDE_DIR AND SECURITY_LIBRARIES)
if(NOT Security_FIND_QUIETLY)
message(STATUS "Found Security ${SECURITY_LIBRARIES}")
endif()
set(SECURITY_FOUND TRUE)
set(SECURITY_LDFLAGS "-framework Security")
check_library_exists("${SECURITY_LIBRARIES}" SSLCreateContext "Security/SecureTransport.h" SECURITY_HAS_SSLCREATECONTEXT)
endif()
IF (Security_FIND_REQUIRED AND NOT SECURITY_FOUND)
MESSAGE(FATAL_ERROR "Security not found")
ENDIF()
if(Security_FIND_REQUIRED AND NOT SECURITY_FOUND)
message(FATAL_ERROR "Security not found")
endif()
MARK_AS_ADVANCED(
mark_as_advanced(
SECURITY_INCLUDE_DIR
SECURITY_LIBRARIES
)
INCLUDE(FeatureSummary)
include(FeatureSummary)
CHECK_STRUCT_HAS_MEMBER ("struct stat" st_mtim "sys/types.h;sys/stat.h"
check_struct_has_member("struct stat" st_mtim "sys/types.h;sys/stat.h"
HAVE_STRUCT_STAT_ST_MTIM LANGUAGE C)
CHECK_STRUCT_HAS_MEMBER ("struct stat" st_mtimespec "sys/types.h;sys/stat.h"
check_struct_has_member("struct stat" st_mtimespec "sys/types.h;sys/stat.h"
HAVE_STRUCT_STAT_ST_MTIMESPEC LANGUAGE C)
CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtime_nsec sys/stat.h
check_struct_has_member("struct stat" st_mtime_nsec sys/stat.h
HAVE_STRUCT_STAT_MTIME_NSEC LANGUAGE C)
IF (HAVE_STRUCT_STAT_ST_MTIM)
CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtim.tv_nsec sys/stat.h
if(HAVE_STRUCT_STAT_ST_MTIM)
check_struct_has_member("struct stat" st_mtim.tv_nsec sys/stat.h
HAVE_STRUCT_STAT_NSEC LANGUAGE C)
ELSEIF (HAVE_STRUCT_STAT_ST_MTIMESPEC)
CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtimespec.tv_nsec sys/stat.h
elseif(HAVE_STRUCT_STAT_ST_MTIMESPEC)
check_struct_has_member("struct stat" st_mtimespec.tv_nsec sys/stat.h
HAVE_STRUCT_STAT_NSEC LANGUAGE C)
ELSE ()
SET( HAVE_STRUCT_STAT_NSEC ON )
ENDIF()
else()
set(HAVE_STRUCT_STAT_NSEC ON )
endif()
IF (HAVE_STRUCT_STAT_NSEC OR WIN32)
OPTION( USE_NSEC "Care about sub-second file mtimes and ctimes" ON )
ELSE()
SET(USE_NSEC OFF)
ENDIF()
ADD_FEATURE_INFO(nanoseconds USE_NSEC "whether to use sub-second file mtimes and ctimes")
add_feature_info(nanoseconds USE_NSEC "support nanosecond precision file mtimes and ctimes")
INCLUDE(EnableWarnings)
include(EnableWarnings)
IF (APPLE)
if(APPLE)
# We cannot simply CHECK_FUNCTION_EXISTS on macOS because
# MACOSX_DEPLOYMENT_TARGET may be set to a version in the past
# that doesn't have futimens. Instead we need to enable warnings
# as errors, then check for the symbol existing in `sys/stat.h`,
# then reset warnings as errors.
ENABLE_WARNINGS(error)
CHECK_SYMBOL_EXISTS(futimens sys/stat.h HAVE_FUTIMENS)
DISABLE_WARNINGS(error)
ELSE ()
CHECK_FUNCTION_EXISTS(futimens HAVE_FUTIMENS)
ENDIF ()
enable_warnings(error)
check_symbol_exists(futimens sys/stat.h HAVE_FUTIMENS)
disable_warnings(error)
else()
check_function_exists(futimens HAVE_FUTIMENS)
endif()
......@@ -13,81 +13,74 @@
# Hint
# MBEDTLS_ROOT_DIR can be pointed to a local mbedTLS installation.
SET(_MBEDTLS_ROOT_HINTS
set(_MBEDTLS_ROOT_HINTS
${MBEDTLS_ROOT_DIR}
ENV MBEDTLS_ROOT_DIR
)
ENV MBEDTLS_ROOT_DIR)
SET(_MBEDTLS_ROOT_HINTS_AND_PATHS
set(_MBEDTLS_ROOT_HINTS_AND_PATHS
HINTS ${_MBEDTLS_ROOT_HINTS}
PATHS ${_MBEDTLS_ROOT_PATHS}
)
PATHS ${_MBEDTLS_ROOT_PATHS})
FIND_PATH(MBEDTLS_INCLUDE_DIR
find_path(MBEDTLS_INCLUDE_DIR
NAMES mbedtls/version.h
${_MBEDTLS_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES include
)
PATH_SUFFIXES include)
IF(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARIES)
if(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARIES)
# Already in cache, be silent
SET(MBEDTLS_FIND_QUIETLY TRUE)
ENDIF()
set(MBEDTLS_FIND_QUIETLY TRUE)
endif()
FIND_LIBRARY(MBEDTLS_LIBRARY
find_library(MBEDTLS_LIBRARY
NAMES mbedtls libmbedtls
${_MBEDTLS_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES library
)
FIND_LIBRARY(MBEDX509_LIBRARY
PATH_SUFFIXES library)
find_library(MBEDX509_LIBRARY
NAMES mbedx509 libmbedx509
${_MBEDTLS_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES library
)
FIND_LIBRARY(MBEDCRYPTO_LIBRARY
PATH_SUFFIXES library)
find_library(MBEDCRYPTO_LIBRARY
NAMES mbedcrypto libmbedcrypto
${_MBEDTLS_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES library
)
PATH_SUFFIXES library)
IF(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARY AND MBEDX509_LIBRARY AND MBEDCRYPTO_LIBRARY)
SET(MBEDTLS_FOUND TRUE)
ENDIF()
if(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARY AND MBEDX509_LIBRARY AND MBEDCRYPTO_LIBRARY)
set(MBEDTLS_FOUND TRUE)
endif()
IF(MBEDTLS_FOUND)
if(MBEDTLS_FOUND)
# split mbedTLS into -L and -l linker options, so we can set them for pkg-config
GET_FILENAME_COMPONENT(MBEDTLS_LIBRARY_DIR ${MBEDTLS_LIBRARY} PATH)
GET_FILENAME_COMPONENT(MBEDTLS_LIBRARY_FILE ${MBEDTLS_LIBRARY} NAME_WE)
GET_FILENAME_COMPONENT(MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY} NAME_WE)
GET_FILENAME_COMPONENT(MBEDCRYPTO_LIBRARY_FILE ${MBEDCRYPTO_LIBRARY} NAME_WE)
STRING(REGEX REPLACE "^lib" "" MBEDTLS_LIBRARY_FILE ${MBEDTLS_LIBRARY_FILE})
STRING(REGEX REPLACE "^lib" "" MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY_FILE})
STRING(REGEX REPLACE "^lib" "" MBEDCRYPTO_LIBRARY_FILE ${MBEDCRYPTO_LIBRARY_FILE})
SET(MBEDTLS_LIBRARIES "-L${MBEDTLS_LIBRARY_DIR} -l${MBEDTLS_LIBRARY_FILE} -l${MBEDX509_LIBRARY_FILE} -l${MBEDCRYPTO_LIBRARY_FILE}")
get_filename_component(MBEDTLS_LIBRARY_DIR ${MBEDTLS_LIBRARY} PATH)
get_filename_component(MBEDTLS_LIBRARY_FILE ${MBEDTLS_LIBRARY} NAME_WE)
get_filename_component(MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY} NAME_WE)
get_filename_component(MBEDCRYPTO_LIBRARY_FILE ${MBEDCRYPTO_LIBRARY} NAME_WE)
string(REGEX REPLACE "^lib" "" MBEDTLS_LIBRARY_FILE ${MBEDTLS_LIBRARY_FILE})
string(REGEX REPLACE "^lib" "" MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY_FILE})
string(REGEX REPLACE "^lib" "" MBEDCRYPTO_LIBRARY_FILE ${MBEDCRYPTO_LIBRARY_FILE})
set(MBEDTLS_LIBRARIES "-L${MBEDTLS_LIBRARY_DIR} -l${MBEDTLS_LIBRARY_FILE} -l${MBEDX509_LIBRARY_FILE} -l${MBEDCRYPTO_LIBRARY_FILE}")
IF(NOT MBEDTLS_FIND_QUIETLY)
MESSAGE(STATUS "Found mbedTLS:")
FILE(READ ${MBEDTLS_INCLUDE_DIR}/mbedtls/version.h MBEDTLSCONTENT)
STRING(REGEX MATCH "MBEDTLS_VERSION_STRING +\"[0-9|.]+\"" MBEDTLSMATCH ${MBEDTLSCONTENT})
IF (MBEDTLSMATCH)
STRING(REGEX REPLACE "MBEDTLS_VERSION_STRING +\"([0-9|.]+)\"" "\\1" MBEDTLS_VERSION ${MBEDTLSMATCH})
MESSAGE(STATUS " version ${MBEDTLS_VERSION}")
ENDIF(MBEDTLSMATCH)
MESSAGE(STATUS " TLS: ${MBEDTLS_LIBRARY}")
MESSAGE(STATUS " X509: ${MBEDX509_LIBRARY}")
MESSAGE(STATUS " Crypto: ${MBEDCRYPTO_LIBRARY}")
ENDIF(NOT MBEDTLS_FIND_QUIETLY)
ELSE(MBEDTLS_FOUND)
IF(MBEDTLS_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find mbedTLS")
ENDIF(MBEDTLS_FIND_REQUIRED)
ENDIF(MBEDTLS_FOUND)
if(NOT MBEDTLS_FIND_QUIETLY)
message(STATUS "Found mbedTLS:")
file(READ ${MBEDTLS_INCLUDE_DIR}/mbedtls/version.h MBEDTLSCONTENT)
string(REGEX MATCH "MBEDTLS_VERSION_STRING +\"[0-9|.]+\"" MBEDTLSMATCH ${MBEDTLSCONTENT})
if(MBEDTLSMATCH)
string(REGEX REPLACE "MBEDTLS_VERSION_STRING +\"([0-9|.]+)\"" "\\1" MBEDTLS_VERSION ${MBEDTLSMATCH})
message(STATUS " version ${MBEDTLS_VERSION}")
endif()
message(STATUS " TLS: ${MBEDTLS_LIBRARY}")
message(STATUS " X509: ${MBEDX509_LIBRARY}")
message(STATUS " Crypto: ${MBEDCRYPTO_LIBRARY}")
endif()
else(MBEDTLS_FOUND)
if(MBEDTLS_FIND_REQUIRED)
message(FATAL_ERROR "Could not find mbedTLS")
endif()
endif()
MARK_AS_ADVANCED(
mark_as_advanced(
MBEDTLS_INCLUDE_DIR
MBEDTLS_LIBRARY_DIR
MBEDTLS_LIBRARIES
MBEDTLS_LIBRARY
MBEDX509_LIBRARY
MBEDCRYPTO_LIBRARY
)
MBEDCRYPTO_LIBRARY)
# This function splits the sources files up into their appropriate
# subdirectories. This is especially useful for IDEs like Xcode and
# Visual Studio, so that you can navigate into the libgit2_clar project,
# Visual Studio, so that you can navigate into the libgit2_tests project,
# and see the folders within the tests folder (instead of just seeing all
# source and tests in a single folder.)
FUNCTION(IDE_SPLIT_SOURCES target)
IF(MSVC_IDE OR CMAKE_GENERATOR STREQUAL Xcode)
GET_TARGET_PROPERTY(sources ${target} SOURCES)
FOREACH(source ${sources})
IF(source MATCHES ".*/")
STRING(REPLACE ${libgit2_SOURCE_DIR}/ "" rel ${source})
IF(rel)
STRING(REGEX REPLACE "/([^/]*)$" "" rel ${rel})
IF(rel)
STRING(REPLACE "/" "\\\\" rel ${rel})
SOURCE_GROUP(${rel} FILES ${source})
ENDIF()
ENDIF()
ENDIF()
ENDFOREACH()
ENDIF()
ENDFUNCTION()
function(IDE_SPLIT_SOURCES target)
if(MSVC_IDE OR CMAKE_GENERATOR STREQUAL Xcode)
get_target_property(sources ${target} SOURCES)
foreach(source ${sources})
if(source MATCHES ".*/")
string(REPLACE ${libgit2_SOURCE_DIR}/ "" rel ${source})
if(rel)
string(REGEX REPLACE "/([^/]*)$" "" rel ${rel})
if(rel)
string(REPLACE "/" "\\\\" rel ${rel})
source_group(${rel} FILES ${source})
endif()
endif()
endif()
endforeach()
endif()
endfunction()
FUNCTION(SanitizeBool VAR)
STRING(TOLOWER "${${VAR}}" VALUE)
IF(VALUE STREQUAL "on")
SET(${VAR} "ON" PARENT_SCOPE)
ELSEIF(VALUE STREQUAL "yes")
SET(${VAR} "ON" PARENT_SCOPE)
ELSEIF(VALUE STREQUAL "true")
SET(${VAR} "ON" PARENT_SCOPE)
ELSEIF(VALUE STREQUAL "1")
SET(${VAR} "ON" PARENT_SCOPE)
ELSEIF(VALUE STREQUAL "off")
SET(${VAR} "OFF" PARENT_SCOPE)
ELSEIF(VALUE STREQUAL "no")
SET(${VAR} "OFF" PARENT_SCOPE)
ELSEIF(VALUE STREQUAL "false")
SET(${VAR} "OFF" PARENT_SCOPE)
ELSEIF(VALUE STREQUAL "0")
SET(${VAR} "OFF" PARENT_SCOPE)
ENDIF()
ENDFUNCTION()
function(SanitizeBool VAR)
string(TOLOWER "${${VAR}}" VALUE)
if(VALUE STREQUAL "on")
set(${VAR} "ON" PARENT_SCOPE)
elseif(VALUE STREQUAL "yes")
set(${VAR} "ON" PARENT_SCOPE)
elseif(VALUE STREQUAL "true")
set(${VAR} "ON" PARENT_SCOPE)
elseif(VALUE STREQUAL "1")
set(${VAR} "ON" PARENT_SCOPE)
elseif(VALUE STREQUAL "off")
set(${VAR} "OFF" PARENT_SCOPE)
elseif(VALUE STREQUAL "no")
set(${VAR} "OFF" PARENT_SCOPE)
elseif(VALUE STREQUAL "false")
set(${VAR} "OFF" PARENT_SCOPE)
elseif(VALUE STREQUAL "0")
set(${VAR} "OFF" PARENT_SCOPE)
endif()
endfunction()
INCLUDE(SanitizeBool)
include(SanitizeBool)
# We try to find any packages our backends might use
FIND_PACKAGE(GSSAPI)
IF (CMAKE_SYSTEM_NAME MATCHES "Darwin")
INCLUDE(FindGSSFramework)
ENDIF()
find_package(GSSAPI)
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
include(FindGSSFramework)
endif()
IF(USE_GSSAPI)
if(USE_GSSAPI)
# Auto-select GSS backend
SanitizeBool(USE_GSSAPI)
IF (USE_GSSAPI STREQUAL ON)
IF (GSSFRAMEWORK_FOUND)
SET(USE_GSSAPI "GSS.framework")
ELSEIF(GSSAPI_FOUND)
SET(USE_GSSAPI "gssapi")
ELSE()
MESSAGE(FATAL_ERROR "Unable to autodetect a usable GSS backend."
sanitizebool(USE_GSSAPI)
if(USE_GSSAPI STREQUAL ON)
if(GSSFRAMEWORK_FOUND)
set(USE_GSSAPI "GSS.framework")
elseif(GSSAPI_FOUND)
set(USE_GSSAPI "gssapi")
else()
message(FATAL_ERROR "Unable to autodetect a usable GSS backend."
"Please pass the backend name explicitly (-DUSE_GSS=backend)")
ENDIF()
ENDIF()
endif()
endif()
# Check that we can find what's required for the selected backend
IF (USE_GSSAPI STREQUAL "GSS.framework")
IF (NOT GSSFRAMEWORK_FOUND)
MESSAGE(FATAL_ERROR "Asked for GSS.framework backend, but it wasn't found")
ENDIF()
if(USE_GSSAPI STREQUAL "GSS.framework")
if(NOT GSSFRAMEWORK_FOUND)
message(FATAL_ERROR "Asked for GSS.framework backend, but it wasn't found")
endif()
LIST(APPEND LIBGIT2_LIBS ${GSSFRAMEWORK_LIBRARIES})
list(APPEND LIBGIT2_SYSTEM_LIBS ${GSSFRAMEWORK_LIBRARIES})
SET(GIT_GSSFRAMEWORK 1)
ADD_FEATURE_INFO(SPNEGO GIT_GSSFRAMEWORK "SPNEGO authentication support (${USE_GSSAPI})")
ELSEIF (USE_GSSAPI STREQUAL "gssapi")
IF (NOT GSSAPI_FOUND)
MESSAGE(FATAL_ERROR "Asked for gssapi GSS backend, but it wasn't found")
ENDIF()
set(GIT_GSSFRAMEWORK 1)
add_feature_info(SPNEGO GIT_GSSFRAMEWORK "SPNEGO authentication support (${USE_GSSAPI})")
elseif(USE_GSSAPI STREQUAL "gssapi")
if(NOT GSSAPI_FOUND)
message(FATAL_ERROR "Asked for gssapi GSS backend, but it wasn't found")
endif()
LIST(APPEND LIBGIT2_LIBS ${GSSAPI_LIBRARIES})
list(APPEND LIBGIT2_SYSTEM_LIBS ${GSSAPI_LIBRARIES})
SET(GIT_GSSAPI 1)
ADD_FEATURE_INFO(SPNEGO GIT_GSSAPI "SPNEGO authentication support (${USE_GSSAPI})")
ELSE()
MESSAGE(FATAL_ERROR "Asked for backend ${USE_GSSAPI} but it wasn't found")
ENDIF()
ELSE()
SET(GIT_GSSAPI 0)
ADD_FEATURE_INFO(SPNEGO NO "SPNEGO authentication support")
ENDIF()
set(GIT_GSSAPI 1)
add_feature_info(SPNEGO GIT_GSSAPI "SPNEGO authentication support (${USE_GSSAPI})")
else()
message(FATAL_ERROR "Asked for backend ${USE_GSSAPI} but it wasn't found")
endif()
else()
set(GIT_GSSAPI 0)
add_feature_info(SPNEGO NO "SPNEGO authentication support")
endif()
# Optional external dependency: http-parser
if(USE_HTTP_PARSER STREQUAL "system")
find_package(HTTP_Parser)
if(HTTP_PARSER_FOUND AND HTTP_PARSER_VERSION_MAJOR EQUAL 2)
list(APPEND LIBGIT2_SYSTEM_INCLUDES ${HTTP_PARSER_INCLUDE_DIRS})
list(APPEND LIBGIT2_SYSTEM_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_DEPENDENCY_INCLUDES "${libgit2_SOURCE_DIR}/deps/http-parser")
list(APPEND LIBGIT2_DEPENDENCY_OBJECTS "$<TARGET_OBJECTS:http-parser>")
add_feature_info(http-parser ON "http-parser support (bundled)")
endif()
INCLUDE(SanitizeBool)
include(SanitizeBool)
# We try to find any packages our backends might use
FIND_PACKAGE(OpenSSL)
FIND_PACKAGE(mbedTLS)
IF (CMAKE_SYSTEM_NAME MATCHES "Darwin")
FIND_PACKAGE(Security)
FIND_PACKAGE(CoreFoundation)
ENDIF()
find_package(OpenSSL)
find_package(mbedTLS)
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
find_package(Security)
find_package(CoreFoundation)
endif()
IF(USE_HTTPS)
if(USE_HTTPS)
# Auto-select TLS backend
SanitizeBool(USE_HTTPS)
IF (USE_HTTPS STREQUAL ON)
IF (SECURITY_FOUND)
IF (SECURITY_HAS_SSLCREATECONTEXT)
SET(USE_HTTPS "SecureTransport")
ELSE()
MESSAGE(STATUS "Security framework is too old, falling back to OpenSSL")
SET(USE_HTTPS "OpenSSL")
ENDIF()
ELSEIF (WINHTTP)
SET(USE_HTTPS "WinHTTP")
ELSEIF(OPENSSL_FOUND)
SET(USE_HTTPS "OpenSSL")
ELSEIF(MBEDTLS_FOUND)
SET(USE_HTTPS "mbedTLS")
ELSE()
MESSAGE(FATAL_ERROR "Unable to autodetect a usable HTTPS backend."
sanitizebool(USE_HTTPS)
if(USE_HTTPS STREQUAL ON)
if(SECURITY_FOUND)
if(SECURITY_HAS_SSLCREATECONTEXT)
set(USE_HTTPS "SecureTransport")
else()
message(STATUS "Security framework is too old, falling back to OpenSSL")
set(USE_HTTPS "OpenSSL")
endif()
elseif(USE_WINHTTP)
set(USE_HTTPS "WinHTTP")
elseif(OPENSSL_FOUND)
set(USE_HTTPS "OpenSSL")
elseif(MBEDTLS_FOUND)
set(USE_HTTPS "mbedTLS")
else()
message(FATAL_ERROR "Unable to autodetect a usable HTTPS backend."
"Please pass the backend name explicitly (-DUSE_HTTPS=backend)")
ENDIF()
ENDIF()
endif()
endif()
# Check that we can find what's required for the selected backend
IF (USE_HTTPS STREQUAL "SecureTransport")
IF (NOT COREFOUNDATION_FOUND)
MESSAGE(FATAL_ERROR "Cannot use SecureTransport backend, CoreFoundation.framework not found")
ENDIF()
IF (NOT SECURITY_FOUND)
MESSAGE(FATAL_ERROR "Cannot use SecureTransport backend, Security.framework not found")
ENDIF()
IF (NOT SECURITY_HAS_SSLCREATECONTEXT)
MESSAGE(FATAL_ERROR "Cannot use SecureTransport backend, SSLCreateContext not supported")
ENDIF()
if(USE_HTTPS STREQUAL "SecureTransport")
if(NOT COREFOUNDATION_FOUND)
message(FATAL_ERROR "Cannot use SecureTransport backend, CoreFoundation.framework not found")
endif()
if(NOT SECURITY_FOUND)
message(FATAL_ERROR "Cannot use SecureTransport backend, Security.framework not found")
endif()
if(NOT SECURITY_HAS_SSLCREATECONTEXT)
message(FATAL_ERROR "Cannot use SecureTransport backend, SSLCreateContext not supported")
endif()
SET(GIT_SECURE_TRANSPORT 1)
LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${SECURITY_INCLUDE_DIR})
LIST(APPEND LIBGIT2_LIBS ${COREFOUNDATION_LDFLAGS} ${SECURITY_LDFLAGS})
LIST(APPEND LIBGIT2_PC_LIBS ${COREFOUNDATION_LDFLAGS} ${SECURITY_LDFLAGS})
ELSEIF (USE_HTTPS STREQUAL "OpenSSL")
IF (NOT OPENSSL_FOUND)
MESSAGE(FATAL_ERROR "Asked for OpenSSL TLS backend, but it wasn't found")
ENDIF()
set(GIT_SECURE_TRANSPORT 1)
list(APPEND LIBGIT2_SYSTEM_INCLUDES ${SECURITY_INCLUDE_DIR})
list(APPEND LIBGIT2_SYSTEM_LIBS ${COREFOUNDATION_LDFLAGS} ${SECURITY_LDFLAGS})
list(APPEND LIBGIT2_PC_LIBS ${COREFOUNDATION_LDFLAGS} ${SECURITY_LDFLAGS})
elseif(USE_HTTPS STREQUAL "OpenSSL")
if(NOT OPENSSL_FOUND)
message(FATAL_ERROR "Asked for OpenSSL TLS backend, but it wasn't found")
endif()
SET(GIT_OPENSSL 1)
LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${OPENSSL_INCLUDE_DIR})
LIST(APPEND LIBGIT2_LIBS ${OPENSSL_LIBRARIES})
LIST(APPEND LIBGIT2_PC_LIBS ${OPENSSL_LDFLAGS})
LIST(APPEND LIBGIT2_PC_REQUIRES "openssl")
ELSEIF(USE_HTTPS STREQUAL "mbedTLS")
IF (NOT MBEDTLS_FOUND)
MESSAGE(FATAL_ERROR "Asked for mbedTLS backend, but it wasn't found")
ENDIF()
set(GIT_OPENSSL 1)
list(APPEND LIBGIT2_SYSTEM_INCLUDES ${OPENSSL_INCLUDE_DIR})
list(APPEND LIBGIT2_SYSTEM_LIBS ${OPENSSL_LIBRARIES})
list(APPEND LIBGIT2_PC_LIBS ${OPENSSL_LDFLAGS})
list(APPEND LIBGIT2_PC_REQUIRES "openssl")
elseif(USE_HTTPS STREQUAL "mbedTLS")
if(NOT MBEDTLS_FOUND)
message(FATAL_ERROR "Asked for mbedTLS backend, but it wasn't found")
endif()
IF(NOT CERT_LOCATION)
MESSAGE(STATUS "Auto-detecting default certificates location")
IF(CMAKE_SYSTEM_NAME MATCHES Darwin)
if(NOT CERT_LOCATION)
message(STATUS "Auto-detecting default certificates location")
if(CMAKE_SYSTEM_NAME MATCHES Darwin)
# Check for an Homebrew installation
SET(OPENSSL_CMD "/usr/local/opt/openssl/bin/openssl")
ELSE()
SET(OPENSSL_CMD "openssl")
ENDIF()
EXECUTE_PROCESS(COMMAND ${OPENSSL_CMD} version -d OUTPUT_VARIABLE OPENSSL_DIR OUTPUT_STRIP_TRAILING_WHITESPACE)
IF(OPENSSL_DIR)
STRING(REGEX REPLACE "^OPENSSLDIR: \"(.*)\"$" "\\1/" OPENSSL_DIR ${OPENSSL_DIR})
set(OPENSSL_CMD "/usr/local/opt/openssl/bin/openssl")
else()
set(OPENSSL_CMD "openssl")
endif()
execute_process(COMMAND ${OPENSSL_CMD} version -d OUTPUT_VARIABLE OPENSSL_DIR OUTPUT_STRIP_TRAILING_WHITESPACE)
if(OPENSSL_DIR)
string(REGEX REPLACE "^OPENSSLDIR: \"(.*)\"$" "\\1/" OPENSSL_DIR ${OPENSSL_DIR})
SET(OPENSSL_CA_LOCATIONS
set(OPENSSL_CA_LOCATIONS
"ca-bundle.pem" # OpenSUSE Leap 42.1
"cert.pem" # Ubuntu 14.04, FreeBSD
"certs/ca-certificates.crt" # Ubuntu 16.04
"certs/ca.pem" # Debian 7
)
FOREACH(SUFFIX IN LISTS OPENSSL_CA_LOCATIONS)
SET(LOC "${OPENSSL_DIR}${SUFFIX}")
IF(NOT CERT_LOCATION AND EXISTS "${OPENSSL_DIR}${SUFFIX}")
SET(CERT_LOCATION ${LOC})
ENDIF()
ENDFOREACH()
ELSE()
MESSAGE(FATAL_ERROR "Unable to find OpenSSL executable. Please provide default certificate location via CERT_LOCATION")
ENDIF()
ENDIF()
foreach(SUFFIX IN LISTS OPENSSL_CA_LOCATIONS)
set(LOC "${OPENSSL_DIR}${SUFFIX}")
if(NOT CERT_LOCATION AND EXISTS "${OPENSSL_DIR}${SUFFIX}")
set(CERT_LOCATION ${LOC})
endif()
endforeach()
else()
message(FATAL_ERROR "Unable to find OpenSSL executable. Please provide default certificate location via CERT_LOCATION")
endif()
endif()
IF(CERT_LOCATION)
IF(NOT EXISTS ${CERT_LOCATION})
MESSAGE(FATAL_ERROR "Cannot use CERT_LOCATION=${CERT_LOCATION} as it doesn't exist")
ENDIF()
ADD_FEATURE_INFO(CERT_LOCATION ON "using certificates from ${CERT_LOCATION}")
ADD_DEFINITIONS(-DGIT_DEFAULT_CERT_LOCATION="${CERT_LOCATION}")
ENDIF()
if(CERT_LOCATION)
if(NOT EXISTS ${CERT_LOCATION})
message(FATAL_ERROR "Cannot use CERT_LOCATION=${CERT_LOCATION} as it doesn't exist")
endif()
add_feature_info(CERT_LOCATION ON "using certificates from ${CERT_LOCATION}")
add_definitions(-DGIT_DEFAULT_CERT_LOCATION="${CERT_LOCATION}")
endif()
SET(GIT_MBEDTLS 1)
LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${MBEDTLS_INCLUDE_DIR})
LIST(APPEND LIBGIT2_LIBS ${MBEDTLS_LIBRARIES})
set(GIT_MBEDTLS 1)
list(APPEND LIBGIT2_SYSTEM_INCLUDES ${MBEDTLS_INCLUDE_DIR})
list(APPEND LIBGIT2_SYSTEM_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_HTTPS STREQUAL "WinHTTP")
list(APPEND LIBGIT2_PC_LIBS ${MBEDTLS_LIBRARIES})
elseif(USE_HTTPS STREQUAL "WinHTTP")
# WinHTTP setup was handled in the WinHTTP-specific block above
ELSEIF (USE_HTTPS STREQUAL "OpenSSL-Dynamic")
SET(GIT_OPENSSL 1)
SET(GIT_OPENSSL_DYNAMIC 1)
LIST(APPEND LIBGIT2_LIBS dl)
ELSE()
MESSAGE(FATAL_ERROR "Asked for backend ${USE_HTTPS} but it wasn't found")
ENDIF()
elseif(USE_HTTPS STREQUAL "OpenSSL-Dynamic")
set(GIT_OPENSSL 1)
set(GIT_OPENSSL_DYNAMIC 1)
list(APPEND LIBGIT2_SYSTEM_LIBS dl)
else()
message(FATAL_ERROR "Asked for backend ${USE_HTTPS} but it wasn't found")
endif()
SET(GIT_HTTPS 1)
ADD_FEATURE_INFO(HTTPS GIT_HTTPS "using ${USE_HTTPS}")
ELSE()
SET(GIT_HTTPS 0)
ADD_FEATURE_INFO(HTTPS NO "")
ENDIF()
set(GIT_HTTPS 1)
add_feature_info(HTTPS GIT_HTTPS "using ${USE_HTTPS}")
else()
set(GIT_HTTPS 0)
add_feature_info(HTTPS NO "")
endif()
# 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\")
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()
elseif(USE_SHA1 STREQUAL "CommonCrypto")
set(GIT_SHA1_COMMON_CRYPTO 1)
elseif(USE_SHA1 STREQUAL "mbedTLS")
set(GIT_SHA1_MBEDTLS 1)
list(APPEND LIBGIT2_SYSTEM_INCLUDES ${MBEDTLS_INCLUDE_DIR})
list(APPEND LIBGIT2_SYSTEM_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 SRC_SHA1 "hash/sha1.h")
list(SORT SRC_SHA1)
list(APPEND LIBGIT2_PC_LIBS ${MBEDTLS_LIBRARIES})
elseif(USE_SHA1 STREQUAL "Win32")
set(GIT_SHA1_WIN32 1)
elseif(NOT (USE_SHA1 STREQUAL "Generic"))
message(FATAL_ERROR "Asked for unknown SHA1 backend: ${USE_SHA1}")
endif()
ADD_FEATURE_INFO(SHA ON "using ${USE_SHA1}")
add_feature_info(SHA ON "using ${USE_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_SYSTEM_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_SYSTEM_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_DEPENDENCY_INCLUDES "${libgit2_SOURCE_DIR}/deps/pcre")
list(APPEND LIBGIT2_DEPENDENCY_OBJECTS $<TARGET_OBJECTS:pcre>)
else()
message(FATAL_ERROR "The REGEX_BACKEND option provided is not supported")
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()
if(NOT LIBSSH2_FOUND)
message(FATAL_ERROR "LIBSSH2 not found. Set CMAKE_PREFIX_PATH if it is installed outside of the default search path.")
endif()
endif()
if(LIBSSH2_FOUND)
set(GIT_SSH 1)
list(APPEND LIBGIT2_SYSTEM_INCLUDES ${LIBSSH2_INCLUDE_DIRS})
list(APPEND LIBGIT2_SYSTEM_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()
if(WIN32 AND EMBED_SSH_PATH)
file(GLOB SSH_SRC "${EMBED_SSH_PATH}/src/*.c")
list(SORT SSH_SRC)
list(APPEND LIBGIT2_DEPENDENCY_OBJECTS ${SSH_SRC})
list(APPEND LIBGIT2_DEPENDENCY_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()
add_feature_info(SSH GIT_SSH "SSH transport support")
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_SYSTEM_LIBS winhttp)
list(APPEND LIBGIT2_DEPENDENCY_INCLUDES "${libgit2_SOURCE_DIR}/deps/winhttp")
else()
list(APPEND LIBGIT2_SYSTEM_LIBS "winhttp")
list(APPEND LIBGIT2_PC_LIBS "-lwinhttp")
endif()
list(APPEND LIBGIT2_SYSTEM_LIBS "rpcrt4" "crypt32" "ole32")
list(APPEND LIBGIT2_PC_LIBS "-lrpcrt4" "-lcrypt32" "-lole32")
endif()
# Optional external dependency: zlib
include(SanitizeBool)
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_SYSTEM_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_DEPENDENCY_INCLUDES "${libgit2_SOURCE_DIR}/deps/chromium-zlib")
list(APPEND LIBGIT2_DEPENDENCY_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_DEPENDENCY_INCLUDES "${libgit2_SOURCE_DIR}/deps/zlib")
list(APPEND LIBGIT2_DEPENDENCY_OBJECTS $<TARGET_OBJECTS:zlib>)
add_feature_info(zlib ON "using bundled zlib")
endif()
......@@ -30,7 +30,7 @@ typedef enum {
NTLM_STATE_CHALLENGE = 1,
NTLM_STATE_RESPONSE = 2,
NTLM_STATE_ERROR = 3,
NTLM_STATE_COMPLETE = 4,
NTLM_STATE_COMPLETE = 4
} ntlm_state;
typedef struct {
......@@ -122,7 +122,7 @@ struct ntlm_client {
};
typedef enum {
NTLM_ENABLE_HOSTVERSION = (1 << 31),
NTLM_ENABLE_HOSTVERSION = (1 << 31)
} ntlm_client_internal_flags;
typedef enum {
......@@ -130,7 +130,7 @@ typedef enum {
NTLM_TARGET_INFO_SERVER = 1,
NTLM_TARGET_INFO_DOMAIN = 2,
NTLM_TARGET_INFO_SERVER_DNS = 3,
NTLM_TARGET_INFO_DOMAIN_DNS = 4,
NTLM_TARGET_INFO_DOMAIN_DNS = 4
} ntlm_target_info_type_t;
typedef enum {
......@@ -168,7 +168,7 @@ typedef enum {
NTLM_NEGOTIATE_TARGET_INFO = 0x00800000,
/* Version information should be provided */
NTLM_NEGOTIATE_VERSION = 0x01000000,
NTLM_NEGOTIATE_VERSION = 0x01000000
} ntlm_negotiate_t;
extern int ntlm_client_set_nonce(ntlm_client *ntlm, uint64_t nonce);
......
......@@ -32,7 +32,7 @@ typedef enum {
/**
* The input provided to the function is missing or invalid.
*/
NTLM_CLIENT_ERROR_INVALID_INPUT = -2,
NTLM_CLIENT_ERROR_INVALID_INPUT = -2
} ntlm_error_code;
/*
......@@ -98,7 +98,7 @@ typedef enum {
* its idea of its hostname in the challenge message. You may
* then set the authentication target based on it.
*/
NTLM_CLIENT_DISABLE_REQUEST_TARGET = (1 << 4),
NTLM_CLIENT_DISABLE_REQUEST_TARGET = (1 << 4)
} ntlm_client_flags;
......
......@@ -120,15 +120,15 @@ In addition to new tests, please ensure that your changes do not cause
any other test failures. Running the entire test suite is helpful
before you submit a pull request. When you build libgit2, the test
suite will also be built. You can run most of the tests by simply running
the resultant `libgit2_clar` binary. If you want to run a specific
the resultant `libgit2_tests` binary. If you want to run a specific
unit test, you can name it with the `-s` option. For example:
libgit2_clar -sstatus::worktree::long_filenames
libgit2_tests -sstatus::worktree::long_filenames
Or you can run an entire class of tests. For example, to run all the
worktree status tests:
libgit2_clar -sstatus::worktree
libgit2_tests -sstatus::worktree
The default test run is fairly exhaustive, but it will exclude some
unit tests by default: in particular, those that talk to network
......@@ -136,7 +136,7 @@ servers and the tests that manipulate the filesystem in onerous
ways (and may need to have special privileges to run). To run the
network tests:
libgit2_clar -ionline
libgit2_tests -ionline
In addition, various tests may be enabled by environment variables,
like the ones that write exceptionally large repositories or manipulate
......
......@@ -21,7 +21,7 @@ critical failures (such as a packfile being corrupted, a loose object
having the wrong access permissions, etc.) all of which will return -1.
When the object lookup is successful, it will return 0.
If libgit2 was compiled with threads enabled (`-DTHREADSAFE=ON` when using
If libgit2 was compiled with threads enabled (`-DUSE_THREADS=ON` when using
CMake), then the error message will be kept in thread-local storage, so it
will not be modified by other threads. If threads are not enabled, then
the error message is in global data.
......
......@@ -21,6 +21,9 @@ There are some objects which are read-only/immutable and are thus safe
to share across threads, such as references and configuration
snapshots.
The `git_odb` object uses locking internally, and is thread-safe to use from
multiple threads simultaneously.
Error messages
--------------
......
include_directories(${LIBGIT2_INCLUDES})
include_directories(SYSTEM ${LIBGIT2_SYSTEM_INCLUDES})
file(GLOB SRC_EXAMPLES *.c *.h)
file(GLOB LG2_SOURCES *.c *.h)
add_executable(lg2 ${LG2_SOURCES})
add_executable(lg2 ${SRC_EXAMPLES})
set_target_properties(lg2 PROPERTIES C_STANDARD 90)
# Ensure that we do not use deprecated functions internally
add_definitions(-DGIT_DEPRECATE_HARD)
target_include_directories(lg2 PRIVATE ${LIBGIT2_INCLUDES} ${LIBGIT2_DEPENDENCY_INCLUDES})
target_include_directories(lg2 SYSTEM PRIVATE ${LIBGIT2_SYSTEM_INCLUDES})
if(WIN32 OR ANDROID)
target_link_libraries(lg2 git2)
else()
......
......@@ -28,7 +28,7 @@
enum index_mode {
INDEX_NONE,
INDEX_ADD,
INDEX_ADD
};
struct index_options {
......@@ -110,22 +110,7 @@ int print_matched_cb(const char *path, const char *matched_pathspec, void *paylo
return ret;
}
void init_array(git_strarray *array, int argc, char **argv)
{
unsigned int i;
array->count = argc;
array->strings = calloc(array->count, sizeof(char *));
assert(array->strings != NULL);
for (i = 0; i < array->count; i++) {
array->strings[i] = argv[i];
}
return;
}
void print_usage(void)
static void print_usage(void)
{
fprintf(stderr, "usage: add [options] [--] file-spec [file-spec] [...]\n\n");
fprintf(stderr, "\t-n, --dry-run dry run\n");
......
......@@ -27,7 +27,7 @@ enum subcmd {
subcmd_remove,
subcmd_rename,
subcmd_seturl,
subcmd_show,
subcmd_show
};
struct remote_opts {
......
......@@ -38,7 +38,7 @@ enum {
FORMAT_DEFAULT = 0,
FORMAT_LONG = 1,
FORMAT_SHORT = 2,
FORMAT_PORCELAIN = 3,
FORMAT_PORCELAIN = 3
};
#define MAX_PATHSPEC 8
......
link_directories(${LIBGIT2_LIBDIRS})
include_directories(${LIBGIT2_INCLUDES})
include_directories(SYSTEM ${LIBGIT2_SYSTEM_INCLUDES})
if(BUILD_FUZZERS AND NOT USE_STANDALONE_FUZZERS)
set(CMAKE_REQUIRED_FLAGS "-fsanitize=fuzzer-no-link")
add_c_flag(-fsanitize=fuzzer)
add_c_flag(-fsanitize=fuzzer-no-link)
unset(CMAKE_REQUIRED_FLAGS)
endif()
file(GLOB SRC_FUZZ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *_fuzzer.c)
foreach(fuzz_target_src ${SRC_FUZZ})
file(GLOB SRC_FUZZERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *_fuzzer.c)
foreach(fuzz_target_src ${SRC_FUZZERS})
string(REPLACE ".c" "" fuzz_target_name ${fuzz_target_src})
string(REPLACE "_fuzzer" "" fuzz_name ${fuzz_target_name})
......@@ -17,7 +16,11 @@ foreach(fuzz_target_src ${SRC_FUZZ})
endif()
add_executable(${fuzz_target_name} ${${fuzz_target_name}_SOURCES})
set_target_properties(${fuzz_target_name} PROPERTIES C_STANDARD 90)
target_link_libraries(${fuzz_target_name} ${LIBGIT2_LIBS})
target_include_directories(${fuzz_target_name} PRIVATE ${LIBGIT2_INCLUDES} ${LIBGIT2_DEPENDENCY_INCLUDES})
target_include_directories(${fuzz_target_name} SYSTEM PRIVATE ${LIBGIT2_SYSTEM_INCLUDES})
target_link_libraries(${fuzz_target_name} ${LIBGIT2_SYSTEM_LIBS})
add_test(${fuzz_target_name} "${CMAKE_CURRENT_BINARY_DIR}/${fuzz_target_name}" "${CMAKE_CURRENT_SOURCE_DIR}/corpora/${fuzz_name}")
endforeach()
......@@ -17,6 +17,8 @@
#include "hash.h"
#include "commit_graph.h"
#include "standalone_driver.h"
int LLVMFuzzerInitialize(int *argc, char ***argv)
{
GIT_UNUSED(argc);
......
......@@ -10,9 +10,11 @@
#include "git2.h"
#include "config_backend.h"
#include "standalone_driver.h"
#define UNUSED(x) (void)(x)
int foreach_cb(const git_config_entry *entry, void *payload)
static int foreach_cb(const git_config_entry *entry, void *payload)
{
UNUSED(entry);
UNUSED(payload);
......
......@@ -187,18 +187,18 @@ Once built, you can run the tests from the `build` directory with the command
Alternatively you can run the test suite directly using,
$ ./libgit2_clar
$ ./libgit2_tests
Invoking the test suite directly is useful because it allows you to execute
individual tests, or groups of tests using the `-s` flag. For example, to
run the index tests:
$ ./libgit2_clar -sindex
$ ./libgit2_tests -sindex
To run a single test named `index::racy::diff`, which corresponds to the test
function (`test_index_racy__diff`)[https://github.com/libgit2/libgit2/blob/master/tests/index/racy.c#L23]:
$ ./libgit2_clar -sindex::racy::diff
$ ./libgit2_tests -sindex::racy::diff
The test suite will print a `.` for every passing test, and an `F` for any
failing test. An `S` indicates that a test was skipped because it is not
......
......@@ -15,6 +15,8 @@
#include "git2/sys/transport.h"
#include "futils.h"
#include "standalone_driver.h"
#define UNUSED(x) (void)(x)
struct fuzzer_buffer {
......@@ -130,7 +132,7 @@ static int fuzzer_subtransport_new(
return 0;
}
int fuzzer_subtransport_cb(
static int fuzzer_subtransport_cb(
git_smart_subtransport **out,
git_transport *owner,
void *payload)
......@@ -145,7 +147,7 @@ int fuzzer_subtransport_cb(
return 0;
}
int fuzzer_transport_cb(git_transport **out, git_remote *owner, void *param)
static int fuzzer_transport_cb(git_transport **out, git_remote *owner, void *param)
{
git_smart_subtransport_definition def = {
fuzzer_subtransport_cb,
......@@ -155,7 +157,7 @@ int fuzzer_transport_cb(git_transport **out, git_remote *owner, void *param)
return git_transport_smart(out, owner, &def);
}
void fuzzer_git_abort(const char *op)
static void fuzzer_git_abort(const char *op)
{
const git_error *err = git_error_last();
fprintf(stderr, "unexpected libgit error: %s: %s\n",
......
......@@ -16,6 +16,8 @@
#include "hash.h"
#include "midx.h"
#include "standalone_driver.h"
int LLVMFuzzerInitialize(int *argc, char ***argv)
{
GIT_UNUSED(argc);
......
......@@ -10,6 +10,8 @@
#include "git2.h"
#include "object.h"
#include "standalone_driver.h"
#define UNUSED(x) (void)(x)
int LLVMFuzzerInitialize(int *argc, char ***argv)
......
......@@ -14,6 +14,8 @@
#include "common.h"
#include "str.h"
#include "standalone_driver.h"
static git_odb *odb = NULL;
static git_odb_backend *mempack = NULL;
......
......@@ -11,6 +11,8 @@
#include "patch.h"
#include "patch_parse.h"
#include "standalone_driver.h"
#define UNUSED(x) (void)(x)
int LLVMFuzzerInitialize(int *argc, char ***argv)
......
......@@ -11,8 +11,7 @@
#include "futils.h"
#include "path.h"
extern int LLVMFuzzerTestOneInput(const unsigned char *data, size_t size);
extern int LLVMFuzzerInitialize(int *argc, char ***argv);
#include "standalone_driver.h"
static int run_one_file(const char *filename)
{
......@@ -52,7 +51,7 @@ int main(int argc, char **argv)
fprintf(stderr, "Running %s against %s\n", argv[0], argv[1]);
LLVMFuzzerInitialize(&argc, &argv);
if (git_path_dirload(&corpus_files, argv[1], 0, 0x0) < 0) {
if (git_fs_path_dirload(&corpus_files, argv[1], 0, 0x0) < 0) {
fprintf(stderr, "Failed to scan corpus directory '%s': %s\n",
argv[1], git_error_last()->message);
error = -1;
......
/*
* 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_standalone_driver_h__
#define INCLUDE_standalone_driver_h__
extern int LLVMFuzzerTestOneInput(const unsigned char *data, size_t size);
extern int LLVMFuzzerInitialize(int *argc, char ***argv);
#endif
......@@ -59,7 +59,7 @@ typedef enum {
* Don't actually make changes, just test that the patch applies.
* This is the equivalent of `git apply --check`.
*/
GIT_APPLY_CHECK = (1 << 0),
GIT_APPLY_CHECK = (1 << 0)
} git_apply_flags_t;
/**
......@@ -127,7 +127,7 @@ typedef enum {
* Apply the patch to both the working directory and the index.
* This is the equivalent of `git apply --index`.
*/
GIT_APPLY_LOCATION_BOTH = 2,
GIT_APPLY_LOCATION_BOTH = 2
} git_apply_location_t;
/**
......
......@@ -83,7 +83,7 @@ typedef enum {
GIT_ATTR_VALUE_UNSPECIFIED = 0, /**< The attribute has been left unspecified */
GIT_ATTR_VALUE_TRUE, /**< The attribute has been set */
GIT_ATTR_VALUE_FALSE, /**< The attribute has been unset */
GIT_ATTR_VALUE_STRING, /**< This attribute has a value */
GIT_ATTR_VALUE_STRING /**< This attribute has a value */
} git_attr_value_t;
/**
......
......@@ -73,7 +73,7 @@ typedef enum {
GIT_BLAME_USE_MAILMAP = (1<<5),
/** Ignore whitespace differences */
GIT_BLAME_IGNORE_WHITESPACE = (1<<6),
GIT_BLAME_IGNORE_WHITESPACE = (1<<6)
} git_blame_flag_t;
/**
......
......@@ -119,7 +119,7 @@ typedef enum {
* When set, filters will be loaded from a `.gitattributes` file
* in the specified commit.
*/
GIT_BLOB_FILTER_ATTRIBUTES_FROM_COMMIT = (1 << 3),
GIT_BLOB_FILTER_ATTRIBUTES_FROM_COMMIT = (1 << 3)
} git_blob_filter_flag_t;
/**
......
......@@ -44,7 +44,7 @@ typedef enum git_cert_t {
* information about the certificate. This is used when using
* curl.
*/
GIT_CERT_STRARRAY,
GIT_CERT_STRARRAY
} git_cert_t;
/**
......@@ -82,7 +82,7 @@ typedef enum {
/** SHA-256 is available */
GIT_CERT_SSH_SHA256 = (1 << 2),
/** Raw hostkey is available */
GIT_CERT_SSH_RAW = (1 << 3),
GIT_CERT_SSH_RAW = (1 << 3)
} git_cert_ssh_t;
typedef enum {
......
......@@ -190,7 +190,7 @@ typedef enum {
/** Recursively checkout submodules with same options (NOT IMPLEMENTED) */
GIT_CHECKOUT_UPDATE_SUBMODULES = (1u << 16),
/** Recursively checkout submodules if HEAD moved in super repo (NOT IMPLEMENTED) */
GIT_CHECKOUT_UPDATE_SUBMODULES_IF_CHANGED = (1u << 17),
GIT_CHECKOUT_UPDATE_SUBMODULES_IF_CHANGED = (1u << 17)
} git_checkout_strategy_t;
......
......@@ -49,7 +49,7 @@ typedef enum {
* Bypass the git-aware transport, but do not try to use
* hardlinks.
*/
GIT_CLONE_LOCAL_NO_LINKS,
GIT_CLONE_LOCAL_NO_LINKS
} git_clone_local_t;
/**
......
......@@ -147,7 +147,7 @@ typedef enum {
* If set, libgit2 was built with support for sub-second resolution in file
* modification times.
*/
GIT_FEATURE_NSEC = (1 << 3),
GIT_FEATURE_NSEC = (1 << 3)
} git_feature_t;
/**
......
......@@ -55,7 +55,7 @@ typedef enum {
/** Represents the highest level available config file (i.e. the most
* specific config file available that actually is loaded)
*/
GIT_CONFIG_HIGHEST_LEVEL = -1,
GIT_CONFIG_HIGHEST_LEVEL = -1
} git_config_level_t;
/**
......
......@@ -75,7 +75,7 @@ typedef enum {
*
* @see git_credential_ssh_key_memory_new
*/
GIT_CREDENTIAL_SSH_MEMORY = (1u << 6),
GIT_CREDENTIAL_SSH_MEMORY = (1u << 6)
} git_credential_t;
/**
......
......@@ -313,7 +313,7 @@ typedef enum {
GIT_DIFF_FORMAT_EMAIL_NONE = 0,
/** Don't insert "[PATCH]" in the subject header*/
GIT_DIFF_FORMAT_EMAIL_EXCLUDE_SUBJECT_PATCH_MARKER = (1 << 0),
GIT_DIFF_FORMAT_EMAIL_EXCLUDE_SUBJECT_PATCH_MARKER = (1 << 0)
} git_diff_format_email_flags_t;
......
......@@ -30,7 +30,7 @@ GIT_BEGIN_DECL
typedef enum {
GIT_DESCRIBE_DEFAULT,
GIT_DESCRIBE_TAGS,
GIT_DESCRIBE_ALL,
GIT_DESCRIBE_ALL
} git_describe_strategy_t;
/**
......
......@@ -170,7 +170,7 @@ typedef enum {
/** Include the necessary deflate / delta information so that `git-apply`
* can apply given diff information to binary files.
*/
GIT_DIFF_SHOW_BINARY = (1u << 30),
GIT_DIFF_SHOW_BINARY = (1u << 30)
} git_diff_option_t;
/**
......@@ -207,7 +207,7 @@ typedef enum {
GIT_DIFF_FLAG_BINARY = (1u << 0), /**< file(s) treated as binary data */
GIT_DIFF_FLAG_NOT_BINARY = (1u << 1), /**< file(s) treated as text data */
GIT_DIFF_FLAG_VALID_ID = (1u << 2), /**< `id` value is known correct */
GIT_DIFF_FLAG_EXISTS = (1u << 3), /**< file exists at this side of the delta */
GIT_DIFF_FLAG_EXISTS = (1u << 3) /**< file exists at this side of the delta */
} git_diff_flag_t;
/**
......@@ -231,7 +231,7 @@ typedef enum {
GIT_DELTA_UNTRACKED = 7, /**< entry is untracked item in workdir */
GIT_DELTA_TYPECHANGE = 8, /**< type of entry changed between old and new */
GIT_DELTA_UNREADABLE = 9, /**< entry is unreadable */
GIT_DELTA_CONFLICTED = 10, /**< entry in the index is conflicted */
GIT_DELTA_CONFLICTED = 10 /**< entry in the index is conflicted */
} git_delta_t;
/**
......@@ -497,7 +497,7 @@ typedef enum {
GIT_DIFF_BINARY_LITERAL,
/** The binary data is the delta from one side to the other. */
GIT_DIFF_BINARY_DELTA,
GIT_DIFF_BINARY_DELTA
} git_diff_binary_t;
/** The contents of one of the files in a binary diff. */
......@@ -706,7 +706,7 @@ typedef enum {
* GIT_DIFF_INCLUDE_UNMODIFIED flag. If you do not want UNMODIFIED
* records in the final result, pass this flag to have them removed.
*/
GIT_DIFF_FIND_REMOVE_UNMODIFIED = (1u << 16),
GIT_DIFF_FIND_REMOVE_UNMODIFIED = (1u << 16)
} git_diff_find_t;
/**
......@@ -1107,7 +1107,7 @@ typedef enum {
GIT_DIFF_FORMAT_RAW = 3u, /**< like git diff --raw */
GIT_DIFF_FORMAT_NAME_ONLY = 4u, /**< like git diff --name-only */
GIT_DIFF_FORMAT_NAME_STATUS = 5u, /**< like git diff --name-status */
GIT_DIFF_FORMAT_PATCH_ID = 6u, /**< git diff as used by git patch-id */
GIT_DIFF_FORMAT_PATCH_ID = 6u /**< git diff as used by git patch-id */
} git_diff_format_t;
/**
......@@ -1311,7 +1311,7 @@ typedef enum {
GIT_DIFF_STATS_NUMBER = (1u << 2),
/** Extended header information such as creations, renames and mode changes, equivalent of `--summary` */
GIT_DIFF_STATS_INCLUDE_SUMMARY = (1u << 3),
GIT_DIFF_STATS_INCLUDE_SUMMARY = (1u << 3)
} git_diff_stats_format_t;
/**
......
......@@ -34,7 +34,7 @@ typedef enum {
GIT_EMAIL_CREATE_ALWAYS_NUMBER = (1u << 1),
/** Do not perform rename or similarity detection. */
GIT_EMAIL_CREATE_NO_RENAMES = (1u << 2),
GIT_EMAIL_CREATE_NO_RENAMES = (1u << 2)
} git_email_create_flags_t;
/**
......
......@@ -57,7 +57,7 @@ typedef enum {
GIT_RETRY = -32, /**< Internal only */
GIT_EMISMATCH = -33, /**< Hashsum mismatch in object */
GIT_EINDEXDIRTY = -34, /**< Unsaved changes in the index would be overwritten */
GIT_EAPPLYFAIL = -35, /**< Patch application failed */
GIT_EAPPLYFAIL = -35 /**< Patch application failed */
} git_error_code;
/**
......
......@@ -32,7 +32,7 @@ typedef enum {
GIT_FILTER_TO_WORKTREE = 0,
GIT_FILTER_SMUDGE = GIT_FILTER_TO_WORKTREE,
GIT_FILTER_TO_ODB = 1,
GIT_FILTER_CLEAN = GIT_FILTER_TO_ODB,
GIT_FILTER_CLEAN = GIT_FILTER_TO_ODB
} git_filter_mode_t;
/**
......@@ -54,7 +54,7 @@ typedef enum {
* Load attributes from `.gitattributes` in a given commit.
* This can only be specified in a `git_filter_options`.
*/
GIT_FILTER_ATTRIBUTES_FROM_COMMIT = (1u << 3),
GIT_FILTER_ATTRIBUTES_FROM_COMMIT = (1u << 3)
} git_filter_flag_t;
/**
......
......@@ -86,7 +86,7 @@ typedef struct git_index_entry {
*/
typedef enum {
GIT_INDEX_ENTRY_EXTENDED = (0x4000),
GIT_INDEX_ENTRY_VALID = (0x8000),
GIT_INDEX_ENTRY_VALID = (0x8000)
} git_index_entry_flag_t;
#define GIT_INDEX_ENTRY_STAGE(E) \
......@@ -119,7 +119,7 @@ typedef enum {
GIT_INDEX_ENTRY_EXTENDED_FLAGS = (GIT_INDEX_ENTRY_INTENT_TO_ADD | GIT_INDEX_ENTRY_SKIP_WORKTREE),
GIT_INDEX_ENTRY_UPTODATE = (1 << 2),
GIT_INDEX_ENTRY_UPTODATE = (1 << 2)
} git_index_entry_extended_flag_t;
/** Capabilities of system that affect index actions. */
......@@ -127,7 +127,7 @@ typedef enum {
GIT_INDEX_CAPABILITY_IGNORE_CASE = 1,
GIT_INDEX_CAPABILITY_NO_FILEMODE = 2,
GIT_INDEX_CAPABILITY_NO_SYMLINKS = 4,
GIT_INDEX_CAPABILITY_FROM_OWNER = -1,
GIT_INDEX_CAPABILITY_FROM_OWNER = -1
} git_index_capability_t;
......@@ -140,7 +140,7 @@ typedef enum {
GIT_INDEX_ADD_DEFAULT = 0,
GIT_INDEX_ADD_FORCE = (1u << 0),
GIT_INDEX_ADD_DISABLE_PATHSPEC_MATCH = (1u << 1),
GIT_INDEX_ADD_CHECK_PATHSPEC = (1u << 2),
GIT_INDEX_ADD_CHECK_PATHSPEC = (1u << 2)
} git_index_add_option_t;
/** Git index stage states */
......@@ -163,7 +163,7 @@ typedef enum {
GIT_INDEX_STAGE_OURS = 2,
/** The "theirs" side of a conflict. */
GIT_INDEX_STAGE_THEIRS = 3,
GIT_INDEX_STAGE_THEIRS = 3
} git_index_stage_t;
/**
......
......@@ -91,7 +91,7 @@ typedef enum {
* instead simply use the first base. This flag provides a similar
* merge base to `git-merge-resolve`.
*/
GIT_MERGE_NO_RECURSIVE = (1 << 3),
GIT_MERGE_NO_RECURSIVE = (1 << 3)
} git_merge_flag_t;
/**
......@@ -127,7 +127,7 @@ typedef enum {
* which has the result of combining both files. The index will not
* record a conflict.
*/
GIT_MERGE_FILE_FAVOR_UNION = 3,
GIT_MERGE_FILE_FAVOR_UNION = 3
} git_merge_file_favor_t;
/**
......@@ -159,7 +159,7 @@ typedef enum {
GIT_MERGE_FILE_DIFF_PATIENCE = (1 << 6),
/** Take extra time to find minimal diff */
GIT_MERGE_FILE_DIFF_MINIMAL = (1 << 7),
GIT_MERGE_FILE_DIFF_MINIMAL = (1 << 7)
} git_merge_file_flag_t;
#define GIT_MERGE_CONFLICT_MARKER_SIZE 7
......@@ -341,7 +341,7 @@ typedef enum {
* a valid commit. No merge can be performed, but the caller may wish
* to simply set HEAD to the target commit(s).
*/
GIT_MERGE_ANALYSIS_UNBORN = (1 << 3),
GIT_MERGE_ANALYSIS_UNBORN = (1 << 3)
} git_merge_analysis_t;
/**
......@@ -364,7 +364,7 @@ typedef enum {
* There is a `merge.ff=only` configuration setting, suggesting that
* the user only wants fast-forward merges.
*/
GIT_MERGE_PREFERENCE_FASTFORWARD_ONLY = (1 << 1),
GIT_MERGE_PREFERENCE_FASTFORWARD_ONLY = (1 << 1)
} git_merge_preference_t;
/**
......
......@@ -22,6 +22,17 @@
*/
GIT_BEGIN_DECL
/** Flags controlling the behavior of ODB lookup operations */
typedef enum {
/**
* Don't call `git_odb_refresh` if the lookup fails. Useful when doing
* a batch of lookup operations for objects that may legitimately not
* exist. When using this flag, you may wish to manually call
* `git_odb_refresh` before processing a batch of objects.
*/
GIT_ODB_LOOKUP_NO_REFRESH = (1 << 0)
} git_odb_lookup_flags_t;
/**
* Function type for callbacks from git_odb_foreach.
*/
......@@ -156,6 +167,17 @@ GIT_EXTERN(int) git_odb_read_header(size_t *len_out, git_object_t *type_out, git
GIT_EXTERN(int) git_odb_exists(git_odb *db, const git_oid *id);
/**
* Determine if the given object can be found in the object database, with
* extended options.
*
* @param db database to be searched for the given object.
* @param id the object to search for.
* @param flags flags affecting the lookup (see `git_odb_lookup_flags_t`)
* @return 1 if the object was found, 0 otherwise
*/
GIT_EXTERN(int) git_odb_exists_ext(git_odb *db, const git_oid *id, unsigned int flags);
/**
* Determine if an object can be found in the object database by an
* abbreviated object ID.
*
......
......@@ -71,7 +71,7 @@ GIT_EXTERN(int) git_odb_backend_one_pack(git_odb_backend **out, const char *inde
typedef enum {
GIT_STREAM_RDONLY = (1 << 1),
GIT_STREAM_WRONLY = (1 << 2),
GIT_STREAM_RW = (GIT_STREAM_RDONLY | GIT_STREAM_WRONLY),
GIT_STREAM_RW = (GIT_STREAM_RDONLY | GIT_STREAM_WRONLY)
} git_odb_stream_t;
/**
......
......@@ -51,7 +51,7 @@ GIT_BEGIN_DECL
*/
typedef enum {
GIT_PACKBUILDER_ADDING_OBJECTS = 0,
GIT_PACKBUILDER_DELTAFICATION = 1,
GIT_PACKBUILDER_DELTAFICATION = 1
} git_packbuilder_stage_t;
/**
......
......@@ -69,7 +69,7 @@ typedef enum {
* just test if there were any matches at all or in combination with
* GIT_PATHSPEC_FIND_FAILURES to validate a pathspec.
*/
GIT_PATHSPEC_FAILURES_ONLY = (1u << 5),
GIT_PATHSPEC_FAILURES_ONLY = (1u << 5)
} git_pathspec_flag_t;
/**
......
......@@ -32,7 +32,7 @@ typedef enum {
/**
* Connect via the URL given in the options
*/
GIT_PROXY_SPECIFIED,
GIT_PROXY_SPECIFIED
} git_proxy_t;
/**
......
......@@ -152,7 +152,7 @@ typedef enum {
* No commit will be cherry-picked. The client should run the given
* command and (if successful) continue.
*/
GIT_REBASE_OPERATION_EXEC,
GIT_REBASE_OPERATION_EXEC
} git_rebase_operation_t;
#define GIT_REBASE_OPTIONS_VERSION 1
......
......@@ -686,7 +686,7 @@ typedef enum {
* so the `ONELEVEL` naming rules aren't enforced and 'master'
* becomes a valid name.
*/
GIT_REFERENCE_FORMAT_REFSPEC_SHORTHAND = (1u << 2),
GIT_REFERENCE_FORMAT_REFSPEC_SHORTHAND = (1u << 2)
} git_reference_format_t;
/**
......
......@@ -49,7 +49,7 @@ typedef enum {
GIT_REMOTE_CREATE_SKIP_INSTEADOF = (1 << 0),
/** Don't build a fetchspec from the name if none is set */
GIT_REMOTE_CREATE_SKIP_DEFAULT_FETCHSPEC = (1 << 1),
GIT_REMOTE_CREATE_SKIP_DEFAULT_FETCHSPEC = (1 << 1)
} git_remote_create_flags;
/**
......@@ -443,7 +443,7 @@ GIT_EXTERN(int) git_remote_list(git_strarray *out, git_repository *repo);
typedef enum git_remote_completion_t {
GIT_REMOTE_COMPLETION_DOWNLOAD,
GIT_REMOTE_COMPLETION_INDEXING,
GIT_REMOTE_COMPLETION_ERROR,
GIT_REMOTE_COMPLETION_ERROR
} git_remote_completion_t;
/** Push network progress notification function */
......@@ -665,7 +665,7 @@ typedef enum {
/**
* Force pruning off
*/
GIT_FETCH_NO_PRUNE,
GIT_FETCH_NO_PRUNE
} git_fetch_prune_t;
/**
......@@ -690,7 +690,7 @@ typedef enum {
/**
* Ask for the all the tags.
*/
GIT_REMOTE_DOWNLOAD_TAGS_ALL,
GIT_REMOTE_DOWNLOAD_TAGS_ALL
} git_remote_autotag_option_t;
/**
......
......@@ -141,7 +141,7 @@ typedef enum {
* `git_repository_open_ext` with this flag will error out if either
* $GIT_WORK_TREE or $GIT_COMMON_DIR is set.
*/
GIT_REPOSITORY_OPEN_FROM_ENV = (1 << 4),
GIT_REPOSITORY_OPEN_FROM_ENV = (1 << 4)
} git_repository_open_flag_t;
/**
......@@ -267,7 +267,7 @@ typedef enum {
* If an alternate workdir is specified, use relative paths for the gitdir
* and core.worktree.
*/
GIT_REPOSITORY_INIT_RELATIVE_GITLINK = (1u << 6),
GIT_REPOSITORY_INIT_RELATIVE_GITLINK = (1u << 6)
} git_repository_init_flag_t;
/**
......@@ -292,7 +292,7 @@ typedef enum {
/**
* Use "--shared=all" behavior, adding world readability.
*/
GIT_REPOSITORY_INIT_SHARED_ALL = 0002777,
GIT_REPOSITORY_INIT_SHARED_ALL = 0002777
} git_repository_init_mode_t;
/**
......@@ -876,7 +876,7 @@ typedef enum {
GIT_REPOSITORY_STATE_REBASE_INTERACTIVE,
GIT_REPOSITORY_STATE_REBASE_MERGE,
GIT_REPOSITORY_STATE_APPLY_MAILBOX,
GIT_REPOSITORY_STATE_APPLY_MAILBOX_OR_REBASE,
GIT_REPOSITORY_STATE_APPLY_MAILBOX_OR_REBASE
} git_repository_state_t;
/**
......
......@@ -26,7 +26,7 @@ GIT_BEGIN_DECL
typedef enum {
GIT_RESET_SOFT = 1, /**< Move the head to the given commit */
GIT_RESET_MIXED = 2, /**< SOFT plus reset index to the commit */
GIT_RESET_HARD = 3, /**< MIXED plus changes in working tree discarded */
GIT_RESET_HARD = 3 /**< MIXED plus changes in working tree discarded */
} git_reset_t;
/**
......
......@@ -74,7 +74,7 @@ typedef enum {
/** The spec targeted a range of commits. */
GIT_REVSPEC_RANGE = 1 << 1,
/** The spec used the '...' operator, which invokes special semantics. */
GIT_REVSPEC_MERGE_BASE = 1 << 2,
GIT_REVSPEC_MERGE_BASE = 1 << 2
} git_revspec_t;
/**
......
......@@ -49,7 +49,7 @@ typedef enum {
* order; this sorting mode can be combined with
* any of the above.
*/
GIT_SORT_REVERSE = 1 << 2,
GIT_SORT_REVERSE = 1 << 2
} git_sort_t;
/**
......
......@@ -44,7 +44,7 @@ typedef enum {
* All ignored files are also stashed and then cleaned up from
* the working directory
*/
GIT_STASH_INCLUDE_IGNORED = (1 << 2),
GIT_STASH_INCLUDE_IGNORED = (1 << 2)
} git_stash_flags;
/**
......@@ -78,7 +78,7 @@ typedef enum {
/* Try to reinstate not only the working tree's changes,
* but also the index's changes.
*/
GIT_STASH_APPLY_REINSTATE_INDEX = (1 << 0),
GIT_STASH_APPLY_REINSTATE_INDEX = (1 << 0)
} git_stash_apply_flags;
/** Stash apply progression states */
......@@ -104,7 +104,7 @@ typedef enum {
GIT_STASH_APPLY_PROGRESS_CHECKOUT_MODIFIED,
/** The stash was applied successfully. */
GIT_STASH_APPLY_PROGRESS_DONE,
GIT_STASH_APPLY_PROGRESS_DONE
} git_stash_apply_progress_t;
/**
......
......@@ -48,7 +48,7 @@ typedef enum {
GIT_STATUS_WT_UNREADABLE = (1u << 12),
GIT_STATUS_IGNORED = (1u << 14),
GIT_STATUS_CONFLICTED = (1u << 15),
GIT_STATUS_CONFLICTED = (1u << 15)
} git_status_t;
/**
......@@ -87,7 +87,7 @@ typedef enum {
* Only gives status based on index to working directory comparison,
* not comparing the index to the HEAD.
*/
GIT_STATUS_SHOW_WORKDIR_ONLY = 2,
GIT_STATUS_SHOW_WORKDIR_ONLY = 2
} git_status_show_t;
/**
......@@ -204,7 +204,7 @@ typedef enum {
* Unreadable files will be detected and given the status
* untracked instead of unreadable.
*/
GIT_STATUS_OPT_INCLUDE_UNREADABLE_AS_UNTRACKED = (1u << 15),
GIT_STATUS_OPT_INCLUDE_UNREADABLE_AS_UNTRACKED = (1u << 15)
} git_status_opt_t;
#define GIT_STATUS_OPT_DEFAULTS \
......
......@@ -85,7 +85,7 @@ typedef enum {
GIT_SUBMODULE_STATUS_WD_MODIFIED = (1u << 10),
GIT_SUBMODULE_STATUS_WD_INDEX_MODIFIED = (1u << 11),
GIT_SUBMODULE_STATUS_WD_WD_MODIFIED = (1u << 12),
GIT_SUBMODULE_STATUS_WD_UNTRACKED = (1u << 13),
GIT_SUBMODULE_STATUS_WD_UNTRACKED = (1u << 13)
} git_submodule_status_t;
#define GIT_SUBMODULE_STATUS__IN_FLAGS 0x000Fu
......
......@@ -94,7 +94,7 @@ typedef enum {
* Do not split commit-graph files. The other split strategy-related option
* fields are ignored.
*/
GIT_COMMIT_GRAPH_SPLIT_STRATEGY_SINGLE_FILE = 0,
GIT_COMMIT_GRAPH_SPLIT_STRATEGY_SINGLE_FILE = 0
} git_commit_graph_split_strategy_t;
/**
......
......@@ -69,11 +69,8 @@ struct git_odb_backend {
* If the backend implements a refreshing mechanism, it should be exposed
* through this endpoint. Each call to `git_odb_refresh()` will invoke it.
*
* However, the backend implementation should try to stay up-to-date as much
* as possible by itself as libgit2 will not automatically invoke
* `git_odb_refresh()`. For instance, a potential strategy for the backend
* implementation to achieve this could be to internally invoke this
* endpoint on failed lookups (ie. `exists()`, `read()`, `read_header()`).
* The odb layer will automatically call this when needed on failed
* lookups (ie. `exists()`, `read()`, `read_header()`).
*/
int GIT_CALLBACK(refresh)(git_odb_backend *);
......
......@@ -79,7 +79,7 @@ typedef enum {
GIT_STREAM_STANDARD = 1,
/** A TLS-encrypted socket. */
GIT_STREAM_TLS = 2,
GIT_STREAM_TLS = 2
} git_stream_t;
/**
......
......@@ -30,7 +30,7 @@ GIT_BEGIN_DECL
* Currently unused.
*/
typedef enum {
GIT_TRANSPORTFLAGS_NONE = 0,
GIT_TRANSPORTFLAGS_NONE = 0
} git_transport_flags_t;
struct git_transport {
......@@ -289,7 +289,7 @@ typedef enum {
GIT_SERVICE_UPLOADPACK_LS = 1,
GIT_SERVICE_UPLOADPACK = 2,
GIT_SERVICE_RECEIVEPACK_LS = 3,
GIT_SERVICE_RECEIVEPACK = 4,
GIT_SERVICE_RECEIVEPACK = 4
} git_smart_service_t;
typedef struct git_smart_subtransport git_smart_subtransport;
......
......@@ -386,7 +386,7 @@ typedef int GIT_CALLBACK(git_treewalk_cb)(
/** Tree traversal modes */
typedef enum {
GIT_TREEWALK_PRE = 0, /* Pre-order */
GIT_TREEWALK_POST = 1, /* Post-order */
GIT_TREEWALK_POST = 1 /* Post-order */
} git_treewalk_mode;
/**
......@@ -428,7 +428,7 @@ typedef enum {
/** Update or insert an entry at the specified path */
GIT_TREE_UPDATE_UPSERT,
/** Remove an entry from the specified path */
GIT_TREE_UPDATE_REMOVE,
GIT_TREE_UPDATE_REMOVE
} git_tree_update_t;
/**
......
......@@ -78,7 +78,7 @@ typedef enum {
GIT_OBJECT_BLOB = 3, /**< A file revision object. */
GIT_OBJECT_TAG = 4, /**< An annotated tag object. */
GIT_OBJECT_OFS_DELTA = 6, /**< A delta, base is given by an offset. */
GIT_OBJECT_REF_DELTA = 7, /**< A delta, base is given by object id. */
GIT_OBJECT_REF_DELTA = 7 /**< A delta, base is given by object id. */
} git_object_t;
/** An open object database handle. */
......@@ -208,14 +208,14 @@ typedef enum {
GIT_REFERENCE_INVALID = 0, /**< Invalid reference */
GIT_REFERENCE_DIRECT = 1, /**< A reference that points at an object id */
GIT_REFERENCE_SYMBOLIC = 2, /**< A reference that points at another reference */
GIT_REFERENCE_ALL = GIT_REFERENCE_DIRECT | GIT_REFERENCE_SYMBOLIC,
GIT_REFERENCE_ALL = GIT_REFERENCE_DIRECT | GIT_REFERENCE_SYMBOLIC
} git_reference_t;
/** Basic type of any Git branch. */
typedef enum {
GIT_BRANCH_LOCAL = 1,
GIT_BRANCH_REMOTE = 2,
GIT_BRANCH_ALL = GIT_BRANCH_LOCAL|GIT_BRANCH_REMOTE,
GIT_BRANCH_ALL = GIT_BRANCH_LOCAL|GIT_BRANCH_REMOTE
} git_branch_t;
/** Valid modes for index and tree entries. */
......@@ -225,7 +225,7 @@ typedef enum {
GIT_FILEMODE_BLOB = 0100644,
GIT_FILEMODE_BLOB_EXECUTABLE = 0100755,
GIT_FILEMODE_LINK = 0120000,
GIT_FILEMODE_COMMIT = 0160000,
GIT_FILEMODE_COMMIT = 0160000
} git_filemode_t;
/**
......@@ -334,7 +334,7 @@ typedef enum {
GIT_SUBMODULE_IGNORE_NONE = 1, /**< any change or untracked == dirty */
GIT_SUBMODULE_IGNORE_UNTRACKED = 2, /**< dirty if tracked files change */
GIT_SUBMODULE_IGNORE_DIRTY = 3, /**< only dirty if HEAD moved */
GIT_SUBMODULE_IGNORE_ALL = 4, /**< never dirty */
GIT_SUBMODULE_IGNORE_ALL = 4 /**< never dirty */
} git_submodule_ignore_t;
/**
......@@ -350,7 +350,7 @@ typedef enum {
typedef enum {
GIT_SUBMODULE_RECURSE_NO = 0,
GIT_SUBMODULE_RECURSE_YES = 1,
GIT_SUBMODULE_RECURSE_ONDEMAND = 2,
GIT_SUBMODULE_RECURSE_ONDEMAND = 2
} git_submodule_recurse_t;
typedef struct git_writestream git_writestream;
......
......@@ -185,7 +185,7 @@ typedef enum {
/* Prune working tree even if it is locked */
GIT_WORKTREE_PRUNE_LOCKED = 1u << 1,
/* Prune checked out working tree */
GIT_WORKTREE_PRUNE_WORKING_TREE = 1u << 2,
GIT_WORKTREE_PRUNE_WORKING_TREE = 1u << 2
} git_worktree_prune_t;
/**
......
......@@ -15,7 +15,7 @@
typedef enum {
GIT_ANNOTATED_COMMIT_REAL = 1,
GIT_ANNOTATED_COMMIT_VIRTUAL = 2,
GIT_ANNOTATED_COMMIT_VIRTUAL = 2
} git_annotated_commit_t;
/**
......
......@@ -629,7 +629,7 @@ static int collect_attr_files(
const char *workdir = git_repository_workdir(repo);
attr_walk_up_info info = { NULL };
GIT_ASSERT(!git_path_is_absolute(path));
GIT_ASSERT(!git_fs_path_is_absolute(path));
if ((error = attr_setup(repo, attr_session, opts)) < 0)
return error;
......@@ -637,10 +637,10 @@ static int collect_attr_files(
/* Resolve path in a non-bare repo */
if (workdir != NULL) {
if (!(error = git_repository_workdir_path(&dir, repo, path)))
error = git_path_find_dir(&dir);
error = git_fs_path_find_dir(&dir);
}
else {
error = git_path_dirname_r(&dir, path);
error = git_fs_path_dirname_r(&dir, path);
}
if (error < 0)
......@@ -670,7 +670,7 @@ static int collect_attr_files(
if (!strcmp(dir.ptr, "."))
error = push_one_attr(&info, "");
else
error = git_path_walk_up(&dir, workdir, push_one_attr, &info);
error = git_fs_path_walk_up(&dir, workdir, push_one_attr, &info);
if (error < 0)
goto cleanup;
......
......@@ -345,7 +345,7 @@ int git_attr_file__parse_buffer(
int error = 0;
/* If subdir file path, convert context for file paths */
if (attrs->entry && git_path_root(attrs->entry->path) < 0 &&
if (attrs->entry && git_fs_path_root(attrs->entry->path) < 0 &&
!git__suffixcmp(attrs->entry->path, "/" GIT_ATTR_FILE))
context = attrs->entry->path;
......@@ -560,7 +560,7 @@ int git_attr_path__init(
/* build full path as best we can */
git_str_init(&info->full, 0);
if (git_path_join_unrooted(&info->full, path, base, &root) < 0)
if (git_fs_path_join_unrooted(&info->full, path, base, &root) < 0)
return -1;
info->path = info->full.ptr + root;
......@@ -596,7 +596,7 @@ int git_attr_path__init(
case GIT_DIR_FLAG_UNKNOWN:
default:
info->is_dir = (int)git_path_isdir(info->full.ptr);
info->is_dir = (int)git_fs_path_isdir(info->full.ptr);
break;
}
......
......@@ -12,6 +12,7 @@
#include "config.h"
#include "sysdir.h"
#include "ignore.h"
#include "path.h"
GIT_INLINE(int) attr_cache_lock(git_attr_cache *cache)
{
......@@ -43,11 +44,12 @@ int git_attr_cache__alloc_file_entry(
const char *path,
git_pool *pool)
{
git_str fullpath_str = GIT_STR_INIT;
size_t baselen = 0, pathlen = strlen(path);
size_t cachesize = sizeof(git_attr_file_entry) + pathlen + 1;
git_attr_file_entry *ce;
if (base != NULL && git_path_root(path) < 0) {
if (base != NULL && git_fs_path_root(path) < 0) {
baselen = strlen(base);
cachesize += baselen;
......@@ -66,7 +68,10 @@ int git_attr_cache__alloc_file_entry(
}
memcpy(&ce->fullpath[baselen], path, pathlen);
if (git_path_validate_workdir_with_len(repo, ce->fullpath, pathlen + baselen) < 0)
fullpath_str.ptr = ce->fullpath;
fullpath_str.size = pathlen + baselen;
if (git_path_validate_str_length(repo, &fullpath_str) < 0)
return -1;
ce->path = &ce->fullpath[baselen];
......@@ -169,11 +174,11 @@ static int attr_cache_lookup(
git_attr_file *file = NULL;
/* join base and path as needed */
if (source->base != NULL && git_path_root(source->filename) < 0) {
if (source->base != NULL && git_fs_path_root(source->filename) < 0) {
git_str *p = attr_session ? &attr_session->tmp : &path;
if (git_str_joinpath(p, source->base, source->filename) < 0 ||
git_path_validate_workdir_buf(repo, p) < 0)
git_path_validate_str_length(repo, p) < 0)
return -1;
filename = p->ptr;
......
......@@ -205,7 +205,7 @@ int git_blob__create_from_paths(
content_path = path.ptr;
}
if ((error = git_path_lstat(content_path, &st)) < 0 ||
if ((error = git_fs_path_lstat(content_path, &st)) < 0 ||
(error = git_repository_odb(&odb, repo)) < 0)
goto done;
......@@ -280,7 +280,7 @@ int git_blob_create_from_disk(
git_str full_path = GIT_STR_INIT;
const char *workdir, *hintpath = NULL;
if ((error = git_path_prettify(&full_path, path, NULL)) < 0) {
if ((error = git_fs_path_prettify(&full_path, path, NULL)) < 0) {
git_str_dispose(&full_path);
return error;
}
......
......@@ -27,10 +27,11 @@
#include "diff_generate.h"
#include "pathspec.h"
#include "diff_xdiff.h"
#include "path.h"
#include "fs_path.h"
#include "attr.h"
#include "pool.h"
#include "strmap.h"
#include "path.h"
/* See docs/checkout-internals.md for more information */
......@@ -44,7 +45,7 @@ enum {
CHECKOUT_ACTION__UPDATE_CONFLICT = 32,
CHECKOUT_ACTION__MAX = 32,
CHECKOUT_ACTION__REMOVE_AND_UPDATE =
(CHECKOUT_ACTION__UPDATE_BLOB | CHECKOUT_ACTION__REMOVE),
(CHECKOUT_ACTION__UPDATE_BLOB | CHECKOUT_ACTION__REMOVE)
};
typedef struct {
......@@ -328,7 +329,7 @@ static int checkout_target_fullpath(
if (path && git_str_puts(&data->target_path, path) < 0)
return -1;
if (git_path_validate_workdir_buf(data->repo, &data->target_path) < 0)
if (git_path_validate_str_length(data->repo, &data->target_path) < 0)
return -1;
*out = &data->target_path;
......@@ -347,7 +348,7 @@ static bool wd_item_is_removable(
if (checkout_target_fullpath(&full, data, wd->path) < 0)
return false;
return !full || !git_path_contains(full, DOT_GIT);
return !full || !git_fs_path_contains(full, DOT_GIT);
}
static int checkout_queue_remove(checkout_data *data, const char *path)
......@@ -481,7 +482,7 @@ static bool checkout_is_empty_dir(checkout_data *data, const char *path)
if (checkout_target_fullpath(&fullpath, data, path) < 0)
return false;
return git_path_is_empty_dir(fullpath->ptr);
return git_fs_path_is_empty_dir(fullpath->ptr);
}
static int checkout_action_with_wd(
......@@ -1201,12 +1202,12 @@ static int checkout_conflicts_mark_directoryfile(
goto done;
}
prefixed = git_path_equal_or_prefixed(path, entry->path, NULL);
prefixed = git_fs_path_equal_or_prefixed(path, entry->path, NULL);
if (prefixed == GIT_PATH_EQUAL)
if (prefixed == GIT_FS_PATH_EQUAL)
continue;
if (prefixed == GIT_PATH_PREFIX)
if (prefixed == GIT_FS_PATH_PREFIX)
conflict->directoryfile = 1;
break;
......@@ -1280,14 +1281,14 @@ static int checkout_verify_paths(
unsigned int flags = GIT_PATH_REJECT_WORKDIR_DEFAULTS;
if (action & CHECKOUT_ACTION__REMOVE) {
if (!git_path_validate(repo, delta->old_file.path, delta->old_file.mode, flags)) {
if (!git_path_is_valid(repo, delta->old_file.path, delta->old_file.mode, flags)) {
git_error_set(GIT_ERROR_CHECKOUT, "cannot remove invalid path '%s'", delta->old_file.path);
return -1;
}
}
if (action & ~CHECKOUT_ACTION__REMOVE) {
if (!git_path_validate(repo, delta->new_file.path, delta->new_file.mode, flags)) {
if (!git_path_is_valid(repo, delta->new_file.path, delta->new_file.mode, flags)) {
git_error_set(GIT_ERROR_CHECKOUT, "cannot checkout to invalid path '%s'", delta->new_file.path);
return -1;
}
......@@ -1949,7 +1950,7 @@ static int checkout_path_suffixed(git_str *path, const char *suffix)
path_len = git_str_len(path);
while (git_path_exists(git_str_cstr(path)) && i < INT_MAX) {
while (git_fs_path_exists(git_str_cstr(path)) && i < INT_MAX) {
git_str_truncate(path, path_len);
if ((error = git_str_putc(path, '_')) < 0 ||
......@@ -2034,7 +2035,7 @@ static int checkout_merge_path(
int error = 0;
if ((error = git_str_joinpath(out, data->opts.target_directory, result->path)) < 0 ||
(error = git_path_validate_workdir_buf(data->repo, out)) < 0)
(error = git_path_validate_str_length(data->repo, out)) < 0)
return error;
/* Most conflicts simply use the filename in the index */
......@@ -2337,10 +2338,10 @@ static int validate_target_directory(checkout_data *data)
{
int error;
if ((error = git_path_validate_workdir(data->repo, data->opts.target_directory)) < 0)
if ((error = git_path_validate_length(data->repo, data->opts.target_directory)) < 0)
return error;
if (git_path_isdir(data->opts.target_directory))
if (git_fs_path_isdir(data->opts.target_directory))
return 0;
error = checkout_mkdir(data, data->opts.target_directory, NULL,
......@@ -2507,7 +2508,7 @@ static int checkout_data_init(
(error = git_vector_init(&data->remove_conflicts, 0, NULL)) < 0 ||
(error = git_vector_init(&data->update_conflicts, 0, NULL)) < 0 ||
(error = git_str_puts(&data->target_path, data->opts.target_directory)) < 0 ||
(error = git_path_to_dir(&data->target_path)) < 0 ||
(error = git_fs_path_to_dir(&data->target_path)) < 0 ||
(error = git_strmap_new(&data->mkdir_map)) < 0)
goto cleanup;
......
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment