Update upstream source from tag 'upstream/1.4.3+dfsg.1'

Update to upstream version '1.4.3+dfsg.1'
with Debian dir 7bd8c13d37
This commit is contained in:
Mohammed Bilal 2022-05-05 10:45:29 +00:00
commit 3ece3aa3db
613 changed files with 19759 additions and 13832 deletions

20
.github/release.yml vendored Normal file
View File

@ -0,0 +1,20 @@
changelog:
categories:
- title: New features
labels:
- feature
- title: Bug fixes
labels:
- bug
- title: Code cleanups
labels:
- cleanup
- title: CI improvements
labels:
- build
- title: Documentation improvements
labels:
- documentation
- title: Other changes
labels:
- '*'

View File

@ -22,8 +22,7 @@ jobs:
# with both the sha and "latest" so that the subsequent runs need not # with both the sha and "latest" so that the subsequent runs need not
# know the sha. Only do this on CI builds (when the event is a "push") # know the sha. Only do this on CI builds (when the event is a "push")
# because PR builds from forks lack permission to write packages. # because PR builds from forks lack permission to write packages.
build_containers: containers:
name: Create docker image
strategy: strategy:
matrix: matrix:
container: container:
@ -46,6 +45,7 @@ jobs:
- name: centos7 - name: centos7
- name: centos8 - name: centos8
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: "Create container: ${{ matrix.container.name }}"
steps: steps:
- name: Check out repository - name: Check out repository
uses: actions/checkout@v2 uses: actions/checkout@v2
@ -80,76 +80,75 @@ jobs:
# and their details. Then we build either in a docker container (Linux) # and their details. Then we build either in a docker container (Linux)
# or on the actual hosts (macOS, Windows). # or on the actual hosts (macOS, Windows).
build: build:
name: Build needs: [ containers ]
needs: [ build_containers ]
strategy: strategy:
matrix: matrix:
platform: platform:
- # Xenial, GCC, OpenSSL - name: "Linux (Xenial, GCC, OpenSSL)"
container: container:
name: xenial name: xenial
env: env:
CC: gcc CC: gcc
CMAKE_GENERATOR: Ninja 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 os: ubuntu-latest
- # Xenial, GCC, mbedTLS - name: Linux (Xenial, GCC, mbedTLS)
container: container:
name: xenial name: xenial
env: env:
CC: gcc CC: gcc
CMAKE_GENERATOR: Ninja 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 os: ubuntu-latest
- # Xenial, Clang, OpenSSL - name: "Linux (Xenial, Clang, OpenSSL)"
container: container:
name: xenial name: xenial
env: env:
CC: clang CC: clang
CMAKE_GENERATOR: Ninja 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 os: ubuntu-latest
- # Xenial, Clang, mbedTLS - name: "Linux (Xenial, Clang, mbedTLS)"
container: container:
name: xenial name: xenial
env: env:
CC: clang 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 CMAKE_GENERATOR: Ninja
os: ubuntu-latest os: ubuntu-latest
- # Focal, Clang 10, mbedTLS, MemorySanitizer - name: "Linux (MemorySanitizer)"
container: container:
name: focal name: focal
env: env:
CC: clang-10 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 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 CMAKE_GENERATOR: Ninja
SKIP_SSH_TESTS: true SKIP_SSH_TESTS: true
SKIP_NEGOTIATE_TESTS: true SKIP_NEGOTIATE_TESTS: true
ASAN_SYMBOLIZER_PATH: /usr/bin/llvm-symbolizer-10 ASAN_SYMBOLIZER_PATH: /usr/bin/llvm-symbolizer-10
UBSAN_OPTIONS: print_stacktrace=1 UBSAN_OPTIONS: print_stacktrace=1
os: ubuntu-latest os: ubuntu-latest
- # Focal, Clang 10, OpenSSL, UndefinedBehaviorSanitizer - name: "Linux (UndefinedBehaviorSanitizer)"
container: container:
name: focal name: focal
env: env:
CC: clang-10 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 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 CMAKE_GENERATOR: Ninja
SKIP_SSH_TESTS: true SKIP_SSH_TESTS: true
SKIP_NEGOTIATE_TESTS: true SKIP_NEGOTIATE_TESTS: true
ASAN_SYMBOLIZER_PATH: /usr/bin/llvm-symbolizer-10 ASAN_SYMBOLIZER_PATH: /usr/bin/llvm-symbolizer-10
UBSAN_OPTIONS: print_stacktrace=1 UBSAN_OPTIONS: print_stacktrace=1
os: ubuntu-latest os: ubuntu-latest
- # Focal, Clang 10, OpenSSL, ThreadSanitizer - name: "Linux (ThreadSanitizer)"
container: container:
name: focal name: focal
env: env:
CC: clang-10 CC: clang-10
CFLAGS: -fsanitize=thread -fno-optimize-sibling-calls -fno-omit-frame-pointer 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 CMAKE_GENERATOR: Ninja
SKIP_SSH_TESTS: true SKIP_SSH_TESTS: true
SKIP_NEGOTIATE_TESTS: true SKIP_NEGOTIATE_TESTS: true
@ -157,7 +156,7 @@ jobs:
UBSAN_OPTIONS: print_stacktrace=1 UBSAN_OPTIONS: print_stacktrace=1
TSAN_OPTIONS: suppressions=/home/libgit2/source/script/thread-sanitizer.supp second_deadlock_stack=1 TSAN_OPTIONS: suppressions=/home/libgit2/source/script/thread-sanitizer.supp second_deadlock_stack=1
os: ubuntu-latest os: ubuntu-latest
- # macOS - name: "macOS"
os: macos-10.15 os: macos-10.15
env: env:
CC: clang CC: clang
@ -166,7 +165,7 @@ jobs:
SKIP_SSH_TESTS: true SKIP_SSH_TESTS: true
SKIP_NEGOTIATE_TESTS: true SKIP_NEGOTIATE_TESTS: true
setup-script: osx setup-script: osx
- # Windows amd64 Visual Studio - name: "Windows (amd64, Visual Studio)"
os: windows-2019 os: windows-2019
env: env:
ARCH: amd64 ARCH: amd64
@ -174,7 +173,7 @@ jobs:
CMAKE_OPTIONS: -A x64 -DWIN32_LEAKCHECK=ON -DDEPRECATE_HARD=ON CMAKE_OPTIONS: -A x64 -DWIN32_LEAKCHECK=ON -DDEPRECATE_HARD=ON
SKIP_SSH_TESTS: true SKIP_SSH_TESTS: true
SKIP_NEGOTIATE_TESTS: true SKIP_NEGOTIATE_TESTS: true
- # Windows x86 Visual Studio - name: "Windows (x86, Visual Studio)"
os: windows-2019 os: windows-2019
env: env:
ARCH: x86 ARCH: x86
@ -182,7 +181,7 @@ jobs:
CMAKE_OPTIONS: -A Win32 -DWIN32_LEAKCHECK=ON -DDEPRECATE_HARD=ON -DUSE_SHA1=HTTPS -DUSE_BUNDLED_ZLIB=ON CMAKE_OPTIONS: -A Win32 -DWIN32_LEAKCHECK=ON -DDEPRECATE_HARD=ON -DUSE_SHA1=HTTPS -DUSE_BUNDLED_ZLIB=ON
SKIP_SSH_TESTS: true SKIP_SSH_TESTS: true
SKIP_NEGOTIATE_TESTS: true SKIP_NEGOTIATE_TESTS: true
- # Windows amd64 mingw - name: "Windows (amd64, mingw)"
os: windows-2019 os: windows-2019
setup-script: mingw setup-script: mingw
env: env:
@ -193,7 +192,7 @@ jobs:
BUILD_PATH: D:\Temp\mingw64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin BUILD_PATH: D:\Temp\mingw64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
SKIP_SSH_TESTS: true SKIP_SSH_TESTS: true
SKIP_NEGOTIATE_TESTS: true SKIP_NEGOTIATE_TESTS: true
- # Windows x86 mingw - name: "Windows (x86, mingw)"
os: windows-2019 os: windows-2019
setup-script: mingw setup-script: mingw
env: env:
@ -207,6 +206,7 @@ jobs:
fail-fast: false fail-fast: false
env: ${{ matrix.platform.env }} env: ${{ matrix.platform.env }}
runs-on: ${{ matrix.platform.os }} runs-on: ${{ matrix.platform.os }}
name: "Build: ${{ matrix.platform.name }}"
steps: steps:
- name: Check out repository - name: Check out repository
uses: actions/checkout@v2 uses: actions/checkout@v2
@ -269,7 +269,7 @@ jobs:
# published to our documentation site. # published to our documentation site.
documentation: documentation:
name: Generate documentation name: Generate documentation
needs: [build_containers] needs: [ containers ]
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Check out repository - name: Check out repository
@ -300,4 +300,4 @@ jobs:
- name: Push documentation branch - name: Push documentation branch
working-directory: source working-directory: source
run: git push origin gh-pages 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'

View File

@ -15,71 +15,71 @@ jobs:
# targets and their details. Then we build either in a docker container # targets and their details. Then we build either in a docker container
# (Linux) or on the actual hosts (macOS, Windows). # (Linux) or on the actual hosts (macOS, Windows).
build: build:
name: Build
strategy: strategy:
matrix: matrix:
platform: platform:
- # Xenial, GCC, OpenSSL - name: Linux (Xenial, GCC, OpenSSL)
container: container:
name: xenial name: xenial
env: env:
CC: gcc CC: gcc
CMAKE_GENERATOR: Ninja 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 os: ubuntu-latest
- # Xenial, GCC, mbedTLS - name: "Linux (Xenial, GCC, mbedTLS)"
container: container:
name: xenial name: xenial
env: env:
CC: gcc CC: gcc
CMAKE_GENERATOR: Ninja 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 os: ubuntu-latest
- # Xenial, Clang, OpenSSL - name: "Linux (Xenial, Clang, OpenSSL)"
container: container:
name: xenial name: xenial
env: env:
CC: clang CC: clang
CMAKE_GENERATOR: Ninja 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 os: ubuntu-latest
- # Xenial, Clang, mbedTLS - name: "Linux (Xenial, Clang, mbedTLS)"
container: container:
name: xenial name: xenial
env: env:
CC: clang 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 CMAKE_GENERATOR: Ninja
os: ubuntu-latest os: ubuntu-latest
- # Xenial, GCC, thread-free - name: "Linux (no threads)"
container: container:
name: xenial name: xenial
env: env:
CC: gcc 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 CMAKE_GENERATOR: Ninja
os: ubuntu-latest os: ubuntu-latest
- # Xenial, Clang, OpenSSL (dynamically loaded) - name: "Linux (dynamically-loaded OpenSSL)"
container: container:
name: xenial name: xenial
env: env:
CC: clang 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 CMAKE_GENERATOR: Ninja
os: ubuntu-latest os: ubuntu-latest
- # Focal, Clang 10, mbedTLS, MemorySanitizer - name: "Linux (MemorySanitizer)"
container: container:
name: focal name: focal
env: env:
CC: clang-10 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 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 CMAKE_GENERATOR: Ninja
SKIP_SSH_TESTS: true SKIP_SSH_TESTS: true
SKIP_NEGOTIATE_TESTS: true SKIP_NEGOTIATE_TESTS: true
ASAN_SYMBOLIZER_PATH: /usr/bin/llvm-symbolizer-10 ASAN_SYMBOLIZER_PATH: /usr/bin/llvm-symbolizer-10
UBSAN_OPTIONS: print_stacktrace=1
os: ubuntu-latest os: ubuntu-latest
- # Focal, Clang 10, OpenSSL, UndefinedBehaviorSanitizer - name: "Linux (UndefinedBehaviorSanitizer)"
container: container:
name: focal name: focal
env: env:
@ -91,7 +91,7 @@ jobs:
SKIP_NEGOTIATE_TESTS: true SKIP_NEGOTIATE_TESTS: true
ASAN_SYMBOLIZER_PATH: /usr/bin/llvm-symbolizer-10 ASAN_SYMBOLIZER_PATH: /usr/bin/llvm-symbolizer-10
os: ubuntu-latest os: ubuntu-latest
- # Focal, Clang 10, OpenSSL, ThreadSanitizer - name: "Linux (ThreadSanitizer)"
container: container:
name: focal name: focal
env: env:
@ -104,7 +104,7 @@ jobs:
ASAN_SYMBOLIZER_PATH: /usr/bin/llvm-symbolizer-10 ASAN_SYMBOLIZER_PATH: /usr/bin/llvm-symbolizer-10
TSAN_OPTIONS: suppressions=/home/libgit2/source/script/thread-sanitizer.supp second_deadlock_stack=1 TSAN_OPTIONS: suppressions=/home/libgit2/source/script/thread-sanitizer.supp second_deadlock_stack=1
os: ubuntu-latest os: ubuntu-latest
- # Focal, Clang 10, mmap emulation (NO_MMAP) - name: "Linux (no mmap)"
container: container:
name: focal name: focal
env: env:
@ -115,23 +115,23 @@ jobs:
SKIP_SSH_TESTS: true SKIP_SSH_TESTS: true
SKIP_NEGOTIATE_TESTS: true SKIP_NEGOTIATE_TESTS: true
os: ubuntu-latest os: ubuntu-latest
- # CentOS 7 - name: "Linux (CentOS 7)"
container: container:
name: centos7 name: centos7
env: 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 PKG_CONFIG_PATH: /usr/local/lib/pkgconfig
SKIP_NEGOTIATE_TESTS: true SKIP_NEGOTIATE_TESTS: true
os: ubuntu-latest os: ubuntu-latest
- # CentOS 7, OpenSSL (dynamically loaded) - name: "Linux (CentOS 7, dynamically-loaded OpenSSL)"
container: container:
name: centos7 name: centos7
env: 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 PKG_CONFIG_PATH: /usr/local/lib/pkgconfig
SKIP_NEGOTIATE_TESTS: true SKIP_NEGOTIATE_TESTS: true
os: ubuntu-latest os: ubuntu-latest
- # CentOS 8 - name: "Linux (CentOS 8)"
container: container:
name: centos8 name: centos8
env: env:
@ -140,7 +140,7 @@ jobs:
SKIP_NEGOTIATE_TESTS: true SKIP_NEGOTIATE_TESTS: true
SKIP_SSH_TESTS: true SKIP_SSH_TESTS: true
os: ubuntu-latest os: ubuntu-latest
- # CentOS 8, OpenSSL (dynamically loaded) - name: "Linux (CentOS 8, dynamically-loaded OpenSSL)"
container: container:
name: centos8 name: centos8
env: env:
@ -149,7 +149,7 @@ jobs:
SKIP_NEGOTIATE_TESTS: true SKIP_NEGOTIATE_TESTS: true
SKIP_SSH_TESTS: true SKIP_SSH_TESTS: true
os: ubuntu-latest os: ubuntu-latest
- # macOS - name: "macOS"
os: macos-10.15 os: macos-10.15
env: env:
CC: clang CC: clang
@ -158,7 +158,7 @@ jobs:
SKIP_SSH_TESTS: true SKIP_SSH_TESTS: true
SKIP_NEGOTIATE_TESTS: true SKIP_NEGOTIATE_TESTS: true
setup-script: osx setup-script: osx
- # Windows amd64 Visual Studio - name: "Windows (amd64, Visual Studio)"
os: windows-2019 os: windows-2019
env: env:
ARCH: amd64 ARCH: amd64
@ -166,7 +166,7 @@ jobs:
CMAKE_OPTIONS: -A x64 -DWIN32_LEAKCHECK=ON -DDEPRECATE_HARD=ON CMAKE_OPTIONS: -A x64 -DWIN32_LEAKCHECK=ON -DDEPRECATE_HARD=ON
SKIP_SSH_TESTS: true SKIP_SSH_TESTS: true
SKIP_NEGOTIATE_TESTS: true SKIP_NEGOTIATE_TESTS: true
- # Windows amd64 Visual Studio (NO_MMAP) - name: "Windows (no mmap)"
os: windows-2019 os: windows-2019
env: env:
ARCH: amd64 ARCH: amd64
@ -175,7 +175,7 @@ jobs:
CMAKE_OPTIONS: -A x64 -DDEPRECATE_HARD=ON CMAKE_OPTIONS: -A x64 -DDEPRECATE_HARD=ON
SKIP_SSH_TESTS: true SKIP_SSH_TESTS: true
SKIP_NEGOTIATE_TESTS: true SKIP_NEGOTIATE_TESTS: true
- # Windows x86 Visual Studio - name: "Windows (x86, Visual Studio)"
os: windows-2019 os: windows-2019
env: env:
ARCH: x86 ARCH: x86
@ -183,7 +183,7 @@ jobs:
CMAKE_OPTIONS: -A Win32 -DWIN32_LEAKCHECK=ON -DDEPRECATE_HARD=ON -DUSE_SHA1=HTTPS -DUSE_BUNDLED_ZLIB=ON CMAKE_OPTIONS: -A Win32 -DWIN32_LEAKCHECK=ON -DDEPRECATE_HARD=ON -DUSE_SHA1=HTTPS -DUSE_BUNDLED_ZLIB=ON
SKIP_SSH_TESTS: true SKIP_SSH_TESTS: true
SKIP_NEGOTIATE_TESTS: true SKIP_NEGOTIATE_TESTS: true
- # Windows amd64 mingw - name: "Windows (amd64, mingw)"
os: windows-2019 os: windows-2019
setup-script: mingw setup-script: mingw
env: env:
@ -194,7 +194,7 @@ jobs:
BUILD_PATH: D:\Temp\mingw64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin BUILD_PATH: D:\Temp\mingw64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
SKIP_SSH_TESTS: true SKIP_SSH_TESTS: true
SKIP_NEGOTIATE_TESTS: true SKIP_NEGOTIATE_TESTS: true
- # Windows x86 mingw - name: "Windows (x86, mingw)"
os: windows-2019 os: windows-2019
setup-script: mingw setup-script: mingw
env: env:
@ -205,17 +205,17 @@ jobs:
BUILD_PATH: D:\Temp\mingw32\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin BUILD_PATH: D:\Temp\mingw32\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
SKIP_SSH_TESTS: true SKIP_SSH_TESTS: true
SKIP_NEGOTIATE_TESTS: true SKIP_NEGOTIATE_TESTS: true
- # Bionic, GCC, OpenSSL (dynamically loaded) - name: "Linux (Bionic, GCC, dynamically-loaded OpenSSL)"
container: container:
name: bionic name: bionic
dockerfile: bionic dockerfile: bionic
env: env:
CC: gcc CC: gcc
CMAKE_GENERATOR: Ninja 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 RUN_INVASIVE_TESTS: true
os: ubuntu-latest os: ubuntu-latest
- # Bionic, x86, Clang, OpenSSL - name: "Linux (x86, Bionic, Clang, OpenSSL)"
container: container:
name: bionic-x86 name: bionic-x86
dockerfile: bionic dockerfile: bionic
@ -223,20 +223,20 @@ jobs:
env: env:
CC: clang CC: clang
CMAKE_GENERATOR: Ninja 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 RUN_INVASIVE_TESTS: true
os: ubuntu-latest os: ubuntu-latest
- # Bionic, x86, GCC, OpenSSL - name: "Linux (x86, Bionic, GCC, OpenSSL)"
container: container:
name: bionic-x86 name: bionic-x86
dockerfile: bionic dockerfile: bionic
env: env:
CC: gcc CC: gcc
CMAKE_GENERATOR: Ninja 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 RUN_INVASIVE_TESTS: true
os: ubuntu-latest os: ubuntu-latest
- # Bionic, arm32, GCC, OpenSSL - name: "Linux (arm32, Bionic, GCC, OpenSSL)"
container: container:
name: bionic-arm32 name: bionic-arm32
dockerfile: bionic dockerfile: bionic
@ -244,11 +244,11 @@ jobs:
env: env:
CC: gcc CC: gcc
CMAKE_GENERATOR: Ninja 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 RUN_INVASIVE_TESTS: true
SKIP_PROXY_TESTS: true SKIP_PROXY_TESTS: true
os: ubuntu-latest os: ubuntu-latest
- # Bionic, arm64, GCC, OpenSSL - name: "Linux (arm64, Bionic, GCC, OpenSSL)"
container: container:
name: bionic-arm64 name: bionic-arm64
dockerfile: bionic dockerfile: bionic
@ -256,11 +256,12 @@ jobs:
env: env:
CC: gcc CC: gcc
CMAKE_GENERATOR: Ninja 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 RUN_INVASIVE_TESTS: true
SKIP_PROXY_TESTS: true SKIP_PROXY_TESTS: true
os: ubuntu-latest os: ubuntu-latest
fail-fast: false fail-fast: false
name: "Build ${{ matrix.platform.name }}"
env: ${{ matrix.platform.env }} env: ${{ matrix.platform.env }}
runs-on: ${{ matrix.platform.os }} runs-on: ${{ matrix.platform.os }}
steps: steps:

4
.vscode/launch.json vendored
View File

@ -8,7 +8,7 @@
"name": "(gdb) Launch", "name": "(gdb) Launch",
"type": "cppdbg", "type": "cppdbg",
"request": "launch", "request": "launch",
"program": "${workspaceFolder}/build/libgit2_clar", "program": "${workspaceFolder}/build/libgit2_tests",
"args": [], "args": [],
"stopAtEntry": false, "stopAtEntry": false,
"cwd": "${fileDirname}", "cwd": "${fileDirname}",
@ -24,4 +24,4 @@
] ]
} }
] ]
} }

4
.vscode/tasks.json vendored
View File

@ -16,7 +16,7 @@
{ {
"label": "Run Tests", "label": "Run Tests",
"type": "shell", "type": "shell",
"command": "build/libgit2_clar -v", "command": "build/libgit2_tests -v",
"group": "test", "group": "test",
"presentation": { "presentation": {
"reveal": "always", "reveal": "always",
@ -24,4 +24,4 @@
} }
} }
] ]
} }

View File

@ -1,306 +1,133 @@
# CMake build script for the libgit2 project # CMake build script for the libgit2 project
# # See `README.md` for build instructions.
# Building (out of source build):
# > mkdir build && cd build
# > cmake .. [-DSETTINGS=VALUE]
# > cmake --build .
#
# Testing:
# > ctest -V
#
# Install:
# > cmake --build . --target install
CMAKE_MINIMUM_REQUIRED(VERSION 3.5.1) cmake_minimum_required(VERSION 3.5.1)
project(libgit2 VERSION "1.3.0" LANGUAGES C) project(libgit2 VERSION "1.4.3" LANGUAGES C)
# Add find modules to the path # Add find modules to the path
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${libgit2_SOURCE_DIR}/cmake/") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")
INCLUDE(CheckLibraryExists)
INCLUDE(CheckFunctionExists)
INCLUDE(CheckSymbolExists)
INCLUDE(CheckStructHasMember)
INCLUDE(CheckPrototypeDefinition) # Added in CMake 3.0
INCLUDE(AddCFlagIfSupported)
INCLUDE(FindPkgLibraries)
INCLUDE(FindThreads)
INCLUDE(FindStatNsec)
INCLUDE(Findfutimens)
INCLUDE(GNUInstallDirs)
INCLUDE(IdeSplitSources)
INCLUDE(FeatureSummary)
INCLUDE(EnableWarnings)
#
# Build options # Build options
# #
OPTION(SONAME "Set the (SO)VERSION of the target" ON)
OPTION(BUILD_SHARED_LIBS "Build Shared Library (OFF for Static)" ON)
OPTION(THREADSAFE "Build libgit2 as threadsafe" ON)
OPTION(BUILD_CLAR "Build Tests using the Clar suite" ON)
OPTION(BUILD_EXAMPLES "Build library usage example apps" OFF)
OPTION(BUILD_FUZZERS "Build the fuzz targets" OFF)
OPTION(ENABLE_TRACE "Enables tracing support" ON)
OPTION(LIBGIT2_FILENAME "Name of the produced binary" OFF)
OPTION(USE_SSH "Link with libssh2 to enable SSH support" ON)
OPTION(USE_HTTPS "Enable HTTPS support. Can be set to a specific backend" ON)
OPTION(USE_SHA1 "Enable SHA1. Can be set to CollisionDetection(ON)/HTTPS/Generic" ON)
OPTION(USE_GSSAPI "Link with libgssapi for SPNEGO auth" OFF)
OPTION(USE_STANDALONE_FUZZERS "Enable standalone fuzzers (compatible with gcc)" OFF)
OPTION(USE_LEAK_CHECKER "Run tests with leak checker" OFF)
OPTION(DEBUG_POOL "Enable debug pool allocator" OFF)
OPTION(DEBUG_STRICT_ALLOC "Enable strict allocator behavior" OFF)
OPTION(DEBUG_STRICT_OPEN "Enable path validation in open" OFF)
OPTION(ENABLE_WERROR "Enable compilation with -Werror" OFF)
OPTION(USE_BUNDLED_ZLIB "Use the bundled version of zlib. Can be set to one of Bundled(ON)/Chromium. The Chromium option requires a x86_64 processor with SSE4.2 and CLMUL" OFF)
SET(USE_HTTP_PARSER "" CACHE STRING "Specifies the HTTP Parser implementation; either system or builtin.")
OPTION(DEPRECATE_HARD "Do not include deprecated functions in the library" OFF)
SET(REGEX_BACKEND "" CACHE STRING "Regular expression implementation. One of regcomp_l, pcre2, pcre, regcomp, or builtin.")
IF (UNIX) # Optional subsystems
IF (NOT USE_HTTPS) option(BUILD_SHARED_LIBS "Build Shared Library (OFF for Static)" ON)
OPTION(USE_NTLMCLIENT "Enable NTLM support on Unix." OFF ) option(BUILD_TESTS "Build Tests using the Clar suite" ON)
ELSE() option(BUILD_EXAMPLES "Build library usage example apps" OFF)
OPTION(USE_NTLMCLIENT "Enable NTLM support on Unix." ON ) option(BUILD_FUZZERS "Build the fuzz targets" OFF)
ENDIF()
ENDIF()
IF (UNIX AND NOT APPLE) # Suggested functionality that may not be available on a per-platform basis
OPTION(ENABLE_REPRODUCIBLE_BUILDS "Enable reproducible builds" OFF) option(USE_THREADS "Use threads for parallel processing when possible" ON)
ENDIF() option(USE_NSEC "Support nanosecond precision file mtimes and ctimes" ON)
IF (APPLE) # Backend selection
OPTION(USE_ICONV "Link with and use iconv library" ON) option(USE_SSH "Link with libssh2 to enable SSH support" OFF)
ENDIF() option(USE_HTTPS "Enable HTTPS support. Can be set to a specific backend" ON)
option(USE_SHA1 "Enable SHA1. Can be set to CollisionDetection(ON)/HTTPS/Generic" ON)
option(USE_GSSAPI "Link with libgssapi for SPNEGO auth" OFF)
set(USE_HTTP_PARSER "" CACHE STRING "Specifies the HTTP Parser implementation; either system or builtin.")
set(REGEX_BACKEND "" CACHE STRING "Regular expression implementation. One of regcomp_l, pcre2, pcre, regcomp, or builtin.")
option(USE_BUNDLED_ZLIB "Use the bundled version of zlib. Can be set to one of Bundled(ON)/Chromium. The Chromium option requires a x86_64 processor with SSE4.2 and CLMUL" OFF)
IF(MSVC) # Debugging options
option(USE_LEAK_CHECKER "Run tests with leak checker" OFF)
option(USE_STANDALONE_FUZZERS "Enable standalone fuzzers (compatible with gcc)" OFF)
option(DEBUG_POOL "Enable debug pool allocator" OFF)
option(DEBUG_STRICT_ALLOC "Enable strict allocator behavior" OFF)
option(DEBUG_STRICT_OPEN "Enable path validation in open" OFF)
# Output options
option(SONAME "Set the (SO)VERSION of the target" ON)
set(LIBGIT2_FILENAME "git2" CACHE STRING "Name of the produced binary")
option(DEPRECATE_HARD "Do not include deprecated functions in the library" OFF)
# Compilation options
option(ENABLE_WERROR "Enable compilation with -Werror" OFF)
if(UNIX)
# NTLM client requires crypto libraries from the system HTTPS stack
if(NOT USE_HTTPS)
option(USE_NTLMCLIENT "Enable NTLM support on Unix." OFF)
else()
option(USE_NTLMCLIENT "Enable NTLM support on Unix." ON)
endif()
option(ENABLE_REPRODUCIBLE_BUILDS "Enable reproducible builds" OFF)
endif()
if(APPLE)
option(USE_ICONV "Link with and use iconv library" ON)
endif()
if(MSVC)
# This option must match the settings used in your program, in particular if you # This option must match the settings used in your program, in particular if you
# are linking statically # are linking statically
OPTION(STATIC_CRT "Link the static CRT libraries" ON) option(STATIC_CRT "Link the static CRT libraries" ON)
# If you want to embed a copy of libssh2 into libgit2, pass a # If you want to embed a copy of libssh2 into libgit2, pass a
# path to libssh2 # path to libssh2
OPTION(EMBED_SSH_PATH "Path to libssh2 to embed (Windows)" OFF) option(EMBED_SSH_PATH "Path to libssh2 to embed (Windows)" OFF)
ENDIF()
IF(WIN32)
# By default, libgit2 is built with WinHTTP. To use the built-in
# HTTP transport, invoke CMake with the "-DWINHTTP=OFF" argument.
OPTION(WINHTTP "Use Win32 WinHTTP routines" ON)
ENDIF()
IF(MSVC)
# Enable leak checking using the debugging C runtime. # Enable leak checking using the debugging C runtime.
OPTION(WIN32_LEAKCHECK "Enable leak reporting via crtdbg" OFF) option(WIN32_LEAKCHECK "Enable leak reporting via crtdbg" OFF)
ENDIF() endif()
IF (DEPRECATE_HARD) if(WIN32)
ADD_DEFINITIONS(-DGIT_DEPRECATE_HARD) # By default, libgit2 is built with WinHTTP. To use the built-in
ENDIF() # HTTP transport, invoke CMake with the "-DUSE_WINHTTP=OFF" argument.
option(USE_WINHTTP "Use Win32 WinHTTP routines" ON)
endif()
# Platform specific compilation flags if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
IF (MSVC) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
IF (STDCALL) endif()
MESSAGE(FATAL_ERROR "The STDCALL option is no longer supported; libgit2 is now always built as a cdecl library. If you're using PInvoke, please add the CallingConventions.Cdecl attribute for support.")
ENDIF()
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}") # Modules
# /GF - String pooling include(CheckLibraryExists)
# /MP - Parallel build include(CheckFunctionExists)
SET(CMAKE_C_FLAGS "/GF /MP /nologo ${CMAKE_C_FLAGS}") include(CheckSymbolExists)
include(CheckStructHasMember)
include(CheckPrototypeDefinition)
include(AddCFlagIfSupported)
include(FindPkgLibraries)
include(FindThreads)
include(FindStatNsec)
include(Findfutimens)
include(GNUInstallDirs)
include(IdeSplitSources)
include(FeatureSummary)
include(EnableWarnings)
include(DefaultCFlags)
# /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 # Subdirectories
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /guard:cf") #
ENDIF()
IF (STATIC_CRT) add_subdirectory(src)
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) if(BUILD_TESTS)
SET(GIT_WIN32_LEAKCHECK 1) enable_testing()
SET(CRT_FLAG_DEBUG "${CRT_FLAG_DEBUG}") add_subdirectory(tests)
SET(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES} Dbghelp.lib") endif()
ENDIF()
# /Zi - Create debugging information if(BUILD_EXAMPLES)
# /Od - Disable optimization add_subdirectory(examples)
# /D_DEBUG - #define _DEBUG endif()
# /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 if(BUILD_FUZZERS)
# /MT - Statically link the multithreaded release version of the CRT if((BUILD_TESTS OR BUILD_EXAMPLES) AND NOT USE_STANDALONE_FUZZERS)
# /MD - Dynamically link the multithreaded release version of the CRT message(FATAL_ERROR "Cannot build the fuzzer and the tests or examples together")
# /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()
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(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()
ENDIF() add_subdirectory(fuzzers)
endif()
# Ensure that MinGW provides the correct header files.
IF (WIN32 AND NOT CYGWIN)
ADD_DEFINITIONS(-DWIN32 -D_WIN32_WINNT=0x0600)
ENDIF()
IF( NOT CMAKE_CONFIGURATION_TYPES ) # Summary
# Build Debug by default
IF (NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
ENDIF ()
ELSE()
# Using a multi-configuration generator eg MSVC or Xcode
# that uses CMAKE_CONFIGURATION_TYPES and not CMAKE_BUILD_TYPE
ENDIF()
IF(BUILD_FUZZERS AND NOT USE_STANDALONE_FUZZERS) feature_summary(WHAT ENABLED_FEATURES DESCRIPTION "Enabled features:")
# The actual sanitizer link target will be added when linking the fuzz feature_summary(WHAT DISABLED_FEATURES DESCRIPTION "Disabled features:")
# targets.
SET(CMAKE_REQUIRED_FLAGS "-fsanitize=fuzzer-no-link")
ADD_C_FLAG(-fsanitize=fuzzer-no-link)
UNSET(CMAKE_REQUIRED_FLAGS)
ENDIF ()
ADD_SUBDIRECTORY(src)
# Tests
IF (NOT MSVC)
IF (NOT BUILD_SHARED_LIBS)
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
ENDIF()
ENDIF ()
IF (BUILD_CLAR)
ENABLE_TESTING()
ADD_SUBDIRECTORY(tests)
ENDIF ()
IF (BUILD_EXAMPLES)
ADD_SUBDIRECTORY(examples)
ENDIF ()
IF(BUILD_FUZZERS)
IF(NOT USE_STANDALONE_FUZZERS)
IF(BUILD_EXAMPLES)
MESSAGE(FATAL_ERROR "Cannot build the fuzzer targets and the examples together")
ENDIF()
IF(BUILD_CLAR)
MESSAGE(FATAL_ERROR "Cannot build the fuzzer targets and the tests together")
ENDIF()
ENDIF()
ADD_SUBDIRECTORY(fuzzers)
ENDIF()
FEATURE_SUMMARY(WHAT ENABLED_FEATURES DESCRIPTION "Enabled features:")
FEATURE_SUMMARY(WHAT DISABLED_FEATURES DESCRIPTION "Disabled features:")

55
COPYING
View File

@ -406,30 +406,35 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
---------------------------------------------------------------------- ----------------------------------------------------------------------
The regex library (deps/regex/) is licensed under the GNU LGPL The bundled PCRE implementation (deps/pcre/) is licensed under the BSD
(available at the end of this file). license.
Definitions for data structures and routines for the regular Redistribution and use in source and binary forms, with or without
expression library. modification, are permitted provided that the following conditions are met:
Copyright (C) 1985,1989-93,1995-98,2000,2001,2002,2003,2005,2006,2008 * Redistributions of source code must retain the above copyright notice,
Free Software Foundation, Inc. this list of conditions and the following disclaimer.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or * Redistributions in binary form must reproduce the above copyright
modify it under the terms of the GNU Lesser General Public notice, this list of conditions and the following disclaimer in the
License as published by the Free Software Foundation; either documentation and/or other materials provided with the distribution.
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful, * Neither the name of the University of Cambridge nor the name of Google
but WITHOUT ANY WARRANTY; without even the implied warranty of Inc. nor the names of their contributors may be used to endorse or
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU promote products derived from this software without specific prior
Lesser General Public License for more details. written permission.
You should have received a copy of the GNU Lesser General Public THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
License along with the GNU C Library; if not, write to the Free AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
02110-1301 USA. ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------- ----------------------------------------------------------------------
@ -1127,3 +1132,15 @@ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE. OF THE POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------
The xoroshiro256** implementation is licensed in the public domain:
Written in 2018 by David Blackman and Sebastiano Vigna (vigna@acm.org)
To the extent possible under law, the author has dedicated all copyright
and related and neighboring rights to this software to the public domain
worldwide. This software is distributed without any warranty.
See <http://creativecommons.org/publicdomain/zero/1.0/>.

View File

@ -4,8 +4,8 @@ libgit2 - the Git linkable library
| Build Status | | | Build Status | |
| ------------ | - | | ------------ | - |
| **main** branch CI builds | [![CI Build](https://github.com/libgit2/libgit2/workflows/CI%20Build/badge.svg?event=push)](https://github.com/libgit2/libgit2/actions?query=workflow%3A%22CI+Build%22+event%3Apush) | | **main** branch CI builds | [![CI Build](https://github.com/libgit2/libgit2/workflows/CI%20Build/badge.svg?event=push)](https://github.com/libgit2/libgit2/actions?query=workflow%3A%22CI+Build%22+event%3Apush) |
| **v1.2 branch** CI builds | [![CI Build](https://github.com/libgit2/libgit2/workflows/CI%20Build/badge.svg?branch=maint%2Fv1.2&event=push)](https://github.com/libgit2/libgit2/actions?query=workflow%3A%22CI+Build%22+event%3Apush+branch%3Amaint%2Fv1.2) | | **v1.4 branch** CI builds | [![CI Build](https://github.com/libgit2/libgit2/workflows/CI%20Build/badge.svg?branch=maint%2Fv1.4&event=push)](https://github.com/libgit2/libgit2/actions?query=workflow%3A%22CI+Build%22+event%3Apush+branch%3Amaint%2Fv1.4) |
| **v1.1 branch** CI builds | [![CI Build](https://github.com/libgit2/libgit2/workflows/CI%20Build/badge.svg?branch=maint%2Fv1.1&event=push)](https://github.com/libgit2/libgit2/actions?query=workflow%3A%22CI+Build%22+event%3Apush+branch%3Amaint%2Fv1.1) | | **v1.3 branch** CI builds | [![CI Build](https://github.com/libgit2/libgit2/workflows/CI%20Build/badge.svg?branch=maint%2Fv1.3&event=push)](https://github.com/libgit2/libgit2/actions?query=workflow%3A%22CI+Build%22+event%3Apush+branch%3Amaint%2Fv1.3) |
| **Nightly** builds | [![Nightly Build](https://github.com/libgit2/libgit2/workflows/Nightly%20Build/badge.svg)](https://github.com/libgit2/libgit2/actions?query=workflow%3A%22Nightly+Build%22) [![Coverity Scan Status](https://scan.coverity.com/projects/639/badge.svg)](https://scan.coverity.com/projects/639) | | **Nightly** builds | [![Nightly Build](https://github.com/libgit2/libgit2/workflows/Nightly%20Build/badge.svg)](https://github.com/libgit2/libgit2/actions?query=workflow%3A%22Nightly+Build%22) [![Coverity Scan Status](https://scan.coverity.com/projects/639/badge.svg)](https://scan.coverity.com/projects/639) |
`libgit2` is a portable, pure C implementation of the Git core methods `libgit2` is a portable, pure C implementation of the Git core methods
@ -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, 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 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 individual tests, or groups of tests using the `-s` flag. For example, to
run the index tests: run the index tests:
$ ./libgit2_clar -sindex $ ./libgit2_tests -sindex
To run a single test named `index::racy::diff`, which corresponds to the test 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): 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 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 failing test. An `S` indicates that a test was skipped because it is not
@ -278,8 +278,8 @@ The following CMake variables are declared:
- `CMAKE_INSTALL_LIBDIR`: Where to install libraries to. - `CMAKE_INSTALL_LIBDIR`: Where to install libraries to.
- `CMAKE_INSTALL_INCLUDEDIR`: Where to install headers to. - `CMAKE_INSTALL_INCLUDEDIR`: Where to install headers to.
- `BUILD_SHARED_LIBS`: Build libgit2 as a Shared Library (defaults to ON) - `BUILD_SHARED_LIBS`: Build libgit2 as a Shared Library (defaults to ON)
- `BUILD_CLAR`: Build [Clar](https://github.com/vmg/clar)-based test suite (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 To list all build options and their current value, you can do the
following: following:
@ -301,6 +301,8 @@ compiler and linker. These flags are rarely used but can be useful for
- `CMAKE_FIND_ROOT_PATH`: Override the search path for libraries - `CMAKE_FIND_ROOT_PATH`: Override the search path for libraries
- `ZLIB_LIBRARY`, `OPENSSL_SSL_LIBRARY` AND `OPENSSL_CRYPTO_LIBRARY`: - `ZLIB_LIBRARY`, `OPENSSL_SSL_LIBRARY` AND `OPENSSL_CRYPTO_LIBRARY`:
Tell CMake where to find those specific libraries Tell CMake where to find those specific libraries
- `LINK_WITH_STATIC_LIBRARIES`: Link only with static versions of
system libraries
MacOS X MacOS X
------- -------
@ -392,8 +394,6 @@ Here are the bindings to libgit2 that are currently available:
* Git-Raw <https://github.com/jacquesg/p5-Git-Raw> * Git-Raw <https://github.com/jacquesg/p5-Git-Raw>
* PHP * PHP
* php-git <https://github.com/libgit2/php-git> * php-git <https://github.com/libgit2/php-git>
* PowerShell
* PSGit <https://github.com/PoshCode/PSGit>
* Python * Python
* pygit2 <https://github.com/libgit2/pygit2> * pygit2 <https://github.com/libgit2/pygit2>
* R * R

View File

@ -83,7 +83,7 @@ echo "##########################################################################
if [ -z "$SKIP_GITDAEMON_TESTS" ]; then if [ -z "$SKIP_GITDAEMON_TESTS" ]; then
echo "Starting git daemon..." echo "Starting git daemon..."
GITDAEMON_DIR=`mktemp -d ${TMPDIR}/gitdaemon.XXXXXXXX` GITDAEMON_DIR=`mktemp -d ${TMPDIR}/gitdaemon.XXXXXXXX`
git init --bare "${GITDAEMON_DIR}/test.git" git init --bare "${GITDAEMON_DIR}/test.git" >/dev/null
git daemon --listen=localhost --export-all --enable=receive-pack --base-path="${GITDAEMON_DIR}" "${GITDAEMON_DIR}" 2>/dev/null & git daemon --listen=localhost --export-all --enable=receive-pack --base-path="${GITDAEMON_DIR}" "${GITDAEMON_DIR}" 2>/dev/null &
GITDAEMON_PID=$! GITDAEMON_PID=$!
disown $GITDAEMON_PID disown $GITDAEMON_PID
@ -101,8 +101,8 @@ if [ -z "$SKIP_PROXY_TESTS" ]; then
java -jar poxyproxy.jar --address 127.0.0.1 --port 8090 --credentials foo:bar --auth-type ntlm --quiet & java -jar poxyproxy.jar --address 127.0.0.1 --port 8090 --credentials foo:bar --auth-type ntlm --quiet &
fi fi
if [ -z "$SKIP_NTLM_TESTS" ]; then if [ -z "$SKIP_NTLM_TESTS" -o -z "$SKIP_ONLINE_TESTS" ]; then
curl --location --silent --show-error https://github.com/ethomson/poxygit/releases/download/v0.4.0/poxygit-0.4.0.jar >poxygit.jar curl --location --silent --show-error https://github.com/ethomson/poxygit/releases/download/v0.5.1/poxygit-0.5.1.jar >poxygit.jar
echo "" echo ""
echo "Starting HTTP server..." echo "Starting HTTP server..."
@ -112,10 +112,11 @@ if [ -z "$SKIP_NTLM_TESTS" ]; then
fi fi
if [ -z "$SKIP_SSH_TESTS" ]; then if [ -z "$SKIP_SSH_TESTS" ]; then
echo ""
echo "Starting ssh daemon..." echo "Starting ssh daemon..."
HOME=`mktemp -d ${TMPDIR}/home.XXXXXXXX` HOME=`mktemp -d ${TMPDIR}/home.XXXXXXXX`
SSHD_DIR=`mktemp -d ${TMPDIR}/sshd.XXXXXXXX` SSHD_DIR=`mktemp -d ${TMPDIR}/sshd.XXXXXXXX`
git init --bare "${SSHD_DIR}/test.git" git init --bare "${SSHD_DIR}/test.git" >/dev/null
cat >"${SSHD_DIR}/sshd_config" <<-EOF cat >"${SSHD_DIR}/sshd_config" <<-EOF
Port 2222 Port 2222
ListenAddress 0.0.0.0 ListenAddress 0.0.0.0
@ -188,9 +189,11 @@ if [ -z "$SKIP_ONLINE_TESTS" ]; then
echo "## Running (online) tests" echo "## Running (online) tests"
echo "##############################################################################" echo "##############################################################################"
export GITTEST_FLAKY_RETRY=5 export GITTEST_REMOTE_REDIRECT_INITIAL="http://localhost:9000/initial-redirect/libgit2/TestGitRepository"
export GITTEST_REMOTE_REDIRECT_SUBSEQUENT="http://localhost:9000/subsequent-redirect/libgit2/TestGitRepository"
run_test online run_test online
unset GITTEST_FLAKY_RETRY unset GITTEST_REMOTE_REDIRECT_INITIAL
unset GITTEST_REMOTE_REDIRECT_SUBSEQUENT
# Run the online tests that immutably change global state separately # Run the online tests that immutably change global state separately
# to avoid polluting the test environment. # to avoid polluting the test environment.
@ -231,9 +234,7 @@ if [ -z "$SKIP_PROXY_TESTS" ]; then
export GITTEST_REMOTE_PROXY_HOST="localhost:8090" export GITTEST_REMOTE_PROXY_HOST="localhost:8090"
export GITTEST_REMOTE_PROXY_USER="foo" export GITTEST_REMOTE_PROXY_USER="foo"
export GITTEST_REMOTE_PROXY_PASS="bar" export GITTEST_REMOTE_PROXY_PASS="bar"
export GITTEST_FLAKY_RETRY=5
run_test proxy run_test proxy
unset GITTEST_FLAKY_RETRY
unset GITTEST_REMOTE_PROXY_HOST unset GITTEST_REMOTE_PROXY_HOST
unset GITTEST_REMOTE_PROXY_USER unset GITTEST_REMOTE_PROXY_USER
unset GITTEST_REMOTE_PROXY_PASS unset GITTEST_REMOTE_PROXY_PASS
@ -299,18 +300,28 @@ if [ -z "$SKIP_NEGOTIATE_TESTS" -a -n "$GITTEST_NEGOTIATE_PASSWORD" ]; then
fi fi
if [ -z "$SKIP_SSH_TESTS" ]; then if [ -z "$SKIP_SSH_TESTS" ]; then
echo ""
echo "Running ssh tests"
echo ""
export GITTEST_REMOTE_URL="ssh://localhost:2222/$SSHD_DIR/test.git"
export GITTEST_REMOTE_USER=$USER export GITTEST_REMOTE_USER=$USER
export GITTEST_REMOTE_SSH_KEY="${HOME}/.ssh/id_rsa" export GITTEST_REMOTE_SSH_KEY="${HOME}/.ssh/id_rsa"
export GITTEST_REMOTE_SSH_PUBKEY="${HOME}/.ssh/id_rsa.pub" export GITTEST_REMOTE_SSH_PUBKEY="${HOME}/.ssh/id_rsa.pub"
export GITTEST_REMOTE_SSH_PASSPHRASE="" export GITTEST_REMOTE_SSH_PASSPHRASE=""
export GITTEST_REMOTE_SSH_FINGERPRINT="${SSH_FINGERPRINT}" export GITTEST_REMOTE_SSH_FINGERPRINT="${SSH_FINGERPRINT}"
echo ""
echo "Running ssh tests"
echo ""
export GITTEST_REMOTE_URL="ssh://localhost:2222/$SSHD_DIR/test.git"
run_test ssh run_test ssh
unset GITTEST_REMOTE_URL unset GITTEST_REMOTE_URL
echo ""
echo "Running ssh tests (scp-style paths)"
echo ""
export GITTEST_REMOTE_URL="[localhost:2222]:$SSHD_DIR/test.git"
run_test ssh
unset GITTEST_REMOTE_URL
unset GITTEST_REMOTE_USER unset GITTEST_REMOTE_USER
unset GITTEST_REMOTE_SSH_KEY unset GITTEST_REMOTE_SSH_KEY
unset GITTEST_REMOTE_SSH_PUBKEY unset GITTEST_REMOTE_SSH_PUBKEY

View File

@ -3,28 +3,28 @@
# <flag> - the compiler flag to test # <flag> - the compiler flag to test
# This internally calls the CHECK_C_COMPILER_FLAG macro. # This internally calls the CHECK_C_COMPILER_FLAG macro.
INCLUDE(CheckCCompilerFlag) include(CheckCCompilerFlag)
MACRO(ADD_C_FLAG _FLAG) macro(ADD_C_FLAG _FLAG)
STRING(TOUPPER ${_FLAG} UPCASE) string(TOUPPER ${_FLAG} UPCASE)
STRING(REGEX REPLACE "[-=]" "_" UPCASE_PRETTY ${UPCASE}) string(REGEX REPLACE "[-=]" "_" UPCASE_PRETTY ${UPCASE})
STRING(REGEX REPLACE "^_+" "" UPCASE_PRETTY ${UPCASE_PRETTY}) string(REGEX REPLACE "^_+" "" UPCASE_PRETTY ${UPCASE_PRETTY})
CHECK_C_COMPILER_FLAG(${_FLAG} IS_${UPCASE_PRETTY}_SUPPORTED) check_c_compiler_flag(${_FLAG} IS_${UPCASE_PRETTY}_SUPPORTED)
IF(IS_${UPCASE_PRETTY}_SUPPORTED) if(IS_${UPCASE_PRETTY}_SUPPORTED)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_FLAG}") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_FLAG}")
ELSE() else()
MESSAGE(FATAL_ERROR "Required flag ${_FLAG} is not supported") message(FATAL_ERROR "Required flag ${_FLAG} is not supported")
ENDIF() endif()
ENDMACRO() endmacro()
MACRO(ADD_C_FLAG_IF_SUPPORTED _FLAG) macro(ADD_C_FLAG_IF_SUPPORTED _FLAG)
STRING(TOUPPER ${_FLAG} UPCASE) string(TOUPPER ${_FLAG} UPCASE)
STRING(REGEX REPLACE "[-=]" "_" UPCASE_PRETTY ${UPCASE}) string(REGEX REPLACE "[-=]" "_" UPCASE_PRETTY ${UPCASE})
STRING(REGEX REPLACE "^_+" "" UPCASE_PRETTY ${UPCASE_PRETTY}) string(REGEX REPLACE "^_+" "" UPCASE_PRETTY ${UPCASE_PRETTY})
CHECK_C_COMPILER_FLAG(${_FLAG} IS_${UPCASE_PRETTY}_SUPPORTED) check_c_compiler_flag(${_FLAG} IS_${UPCASE_PRETTY}_SUPPORTED)
IF(IS_${UPCASE_PRETTY}_SUPPORTED) if(IS_${UPCASE_PRETTY}_SUPPORTED)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_FLAG}") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_FLAG}")
ENDIF() endif()
ENDMACRO() endmacro()

154
cmake/DefaultCFlags.cmake Normal file
View File

@ -0,0 +1,154 @@
# 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 AND LINK_WITH_STATIC_LIBRARIES)
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()

View File

@ -1,15 +1,15 @@
MACRO(ENABLE_WARNINGS flag) macro(ENABLE_WARNINGS flag)
ADD_C_FLAG_IF_SUPPORTED(-W${flag}) add_c_flag_if_supported(-W${flag})
ENDMACRO() endmacro()
MACRO(DISABLE_WARNINGS flag) macro(DISABLE_WARNINGS flag)
ADD_C_FLAG_IF_SUPPORTED(-Wno-${flag}) add_c_flag_if_supported(-Wno-${flag})
ENDMACRO() endmacro()
IF(ENABLE_WERROR) if(ENABLE_WERROR)
IF(MSVC) if(MSVC)
ADD_COMPILE_OPTIONS(-WX) add_compile_options(-WX)
ELSE() else()
ADD_C_FLAG_IF_SUPPORTED(-Werror) add_c_flag_if_supported(-Werror)
ENDIF() endif()
ENDIF() endif()

View File

@ -6,21 +6,21 @@
# COREFOUNDATION_LDFLAGS # COREFOUNDATION_LDFLAGS
# #
FIND_PATH(COREFOUNDATION_INCLUDE_DIR NAMES CoreFoundation.h) find_path(COREFOUNDATION_INCLUDE_DIR NAMES CoreFoundation.h)
FIND_LIBRARY(COREFOUNDATION_LIBRARIES NAMES CoreFoundation) find_library(COREFOUNDATION_LIBRARIES NAMES CoreFoundation)
IF (COREFOUNDATION_INCLUDE_DIR AND COREFOUNDATION_LIBRARIES) if(COREFOUNDATION_INCLUDE_DIR AND COREFOUNDATION_LIBRARIES)
IF (NOT CoreFoundation_FIND_QUIETLY) if(NOT CoreFoundation_FIND_QUIETLY)
MESSAGE(STATUS "Found CoreFoundation ${COREFOUNDATION_LIBRARIES}") message(STATUS "Found CoreFoundation ${COREFOUNDATION_LIBRARIES}")
ENDIF() endif()
SET(COREFOUNDATION_FOUND TRUE) set(COREFOUNDATION_FOUND TRUE)
SET(COREFOUNDATION_LDFLAGS "-framework CoreFoundation") set(COREFOUNDATION_LDFLAGS "-framework CoreFoundation")
ENDIF () endif()
IF (CoreFoundation_FIND_REQUIRED AND NOT COREFOUNDATION_FOUND) if(CoreFoundation_FIND_REQUIRED AND NOT COREFOUNDATION_FOUND)
MESSAGE(FATAL_ERROR "CoreFoundation not found") message(FATAL_ERROR "CoreFoundation not found")
ENDIF() endif()
MARK_AS_ADVANCED( mark_as_advanced(
COREFOUNDATION_INCLUDE_DIR COREFOUNDATION_INCLUDE_DIR
COREFOUNDATION_LIBRARIES COREFOUNDATION_LIBRARIES
) )

View File

@ -5,7 +5,7 @@
# GSSAPI_ROOT_DIR - Set this variable to the root installation of GSSAPI # GSSAPI_ROOT_DIR - Set this variable to the root installation of GSSAPI
# #
# Read-Only variables: # Read-Only variables:
# GSSAPI_FLAVOR_MIT - set to TURE if MIT Kerberos has been found # GSSAPI_FLAVOR_MIT - set to TRUE if MIT Kerberos has been found
# GSSAPI_FLAVOR_HEIMDAL - set to TRUE if Heimdal Kerberos has been found # GSSAPI_FLAVOR_HEIMDAL - set to TRUE if Heimdal Kerberos has been found
# GSSAPI_FOUND - system has GSSAPI # GSSAPI_FOUND - system has GSSAPI
# GSSAPI_INCLUDE_DIR - the GSSAPI include directory # GSSAPI_INCLUDE_DIR - the GSSAPI include directory
@ -25,300 +25,184 @@
# #
find_path(GSSAPI_ROOT_DIR find_path(GSSAPI_ROOT_DIR
NAMES NAMES include/gssapi.h include/gssapi/gssapi.h
include/gssapi.h HINTS ${_GSSAPI_ROOT_HINTS}
include/gssapi/gssapi.h PATHS ${_GSSAPI_ROOT_PATHS})
HINTS
${_GSSAPI_ROOT_HINTS}
PATHS
${_GSSAPI_ROOT_PATHS}
)
mark_as_advanced(GSSAPI_ROOT_DIR) mark_as_advanced(GSSAPI_ROOT_DIR)
if (UNIX) if(UNIX)
find_program(KRB5_CONFIG find_program(KRB5_CONFIG
NAMES NAMES krb5-config
krb5-config PATHS ${GSSAPI_ROOT_DIR}/bin /opt/local/bin)
PATHS mark_as_advanced(KRB5_CONFIG)
${GSSAPI_ROOT_DIR}/bin
/opt/local/bin)
mark_as_advanced(KRB5_CONFIG)
if (KRB5_CONFIG) if(KRB5_CONFIG)
# Check if we have MIT KRB5 # Check if we have MIT KRB5
execute_process( execute_process(
COMMAND COMMAND ${KRB5_CONFIG} --vendor
${KRB5_CONFIG} --vendor RESULT_VARIABLE _GSSAPI_VENDOR_RESULT
RESULT_VARIABLE OUTPUT_VARIABLE _GSSAPI_VENDOR_STRING)
_GSSAPI_VENDOR_RESULT
OUTPUT_VARIABLE
_GSSAPI_VENDOR_STRING)
if (_GSSAPI_VENDOR_STRING MATCHES ".*Massachusetts.*") if(_GSSAPI_VENDOR_STRING MATCHES ".*Massachusetts.*")
set(GSSAPI_FLAVOR_MIT TRUE) set(GSSAPI_FLAVOR_MIT TRUE)
else() else()
execute_process( execute_process(
COMMAND COMMAND ${KRB5_CONFIG} --libs gssapi
${KRB5_CONFIG} --libs gssapi RESULT_VARIABLE _GSSAPI_LIBS_RESULT
RESULT_VARIABLE OUTPUT_VARIABLE _GSSAPI_LIBS_STRING)
_GSSAPI_LIBS_RESULT
OUTPUT_VARIABLE
_GSSAPI_LIBS_STRING)
if (_GSSAPI_LIBS_STRING MATCHES ".*roken.*") if(_GSSAPI_LIBS_STRING MATCHES ".*roken.*")
set(GSSAPI_FLAVOR_HEIMDAL TRUE) set(GSSAPI_FLAVOR_HEIMDAL TRUE)
endif() endif()
endif() endif()
# Get the include dir # Get the include dir
execute_process( execute_process(
COMMAND COMMAND ${KRB5_CONFIG} --cflags gssapi
${KRB5_CONFIG} --cflags gssapi RESULT_VARIABLE _GSSAPI_INCLUDE_RESULT
RESULT_VARIABLE OUTPUT_VARIABLE _GSSAPI_INCLUDE_STRING)
_GSSAPI_INCLUDE_RESULT string(REGEX REPLACE "(\r?\n)+$" "" _GSSAPI_INCLUDE_STRING "${_GSSAPI_INCLUDE_STRING}")
OUTPUT_VARIABLE string(REGEX REPLACE " *-I" "" _GSSAPI_INCLUDEDIR "${_GSSAPI_INCLUDE_STRING}")
_GSSAPI_INCLUDE_STRING) endif()
string(REGEX REPLACE "(\r?\n)+$" "" _GSSAPI_INCLUDE_STRING "${_GSSAPI_INCLUDE_STRING}")
string(REGEX REPLACE " *-I" "" _GSSAPI_INCLUDEDIR "${_GSSAPI_INCLUDE_STRING}")
endif()
if (NOT GSSAPI_FLAVOR_MIT AND NOT GSSAPI_FLAVOR_HEIMDAL) if(NOT GSSAPI_FLAVOR_MIT AND NOT GSSAPI_FLAVOR_HEIMDAL)
# Check for HEIMDAL # Check for HEIMDAL
find_package(PkgConfig) find_package(PkgConfig)
if (PKG_CONFIG_FOUND) if(PKG_CONFIG_FOUND)
pkg_check_modules(_GSSAPI heimdal-gssapi) pkg_check_modules(_GSSAPI heimdal-gssapi)
endif (PKG_CONFIG_FOUND) endif()
if (_GSSAPI_FOUND) if(_GSSAPI_FOUND)
set(GSSAPI_FLAVOR_HEIMDAL TRUE) set(GSSAPI_FLAVOR_HEIMDAL TRUE)
else() else()
find_path(_GSSAPI_ROKEN find_path(_GSSAPI_ROKEN
NAMES NAMES roken.h
roken.h PATHS ${GSSAPI_ROOT_DIR}/include ${_GSSAPI_INCLUDEDIR})
PATHS if(_GSSAPI_ROKEN)
${GSSAPI_ROOT_DIR}/include set(GSSAPI_FLAVOR_HEIMDAL TRUE)
${_GSSAPI_INCLUDEDIR}) endif()
if (_GSSAPI_ROKEN) endif()
set(GSSAPI_FLAVOR_HEIMDAL TRUE) endif()
endif() endif()
endif ()
endif()
endif (UNIX)
find_path(GSSAPI_INCLUDE_DIR find_path(GSSAPI_INCLUDE_DIR
NAMES NAMES gssapi.h gssapi/gssapi.h
gssapi.h PATHS ${GSSAPI_ROOT_DIR}/include ${_GSSAPI_INCLUDEDIR})
gssapi/gssapi.h
PATHS
${GSSAPI_ROOT_DIR}/include
${_GSSAPI_INCLUDEDIR}
)
if (GSSAPI_FLAVOR_MIT) if(GSSAPI_FLAVOR_MIT)
find_library(GSSAPI_LIBRARY find_library(GSSAPI_LIBRARY
NAMES NAMES gssapi_krb5
gssapi_krb5 PATHS ${GSSAPI_ROOT_DIR}/lib ${_GSSAPI_LIBDIR})
PATHS
${GSSAPI_ROOT_DIR}/lib
${_GSSAPI_LIBDIR}
)
find_library(KRB5_LIBRARY find_library(KRB5_LIBRARY
NAMES NAMES krb5
krb5 PATHS ${GSSAPI_ROOT_DIR}/lib ${_GSSAPI_LIBDIR})
PATHS
${GSSAPI_ROOT_DIR}/lib
${_GSSAPI_LIBDIR}
)
find_library(K5CRYPTO_LIBRARY find_library(K5CRYPTO_LIBRARY
NAMES NAMES k5crypto
k5crypto PATHS ${GSSAPI_ROOT_DIR}/lib ${_GSSAPI_LIBDIR})
PATHS
${GSSAPI_ROOT_DIR}/lib
${_GSSAPI_LIBDIR}
)
find_library(COM_ERR_LIBRARY find_library(COM_ERR_LIBRARY
NAMES NAMES com_err
com_err PATHS ${GSSAPI_ROOT_DIR}/lib ${_GSSAPI_LIBDIR})
PATHS
${GSSAPI_ROOT_DIR}/lib
${_GSSAPI_LIBDIR}
)
if (GSSAPI_LIBRARY) if(GSSAPI_LIBRARY)
set(GSSAPI_LIBRARIES set(GSSAPI_LIBRARIES ${GSSAPI_LIBRARIES} ${GSSAPI_LIBRARY})
${GSSAPI_LIBRARIES} endif()
${GSSAPI_LIBRARY}
)
endif (GSSAPI_LIBRARY)
if (KRB5_LIBRARY) if(KRB5_LIBRARY)
set(GSSAPI_LIBRARIES set(GSSAPI_LIBRARIES ${GSSAPI_LIBRARIES} ${KRB5_LIBRARY})
${GSSAPI_LIBRARIES} endif()
${KRB5_LIBRARY}
)
endif (KRB5_LIBRARY)
if (K5CRYPTO_LIBRARY) if(K5CRYPTO_LIBRARY)
set(GSSAPI_LIBRARIES set(GSSAPI_LIBRARIES ${GSSAPI_LIBRARIES} ${K5CRYPTO_LIBRARY})
${GSSAPI_LIBRARIES} endif()
${K5CRYPTO_LIBRARY}
)
endif (K5CRYPTO_LIBRARY)
if (COM_ERR_LIBRARY) if(COM_ERR_LIBRARY)
set(GSSAPI_LIBRARIES set(GSSAPI_LIBRARIES ${GSSAPI_LIBRARIES} ${COM_ERR_LIBRARY})
${GSSAPI_LIBRARIES} endif()
${COM_ERR_LIBRARY} endif()
)
endif (COM_ERR_LIBRARY)
endif (GSSAPI_FLAVOR_MIT)
if (GSSAPI_FLAVOR_HEIMDAL) if(GSSAPI_FLAVOR_HEIMDAL)
find_library(GSSAPI_LIBRARY find_library(GSSAPI_LIBRARY
NAMES NAMES gssapi
gssapi PATHS ${GSSAPI_ROOT_DIR}/lib ${_GSSAPI_LIBDIR})
PATHS
${GSSAPI_ROOT_DIR}/lib
${_GSSAPI_LIBDIR}
)
find_library(KRB5_LIBRARY find_library(KRB5_LIBRARY
NAMES NAMES krb5
krb5 PATHS ${GSSAPI_ROOT_DIR}/lib ${_GSSAPI_LIBDIR})
PATHS
${GSSAPI_ROOT_DIR}/lib
${_GSSAPI_LIBDIR}
)
find_library(HCRYPTO_LIBRARY find_library(HCRYPTO_LIBRARY
NAMES NAMES hcrypto
hcrypto PATHS ${GSSAPI_ROOT_DIR}/lib ${_GSSAPI_LIBDIR})
PATHS
${GSSAPI_ROOT_DIR}/lib
${_GSSAPI_LIBDIR}
)
find_library(COM_ERR_LIBRARY find_library(COM_ERR_LIBRARY
NAMES NAMES com_err
com_err PATHS ${GSSAPI_ROOT_DIR}/lib ${_GSSAPI_LIBDIR})
PATHS
${GSSAPI_ROOT_DIR}/lib
${_GSSAPI_LIBDIR}
)
find_library(HEIMNTLM_LIBRARY find_library(HEIMNTLM_LIBRARY
NAMES NAMES heimntlm
heimntlm PATHS ${GSSAPI_ROOT_DIR}/lib ${_GSSAPI_LIBDIR})
PATHS
${GSSAPI_ROOT_DIR}/lib
${_GSSAPI_LIBDIR}
)
find_library(HX509_LIBRARY find_library(HX509_LIBRARY
NAMES NAMES hx509
hx509 PATHS ${GSSAPI_ROOT_DIR}/lib ${_GSSAPI_LIBDIR})
PATHS
${GSSAPI_ROOT_DIR}/lib
${_GSSAPI_LIBDIR}
)
find_library(ASN1_LIBRARY find_library(ASN1_LIBRARY
NAMES NAMES asn1
asn1 PATHS ${GSSAPI_ROOT_DIR}/lib ${_GSSAPI_LIBDIR})
PATHS
${GSSAPI_ROOT_DIR}/lib
${_GSSAPI_LIBDIR}
)
find_library(WIND_LIBRARY find_library(WIND_LIBRARY
NAMES NAMES wind
wind PATHS ${GSSAPI_ROOT_DIR}/lib ${_GSSAPI_LIBDIR})
PATHS
${GSSAPI_ROOT_DIR}/lib
${_GSSAPI_LIBDIR}
)
find_library(ROKEN_LIBRARY find_library(ROKEN_LIBRARY
NAMES NAMES roken
roken PATHS ${GSSAPI_ROOT_DIR}/lib ${_GSSAPI_LIBDIR})
PATHS
${GSSAPI_ROOT_DIR}/lib
${_GSSAPI_LIBDIR}
)
if (GSSAPI_LIBRARY) if(GSSAPI_LIBRARY)
set(GSSAPI_LIBRARIES set(GSSAPI_LIBRARIES ${GSSAPI_LIBRARIES} ${GSSAPI_LIBRARY})
${GSSAPI_LIBRARIES} endif()
${GSSAPI_LIBRARY}
)
endif (GSSAPI_LIBRARY)
if (KRB5_LIBRARY) if(KRB5_LIBRARY)
set(GSSAPI_LIBRARIES set(GSSAPI_LIBRARIES ${GSSAPI_LIBRARIES} ${KRB5_LIBRARY})
${GSSAPI_LIBRARIES} endif()
${KRB5_LIBRARY}
)
endif (KRB5_LIBRARY)
if (HCRYPTO_LIBRARY) if(HCRYPTO_LIBRARY)
set(GSSAPI_LIBRARIES set(GSSAPI_LIBRARIES ${GSSAPI_LIBRARIES} ${HCRYPTO_LIBRARY})
${GSSAPI_LIBRARIES} endif()
${HCRYPTO_LIBRARY}
)
endif (HCRYPTO_LIBRARY)
if (COM_ERR_LIBRARY) if(COM_ERR_LIBRARY)
set(GSSAPI_LIBRARIES set(GSSAPI_LIBRARIES ${GSSAPI_LIBRARIES} ${COM_ERR_LIBRARY})
${GSSAPI_LIBRARIES} endif()
${COM_ERR_LIBRARY}
)
endif (COM_ERR_LIBRARY)
if (HEIMNTLM_LIBRARY) if(HEIMNTLM_LIBRARY)
set(GSSAPI_LIBRARIES set(GSSAPI_LIBRARIES ${GSSAPI_LIBRARIES} ${HEIMNTLM_LIBRARY})
${GSSAPI_LIBRARIES} endif()
${HEIMNTLM_LIBRARY}
)
endif (HEIMNTLM_LIBRARY)
if (HX509_LIBRARY) if(HX509_LIBRARY)
set(GSSAPI_LIBRARIES set(GSSAPI_LIBRARIES ${GSSAPI_LIBRARIES} ${HX509_LIBRARY})
${GSSAPI_LIBRARIES} endif()
${HX509_LIBRARY}
)
endif (HX509_LIBRARY)
if (ASN1_LIBRARY) if(ASN1_LIBRARY)
set(GSSAPI_LIBRARIES set(GSSAPI_LIBRARIES ${GSSAPI_LIBRARIES} ${ASN1_LIBRARY})
${GSSAPI_LIBRARIES} endif()
${ASN1_LIBRARY}
)
endif (ASN1_LIBRARY)
if (WIND_LIBRARY) if(WIND_LIBRARY)
set(GSSAPI_LIBRARIES set(GSSAPI_LIBRARIES ${GSSAPI_LIBRARIES} ${WIND_LIBRARY})
${GSSAPI_LIBRARIES} endif()
${WIND_LIBRARY}
)
endif (WIND_LIBRARY)
if (ROKEN_LIBRARY) if(ROKEN_LIBRARY)
set(GSSAPI_LIBRARIES set(GSSAPI_LIBRARIES ${GSSAPI_LIBRARIES} ${WIND_LIBRARY})
${GSSAPI_LIBRARIES} endif()
${WIND_LIBRARY} endif()
)
endif (ROKEN_LIBRARY)
endif (GSSAPI_FLAVOR_HEIMDAL)
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GSSAPI DEFAULT_MSG GSSAPI_LIBRARIES GSSAPI_INCLUDE_DIR) find_package_handle_standard_args(GSSAPI DEFAULT_MSG GSSAPI_LIBRARIES GSSAPI_INCLUDE_DIR)
if (GSSAPI_INCLUDE_DIRS AND GSSAPI_LIBRARIES) if(GSSAPI_INCLUDE_DIRS AND GSSAPI_LIBRARIES)
set(GSSAPI_FOUND TRUE) set(GSSAPI_FOUND TRUE)
endif (GSSAPI_INCLUDE_DIRS AND GSSAPI_LIBRARIES) endif(GSSAPI_INCLUDE_DIRS AND GSSAPI_LIBRARIES)
# show the GSSAPI_INCLUDE_DIRS and GSSAPI_LIBRARIES variables only in the advanced view # show the GSSAPI_INCLUDE_DIRS and GSSAPI_LIBRARIES variables only in the advanced view
mark_as_advanced(GSSAPI_INCLUDE_DIRS GSSAPI_LIBRARIES) mark_as_advanced(GSSAPI_INCLUDE_DIRS GSSAPI_LIBRARIES)

View File

@ -7,21 +7,21 @@
# GSSFRAMEWORK_LDFLAGS # GSSFRAMEWORK_LDFLAGS
# #
FIND_PATH(GSSFRAMEWORK_INCLUDE_DIR NAMES GSS.h) find_path(GSSFRAMEWORK_INCLUDE_DIR NAMES GSS.h)
FIND_LIBRARY(GSSFRAMEWORK_LIBRARIES NAMES GSS) find_library(GSSFRAMEWORK_LIBRARIES NAMES GSS)
IF (GSSFRAMEWORK_INCLUDE_DIR AND GSSFRAMEWORK_LIBRARIES) if(GSSFRAMEWORK_INCLUDE_DIR AND GSSFRAMEWORK_LIBRARIES)
IF (NOT CoreFoundation_FIND_QUIETLY) if(NOT CoreFoundation_FIND_QUIETLY)
MESSAGE(STATUS "Found GSS.framework ${GSSFRAMEWORK_LIBRARIES}") message(STATUS "Found GSS.framework ${GSSFRAMEWORK_LIBRARIES}")
ENDIF() endif()
SET(GSSFRAMEWORK_FOUND TRUE) set(GSSFRAMEWORK_FOUND TRUE)
SET(GSSFRAMEWORK_LDFLAGS "-framework GSS") set(GSSFRAMEWORK_LDFLAGS "-framework GSS")
ENDIF () endif()
IF (GSS_FIND_REQUIRED AND NOT GSSFRAMEWORK_FOUND) if(GSS_FIND_REQUIRED AND NOT GSSFRAMEWORK_FOUND)
MESSAGE(FATAL_ERROR "CoreFoundation not found") message(FATAL_ERROR "CoreFoundation not found")
ENDIF() endif()
MARK_AS_ADVANCED( mark_as_advanced(
GSSFRAMEWORK_INCLUDE_DIR GSSFRAMEWORK_INCLUDE_DIR
GSSFRAMEWORK_LIBRARIES GSSFRAMEWORK_LIBRARIES
GSSFRAMEWORK_LDFLAGS GSSFRAMEWORK_LDFLAGS

View File

@ -10,30 +10,30 @@
# HTTP_PARSER_VERSION_STRING - the version of http-parser found # HTTP_PARSER_VERSION_STRING - the version of http-parser found
# Find the header and library # Find the header and library
FIND_PATH(HTTP_PARSER_INCLUDE_DIR NAMES http_parser.h) find_path(HTTP_PARSER_INCLUDE_DIR NAMES http_parser.h)
FIND_LIBRARY(HTTP_PARSER_LIBRARY NAMES http_parser libhttp_parser) find_library(HTTP_PARSER_LIBRARY NAMES http_parser libhttp_parser)
# Found the header, read version # Found the header, read version
if (HTTP_PARSER_INCLUDE_DIR AND EXISTS "${HTTP_PARSER_INCLUDE_DIR}/http_parser.h") 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) file(READ "${HTTP_PARSER_INCLUDE_DIR}/http_parser.h" HTTP_PARSER_H)
IF (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_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}") 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}") set(HTTP_PARSER_VERSION_STRING "${HTTP_PARSER_VERSION_MAJOR}.${HTTP_PARSER_VERSION_MINOR}")
ENDIF() endif()
UNSET(HTTP_PARSER_H) unset(HTTP_PARSER_H)
ENDIF() endif()
# Handle the QUIETLY and REQUIRED arguments and set HTTP_PARSER_FOUND # Handle the QUIETLY and REQUIRED arguments and set HTTP_PARSER_FOUND
# to TRUE if all listed variables are TRUE # to TRUE if all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(HTTP_Parser REQUIRED_VARS HTTP_PARSER_INCLUDE_DIR HTTP_PARSER_LIBRARY) find_package_handle_standard_args(HTTP_Parser REQUIRED_VARS HTTP_PARSER_INCLUDE_DIR HTTP_PARSER_LIBRARY)
# Hide advanced variables # 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 # Set standard variables
IF (HTTP_PARSER_FOUND) if(HTTP_PARSER_FOUND)
SET(HTTP_PARSER_LIBRARIES ${HTTP_PARSER_LIBRARY}) set(HTTP_PARSER_LIBRARIES ${HTTP_PARSER_LIBRARY})
set(HTTP_PARSER_INCLUDE_DIRS ${HTTP_PARSER_INCLUDE_DIR}) set(HTTP_PARSER_INCLUDE_DIRS ${HTTP_PARSER_INCLUDE_DIR})
ENDIF() endif()

View File

@ -6,40 +6,40 @@
# ICONV_LIBRARIES - Link these to use Iconv # 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 # Already in cache, be silent
SET(ICONV_FIND_QUIETLY TRUE) set(ICONV_FIND_QUIETLY TRUE)
ENDIF() endif()
FIND_PATH(ICONV_INCLUDE_DIR iconv.h) find_path(ICONV_INCLUDE_DIR iconv.h)
CHECK_FUNCTION_EXISTS(iconv_open libc_has_iconv) check_function_exists(iconv_open libc_has_iconv)
FIND_LIBRARY(iconv_lib NAMES iconv libiconv libiconv-2 c) find_library(iconv_lib NAMES iconv libiconv libiconv-2 c)
IF(ICONV_INCLUDE_DIR AND libc_has_iconv) if(ICONV_INCLUDE_DIR AND libc_has_iconv)
SET(ICONV_FOUND TRUE) set(ICONV_FOUND TRUE)
SET(ICONV_LIBRARIES "") set(ICONV_LIBRARIES "")
IF(NOT ICONV_FIND_QUIETLY) if(NOT ICONV_FIND_QUIETLY)
MESSAGE(STATUS "Found Iconv: provided by libc") message(STATUS "Found Iconv: provided by libc")
ENDIF(NOT ICONV_FIND_QUIETLY) endif(NOT ICONV_FIND_QUIETLY)
ELSEIF(ICONV_INCLUDE_DIR AND iconv_lib) elseif(ICONV_INCLUDE_DIR AND iconv_lib)
SET(ICONV_FOUND TRUE) set(ICONV_FOUND TRUE)
# split iconv into -L and -l linker options, so we can # split iconv into -L and -l linker options, so we can
# set them for pkg-config # set them for pkg-config
GET_FILENAME_COMPONENT(iconv_path ${iconv_lib} PATH) get_filename_component(iconv_path ${iconv_lib} PATH)
GET_FILENAME_COMPONENT(iconv_name ${iconv_lib} NAME_WE) get_filename_component(iconv_name ${iconv_lib} NAME_WE)
STRING(REGEX REPLACE "^lib" "" iconv_name ${iconv_name}) string(REGEX REPLACE "^lib" "" iconv_name ${iconv_name})
SET(ICONV_LIBRARIES "-L${iconv_path} -l${iconv_name}") set(ICONV_LIBRARIES "-L${iconv_path} -l${iconv_name}")
IF(NOT ICONV_FIND_QUIETLY) if(NOT ICONV_FIND_QUIETLY)
MESSAGE(STATUS "Found Iconv: ${ICONV_LIBRARIES}") message(STATUS "Found Iconv: ${ICONV_LIBRARIES}")
ENDIF(NOT ICONV_FIND_QUIETLY) endif()
ELSE() else()
IF(Iconv_FIND_REQUIRED) if(Iconv_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find Iconv") message(FATAL_ERROR "Could not find Iconv")
ENDIF(Iconv_FIND_REQUIRED) endif(Iconv_FIND_REQUIRED)
ENDIF() endif()
MARK_AS_ADVANCED( mark_as_advanced(
ICONV_INCLUDE_DIR ICONV_INCLUDE_DIR
ICONV_LIBRARIES ICONV_LIBRARIES
) )

View File

@ -2,12 +2,12 @@
# LIBSSH2_INCLUDE_DIR - the libssh2 include directory # LIBSSH2_INCLUDE_DIR - the libssh2 include directory
# LIBSSH2_LIBRARY - the libssh2 library name # 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 find_package_handle_standard_args(LibSSH2
REQUIRED_VARS LIBSSH2_LIBRARY LIBSSH2_INCLUDE_DIR) REQUIRED_VARS LIBSSH2_LIBRARY LIBSSH2_INCLUDE_DIR)
MARK_AS_ADVANCED(LIBSSH2_INCLUDE_DIR LIBSSH2_LIBRARY) mark_as_advanced(LIBSSH2_INCLUDE_DIR LIBSSH2_LIBRARY)

View File

@ -16,23 +16,23 @@
# PCRE_FOUND - True if pcre found. # PCRE_FOUND - True if pcre found.
# Look for the header file. # 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. # Look for the library.
FIND_LIBRARY(PCRE_LIBRARY NAMES pcre) find_library(PCRE_LIBRARY NAMES pcre)
FIND_LIBRARY(PCRE_POSIX_LIBRARY NAMES pcreposix) 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. # Handle the QUIETLY and REQUIRED arguments and set PCRE_FOUND to TRUE if all listed variables are TRUE.
INCLUDE(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCRE DEFAULT_MSG PCRE_LIBRARY PCRE_POSIX_LIBRARY PCRE_INCLUDE_DIR) find_package_handle_standard_args(PCRE DEFAULT_MSG PCRE_LIBRARY PCRE_POSIX_LIBRARY PCRE_INCLUDE_DIR)
# Copy the results to the output variables. # Copy the results to the output variables.
IF(PCRE_FOUND) if(PCRE_FOUND)
SET(PCRE_LIBRARIES ${PCRE_LIBRARY} ${PCRE_POSIX_LIBRARY}) set(PCRE_LIBRARIES ${PCRE_LIBRARY} ${PCRE_POSIX_LIBRARY})
SET(PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIR}) set(PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIR})
ELSE(PCRE_FOUND) else(PCRE_FOUND)
SET(PCRE_LIBRARIES) set(PCRE_LIBRARIES)
SET(PCRE_INCLUDE_DIRS) set(PCRE_INCLUDE_DIRS)
ENDIF(PCRE_FOUND) endif()
MARK_AS_ADVANCED(PCRE_INCLUDE_DIRS PCRE_LIBRARIES) mark_as_advanced(PCRE_INCLUDE_DIRS PCRE_LIBRARIES)

View File

@ -16,22 +16,22 @@
# PCRE2_FOUND - True if pcre found. # PCRE2_FOUND - True if pcre found.
# Look for the header file. # 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. # 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. # Handle the QUIETLY and REQUIRED arguments and set PCRE2_FOUND to TRUE if all listed variables are TRUE.
INCLUDE(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCRE2 DEFAULT_MSG PCRE2_LIBRARY PCRE2_INCLUDE_DIR) find_package_handle_standard_args(PCRE2 DEFAULT_MSG PCRE2_LIBRARY PCRE2_INCLUDE_DIR)
# Copy the results to the output variables. # Copy the results to the output variables.
IF(PCRE2_FOUND) if(PCRE2_FOUND)
SET(PCRE2_LIBRARIES ${PCRE2_LIBRARY}) set(PCRE2_LIBRARIES ${PCRE2_LIBRARY})
SET(PCRE2_INCLUDE_DIRS ${PCRE2_INCLUDE_DIR}) set(PCRE2_INCLUDE_DIRS ${PCRE2_INCLUDE_DIR})
ELSE(PCRE2_FOUND) else(PCRE2_FOUND)
SET(PCRE2_LIBRARIES) set(PCRE2_LIBRARIES)
SET(PCRE2_INCLUDE_DIRS) set(PCRE2_INCLUDE_DIRS)
ENDIF(PCRE2_FOUND) endif()
MARK_AS_ADVANCED(PCRE2_INCLUDE_DIRS PCRE2_LIBRARIES) mark_as_advanced(PCRE2_INCLUDE_DIRS PCRE2_LIBRARIES)

View File

@ -1,28 +1,28 @@
INCLUDE(FindPkgConfig) include(FindPkgConfig)
# This function will find and set up a pkg-config based module. # This function will find and set up a pkg-config based module.
# If a pc-file was found, it will resolve library paths to # If a pc-file was found, it will resolve library paths to
# absolute paths. Furthermore, the function will automatically # absolute paths. Furthermore, the function will automatically
# fall back to use static libraries in case no dynamic libraries # fall back to use static libraries in case no dynamic libraries
# were found. # were found.
FUNCTION(FIND_PKGLIBRARIES prefix package) function(FIND_PKGLIBRARIES prefix package)
PKG_CHECK_MODULES(${prefix} ${package}) pkg_check_modules(${prefix} ${package})
IF(NOT ${prefix}_FOUND) if(NOT ${prefix}_FOUND)
RETURN() return()
ENDIF() endif()
FOREACH(LIBRARY ${${prefix}_LIBRARIES}) foreach(LIBRARY ${${prefix}_LIBRARIES})
FIND_LIBRARY(${LIBRARY}_RESOLVED ${LIBRARY} PATHS ${${prefix}_LIBRARY_DIRS}) find_library(${LIBRARY}_RESOLVED ${LIBRARY} PATHS ${${prefix}_LIBRARY_DIRS})
IF(${${LIBRARY}_RESOLVED} STREQUAL "${LIBRARY}_RESOLVED-NOTFOUND") if(${${LIBRARY}_RESOLVED} STREQUAL "${LIBRARY}_RESOLVED-NOTFOUND")
MESSAGE(FATAL_ERROR "could not resolve ${LIBRARY}") message(FATAL_ERROR "could not resolve ${LIBRARY}")
ENDIF() endif()
LIST(APPEND RESOLVED_LIBRARIES ${${LIBRARY}_RESOLVED}) list(APPEND RESOLVED_LIBRARIES ${${LIBRARY}_RESOLVED})
ENDFOREACH(LIBRARY) endforeach()
SET(${prefix}_FOUND 1 PARENT_SCOPE) set(${prefix}_FOUND 1 PARENT_SCOPE)
SET(${prefix}_LIBRARIES ${RESOLVED_LIBRARIES} PARENT_SCOPE) set(${prefix}_LIBRARIES ${RESOLVED_LIBRARIES} PARENT_SCOPE)
SET(${prefix}_INCLUDE_DIRS ${${prefix}_INCLUDE_DIRS} PARENT_SCOPE) set(${prefix}_INCLUDE_DIRS ${${prefix}_INCLUDE_DIRS} PARENT_SCOPE)
SET(${prefix}_LDFLAGS ${${prefix}_LDFLAGS} PARENT_SCOPE) set(${prefix}_LDFLAGS ${${prefix}_LDFLAGS} PARENT_SCOPE)
MESSAGE(STATUS " Resolved libraries: ${RESOLVED_LIBRARIES}") message(STATUS " Resolved libraries: ${RESOLVED_LIBRARIES}")
ENDFUNCTION() endfunction()

View File

@ -7,22 +7,22 @@
# SECURITY_HAS_SSLCREATECONTEXT # SECURITY_HAS_SSLCREATECONTEXT
# #
FIND_PATH(SECURITY_INCLUDE_DIR NAMES Security/Security.h) find_path(SECURITY_INCLUDE_DIR NAMES Security/Security.h)
FIND_LIBRARY(SECURITY_LIBRARIES NAMES Security) find_library(SECURITY_LIBRARIES NAMES Security)
IF (SECURITY_INCLUDE_DIR AND SECURITY_LIBRARIES) if(SECURITY_INCLUDE_DIR AND SECURITY_LIBRARIES)
IF (NOT Security_FIND_QUIETLY) if(NOT Security_FIND_QUIETLY)
MESSAGE(STATUS "Found Security ${SECURITY_LIBRARIES}") message(STATUS "Found Security ${SECURITY_LIBRARIES}")
ENDIF() endif()
SET(SECURITY_FOUND TRUE) set(SECURITY_FOUND TRUE)
SET(SECURITY_LDFLAGS "-framework Security") set(SECURITY_LDFLAGS "-framework Security")
CHECK_LIBRARY_EXISTS("${SECURITY_LIBRARIES}" SSLCreateContext "Security/SecureTransport.h" SECURITY_HAS_SSLCREATECONTEXT) check_library_exists("${SECURITY_LIBRARIES}" SSLCreateContext "Security/SecureTransport.h" SECURITY_HAS_SSLCREATECONTEXT)
ENDIF () endif()
IF (Security_FIND_REQUIRED AND NOT SECURITY_FOUND) if(Security_FIND_REQUIRED AND NOT SECURITY_FOUND)
MESSAGE(FATAL_ERROR "Security not found") message(FATAL_ERROR "Security not found")
ENDIF() endif()
MARK_AS_ADVANCED( mark_as_advanced(
SECURITY_INCLUDE_DIR SECURITY_INCLUDE_DIR
SECURITY_LIBRARIES SECURITY_LIBRARIES
) )

View File

@ -1,26 +1,20 @@
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) 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) 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) HAVE_STRUCT_STAT_MTIME_NSEC LANGUAGE C)
IF (HAVE_STRUCT_STAT_ST_MTIM) if(HAVE_STRUCT_STAT_ST_MTIM)
CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtim.tv_nsec sys/stat.h check_struct_has_member("struct stat" st_mtim.tv_nsec sys/stat.h
HAVE_STRUCT_STAT_NSEC LANGUAGE C) HAVE_STRUCT_STAT_NSEC LANGUAGE C)
ELSEIF (HAVE_STRUCT_STAT_ST_MTIMESPEC) elseif(HAVE_STRUCT_STAT_ST_MTIMESPEC)
CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtimespec.tv_nsec sys/stat.h check_struct_has_member("struct stat" st_mtimespec.tv_nsec sys/stat.h
HAVE_STRUCT_STAT_NSEC LANGUAGE C) HAVE_STRUCT_STAT_NSEC LANGUAGE C)
ELSE () else()
SET( HAVE_STRUCT_STAT_NSEC ON ) set(HAVE_STRUCT_STAT_NSEC ON )
ENDIF() endif()
IF (HAVE_STRUCT_STAT_NSEC OR WIN32) add_feature_info(nanoseconds USE_NSEC "support nanosecond precision file mtimes and ctimes")
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")

View File

@ -1,14 +1,14 @@
INCLUDE(EnableWarnings) include(EnableWarnings)
IF (APPLE) if(APPLE)
# We cannot simply CHECK_FUNCTION_EXISTS on macOS because # We cannot simply CHECK_FUNCTION_EXISTS on macOS because
# MACOSX_DEPLOYMENT_TARGET may be set to a version in the past # MACOSX_DEPLOYMENT_TARGET may be set to a version in the past
# that doesn't have futimens. Instead we need to enable warnings # that doesn't have futimens. Instead we need to enable warnings
# as errors, then check for the symbol existing in `sys/stat.h`, # as errors, then check for the symbol existing in `sys/stat.h`,
# then reset warnings as errors. # then reset warnings as errors.
ENABLE_WARNINGS(error) enable_warnings(error)
CHECK_SYMBOL_EXISTS(futimens sys/stat.h HAVE_FUTIMENS) check_symbol_exists(futimens sys/stat.h HAVE_FUTIMENS)
DISABLE_WARNINGS(error) disable_warnings(error)
ELSE () else()
CHECK_FUNCTION_EXISTS(futimens HAVE_FUTIMENS) check_function_exists(futimens HAVE_FUTIMENS)
ENDIF () endif()

View File

@ -13,81 +13,74 @@
# Hint # Hint
# MBEDTLS_ROOT_DIR can be pointed to a local mbedTLS installation. # MBEDTLS_ROOT_DIR can be pointed to a local mbedTLS installation.
SET(_MBEDTLS_ROOT_HINTS set(_MBEDTLS_ROOT_HINTS
${MBEDTLS_ROOT_DIR} ${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} 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 NAMES mbedtls/version.h
${_MBEDTLS_ROOT_HINTS_AND_PATHS} ${_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 # Already in cache, be silent
SET(MBEDTLS_FIND_QUIETLY TRUE) set(MBEDTLS_FIND_QUIETLY TRUE)
ENDIF() endif()
FIND_LIBRARY(MBEDTLS_LIBRARY find_library(MBEDTLS_LIBRARY
NAMES mbedtls libmbedtls NAMES mbedtls libmbedtls
${_MBEDTLS_ROOT_HINTS_AND_PATHS} ${_MBEDTLS_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES library PATH_SUFFIXES library)
) find_library(MBEDX509_LIBRARY
FIND_LIBRARY(MBEDX509_LIBRARY NAMES mbedx509 libmbedx509
NAMES mbedx509 libmbedx509 ${_MBEDTLS_ROOT_HINTS_AND_PATHS}
${_MBEDTLS_ROOT_HINTS_AND_PATHS} PATH_SUFFIXES library)
PATH_SUFFIXES library find_library(MBEDCRYPTO_LIBRARY
) NAMES mbedcrypto libmbedcrypto
FIND_LIBRARY(MBEDCRYPTO_LIBRARY ${_MBEDTLS_ROOT_HINTS_AND_PATHS}
NAMES mbedcrypto libmbedcrypto PATH_SUFFIXES library)
${_MBEDTLS_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES library
)
IF(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARY AND MBEDX509_LIBRARY AND MBEDCRYPTO_LIBRARY) if(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARY AND MBEDX509_LIBRARY AND MBEDCRYPTO_LIBRARY)
SET(MBEDTLS_FOUND TRUE) set(MBEDTLS_FOUND TRUE)
ENDIF() endif()
IF(MBEDTLS_FOUND) if(MBEDTLS_FOUND)
# split mbedTLS into -L and -l linker options, so we can set them for pkg-config # 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_DIR ${MBEDTLS_LIBRARY} PATH)
GET_FILENAME_COMPONENT(MBEDTLS_LIBRARY_FILE ${MBEDTLS_LIBRARY} NAME_WE) get_filename_component(MBEDTLS_LIBRARY_FILE ${MBEDTLS_LIBRARY} NAME_WE)
GET_FILENAME_COMPONENT(MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY} NAME_WE) get_filename_component(MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY} NAME_WE)
GET_FILENAME_COMPONENT(MBEDCRYPTO_LIBRARY_FILE ${MBEDCRYPTO_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" "" MBEDTLS_LIBRARY_FILE ${MBEDTLS_LIBRARY_FILE})
STRING(REGEX REPLACE "^lib" "" MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY_FILE}) string(REGEX REPLACE "^lib" "" MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY_FILE})
STRING(REGEX REPLACE "^lib" "" MBEDCRYPTO_LIBRARY_FILE ${MBEDCRYPTO_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}") set(MBEDTLS_LIBRARIES "-L${MBEDTLS_LIBRARY_DIR} -l${MBEDTLS_LIBRARY_FILE} -l${MBEDX509_LIBRARY_FILE} -l${MBEDCRYPTO_LIBRARY_FILE}")
IF(NOT MBEDTLS_FIND_QUIETLY) if(NOT MBEDTLS_FIND_QUIETLY)
MESSAGE(STATUS "Found mbedTLS:") message(STATUS "Found mbedTLS:")
FILE(READ ${MBEDTLS_INCLUDE_DIR}/mbedtls/version.h MBEDTLSCONTENT) file(READ ${MBEDTLS_INCLUDE_DIR}/mbedtls/version.h MBEDTLSCONTENT)
STRING(REGEX MATCH "MBEDTLS_VERSION_STRING +\"[0-9|.]+\"" MBEDTLSMATCH ${MBEDTLSCONTENT}) string(REGEX MATCH "MBEDTLS_VERSION_STRING +\"[0-9|.]+\"" MBEDTLSMATCH ${MBEDTLSCONTENT})
IF (MBEDTLSMATCH) if(MBEDTLSMATCH)
STRING(REGEX REPLACE "MBEDTLS_VERSION_STRING +\"([0-9|.]+)\"" "\\1" MBEDTLS_VERSION ${MBEDTLSMATCH}) string(REGEX REPLACE "MBEDTLS_VERSION_STRING +\"([0-9|.]+)\"" "\\1" MBEDTLS_VERSION ${MBEDTLSMATCH})
MESSAGE(STATUS " version ${MBEDTLS_VERSION}") message(STATUS " version ${MBEDTLS_VERSION}")
ENDIF(MBEDTLSMATCH) endif()
MESSAGE(STATUS " TLS: ${MBEDTLS_LIBRARY}") message(STATUS " TLS: ${MBEDTLS_LIBRARY}")
MESSAGE(STATUS " X509: ${MBEDX509_LIBRARY}") message(STATUS " X509: ${MBEDX509_LIBRARY}")
MESSAGE(STATUS " Crypto: ${MBEDCRYPTO_LIBRARY}") message(STATUS " Crypto: ${MBEDCRYPTO_LIBRARY}")
ENDIF(NOT MBEDTLS_FIND_QUIETLY) endif()
ELSE(MBEDTLS_FOUND) else(MBEDTLS_FOUND)
IF(MBEDTLS_FIND_REQUIRED) if(MBEDTLS_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find mbedTLS") message(FATAL_ERROR "Could not find mbedTLS")
ENDIF(MBEDTLS_FIND_REQUIRED) endif()
ENDIF(MBEDTLS_FOUND) endif()
MARK_AS_ADVANCED( mark_as_advanced(
MBEDTLS_INCLUDE_DIR MBEDTLS_INCLUDE_DIR
MBEDTLS_LIBRARY_DIR MBEDTLS_LIBRARY_DIR
MBEDTLS_LIBRARIES MBEDTLS_LIBRARIES
MBEDTLS_LIBRARY MBEDTLS_LIBRARY
MBEDX509_LIBRARY MBEDX509_LIBRARY
MBEDCRYPTO_LIBRARY MBEDCRYPTO_LIBRARY)
)

View File

@ -1,22 +1,22 @@
# This function splits the sources files up into their appropriate # This function splits the sources files up into their appropriate
# subdirectories. This is especially useful for IDEs like Xcode and # 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 # and see the folders within the tests folder (instead of just seeing all
# source and tests in a single folder.) # source and tests in a single folder.)
FUNCTION(IDE_SPLIT_SOURCES target) function(IDE_SPLIT_SOURCES target)
IF(MSVC_IDE OR CMAKE_GENERATOR STREQUAL Xcode) if(MSVC_IDE OR CMAKE_GENERATOR STREQUAL Xcode)
GET_TARGET_PROPERTY(sources ${target} SOURCES) get_target_property(sources ${target} SOURCES)
FOREACH(source ${sources}) foreach(source ${sources})
IF(source MATCHES ".*/") if(source MATCHES ".*/")
STRING(REPLACE ${libgit2_SOURCE_DIR}/ "" rel ${source}) string(REPLACE ${PROJECT_SOURCE_DIR}/ "" rel ${source})
IF(rel) if(rel)
STRING(REGEX REPLACE "/([^/]*)$" "" rel ${rel}) string(REGEX REPLACE "/([^/]*)$" "" rel ${rel})
IF(rel) if(rel)
STRING(REPLACE "/" "\\\\" rel ${rel}) string(REPLACE "/" "\\\\" rel ${rel})
SOURCE_GROUP(${rel} FILES ${source}) source_group(${rel} FILES ${source})
ENDIF() endif()
ENDIF() endif()
ENDIF() endif()
ENDFOREACH() endforeach()
ENDIF() endif()
ENDFUNCTION() endfunction()

View File

@ -2,76 +2,76 @@
# #
function(pkg_build_config) function(pkg_build_config)
set(options) set(options)
set(oneValueArgs NAME DESCRIPTION VERSION FILENAME LIBS_SELF) set(oneValueArgs NAME DESCRIPTION VERSION FILENAME LIBS_SELF)
set(multiValueArgs LIBS PRIVATE_LIBS REQUIRES CFLAGS) set(multiValueArgs LIBS PRIVATE_LIBS REQUIRES CFLAGS)
cmake_parse_arguments(PKGCONFIG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) cmake_parse_arguments(PKGCONFIG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if (NOT DEFINED PKGCONFIG_FILENAME AND DEFINED PKGCONFIG_NAME) if (NOT DEFINED PKGCONFIG_FILENAME AND DEFINED PKGCONFIG_NAME)
set(PKGCONFIG_FILENAME ${PKGCONFIG_NAME}) set(PKGCONFIG_FILENAME ${PKGCONFIG_NAME})
endif() endif()
if (NOT DEFINED PKGCONFIG_FILENAME) if (NOT DEFINED PKGCONFIG_FILENAME)
message(FATAL_ERROR "Missing FILENAME argument") message(FATAL_ERROR "Missing FILENAME argument")
endif() endif()
set(PKGCONFIG_FILE "${PROJECT_BINARY_DIR}/${PKGCONFIG_FILENAME}.pc") set(PKGCONFIG_FILE "${PROJECT_BINARY_DIR}/${PKGCONFIG_FILENAME}.pc")
if (NOT DEFINED PKGCONFIG_DESCRIPTION) if (NOT DEFINED PKGCONFIG_DESCRIPTION)
message(FATAL_ERROR "Missing DESCRIPTION argument") message(FATAL_ERROR "Missing DESCRIPTION argument")
endif() endif()
if (NOT DEFINED PKGCONFIG_VERSION) if (NOT DEFINED PKGCONFIG_VERSION)
message(FATAL_ERROR "Missing VERSION argument") message(FATAL_ERROR "Missing VERSION argument")
endif() endif()
# Write .pc "header" # Write .pc "header"
file(WRITE "${PKGCONFIG_FILE}" file(WRITE "${PKGCONFIG_FILE}"
"prefix=\"${CMAKE_INSTALL_PREFIX}\"\n" "prefix=\"${CMAKE_INSTALL_PREFIX}\"\n"
"libdir=\"${CMAKE_INSTALL_FULL_LIBDIR}\"\n" "libdir=\"${CMAKE_INSTALL_FULL_LIBDIR}\"\n"
"includedir=\"${CMAKE_INSTALL_FULL_INCLUDEDIR}\"\n" "includedir=\"${CMAKE_INSTALL_FULL_INCLUDEDIR}\"\n"
"\n" "\n"
"Name: ${PKGCONFIG_NAME}\n" "Name: ${PKGCONFIG_NAME}\n"
"Description: ${PKGCONFIG_DESCRIPTION}\n" "Description: ${PKGCONFIG_DESCRIPTION}\n"
"Version: ${PKGCONFIG_VERSION}\n" "Version: ${PKGCONFIG_VERSION}\n"
) )
# Prepare Libs # Prepare Libs
if(NOT DEFINED PKGCONFIG_LIBS_SELF) if(NOT DEFINED PKGCONFIG_LIBS_SELF)
set(PKGCONFIG_LIBS_SELF "${PKGCONFIG_FILE}") set(PKGCONFIG_LIBS_SELF "${PKGCONFIG_FILE}")
endif() endif()
if(NOT DEFINED PKGCONFIG_LIBS) if(NOT DEFINED PKGCONFIG_LIBS)
set(PKGCONFIG_LIBS "-l${PKGCONFIG_LIBS_SELF}") set(PKGCONFIG_LIBS "-l${PKGCONFIG_LIBS_SELF}")
else() else()
list(INSERT PKGCONFIG_LIBS 0 "-l${PKGCONFIG_LIBS_SELF}") list(INSERT PKGCONFIG_LIBS 0 "-l${PKGCONFIG_LIBS_SELF}")
endif() endif()
list(REMOVE_DUPLICATES PKGCONFIG_LIBS) list(REMOVE_DUPLICATES PKGCONFIG_LIBS)
string(REPLACE ";" " " PKGCONFIG_LIBS "${PKGCONFIG_LIBS}") string(REPLACE ";" " " PKGCONFIG_LIBS "${PKGCONFIG_LIBS}")
file(APPEND "${PKGCONFIG_FILE}" "Libs: -L\${libdir} ${PKGCONFIG_LIBS}\n") file(APPEND "${PKGCONFIG_FILE}" "Libs: -L\${libdir} ${PKGCONFIG_LIBS}\n")
# Prepare Libs.private # Prepare Libs.private
if(DEFINED PKGCONFIG_PRIVATE_LIBS) if(DEFINED PKGCONFIG_PRIVATE_LIBS)
list(REMOVE_DUPLICATES PKGCONFIG_PRIVATE_LIBS) list(REMOVE_DUPLICATES PKGCONFIG_PRIVATE_LIBS)
string(REPLACE ";" " " PKGCONFIG_PRIVATE_LIBS "${PKGCONFIG_PRIVATE_LIBS}") string(REPLACE ";" " " PKGCONFIG_PRIVATE_LIBS "${PKGCONFIG_PRIVATE_LIBS}")
file(APPEND "${PKGCONFIG_FILE}" "Libs.private: ${PKGCONFIG_PRIVATE_LIBS}\n") file(APPEND "${PKGCONFIG_FILE}" "Libs.private: ${PKGCONFIG_PRIVATE_LIBS}\n")
endif() endif()
# Prepare Requires.private # Prepare Requires.private
if(DEFINED PKGCONFIG_REQUIRES) if(DEFINED PKGCONFIG_REQUIRES)
list(REMOVE_DUPLICATES PKGCONFIG_REQUIRES) list(REMOVE_DUPLICATES PKGCONFIG_REQUIRES)
string(REPLACE ";" " " PKGCONFIG_REQUIRES "${PKGCONFIG_REQUIRES}") string(REPLACE ";" " " PKGCONFIG_REQUIRES "${PKGCONFIG_REQUIRES}")
file(APPEND "${PKGCONFIG_FILE}" "Requires.private: ${PKGCONFIG_REQUIRES}\n") file(APPEND "${PKGCONFIG_FILE}" "Requires.private: ${PKGCONFIG_REQUIRES}\n")
endif() endif()
# Prepare Cflags # Prepare Cflags
if(DEFINED PKGCONFIG_CFLAGS) if(DEFINED PKGCONFIG_CFLAGS)
string(REPLACE ";" " " PKGCONFIG_CFLAGS "${PKGCONFIG_CFLAGS}") string(REPLACE ";" " " PKGCONFIG_CFLAGS "${PKGCONFIG_CFLAGS}")
else() else()
set(PKGCONFIG_CFLAGS "") set(PKGCONFIG_CFLAGS "")
endif() endif()
file(APPEND "${PKGCONFIG_FILE}" "Cflags: -I\${includedir} ${PKGCONFIG_CFLAGS}\n") file(APPEND "${PKGCONFIG_FILE}" "Cflags: -I\${includedir} ${PKGCONFIG_CFLAGS}\n")
# Install .pc file # Install .pc file
install(FILES "${PKGCONFIG_FILE}" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") install(FILES "${PKGCONFIG_FILE}" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
endfunction() endfunction()

View File

@ -1,20 +1,20 @@
FUNCTION(SanitizeBool VAR) function(SanitizeBool VAR)
STRING(TOLOWER "${${VAR}}" VALUE) string(TOLOWER "${${VAR}}" VALUE)
IF(VALUE STREQUAL "on") if(VALUE STREQUAL "on")
SET(${VAR} "ON" PARENT_SCOPE) set(${VAR} "ON" PARENT_SCOPE)
ELSEIF(VALUE STREQUAL "yes") elseif(VALUE STREQUAL "yes")
SET(${VAR} "ON" PARENT_SCOPE) set(${VAR} "ON" PARENT_SCOPE)
ELSEIF(VALUE STREQUAL "true") elseif(VALUE STREQUAL "true")
SET(${VAR} "ON" PARENT_SCOPE) set(${VAR} "ON" PARENT_SCOPE)
ELSEIF(VALUE STREQUAL "1") elseif(VALUE STREQUAL "1")
SET(${VAR} "ON" PARENT_SCOPE) set(${VAR} "ON" PARENT_SCOPE)
ELSEIF(VALUE STREQUAL "off") elseif(VALUE STREQUAL "off")
SET(${VAR} "OFF" PARENT_SCOPE) set(${VAR} "OFF" PARENT_SCOPE)
ELSEIF(VALUE STREQUAL "no") elseif(VALUE STREQUAL "no")
SET(${VAR} "OFF" PARENT_SCOPE) set(${VAR} "OFF" PARENT_SCOPE)
ELSEIF(VALUE STREQUAL "false") elseif(VALUE STREQUAL "false")
SET(${VAR} "OFF" PARENT_SCOPE) set(${VAR} "OFF" PARENT_SCOPE)
ELSEIF(VALUE STREQUAL "0") elseif(VALUE STREQUAL "0")
SET(${VAR} "OFF" PARENT_SCOPE) set(${VAR} "OFF" PARENT_SCOPE)
ENDIF() endif()
ENDFUNCTION() endfunction()

View File

@ -1,48 +1,48 @@
INCLUDE(SanitizeBool) include(SanitizeBool)
# We try to find any packages our backends might use # We try to find any packages our backends might use
FIND_PACKAGE(GSSAPI) find_package(GSSAPI)
IF (CMAKE_SYSTEM_NAME MATCHES "Darwin") if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
INCLUDE(FindGSSFramework) include(FindGSSFramework)
ENDIF() endif()
IF(USE_GSSAPI) if(USE_GSSAPI)
# Auto-select GSS backend # Auto-select GSS backend
SanitizeBool(USE_GSSAPI) sanitizebool(USE_GSSAPI)
IF (USE_GSSAPI STREQUAL ON) if(USE_GSSAPI STREQUAL ON)
IF (GSSFRAMEWORK_FOUND) if(GSSFRAMEWORK_FOUND)
SET(USE_GSSAPI "GSS.framework") set(USE_GSSAPI "GSS.framework")
ELSEIF(GSSAPI_FOUND) elseif(GSSAPI_FOUND)
SET(USE_GSSAPI "gssapi") set(USE_GSSAPI "gssapi")
ELSE() else()
MESSAGE(FATAL_ERROR "Unable to autodetect a usable GSS backend." message(FATAL_ERROR "Unable to autodetect a usable GSS backend."
"Please pass the backend name explicitly (-DUSE_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 # Check that we can find what's required for the selected backend
IF (USE_GSSAPI STREQUAL "GSS.framework") if(USE_GSSAPI STREQUAL "GSS.framework")
IF (NOT GSSFRAMEWORK_FOUND) if(NOT GSSFRAMEWORK_FOUND)
MESSAGE(FATAL_ERROR "Asked for GSS.framework backend, but it wasn't found") message(FATAL_ERROR "Asked for GSS.framework backend, but it wasn't found")
ENDIF() endif()
LIST(APPEND LIBGIT2_LIBS ${GSSFRAMEWORK_LIBRARIES}) list(APPEND LIBGIT2_SYSTEM_LIBS ${GSSFRAMEWORK_LIBRARIES})
SET(GIT_GSSFRAMEWORK 1) set(GIT_GSSFRAMEWORK 1)
ADD_FEATURE_INFO(SPNEGO GIT_GSSFRAMEWORK "SPNEGO authentication support (${USE_GSSAPI})") add_feature_info(SPNEGO GIT_GSSFRAMEWORK "SPNEGO authentication support (${USE_GSSAPI})")
ELSEIF (USE_GSSAPI STREQUAL "gssapi") elseif(USE_GSSAPI STREQUAL "gssapi")
IF (NOT GSSAPI_FOUND) if(NOT GSSAPI_FOUND)
MESSAGE(FATAL_ERROR "Asked for gssapi GSS backend, but it wasn't found") message(FATAL_ERROR "Asked for gssapi GSS backend, but it wasn't found")
ENDIF() endif()
LIST(APPEND LIBGIT2_LIBS ${GSSAPI_LIBRARIES}) list(APPEND LIBGIT2_SYSTEM_LIBS ${GSSAPI_LIBRARIES})
SET(GIT_GSSAPI 1) set(GIT_GSSAPI 1)
ADD_FEATURE_INFO(SPNEGO GIT_GSSAPI "SPNEGO authentication support (${USE_GSSAPI})") add_feature_info(SPNEGO GIT_GSSAPI "SPNEGO authentication support (${USE_GSSAPI})")
ELSE() else()
MESSAGE(FATAL_ERROR "Asked for backend ${USE_GSSAPI} but it wasn't found") message(FATAL_ERROR "Asked for backend ${USE_GSSAPI} but it wasn't found")
ENDIF() endif()
ELSE() else()
SET(GIT_GSSAPI 0) set(GIT_GSSAPI 0)
ADD_FEATURE_INFO(SPNEGO NO "SPNEGO authentication support") add_feature_info(SPNEGO NO "SPNEGO authentication support")
ENDIF() endif()

View File

@ -0,0 +1,19 @@
# Optional external dependency: http-parser
if(USE_HTTP_PARSER STREQUAL "system")
find_package(HTTPParser)
if(HTTP_PARSER_FOUND AND HTTP_PARSER_VERSION_MAJOR EQUAL 2)
list(APPEND LIBGIT2_SYSTEM_INCLUDES ${HTTP_PARSER_INCLUDE_DIRS})
list(APPEND LIBGIT2_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("${PROJECT_SOURCE_DIR}/deps/http-parser" "${PROJECT_BINARY_DIR}/deps/http-parser")
list(APPEND LIBGIT2_DEPENDENCY_INCLUDES "${PROJECT_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()

View File

@ -1,124 +1,124 @@
INCLUDE(SanitizeBool) include(SanitizeBool)
# We try to find any packages our backends might use # We try to find any packages our backends might use
FIND_PACKAGE(OpenSSL) find_package(OpenSSL)
FIND_PACKAGE(mbedTLS) find_package(mbedTLS)
IF (CMAKE_SYSTEM_NAME MATCHES "Darwin") if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
FIND_PACKAGE(Security) find_package(Security)
FIND_PACKAGE(CoreFoundation) find_package(CoreFoundation)
ENDIF() endif()
IF(USE_HTTPS) if(USE_HTTPS)
# Auto-select TLS backend # Auto-select TLS backend
SanitizeBool(USE_HTTPS) sanitizebool(USE_HTTPS)
IF (USE_HTTPS STREQUAL ON) if(USE_HTTPS STREQUAL ON)
IF (SECURITY_FOUND) if(SECURITY_FOUND)
IF (SECURITY_HAS_SSLCREATECONTEXT) if(SECURITY_HAS_SSLCREATECONTEXT)
SET(USE_HTTPS "SecureTransport") set(USE_HTTPS "SecureTransport")
ELSE() else()
MESSAGE(STATUS "Security framework is too old, falling back to OpenSSL") message(STATUS "Security framework is too old, falling back to OpenSSL")
SET(USE_HTTPS "OpenSSL") set(USE_HTTPS "OpenSSL")
ENDIF() endif()
ELSEIF (WINHTTP) elseif(USE_WINHTTP)
SET(USE_HTTPS "WinHTTP") set(USE_HTTPS "WinHTTP")
ELSEIF(OPENSSL_FOUND) elseif(OPENSSL_FOUND)
SET(USE_HTTPS "OpenSSL") set(USE_HTTPS "OpenSSL")
ELSEIF(MBEDTLS_FOUND) elseif(MBEDTLS_FOUND)
SET(USE_HTTPS "mbedTLS") set(USE_HTTPS "mbedTLS")
ELSE() else()
MESSAGE(FATAL_ERROR "Unable to autodetect a usable HTTPS backend." message(FATAL_ERROR "Unable to autodetect a usable HTTPS backend."
"Please pass the backend name explicitly (-DUSE_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 # Check that we can find what's required for the selected backend
IF (USE_HTTPS STREQUAL "SecureTransport") if(USE_HTTPS STREQUAL "SecureTransport")
IF (NOT COREFOUNDATION_FOUND) if(NOT COREFOUNDATION_FOUND)
MESSAGE(FATAL_ERROR "Cannot use SecureTransport backend, CoreFoundation.framework not found") message(FATAL_ERROR "Cannot use SecureTransport backend, CoreFoundation.framework not found")
ENDIF() endif()
IF (NOT SECURITY_FOUND) if(NOT SECURITY_FOUND)
MESSAGE(FATAL_ERROR "Cannot use SecureTransport backend, Security.framework not found") message(FATAL_ERROR "Cannot use SecureTransport backend, Security.framework not found")
ENDIF() endif()
IF (NOT SECURITY_HAS_SSLCREATECONTEXT) if(NOT SECURITY_HAS_SSLCREATECONTEXT)
MESSAGE(FATAL_ERROR "Cannot use SecureTransport backend, SSLCreateContext not supported") message(FATAL_ERROR "Cannot use SecureTransport backend, SSLCreateContext not supported")
ENDIF() endif()
SET(GIT_SECURE_TRANSPORT 1) set(GIT_SECURE_TRANSPORT 1)
LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${SECURITY_INCLUDE_DIR}) list(APPEND LIBGIT2_SYSTEM_INCLUDES ${SECURITY_INCLUDE_DIR})
LIST(APPEND LIBGIT2_LIBS ${COREFOUNDATION_LDFLAGS} ${SECURITY_LDFLAGS}) list(APPEND LIBGIT2_SYSTEM_LIBS ${COREFOUNDATION_LDFLAGS} ${SECURITY_LDFLAGS})
LIST(APPEND LIBGIT2_PC_LIBS ${COREFOUNDATION_LDFLAGS} ${SECURITY_LDFLAGS}) list(APPEND LIBGIT2_PC_LIBS ${COREFOUNDATION_LDFLAGS} ${SECURITY_LDFLAGS})
ELSEIF (USE_HTTPS STREQUAL "OpenSSL") elseif(USE_HTTPS STREQUAL "OpenSSL")
IF (NOT OPENSSL_FOUND) if(NOT OPENSSL_FOUND)
MESSAGE(FATAL_ERROR "Asked for OpenSSL TLS backend, but it wasn't found") message(FATAL_ERROR "Asked for OpenSSL TLS backend, but it wasn't found")
ENDIF() endif()
SET(GIT_OPENSSL 1) set(GIT_OPENSSL 1)
LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${OPENSSL_INCLUDE_DIR}) list(APPEND LIBGIT2_SYSTEM_INCLUDES ${OPENSSL_INCLUDE_DIR})
LIST(APPEND LIBGIT2_LIBS ${OPENSSL_LIBRARIES}) list(APPEND LIBGIT2_SYSTEM_LIBS ${OPENSSL_LIBRARIES})
LIST(APPEND LIBGIT2_PC_LIBS ${OPENSSL_LDFLAGS}) list(APPEND LIBGIT2_PC_LIBS ${OPENSSL_LDFLAGS})
LIST(APPEND LIBGIT2_PC_REQUIRES "openssl") list(APPEND LIBGIT2_PC_REQUIRES "openssl")
ELSEIF(USE_HTTPS STREQUAL "mbedTLS") elseif(USE_HTTPS STREQUAL "mbedTLS")
IF (NOT MBEDTLS_FOUND) if(NOT MBEDTLS_FOUND)
MESSAGE(FATAL_ERROR "Asked for mbedTLS backend, but it wasn't found") message(FATAL_ERROR "Asked for mbedTLS backend, but it wasn't found")
ENDIF() endif()
IF(NOT CERT_LOCATION) if(NOT CERT_LOCATION)
MESSAGE(STATUS "Auto-detecting default certificates location") message(STATUS "Auto-detecting default certificates location")
IF(CMAKE_SYSTEM_NAME MATCHES Darwin) if(CMAKE_SYSTEM_NAME MATCHES Darwin)
# Check for an Homebrew installation # Check for an Homebrew installation
SET(OPENSSL_CMD "/usr/local/opt/openssl/bin/openssl") set(OPENSSL_CMD "/usr/local/opt/openssl/bin/openssl")
ELSE() else()
SET(OPENSSL_CMD "openssl") set(OPENSSL_CMD "openssl")
ENDIF() endif()
EXECUTE_PROCESS(COMMAND ${OPENSSL_CMD} version -d OUTPUT_VARIABLE OPENSSL_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process(COMMAND ${OPENSSL_CMD} version -d OUTPUT_VARIABLE OPENSSL_DIR OUTPUT_STRIP_TRAILING_WHITESPACE)
IF(OPENSSL_DIR) if(OPENSSL_DIR)
STRING(REGEX REPLACE "^OPENSSLDIR: \"(.*)\"$" "\\1/" OPENSSL_DIR ${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 "ca-bundle.pem" # OpenSUSE Leap 42.1
"cert.pem" # Ubuntu 14.04, FreeBSD "cert.pem" # Ubuntu 14.04, FreeBSD
"certs/ca-certificates.crt" # Ubuntu 16.04 "certs/ca-certificates.crt" # Ubuntu 16.04
"certs/ca.pem" # Debian 7 "certs/ca.pem" # Debian 7
) )
FOREACH(SUFFIX IN LISTS OPENSSL_CA_LOCATIONS) foreach(SUFFIX IN LISTS OPENSSL_CA_LOCATIONS)
SET(LOC "${OPENSSL_DIR}${SUFFIX}") set(LOC "${OPENSSL_DIR}${SUFFIX}")
IF(NOT CERT_LOCATION AND EXISTS "${OPENSSL_DIR}${SUFFIX}") if(NOT CERT_LOCATION AND EXISTS "${OPENSSL_DIR}${SUFFIX}")
SET(CERT_LOCATION ${LOC}) set(CERT_LOCATION ${LOC})
ENDIF() endif()
ENDFOREACH() endforeach()
ELSE() else()
MESSAGE(FATAL_ERROR "Unable to find OpenSSL executable. Please provide default certificate location via CERT_LOCATION") message(FATAL_ERROR "Unable to find OpenSSL executable. Please provide default certificate location via CERT_LOCATION")
ENDIF() endif()
ENDIF() endif()
IF(CERT_LOCATION) if(CERT_LOCATION)
IF(NOT EXISTS ${CERT_LOCATION}) if(NOT EXISTS ${CERT_LOCATION})
MESSAGE(FATAL_ERROR "Cannot use CERT_LOCATION=${CERT_LOCATION} as it doesn't exist") message(FATAL_ERROR "Cannot use CERT_LOCATION=${CERT_LOCATION} as it doesn't exist")
ENDIF() endif()
ADD_FEATURE_INFO(CERT_LOCATION ON "using certificates from ${CERT_LOCATION}") add_feature_info(CERT_LOCATION ON "using certificates from ${CERT_LOCATION}")
ADD_DEFINITIONS(-DGIT_DEFAULT_CERT_LOCATION="${CERT_LOCATION}") add_definitions(-DGIT_DEFAULT_CERT_LOCATION="${CERT_LOCATION}")
ENDIF() endif()
SET(GIT_MBEDTLS 1) set(GIT_MBEDTLS 1)
LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${MBEDTLS_INCLUDE_DIR}) list(APPEND LIBGIT2_SYSTEM_INCLUDES ${MBEDTLS_INCLUDE_DIR})
LIST(APPEND LIBGIT2_LIBS ${MBEDTLS_LIBRARIES}) list(APPEND LIBGIT2_SYSTEM_LIBS ${MBEDTLS_LIBRARIES})
# mbedTLS has no pkgconfig file, hence we can't require it # mbedTLS has no pkgconfig file, hence we can't require it
# https://github.com/ARMmbed/mbedtls/issues/228 # https://github.com/ARMmbed/mbedtls/issues/228
# For now, pass its link flags as our own # For now, pass its link flags as our own
LIST(APPEND LIBGIT2_PC_LIBS ${MBEDTLS_LIBRARIES}) list(APPEND LIBGIT2_PC_LIBS ${MBEDTLS_LIBRARIES})
ELSEIF (USE_HTTPS STREQUAL "WinHTTP") elseif(USE_HTTPS STREQUAL "WinHTTP")
# WinHTTP setup was handled in the WinHTTP-specific block above # WinHTTP setup was handled in the WinHTTP-specific block above
ELSEIF (USE_HTTPS STREQUAL "OpenSSL-Dynamic") elseif(USE_HTTPS STREQUAL "OpenSSL-Dynamic")
SET(GIT_OPENSSL 1) set(GIT_OPENSSL 1)
SET(GIT_OPENSSL_DYNAMIC 1) set(GIT_OPENSSL_DYNAMIC 1)
LIST(APPEND LIBGIT2_LIBS dl) list(APPEND LIBGIT2_SYSTEM_LIBS dl)
ELSE() else()
MESSAGE(FATAL_ERROR "Asked for backend ${USE_HTTPS} but it wasn't found") message(FATAL_ERROR "Asked for backend ${USE_HTTPS} but it wasn't found")
ENDIF() endif()
SET(GIT_HTTPS 1) set(GIT_HTTPS 1)
ADD_FEATURE_INFO(HTTPS GIT_HTTPS "using ${USE_HTTPS}") add_feature_info(HTTPS GIT_HTTPS "using ${USE_HTTPS}")
ELSE() else()
SET(GIT_HTTPS 0) set(GIT_HTTPS 0)
ADD_FEATURE_INFO(HTTPS NO "") add_feature_info(HTTPS NO "")
ENDIF() endif()

View File

@ -1,62 +1,52 @@
# Select a hash backend # Select a hash backend
INCLUDE(SanitizeBool) include(SanitizeBool)
# USE_SHA1=CollisionDetection(ON)/HTTPS/Generic/OFF # 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") SET(USE_SHA1 "CollisionDetection")
ELSEIF(USE_SHA1 STREQUAL "HTTPS") elseif(USE_SHA1 STREQUAL "HTTPS")
IF(USE_HTTPS STREQUAL "SecureTransport") if(USE_HTTPS STREQUAL "SecureTransport")
SET(USE_SHA1 "CommonCrypto") set(USE_SHA1 "CommonCrypto")
ELSEIF(USE_HTTPS STREQUAL "WinHTTP") elseif(USE_HTTPS STREQUAL "WinHTTP")
SET(USE_SHA1 "Win32") set(USE_SHA1 "Win32")
ELSEIF(USE_HTTPS) elseif(USE_HTTPS)
SET(USE_SHA1 ${USE_HTTPS}) set(USE_SHA1 ${USE_HTTPS})
ELSE() else()
SET(USE_SHA1 "CollisionDetection") set(USE_SHA1 "CollisionDetection")
ENDIF() endif()
ENDIF() endif()
IF(USE_SHA1 STREQUAL "CollisionDetection") if(USE_SHA1 STREQUAL "CollisionDetection")
SET(GIT_SHA1_COLLISIONDETECT 1) set(GIT_SHA1_COLLISIONDETECT 1)
ADD_DEFINITIONS(-DSHA1DC_NO_STANDARD_INCLUDES=1) add_definitions(-DSHA1DC_NO_STANDARD_INCLUDES=1)
ADD_DEFINITIONS(-DSHA1DC_CUSTOM_INCLUDE_SHA1_C=\"common.h\") add_definitions(-DSHA1DC_CUSTOM_INCLUDE_SHA1_C=\"common.h\")
ADD_DEFINITIONS(-DSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_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")
ELSEIF(USE_SHA1 STREQUAL "OpenSSL")
# OPENSSL_FOUND should already be set, we're checking USE_HTTPS # OPENSSL_FOUND should already be set, we're checking USE_HTTPS
SET(GIT_SHA1_OPENSSL 1) set(GIT_SHA1_OPENSSL 1)
IF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
LIST(APPEND LIBGIT2_PC_LIBS "-lssl") list(APPEND LIBGIT2_PC_LIBS "-lssl")
ELSE() else()
LIST(APPEND LIBGIT2_PC_REQUIRES "openssl") list(APPEND LIBGIT2_PC_REQUIRES "openssl")
ENDIF() endif()
FILE(GLOB SRC_SHA1 hash/sha1/openssl.*) elseif(USE_SHA1 STREQUAL "CommonCrypto")
ELSEIF(USE_SHA1 STREQUAL "CommonCrypto") set(GIT_SHA1_COMMON_CRYPTO 1)
SET(GIT_SHA1_COMMON_CRYPTO 1) elseif(USE_SHA1 STREQUAL "mbedTLS")
FILE(GLOB SRC_SHA1 hash/sha1/common_crypto.*) set(GIT_SHA1_MBEDTLS 1)
ELSEIF(USE_SHA1 STREQUAL "mbedTLS") list(APPEND LIBGIT2_SYSTEM_INCLUDES ${MBEDTLS_INCLUDE_DIR})
SET(GIT_SHA1_MBEDTLS 1) list(APPEND LIBGIT2_SYSTEM_LIBS ${MBEDTLS_LIBRARIES})
FILE(GLOB SRC_SHA1 hash/sha1/mbedtls.*)
LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${MBEDTLS_INCLUDE_DIR})
LIST(APPEND LIBGIT2_LIBS ${MBEDTLS_LIBRARIES})
# mbedTLS has no pkgconfig file, hence we can't require it # mbedTLS has no pkgconfig file, hence we can't require it
# https://github.com/ARMmbed/mbedtls/issues/228 # https://github.com/ARMmbed/mbedtls/issues/228
# For now, pass its link flags as our own # For now, pass its link flags as our own
LIST(APPEND LIBGIT2_PC_LIBS ${MBEDTLS_LIBRARIES}) list(APPEND LIBGIT2_PC_LIBS ${MBEDTLS_LIBRARIES})
ELSEIF(USE_SHA1 STREQUAL "Win32") elseif(USE_SHA1 STREQUAL "Win32")
SET(GIT_SHA1_WIN32 1) set(GIT_SHA1_WIN32 1)
FILE(GLOB SRC_SHA1 hash/sha1/win32.*) elseif(NOT (USE_SHA1 STREQUAL "Generic"))
ELSEIF(USE_SHA1 STREQUAL "Generic") message(FATAL_ERROR "Asked for unknown SHA1 backend: ${USE_SHA1}")
FILE(GLOB SRC_SHA1 hash/sha1/generic.*) endif()
ELSE()
MESSAGE(FATAL_ERROR "Asked for unknown SHA1 backend: ${USE_SHA1}")
ENDIF()
list(APPEND SRC_SHA1 "hash/sha1.h") add_feature_info(SHA ON "using ${USE_SHA1}")
list(SORT SRC_SHA1)
ADD_FEATURE_INFO(SHA ON "using ${USE_SHA1}")

51
cmake/SelectRegex.cmake Normal file
View File

@ -0,0 +1,51 @@
# 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("${PROJECT_SOURCE_DIR}/deps/pcre" "${PROJECT_BINARY_DIR}/deps/pcre")
list(APPEND LIBGIT2_DEPENDENCY_INCLUDES "${PROJECT_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()

41
cmake/SelectSSH.cmake Normal file
View File

@ -0,0 +1,41 @@
# 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")

17
cmake/SelectWinHTTP.cmake Normal file
View File

@ -0,0 +1,17 @@
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("${PROJECT_SOURCE_DIR}/deps/winhttp" "${PROJECT_BINARY_DIR}/deps/winhttp")
list(APPEND LIBGIT2_SYSTEM_LIBS winhttp)
list(APPEND LIBGIT2_DEPENDENCY_INCLUDES "${PROJECT_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()

34
cmake/SelectZlib.cmake Normal file
View File

@ -0,0 +1,34 @@
# 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("${PROJECT_SOURCE_DIR}/deps/chromium-zlib" "${PROJECT_BINARY_DIR}/deps/chromium-zlib")
list(APPEND LIBGIT2_DEPENDENCY_INCLUDES "${PROJECT_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("${PROJECT_SOURCE_DIR}/deps/zlib" "${PROJECT_BINARY_DIR}/deps/zlib")
list(APPEND LIBGIT2_DEPENDENCY_INCLUDES "${PROJECT_SOURCE_DIR}/deps/zlib")
list(APPEND LIBGIT2_DEPENDENCY_OBJECTS $<TARGET_OBJECTS:zlib>)
add_feature_info(zlib ON "using bundled zlib")
endif()

63
docs/api-stability.md Normal file
View File

@ -0,0 +1,63 @@
The maintainers of the libgit2 project believe that having a stable API
to program against is important for our users and the ecosystem - whether
you're building against the libgit2 C APIs directly, creating a wrapper to
a managed language, or programming against one of those managed wrappers
like LibGit2Sharp or Rugged.
Our API stability considerations are:
* Our standard API is considered stable through a major release.
* We define our "standard API" to be anything included in the "git2.h"
header - in other words, anything defined in a header in the `git2`
directory.
* APIs will maintain their signature and will not be removed within a
major release, but new APIs may be added.
* Any APIs may be marked as deprecated within a major release, but will
not be removed until the next major release (at the earliest). You
may define `GIT_DEPRECATE_HARD` to produce compiler warnings if you
target these deprecated APIs.
* We consider API compatibility to be against the C APIs. That means
that we may use macros to keep API compatibility - for example, if we
rename a structure from `git_widget_options` to `git_foobar_options`
then we would `#define git_widget_options git_foobar_options` to retain
API compatibility. Note that this does _not_ provide ABI compatibility.
* Our systems API is only considered stable through a _minor_ release.
* We define our "systems API" to be anything included in the `git2/sys`
directory. These are not "standard" APIs but are mechanisms to extend
libgit2 by adding new extensions - for example, a custom HTTPS transport,
TLS engine, or merge strategy.
* Additionally, the cmake options and the resulting constants that it
produces to be "systems API".
* Generally these mechanism are well defined and will not need significant
changes, but are considered a part of the library itself and may need
* Systems API changes will be noted specially within a release's changelog.
* Our ABI is only considered stable through a _minor_ release.
* Our ABI consists of actual symbol names in the library, the function
signatures, and the actual layout of structures. These are only
stable within minor releases, they are not stable within major releases
(yet).
* Since many FFIs use ABIs directly (for example, .NET P/Invoke or Rust),
this instability is unfortunate.
* In a future major release, we will begin providing ABI stability
throughout the major release cycle.
* ABI changes will be noted specially within a release's changelog.
* Point releases are _generally_ only for bugfixes, and generally do _not_
include new features. This means that point releases generally do _not_
include new APIs. Point releases will never break API, systems API or
ABI compatibility.

63
docs/buffers.md Normal file
View File

@ -0,0 +1,63 @@
Memory allocation and ownership
-------------------------------
Any library needs to _take_ data from users, and then _return_ data to
users. With some types this is simple - integer parameters and return
types are trivial. But with more complex data types, things are more
complicated. Even something seemingly simple, like a C string, requires
discipline: we cannot simple return an allocated hunk of memory for
callers to `free`, since some systems have multiple allocators and users
cannot necessarily reason about the allocator used and which corresponding
deallocation function to call to free the memory.
## Objects
Most types in libgit2 are "opaque" types, which we treat as "objects" (even
though C is "not an object oriented language"). You may create an object -
for example, with `git_odb_new`, or libgit2 may return you an object as an
"out" parameter - for example, with `git_repository_open`. With any of
these objects, you should call their corresponding `_free` function (for
example, `git_odb_free` or `git_repository_free`) when you are done using
them.
## Structures
libgit2 will often take _input_ as structures (for example, options
structures like `git_merge_options`). Rarely, libgit2 will return data in
a structure. This is typically used for simpler data types, like `git_buf`
and `git_strarray`. Users should allocate the structure themselves (either
on the stack or the heap) and pass a pointer to it. Since libgit2 does not
allocate the structure itself, only the data inside of it, the deallocation
functions are suffixed with `_dispose` instead of `_free`, since they only
free the data _inside_ the structure.
## Strings or continuous memory buffers (`git_buf`)
libgit2 typically _takes_ NUL-terminated strings ("C strings") with a
`const char *`, and typically _takes_ raw data with a `const char *` and a
corresponding `size_t` for its size. libgit2 typically _returns_ strings
or raw data in a `git_buf` structure. The given data buffer will always be
NUL terminated (even if it contains binary data) and the `size` member will
always contain the size (in bytes) of the contents of the pointer (excluding
the NUL terminator).
In other words, if a `git_buf` contains the string `foo` then the memory
buffer will be { `f`, `o`, `o`, `\0` } and the size will be `3`.
Callers _must_ initialize the buffer with `GIT_BUF_INIT` (or by setting
all the members to `0`) when it is created, before passing a pointer
to the buffer to libgit2 for the first time.
Subsequent calls to libgit2 APIs that take a buffer can re-use a
buffer that was previously used. The buffer will be cleared and grown
to accommodate the new contents (if necessary). The new data will
written into the buffer, overwriting the previous contents. This
allows callers to reduce the number of allocations performed by the
library.
Callers must call `git_buf_dispose` when they have finished.
Note that the deprecated `git_diff_format_email` API does not follow
this behavior; subsequent calls will concatenate data to the buffer
instead of rewriting it. Users should move to the new `git_email`
APIs that follow the `git_buf` standards.

View File

@ -1,3 +1,133 @@
v1.4.3
------
🔒 This is a security release to provide compatibility with git's changes to address [CVE 2022-24765](https://github.blog/2022-04-12-git-security-vulnerability-announced/).
**libgit2 is not directly affected** by this vulnerability, because libgit2 does not directly invoke any executable. But we are providing these changes as a security release for any users that use libgit2 for repository discovery and then _also_ use git on that repository. In this release, we will now validate that the user opening the repository is the same user that owns the on-disk repository. This is to match git's behavior.
In addition, we are providing several correctness fixes where invalid input can lead to a crash. These may prevent possible denial of service attacks. At this time there are not known exploits to these issues.
Full list of changes:
* Validate repository directory ownership (v1.4) by @ethomson in https://github.com/libgit2/libgit2/pull/6267
* midx: Fix an undefined behavior (left-shift signed overflow) by @lhchavez in https://github.com/libgit2/libgit2/pull/6260
* fetch: support OID refspec without dst by @ethomson in https://github.com/libgit2/libgit2/pull/6251
* Fix crash when regenerating a patch with unquoted spaces in filename by @jorio in https://github.com/libgit2/libgit2/pull/6244
All users of the v1.4 release line are recommended to upgrade.
**Full Changelog**: https://github.com/libgit2/libgit2/compare/v1.4.2...v1.4.3
v1.4.2
------
This is a bugfix release with the following changes:
* remote: do store the update_tips callback error value by @carlosmn in https://github.com/libgit2/libgit2/pull/6226
* win32: `find_system_dirs` does not return `GIT_ENOTFOUND` by @ethomson in https://github.com/libgit2/libgit2/pull/6228
v1.4.1
------
This is a bugfix release with the following changes:
* xdiff: use xdl_free not free by @ethomson
* cmake: Fix package name for system http-parser by @mgorny
* Free parent and ref in lg2_commit before returning by @apnadkarni
v1.4
----
This is release v1.4.0, "Fisematenten". This release includes several new features and bugfixes, improves compatibility with git, and begins preparation for SHA256 support in a future release.
## What's Changed
### New features
* diff: update rename limit to 1000 to match git's behavior by @ethomson in https://github.com/libgit2/libgit2/pull/6092
* odb: support checking for object existence without refresh by @joshtriplett in https://github.com/libgit2/libgit2/pull/6107
* object: provide a low-level mechanism to validate whether a raw object is valid (`git_object_rawcontent_is_valid`) by @ethomson in https://github.com/libgit2/libgit2/pull/6128
* blob: provide a function to identify binary content by @ethomson in https://github.com/libgit2/libgit2/pull/6142
* status: add `rename_threshold` to `git_status_options`. by @arroz in https://github.com/libgit2/libgit2/pull/6158
* remote: support `http.followRedirects` (`false` and `initial`) and follow initial redirects by default by @ethomson in https://github.com/libgit2/libgit2/pull/6175
* remote: support scp style paths with ports (`[git@github.com:22]:libgit2/libgit2`) by @ethomson in https://github.com/libgit2/libgit2/pull/6167
* win32: update git for windows configuration file location compatibility by @csware in https://github.com/libgit2/libgit2/pull/6151 and @ethomson in https://github.com/libgit2/libgit2/pull/6180
* refs: speed up packed reference lookups when packed refs are sorted by @ccstolley in https://github.com/libgit2/libgit2/pull/6138
* merge: support zdiff3 conflict styles by @ethomson in https://github.com/libgit2/libgit2/pull/6195
* remote: support fetching by object id (using "+oid:ref" refspec syntax) by @ethomson in https://github.com/libgit2/libgit2/pull/6203
* merge: callers can specify virtual-base building behavior and to optionally accept conflict markers as a resolution by @boretrk in https://github.com/libgit2/libgit2/pull/6204
### Bug fixes
* Fix a gcc 11 warning in src/threadstate.c by @lhchavez in https://github.com/libgit2/libgit2/pull/6115
* Fix a gcc 11 warning in src/thread.h by @lhchavez in https://github.com/libgit2/libgit2/pull/6116
* cmake: re-enable WinHTTP by @ethomson in https://github.com/libgit2/libgit2/pull/6120
* Fix repo init when template dir is non-existent by @ammgws in https://github.com/libgit2/libgit2/pull/6106
* cmake: use project-specific root variable instead of CMAKE_SOURCE_DIR by @Qix- in https://github.com/libgit2/libgit2/pull/6146
* Better revparse compatibility for at time notation by @yoichi in https://github.com/libgit2/libgit2/pull/6095
* remotes: fix insteadOf/pushInsteadOf handling by @mkhl in https://github.com/libgit2/libgit2/pull/6101
* git_commit_summary: ignore lines with spaces by @stforek in https://github.com/libgit2/libgit2/pull/6125
* Config parsing by @csware in https://github.com/libgit2/libgit2/pull/6124
* config: handle empty conditional in includeIf by @ethomson in https://github.com/libgit2/libgit2/pull/6165
* #6154 git_status_list_new case insensitive fix by @arroz in https://github.com/libgit2/libgit2/pull/6159
* futils_mktmp: don't use umask by @boretrk in https://github.com/libgit2/libgit2/pull/6178
* revparse: support bare '@' by @ethomson in https://github.com/libgit2/libgit2/pull/6196
* odb: check for write failures by @ethomson in https://github.com/libgit2/libgit2/pull/6206
* push: Prepare pack before sending pack header. by @ccstolley in https://github.com/libgit2/libgit2/pull/6205
* mktmp: improve our temp file creation by @ethomson in https://github.com/libgit2/libgit2/pull/6207
* diff_file: fix crash if size of diffed file changes in workdir by @jorio in https://github.com/libgit2/libgit2/pull/6208
* merge: comment conflicts lines in MERGE_MSG by @ethomson in https://github.com/libgit2/libgit2/pull/6197
* Fix crashes in example programs on Windows (sprintf_s not compatible with snprintf) by @apnadkarni in https://github.com/libgit2/libgit2/pull/6212
### Code cleanups
* Introduce `git_remote_connect_options` by @ethomson in https://github.com/libgit2/libgit2/pull/6161
* hash: separate hashes and git_oid by @ethomson in https://github.com/libgit2/libgit2/pull/6082
* `git_buf`: now a public-only API (`git_str` is our internal API) by @ethomson in https://github.com/libgit2/libgit2/pull/6078
* cmake: cleanups and consistency by @ethomson in https://github.com/libgit2/libgit2/pull/6084
* path: refactor utility path functions by @ethomson in https://github.com/libgit2/libgit2/pull/6104
* str: git_str_free is never a function by @ethomson in https://github.com/libgit2/libgit2/pull/6111
* cmake refactorings by @ethomson in https://github.com/libgit2/libgit2/pull/6112
* Add missing-declarations warning globally by @ethomson in https://github.com/libgit2/libgit2/pull/6113
* cmake: further refactorings by @ethomson in https://github.com/libgit2/libgit2/pull/6114
* tag: set validity to 0 by default by @ethomson in https://github.com/libgit2/libgit2/pull/6119
* util: minor cleanup and refactoring to the date class by @ethomson in https://github.com/libgit2/libgit2/pull/6121
* Minor code cleanups by @ethomson in https://github.com/libgit2/libgit2/pull/6122
* Fix a long long that crept past by @NattyNarwhal in https://github.com/libgit2/libgit2/pull/6094
* remote: refactor insteadof application by @ethomson in https://github.com/libgit2/libgit2/pull/6147
* ntmlclient: fix linking with libressl by @boretrk in https://github.com/libgit2/libgit2/pull/6157
* c99: change single bit flags to unsigned by @boretrk in https://github.com/libgit2/libgit2/pull/6179
* Fix typos by @rex4539 in https://github.com/libgit2/libgit2/pull/6164
* diff_driver: split global_drivers array into separate elements by @boretrk in https://github.com/libgit2/libgit2/pull/6184
* cmake: disable some gnu extensions by @boretrk in https://github.com/libgit2/libgit2/pull/6185
* Disabling setting `CMAKE_FIND_LIBRARY_SUFFIXES` on Apple platforms. by @arroz in https://github.com/libgit2/libgit2/pull/6153
* C90: add inline macro to xdiff and mbedtls by @boretrk in https://github.com/libgit2/libgit2/pull/6200
* SHA256: early preparation by @ethomson in https://github.com/libgit2/libgit2/pull/6192
### CI improvements
* tests: rename test runner to `libgit2_tests`, build option to `BUILD_TESTS`. by @ethomson in https://github.com/libgit2/libgit2/pull/6083
* ci: only update docs on push by @ethomson in https://github.com/libgit2/libgit2/pull/6108
* Pedantic header test by @boretrk in https://github.com/libgit2/libgit2/pull/6086
* ci: build with ssh on nightly by @ethomson in https://github.com/libgit2/libgit2/pull/6148
* ci: improve the name in CI runs by @ethomson in https://github.com/libgit2/libgit2/pull/6198
### Documentation improvements
* Document that `git_odb` is thread-safe by @joshtriplett in https://github.com/libgit2/libgit2/pull/6109
* Improve documentation by @punkymaniac in https://github.com/libgit2/libgit2/pull/6168
### Other changes
* libgit2_clar is now libgit2_tests by @mkhl in https://github.com/libgit2/libgit2/pull/6100
* Remove PSGit from Language Bindings section of README by @cestrand in https://github.com/libgit2/libgit2/pull/6150
* COPYING: remove regex copyright, add PCRE copyright by @ethomson in https://github.com/libgit2/libgit2/pull/6187
* meta: add a release configuration file by @ethomson in https://github.com/libgit2/libgit2/pull/6211
## New Contributors
* @mkhl made their first contribution in https://github.com/libgit2/libgit2/pull/6100
* @ammgws made their first contribution in https://github.com/libgit2/libgit2/pull/6106
* @yoichi made their first contribution in https://github.com/libgit2/libgit2/pull/6095
* @stforek made their first contribution in https://github.com/libgit2/libgit2/pull/6125
* @cestrand made their first contribution in https://github.com/libgit2/libgit2/pull/6150
* @rex4539 made their first contribution in https://github.com/libgit2/libgit2/pull/6164
* @jorio made their first contribution in https://github.com/libgit2/libgit2/pull/6208
**Full Changelog**: https://github.com/libgit2/libgit2/compare/v1.3.0...v1.4.0
v1.3 v1.3
---- ----
@ -1963,3 +2093,8 @@ v0.22
functions. This is not something which we can know to do. A functions. This is not something which we can know to do. A
last-resort convenience function is provided in sys/openssl.h, last-resort convenience function is provided in sys/openssl.h,
`git_openssl_set_locking()` which can be used to set the locking. `git_openssl_set_locking()` which can be used to set the locking.
* `git_reference_*()` functions use mmap() + binary search for packed
refs lookups when using the fs backend. Previously all entries were
read into a hashtable, which could be slow for repositories with a
large number of refs.

View File

@ -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 any other test failures. Running the entire test suite is helpful
before you submit a pull request. When you build libgit2, the test 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 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: 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 Or you can run an entire class of tests. For example, to run all the
worktree status tests: worktree status tests:
libgit2_clar -sstatus::worktree libgit2_tests -sstatus::worktree
The default test run is fairly exhaustive, but it will exclude some The default test run is fairly exhaustive, but it will exclude some
unit tests by default: in particular, those that talk to network 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 ways (and may need to have special privileges to run). To run the
network tests: network tests:
libgit2_clar -ionline libgit2_tests -ionline
In addition, various tests may be enabled by environment variables, In addition, various tests may be enabled by environment variables,
like the ones that write exceptionally large repositories or manipulate like the ones that write exceptionally large repositories or manipulate

View File

@ -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. having the wrong access permissions, etc.) all of which will return -1.
When the object lookup is successful, it will return 0. 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 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 will not be modified by other threads. If threads are not enabled, then
the error message is in global data. the error message is in global data.

View File

@ -19,7 +19,7 @@ automated fuzz testing. libFuzzer only works with clang.
and [`leak`/`address,leak`](https://clang.llvm.org/docs/LeakSanitizer.html). and [`leak`/`address,leak`](https://clang.llvm.org/docs/LeakSanitizer.html).
3. Create the cmake build environment and configure the build with the 3. Create the cmake build environment and configure the build with the
sanitizer chosen: `CC=/usr/bin/clang-6.0 CFLAGS="-fsanitize=address" cmake sanitizer chosen: `CC=/usr/bin/clang-6.0 CFLAGS="-fsanitize=address" cmake
-DBUILD_CLAR=OFF -DBUILD_FUZZERS=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo ..`. -DBUILD_TESTS=OFF -DBUILD_FUZZERS=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo ..`.
Note that building the fuzzer targets is incompatible with the Note that building the fuzzer targets is incompatible with the
tests and examples. tests and examples.
4. Build libgit2: `cmake --build .` 4. Build libgit2: `cmake --build .`

View File

@ -80,4 +80,4 @@ and run it against our description file with the tip of `main` checked out.
cm doc api.docurium cm doc api.docurium
It will start up a few proceses and write out the results as a new commit onto the `gh-pages` branch. That can be pushed to GitHub to update what will show up on our documentation reference site. It will start up a few processes and write out the results as a new commit onto the `gh-pages` branch. That can be pushed to GitHub to update what will show up on our documentation reference site.

View File

@ -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 to share across threads, such as references and configuration
snapshots. snapshots.
The `git_odb` object uses locking internally, and is thread-safe to use from
multiple threads simultaneously.
Error messages Error messages
-------------- --------------

View File

@ -1,15 +1,16 @@
INCLUDE_DIRECTORIES(${LIBGIT2_INCLUDES}) file(GLOB SRC_EXAMPLES *.c *.h)
INCLUDE_DIRECTORIES(SYSTEM ${LIBGIT2_SYSTEM_INCLUDES})
FILE(GLOB LG2_SOURCES *.c *.h) add_executable(lg2 ${SRC_EXAMPLES})
ADD_EXECUTABLE(lg2 ${LG2_SOURCES}) set_target_properties(lg2 PROPERTIES C_STANDARD 90)
SET_TARGET_PROPERTIES(lg2 PROPERTIES C_STANDARD 90)
# Ensure that we do not use deprecated functions internally # Ensure that we do not use deprecated functions internally
ADD_DEFINITIONS(-DGIT_DEPRECATE_HARD) add_definitions(-DGIT_DEPRECATE_HARD)
IF(WIN32 OR ANDROID) target_include_directories(lg2 PRIVATE ${LIBGIT2_INCLUDES} ${LIBGIT2_DEPENDENCY_INCLUDES})
TARGET_LINK_LIBRARIES(lg2 git2) target_include_directories(lg2 SYSTEM PRIVATE ${LIBGIT2_SYSTEM_INCLUDES})
ELSE()
TARGET_LINK_LIBRARIES(lg2 git2 pthread) if(WIN32 OR ANDROID)
ENDIF() target_link_libraries(lg2 git2)
else()
target_link_libraries(lg2 git2 pthread)
endif()

View File

@ -28,7 +28,7 @@
enum index_mode { enum index_mode {
INDEX_NONE, INDEX_NONE,
INDEX_ADD, INDEX_ADD
}; };
struct index_options { struct index_options {
@ -110,22 +110,7 @@ int print_matched_cb(const char *path, const char *matched_pathspec, void *paylo
return ret; return ret;
} }
void init_array(git_strarray *array, int argc, char **argv) static void print_usage(void)
{
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)
{ {
fprintf(stderr, "usage: add [options] [--] file-spec [file-spec] [...]\n\n"); fprintf(stderr, "usage: add [options] [--] file-spec [file-spec] [...]\n\n");
fprintf(stderr, "\t-n, --dry-run dry run\n"); fprintf(stderr, "\t-n, --dry-run dry run\n");

View File

@ -49,7 +49,7 @@ int lg2_blame(git_repository *repo, int argc, char *argv[])
if (o.F) blameopts.flags |= GIT_BLAME_FIRST_PARENT; if (o.F) blameopts.flags |= GIT_BLAME_FIRST_PARENT;
/** /**
* The commit range comes in "commitish" form. Use the rev-parse API to * The commit range comes in "committish" form. Use the rev-parse API to
* nail down the end points. * nail down the end points.
*/ */
if (o.commitspec) { if (o.commitspec) {
@ -70,7 +70,7 @@ int lg2_blame(git_repository *repo, int argc, char *argv[])
/** /**
* Get the raw data inside the blob for output. We use the * Get the raw data inside the blob for output. We use the
* `commitish:path/to/file.txt` format to find it. * `committish:path/to/file.txt` format to find it.
*/ */
if (git_oid_is_zero(&blameopts.newest_commit)) if (git_oid_is_zero(&blameopts.newest_commit))
strcpy(spec, "HEAD"); strcpy(spec, "HEAD");

View File

@ -26,7 +26,7 @@
* This does have: * This does have:
* *
* - Example of performing a git commit with a comment * - Example of performing a git commit with a comment
* *
*/ */
int lg2_commit(git_repository *repo, int argc, char **argv) int lg2_commit(git_repository *repo, int argc, char **argv)
{ {
@ -36,10 +36,10 @@ int lg2_commit(git_repository *repo, int argc, char **argv)
git_oid commit_oid,tree_oid; git_oid commit_oid,tree_oid;
git_tree *tree; git_tree *tree;
git_index *index; git_index *index;
git_object *parent = NULL; git_object *parent = NULL;
git_reference *ref = NULL; git_reference *ref = NULL;
git_signature *signature; git_signature *signature;
/* Validate args */ /* Validate args */
if (argc < 3 || strcmp(opt, "-m") != 0) { if (argc < 3 || strcmp(opt, "-m") != 0) {
@ -62,9 +62,9 @@ int lg2_commit(git_repository *repo, int argc, char **argv)
check_lg2(git_index_write(index), "Could not write index", NULL);; check_lg2(git_index_write(index), "Could not write index", NULL);;
check_lg2(git_tree_lookup(&tree, repo, &tree_oid), "Error looking up tree", NULL); check_lg2(git_tree_lookup(&tree, repo, &tree_oid), "Error looking up tree", NULL);
check_lg2(git_signature_default(&signature, repo), "Error creating signature", NULL); check_lg2(git_signature_default(&signature, repo), "Error creating signature", NULL);
check_lg2(git_commit_create_v( check_lg2(git_commit_create_v(
&commit_oid, &commit_oid,
repo, repo,
@ -78,7 +78,9 @@ int lg2_commit(git_repository *repo, int argc, char **argv)
git_index_free(index); git_index_free(index);
git_signature_free(signature); git_signature_free(signature);
git_tree_free(tree); git_tree_free(tree);
git_object_free(parent);
git_reference_free(ref);
return error; return error;
} }

View File

@ -45,7 +45,7 @@
#endif #endif
#ifdef _MSC_VER #ifdef _MSC_VER
#define snprintf sprintf_s #define snprintf _snprintf
#define strcasecmp strcmpi #define strcasecmp strcmpi
#endif #endif

View File

@ -344,7 +344,7 @@ static void parse_opts(struct diff_options *o, int argc, char *argv[])
static void diff_print_stats(git_diff *diff, struct diff_options *o) static void diff_print_stats(git_diff *diff, struct diff_options *o)
{ {
git_diff_stats *stats; git_diff_stats *stats;
git_buf b = GIT_BUF_INIT_CONST(NULL, 0); git_buf b = GIT_BUF_INIT;
git_diff_stats_format_t format = 0; git_diff_stats_format_t format = 0;
check_lg2( check_lg2(

View File

@ -17,7 +17,6 @@ int lg2_index_pack(git_repository *repo, int argc, char **argv)
git_indexer *idx; git_indexer *idx;
git_indexer_progress stats = {0, 0}; git_indexer_progress stats = {0, 0};
int error; int error;
char hash[GIT_OID_HEXSZ + 1] = {0};
int fd; int fd;
ssize_t read_bytes; ssize_t read_bytes;
char buf[512]; char buf[512];
@ -61,8 +60,7 @@ int lg2_index_pack(git_repository *repo, int argc, char **argv)
printf("\rIndexing %u of %u\n", stats.indexed_objects, stats.total_objects); printf("\rIndexing %u of %u\n", stats.indexed_objects, stats.total_objects);
git_oid_fmt(hash, git_indexer_hash(idx)); puts(git_indexer_name(idx));
puts(hash);
cleanup: cleanup:
close(fd); close(fd);

View File

@ -27,7 +27,7 @@ enum subcmd {
subcmd_remove, subcmd_remove,
subcmd_rename, subcmd_rename,
subcmd_seturl, subcmd_seturl,
subcmd_show, subcmd_show
}; };
struct remote_opts { struct remote_opts {

View File

@ -38,7 +38,7 @@ enum {
FORMAT_DEFAULT = 0, FORMAT_DEFAULT = 0,
FORMAT_LONG = 1, FORMAT_LONG = 1,
FORMAT_SHORT = 2, FORMAT_SHORT = 2,
FORMAT_PORCELAIN = 3, FORMAT_PORCELAIN = 3
}; };
#define MAX_PATHSPEC 8 #define MAX_PATHSPEC 8

View File

@ -1,23 +1,26 @@
LINK_DIRECTORIES(${LIBGIT2_LIBDIRS}) if(BUILD_FUZZERS AND NOT USE_STANDALONE_FUZZERS)
INCLUDE_DIRECTORIES(${LIBGIT2_INCLUDES}) set(CMAKE_REQUIRED_FLAGS "-fsanitize=fuzzer-no-link")
INCLUDE_DIRECTORIES(SYSTEM ${LIBGIT2_SYSTEM_INCLUDES}) add_c_flag(-fsanitize=fuzzer)
add_c_flag(-fsanitize=fuzzer-no-link)
unset(CMAKE_REQUIRED_FLAGS)
endif()
IF(BUILD_FUZZERS AND NOT USE_STANDALONE_FUZZERS) file(GLOB SRC_FUZZERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *_fuzzer.c)
ADD_C_FLAG(-fsanitize=fuzzer) foreach(fuzz_target_src ${SRC_FUZZERS})
ENDIF () string(REPLACE ".c" "" fuzz_target_name ${fuzz_target_src})
string(REPLACE "_fuzzer" "" fuzz_name ${fuzz_target_name})
FILE(GLOB SRC_FUZZ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *_fuzzer.c) set(${fuzz_target_name}_SOURCES ${fuzz_target_src} ${LIBGIT2_OBJECTS})
FOREACH(fuzz_target_src ${SRC_FUZZ}) if(USE_STANDALONE_FUZZERS)
STRING(REPLACE ".c" "" fuzz_target_name ${fuzz_target_src}) list(APPEND ${fuzz_target_name}_SOURCES "standalone_driver.c")
STRING(REPLACE "_fuzzer" "" fuzz_name ${fuzz_target_name}) endif()
add_executable(${fuzz_target_name} ${${fuzz_target_name}_SOURCES})
set_target_properties(${fuzz_target_name} PROPERTIES C_STANDARD 90)
SET(${fuzz_target_name}_SOURCES ${fuzz_target_src} ${LIBGIT2_OBJECTS}) target_include_directories(${fuzz_target_name} PRIVATE ${LIBGIT2_INCLUDES} ${LIBGIT2_DEPENDENCY_INCLUDES})
IF(USE_STANDALONE_FUZZERS) target_include_directories(${fuzz_target_name} SYSTEM PRIVATE ${LIBGIT2_SYSTEM_INCLUDES})
LIST(APPEND ${fuzz_target_name}_SOURCES "standalone_driver.c")
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})
ADD_TEST(${fuzz_target_name} "${CMAKE_CURRENT_BINARY_DIR}/${fuzz_target_name}" "${CMAKE_CURRENT_SOURCE_DIR}/corpora/${fuzz_name}") target_link_libraries(${fuzz_target_name} ${LIBGIT2_SYSTEM_LIBS})
ENDFOREACH()
add_test(${fuzz_target_name} "${CMAKE_CURRENT_BINARY_DIR}/${fuzz_target_name}" "${CMAKE_CURRENT_SOURCE_DIR}/corpora/${fuzz_name}")
endforeach()

View File

@ -11,12 +11,14 @@
#include "git2.h" #include "git2.h"
#include "buffer.h"
#include "common.h" #include "common.h"
#include "str.h"
#include "futils.h" #include "futils.h"
#include "hash.h" #include "hash.h"
#include "commit_graph.h" #include "commit_graph.h"
#include "standalone_driver.h"
int LLVMFuzzerInitialize(int *argc, char ***argv) int LLVMFuzzerInitialize(int *argc, char ***argv)
{ {
GIT_UNUSED(argc); GIT_UNUSED(argc);
@ -33,7 +35,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{ {
git_commit_graph_file file = {{0}}; git_commit_graph_file file = {{0}};
git_commit_graph_entry e; git_commit_graph_entry e;
git_buf commit_graph_buf = GIT_BUF_INIT; git_str commit_graph_buf = GIT_STR_INIT;
unsigned char hash[GIT_HASH_SHA1_SIZE];
git_oid oid = {{0}}; git_oid oid = {{0}};
bool append_hash = false; bool append_hash = false;
@ -50,22 +53,24 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
size -= 4; size -= 4;
if (append_hash) { if (append_hash) {
if (git_buf_init(&commit_graph_buf, size + sizeof(oid)) < 0) if (git_str_init(&commit_graph_buf, size + GIT_HASH_SHA1_SIZE) < 0)
goto cleanup; goto cleanup;
if (git_hash_buf(&oid, data, size) < 0) { if (git_hash_buf(hash, data, size, GIT_HASH_ALGORITHM_SHA1) < 0) {
fprintf(stderr, "Failed to compute the SHA1 hash\n"); fprintf(stderr, "Failed to compute the SHA1 hash\n");
abort(); abort();
} }
memcpy(commit_graph_buf.ptr, data, size); memcpy(commit_graph_buf.ptr, data, size);
memcpy(commit_graph_buf.ptr + size, &oid, sizeof(oid)); memcpy(commit_graph_buf.ptr + size, hash, GIT_HASH_SHA1_SIZE);
memcpy(oid.id, hash, GIT_OID_RAWSZ);
} else { } else {
git_buf_attach_notowned(&commit_graph_buf, (char *)data, size); git_str_attach_notowned(&commit_graph_buf, (char *)data, size);
} }
if (git_commit_graph_file_parse( if (git_commit_graph_file_parse(
&file, &file,
(const unsigned char *)git_buf_cstr(&commit_graph_buf), (const unsigned char *)git_str_cstr(&commit_graph_buf),
git_buf_len(&commit_graph_buf)) git_str_len(&commit_graph_buf))
< 0) < 0)
goto cleanup; goto cleanup;
@ -75,6 +80,6 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
cleanup: cleanup:
git_commit_graph_file_close(&file); git_commit_graph_file_close(&file);
git_buf_dispose(&commit_graph_buf); git_str_dispose(&commit_graph_buf);
return 0; return 0;
} }

View File

@ -10,9 +10,11 @@
#include "git2.h" #include "git2.h"
#include "config_backend.h" #include "config_backend.h"
#include "standalone_driver.h"
#define UNUSED(x) (void)(x) #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(entry);
UNUSED(payload); UNUSED(payload);

View File

@ -64,7 +64,7 @@ slack channel once you've registered.
If you have questions about the library, please be sure to check out the If you have questions about the library, please be sure to check out the
[API documentation](http://libgit2.github.com/libgit2/). If you still have [API documentation](http://libgit2.github.com/libgit2/). If you still have
questions, reach out to us on Slack or post a question on questions, reach out to us on Slack or post a question on
[StackOverflow](http://stackoverflow.com/questions/tagged/libgit2) (with the `libgit2` tag). [StackOverflow](http://stackoverflow.com/questions/tagged/libgit2) (with the `libgit2` tag).
**Reporting Bugs** **Reporting Bugs**
@ -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, 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 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 individual tests, or groups of tests using the `-s` flag. For example, to
run the index tests: run the index tests:
$ ./libgit2_clar -sindex $ ./libgit2_tests -sindex
To run a single test named `index::racy::diff`, which corresponds to the test 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]: 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 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 failing test. An `S` indicates that a test was skipped because it is not
@ -229,7 +229,7 @@ The following CMake variables are declared:
- `LIB_INSTALL_DIR`: Where to install libraries to. - `LIB_INSTALL_DIR`: Where to install libraries to.
- `INCLUDE_INSTALL_DIR`: Where to install headers to. - `INCLUDE_INSTALL_DIR`: Where to install headers to.
- `BUILD_SHARED_LIBS`: Build libgit2 as a Shared Library (defaults to ON) - `BUILD_SHARED_LIBS`: Build libgit2 as a Shared Library (defaults to ON)
- `BUILD_CLAR`: Build [Clar](https://github.com/vmg/clar)-based test suite (defaults to ON) - `BUILD_TESTS`: Build [Clar](https://github.com/vmg/clar)-based test suite (defaults to ON)
- `THREADSAFE`: Build libgit2 with threading support (defaults to ON) - `THREADSAFE`: Build libgit2 with threading support (defaults to ON)
- `STDCALL`: Build libgit2 as `stdcall`. Turn off for `cdecl` (Windows; defaults to ON) - `STDCALL`: Build libgit2 as `stdcall`. Turn off for `cdecl` (Windows; defaults to ON)

View File

@ -15,6 +15,8 @@
#include "git2/sys/transport.h" #include "git2/sys/transport.h"
#include "futils.h" #include "futils.h"
#include "standalone_driver.h"
#define UNUSED(x) (void)(x) #define UNUSED(x) (void)(x)
struct fuzzer_buffer { struct fuzzer_buffer {
@ -130,7 +132,7 @@ static int fuzzer_subtransport_new(
return 0; return 0;
} }
int fuzzer_subtransport_cb( static int fuzzer_subtransport_cb(
git_smart_subtransport **out, git_smart_subtransport **out,
git_transport *owner, git_transport *owner,
void *payload) void *payload)
@ -145,7 +147,7 @@ int fuzzer_subtransport_cb(
return 0; 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 = { git_smart_subtransport_definition def = {
fuzzer_subtransport_cb, 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); 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(); const git_error *err = git_error_last();
fprintf(stderr, "unexpected libgit error: %s: %s\n", fprintf(stderr, "unexpected libgit error: %s: %s\n",

View File

@ -11,12 +11,13 @@
#include "git2.h" #include "git2.h"
#include "buffer.h"
#include "common.h" #include "common.h"
#include "futils.h" #include "futils.h"
#include "hash.h" #include "hash.h"
#include "midx.h" #include "midx.h"
#include "standalone_driver.h"
int LLVMFuzzerInitialize(int *argc, char ***argv) int LLVMFuzzerInitialize(int *argc, char ***argv)
{ {
GIT_UNUSED(argc); GIT_UNUSED(argc);
@ -33,7 +34,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{ {
git_midx_file idx = {{0}}; git_midx_file idx = {{0}};
git_midx_entry e; git_midx_entry e;
git_buf midx_buf = GIT_BUF_INIT; git_str midx_buf = GIT_STR_INIT;
unsigned char hash[GIT_HASH_SHA1_SIZE];
git_oid oid = {{0}}; git_oid oid = {{0}};
bool append_hash = false; bool append_hash = false;
@ -50,19 +52,21 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
size -= 4; size -= 4;
if (append_hash) { if (append_hash) {
if (git_buf_init(&midx_buf, size + sizeof(oid)) < 0) if (git_str_init(&midx_buf, size + GIT_HASH_SHA1_SIZE) < 0)
goto cleanup; goto cleanup;
if (git_hash_buf(&oid, data, size) < 0) { if (git_hash_buf(hash, data, size, GIT_HASH_ALGORITHM_SHA1) < 0) {
fprintf(stderr, "Failed to compute the SHA1 hash\n"); fprintf(stderr, "Failed to compute the SHA1 hash\n");
abort(); abort();
} }
memcpy(midx_buf.ptr, data, size); memcpy(midx_buf.ptr, data, size);
memcpy(midx_buf.ptr + size, &oid, sizeof(oid)); memcpy(midx_buf.ptr + size, hash, GIT_HASH_SHA1_SIZE);
memcpy(oid.id, hash, GIT_OID_RAWSZ);
} else { } else {
git_buf_attach_notowned(&midx_buf, (char *)data, size); git_str_attach_notowned(&midx_buf, (char *)data, size);
} }
if (git_midx_parse(&idx, (const unsigned char *)git_buf_cstr(&midx_buf), git_buf_len(&midx_buf)) < 0) if (git_midx_parse(&idx, (const unsigned char *)git_str_cstr(&midx_buf), git_str_len(&midx_buf)) < 0)
goto cleanup; goto cleanup;
/* Search for any oid, just to exercise that codepath. */ /* Search for any oid, just to exercise that codepath. */
@ -71,6 +75,6 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
cleanup: cleanup:
git_midx_close(&idx); git_midx_close(&idx);
git_buf_dispose(&midx_buf); git_str_dispose(&midx_buf);
return 0; return 0;
} }

View File

@ -10,6 +10,8 @@
#include "git2.h" #include "git2.h"
#include "object.h" #include "object.h"
#include "standalone_driver.h"
#define UNUSED(x) (void)(x) #define UNUSED(x) (void)(x)
int LLVMFuzzerInitialize(int *argc, char ***argv) int LLVMFuzzerInitialize(int *argc, char ***argv)

View File

@ -12,7 +12,9 @@
#include "git2.h" #include "git2.h"
#include "git2/sys/mempack.h" #include "git2/sys/mempack.h"
#include "common.h" #include "common.h"
#include "buffer.h" #include "str.h"
#include "standalone_driver.h"
static git_odb *odb = NULL; static git_odb *odb = NULL;
static git_odb_backend *mempack = NULL; static git_odb_backend *mempack = NULL;
@ -53,7 +55,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{ {
git_indexer_progress stats = {0, 0}; git_indexer_progress stats = {0, 0};
git_indexer *indexer = NULL; git_indexer *indexer = NULL;
git_buf path = GIT_BUF_INIT; git_str path = GIT_STR_INIT;
git_oid oid; git_oid oid;
bool append_hash = false; bool append_hash = false;
@ -99,19 +101,19 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
if (git_indexer_commit(indexer, &stats) < 0) if (git_indexer_commit(indexer, &stats) < 0)
goto cleanup; goto cleanup;
if (git_buf_printf(&path, "pack-%s.idx", git_oid_tostr_s(git_indexer_hash(indexer))) < 0) if (git_str_printf(&path, "pack-%s.idx", git_indexer_name(indexer)) < 0)
goto cleanup; goto cleanup;
p_unlink(git_buf_cstr(&path)); p_unlink(git_str_cstr(&path));
git_buf_clear(&path); git_str_clear(&path);
if (git_buf_printf(&path, "pack-%s.pack", git_oid_tostr_s(git_indexer_hash(indexer))) < 0) if (git_str_printf(&path, "pack-%s.pack", git_indexer_name(indexer)) < 0)
goto cleanup; goto cleanup;
p_unlink(git_buf_cstr(&path)); p_unlink(git_str_cstr(&path));
cleanup: cleanup:
git_mempack_reset(mempack); git_mempack_reset(mempack);
git_indexer_free(indexer); git_indexer_free(indexer);
git_buf_dispose(&path); git_str_dispose(&path);
return 0; return 0;
} }

View File

@ -11,6 +11,8 @@
#include "patch.h" #include "patch.h"
#include "patch_parse.h" #include "patch_parse.h"
#include "standalone_driver.h"
#define UNUSED(x) (void)(x) #define UNUSED(x) (void)(x)
int LLVMFuzzerInitialize(int *argc, char ***argv) int LLVMFuzzerInitialize(int *argc, char ***argv)

View File

@ -11,12 +11,11 @@
#include "futils.h" #include "futils.h"
#include "path.h" #include "path.h"
extern int LLVMFuzzerTestOneInput(const unsigned char *data, size_t size); #include "standalone_driver.h"
extern int LLVMFuzzerInitialize(int *argc, char ***argv);
static int run_one_file(const char *filename) static int run_one_file(const char *filename)
{ {
git_buf buf = GIT_BUF_INIT; git_str buf = GIT_STR_INIT;
int error = 0; int error = 0;
if (git_futils_readbuffer(&buf, filename) < 0) { if (git_futils_readbuffer(&buf, filename) < 0) {
@ -27,7 +26,7 @@ static int run_one_file(const char *filename)
LLVMFuzzerTestOneInput((const unsigned char *)buf.ptr, buf.size); LLVMFuzzerTestOneInput((const unsigned char *)buf.ptr, buf.size);
exit: exit:
git_buf_dispose(&buf); git_str_dispose(&buf);
return error; return error;
} }
@ -52,7 +51,7 @@ int main(int argc, char **argv)
fprintf(stderr, "Running %s against %s\n", argv[0], argv[1]); fprintf(stderr, "Running %s against %s\n", argv[0], argv[1]);
LLVMFuzzerInitialize(&argc, &argv); 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", fprintf(stderr, "Failed to scan corpus directory '%s': %s\n",
argv[1], git_error_last()->message); argv[1], git_error_last()->message);
error = -1; error = -1;

View File

@ -0,0 +1,14 @@
/*
* 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

View File

@ -32,6 +32,8 @@ GIT_BEGIN_DECL
* *
* @param delta The delta to be applied * @param delta The delta to be applied
* @param payload User-specified payload * @param payload User-specified payload
* @return 0 if the delta is applied, < 0 if the apply process will be aborted
* or > 0 if the delta will not be applied.
*/ */
typedef int GIT_CALLBACK(git_apply_delta_cb)( typedef int GIT_CALLBACK(git_apply_delta_cb)(
const git_diff_delta *delta, const git_diff_delta *delta,
@ -48,6 +50,8 @@ typedef int GIT_CALLBACK(git_apply_delta_cb)(
* *
* @param hunk The hunk to be applied * @param hunk The hunk to be applied
* @param payload User-specified payload * @param payload User-specified payload
* @return 0 if the hunk is applied, < 0 if the apply process will be aborted
* or > 0 if the hunk will not be applied.
*/ */
typedef int GIT_CALLBACK(git_apply_hunk_cb)( typedef int GIT_CALLBACK(git_apply_hunk_cb)(
const git_diff_hunk *hunk, const git_diff_hunk *hunk,
@ -59,7 +63,7 @@ typedef enum {
* Don't actually make changes, just test that the patch applies. * Don't actually make changes, just test that the patch applies.
* This is the equivalent of `git apply --check`. * This is the equivalent of `git apply --check`.
*/ */
GIT_APPLY_CHECK = (1 << 0), GIT_APPLY_CHECK = (1 << 0)
} git_apply_flags_t; } git_apply_flags_t;
/** /**
@ -89,6 +93,16 @@ typedef struct {
#define GIT_APPLY_OPTIONS_VERSION 1 #define GIT_APPLY_OPTIONS_VERSION 1
#define GIT_APPLY_OPTIONS_INIT {GIT_APPLY_OPTIONS_VERSION} #define GIT_APPLY_OPTIONS_INIT {GIT_APPLY_OPTIONS_VERSION}
/**
* Initialize git_apply_options structure
*
* Initialize a `git_apply_options` with default values. Equivalent to creating
* an instance with GIT_APPLY_OPTIONS_INIT.
*
* @param opts The `git_apply_options` struct to initialize.
* @param version The struct version; pass `GIT_APPLY_OPTIONS_VERSION`
* @return 0 on success or -1 on failure.
*/
GIT_EXTERN(int) git_apply_options_init(git_apply_options *opts, unsigned int version); GIT_EXTERN(int) git_apply_options_init(git_apply_options *opts, unsigned int version);
/** /**
@ -127,7 +141,7 @@ typedef enum {
* Apply the patch to both the working directory and the index. * Apply the patch to both the working directory and the index.
* This is the equivalent of `git apply --index`. * This is the equivalent of `git apply --index`.
*/ */
GIT_APPLY_LOCATION_BOTH = 2, GIT_APPLY_LOCATION_BOTH = 2
} git_apply_location_t; } git_apply_location_t;
/** /**

View File

@ -83,7 +83,7 @@ typedef enum {
GIT_ATTR_VALUE_UNSPECIFIED = 0, /**< The attribute has been left unspecified */ GIT_ATTR_VALUE_UNSPECIFIED = 0, /**< The attribute has been left unspecified */
GIT_ATTR_VALUE_TRUE, /**< The attribute has been set */ GIT_ATTR_VALUE_TRUE, /**< The attribute has been set */
GIT_ATTR_VALUE_FALSE, /**< The attribute has been unset */ 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; } git_attr_value_t;
/** /**
@ -177,6 +177,7 @@ typedef struct {
* not have to exist, but if it does not, then it will be * not have to exist, but if it does not, then it will be
* treated as a plain file (not a directory). * treated as a plain file (not a directory).
* @param name The name of the attribute to look up. * @param name The name of the attribute to look up.
* @return 0 or an error code.
*/ */
GIT_EXTERN(int) git_attr_get( GIT_EXTERN(int) git_attr_get(
const char **value_out, const char **value_out,
@ -199,6 +200,7 @@ GIT_EXTERN(int) git_attr_get(
* not have to exist, but if it does not, then it will be * not have to exist, but if it does not, then it will be
* treated as a plain file (not a directory). * treated as a plain file (not a directory).
* @param name The name of the attribute to look up. * @param name The name of the attribute to look up.
* @return 0 or an error code.
*/ */
GIT_EXTERN(int) git_attr_get_ext( GIT_EXTERN(int) git_attr_get_ext(
const char **value_out, const char **value_out,
@ -235,6 +237,7 @@ GIT_EXTERN(int) git_attr_get_ext(
* it will be treated as a plain file (i.e. not a directory). * it will be treated as a plain file (i.e. not a directory).
* @param num_attr The number of attributes being looked up * @param num_attr The number of attributes being looked up
* @param names An array of num_attr strings containing attribute names. * @param names An array of num_attr strings containing attribute names.
* @return 0 or an error code.
*/ */
GIT_EXTERN(int) git_attr_get_many( GIT_EXTERN(int) git_attr_get_many(
const char **values_out, const char **values_out,
@ -259,6 +262,7 @@ GIT_EXTERN(int) git_attr_get_many(
* it will be treated as a plain file (i.e. not a directory). * it will be treated as a plain file (i.e. not a directory).
* @param num_attr The number of attributes being looked up * @param num_attr The number of attributes being looked up
* @param names An array of num_attr strings containing attribute names. * @param names An array of num_attr strings containing attribute names.
* @return 0 or an error code.
*/ */
GIT_EXTERN(int) git_attr_get_many_ext( GIT_EXTERN(int) git_attr_get_many_ext(
const char **values_out, const char **values_out,
@ -344,11 +348,16 @@ GIT_EXTERN(int) git_attr_cache_flush(
* Add a macro definition. * Add a macro definition.
* *
* Macros will automatically be loaded from the top level `.gitattributes` * Macros will automatically be loaded from the top level `.gitattributes`
* file of the repository (plus the build-in "binary" macro). This * file of the repository (plus the built-in "binary" macro). This
* function allows you to add others. For example, to add the default * function allows you to add others. For example, to add the default
* macro, you would call: * macro, you would call:
* *
* git_attr_add_macro(repo, "binary", "-diff -crlf"); * git_attr_add_macro(repo, "binary", "-diff -crlf");
*
* @param repo The repository to add the macro in.
* @param name The name of the macro.
* @param values The value for the macro.
* @return 0 or an error code.
*/ */
GIT_EXTERN(int) git_attr_add_macro( GIT_EXTERN(int) git_attr_add_macro(
git_repository *repo, git_repository *repo,

View File

@ -73,7 +73,7 @@ typedef enum {
GIT_BLAME_USE_MAILMAP = (1<<5), GIT_BLAME_USE_MAILMAP = (1<<5),
/** Ignore whitespace differences */ /** Ignore whitespace differences */
GIT_BLAME_IGNORE_WHITESPACE = (1<<6), GIT_BLAME_IGNORE_WHITESPACE = (1<<6)
} git_blame_flag_t; } git_blame_flag_t;
/** /**
@ -203,6 +203,9 @@ typedef struct git_blame git_blame;
/** /**
* Gets the number of hunks that exist in the blame structure. * Gets the number of hunks that exist in the blame structure.
*
* @param blame The blame structure to query.
* @return The number of hunks.
*/ */
GIT_EXTERN(uint32_t) git_blame_get_hunk_count(git_blame *blame); GIT_EXTERN(uint32_t) git_blame_get_hunk_count(git_blame *blame);

View File

@ -119,7 +119,7 @@ typedef enum {
* When set, filters will be loaded from a `.gitattributes` file * When set, filters will be loaded from a `.gitattributes` file
* in the specified commit. * 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; } git_blob_filter_flag_t;
/** /**
@ -284,12 +284,25 @@ GIT_EXTERN(int) git_blob_create_from_buffer(
*/ */
GIT_EXTERN(int) git_blob_is_binary(const git_blob *blob); GIT_EXTERN(int) git_blob_is_binary(const git_blob *blob);
/**
* Determine if the given content is most certainly binary or not;
* this is the same mechanism used by `git_blob_is_binary` but only
* looking at raw data.
*
* @param data The blob data which content should be analyzed
* @param len The length of the data
* @return 1 if the content of the blob is detected
* as binary; 0 otherwise.
*/
GIT_EXTERN(int) git_blob_data_is_binary(const char *data, size_t len);
/** /**
* Create an in-memory copy of a blob. The copy must be explicitly * Create an in-memory copy of a blob. The copy must be explicitly
* free'd or it will leak. * free'd or it will leak.
* *
* @param out Pointer to store the copy of the object * @param out Pointer to store the copy of the object
* @param source Original object to copy * @param source Original object to copy
* @return 0.
*/ */
GIT_EXTERN(int) git_blob_dup(git_blob **out, git_blob *source); GIT_EXTERN(int) git_blob_dup(git_blob **out, git_blob *source);

View File

@ -34,6 +34,8 @@ GIT_BEGIN_DECL
* *
* @param out Pointer where to store the underlying reference. * @param out Pointer where to store the underlying reference.
* *
* @param repo the repository to create the branch in.
*
* @param branch_name Name for the branch; this name is * @param branch_name Name for the branch; this name is
* validated for consistency. It should also not conflict with * validated for consistency. It should also not conflict with
* an already existing branch name. * an already existing branch name.

View File

@ -23,110 +23,50 @@ GIT_BEGIN_DECL
* *
* Sometimes libgit2 wants to return an allocated data buffer to the * Sometimes libgit2 wants to return an allocated data buffer to the
* caller and have the caller take responsibility for freeing that memory. * caller and have the caller take responsibility for freeing that memory.
* This can be awkward if the caller does not have easy access to the same * To make ownership clear in these cases, libgit2 uses `git_buf` to
* allocation functions that libgit2 is using. In those cases, libgit2 * return this data. Callers should use `git_buf_dispose()` to release
* will fill in a `git_buf` and the caller can use `git_buf_dispose()` to * the memory when they are done.
* release it when they are done.
* *
* A `git_buf` may also be used for the caller to pass in a reference to * A `git_buf` contains a pointer to a NUL-terminated C string, and
* a block of memory they hold. In this case, libgit2 will not resize or * the length of the string (not including the NUL terminator).
* free the memory, but will read from it as needed.
*
* Some APIs may occasionally do something slightly unusual with a buffer,
* such as setting `ptr` to a value that was passed in by the user. In
* those cases, the behavior will be clearly documented by the API.
*/ */
typedef struct { typedef struct {
/** /**
* The buffer contents. * The buffer contents. `ptr` points to the start of the buffer
* * being returned. The buffer's length (in bytes) is specified
* `ptr` points to the start of the allocated memory. If it is NULL, * by the `size` member of the structure, and contains a NUL
* then the `git_buf` is considered empty and libgit2 will feel free * terminator at position `(size + 1)`.
* to overwrite it with new data.
*/ */
char *ptr; char *ptr;
/** /**
* `asize` holds the known total amount of allocated memory if the `ptr` * This field is reserved and unused.
* was allocated by libgit2. It may be larger than `size`. If `ptr`
* was not allocated by libgit2 and should not be resized and/or freed,
* then `asize` will be set to zero.
*/ */
size_t asize; size_t reserved;
/** /**
* `size` holds the size (in bytes) of the data that is actually used. * The length (in bytes) of the buffer pointed to by `ptr`,
* not including a NUL terminator.
*/ */
size_t size; size_t size;
} git_buf; } git_buf;
/** /**
* Static initializer for git_buf from static buffer * Use to initialize a `git_buf` before passing it to a function that
* will populate it.
*/ */
#define GIT_BUF_INIT_CONST(STR,LEN) { (char *)(STR), 0, (size_t)(LEN) } #define GIT_BUF_INIT { NULL, 0, 0 }
/** /**
* Free the memory referred to by the git_buf. * Free the memory referred to by the git_buf.
* *
* Note that this does not free the `git_buf` itself, just the memory * Note that this does not free the `git_buf` itself, just the memory
* pointed to by `buffer->ptr`. This will not free the memory if it looks * pointed to by `buffer->ptr`.
* like it was not allocated internally, but it will clear the buffer back
* to the empty state.
* *
* @param buffer The buffer to deallocate * @param buffer The buffer to deallocate
*/ */
GIT_EXTERN(void) git_buf_dispose(git_buf *buffer); GIT_EXTERN(void) git_buf_dispose(git_buf *buffer);
/**
* Resize the buffer allocation to make more space.
*
* This will attempt to grow the buffer to accommodate the target size.
*
* If the buffer refers to memory that was not allocated by libgit2 (i.e.
* the `asize` field is zero), then `ptr` will be replaced with a newly
* allocated block of data. Be careful so that memory allocated by the
* caller is not lost. As a special variant, if you pass `target_size` as
* 0 and the memory is not allocated by libgit2, this will allocate a new
* buffer of size `size` and copy the external data into it.
*
* Currently, this will never shrink a buffer, only expand it.
*
* If the allocation fails, this will return an error and the buffer will be
* marked as invalid for future operations, invaliding the contents.
*
* @param buffer The buffer to be resized; may or may not be allocated yet
* @param target_size The desired available size
* @return 0 on success, -1 on allocation failure
*/
GIT_EXTERN(int) git_buf_grow(git_buf *buffer, size_t target_size);
/**
* Set buffer to a copy of some raw data.
*
* @param buffer The buffer to set
* @param data The data to copy into the buffer
* @param datalen The length of the data to copy into the buffer
* @return 0 on success, -1 on allocation failure
*/
GIT_EXTERN(int) git_buf_set(
git_buf *buffer, const void *data, size_t datalen);
/**
* Check quickly if buffer looks like it contains binary data
*
* @param buf Buffer to check
* @return 1 if buffer looks like non-text data
*/
GIT_EXTERN(int) git_buf_is_binary(const git_buf *buf);
/**
* Check quickly if buffer contains a NUL byte
*
* @param buf Buffer to check
* @return 1 if buffer contains a NUL byte
*/
GIT_EXTERN(int) git_buf_contains_nul(const git_buf *buf);
GIT_END_DECL GIT_END_DECL
/** @} */ /** @} */

View File

@ -44,7 +44,7 @@ typedef enum git_cert_t {
* information about the certificate. This is used when using * information about the certificate. This is used when using
* curl. * curl.
*/ */
GIT_CERT_STRARRAY, GIT_CERT_STRARRAY
} git_cert_t; } git_cert_t;
/** /**
@ -82,7 +82,7 @@ typedef enum {
/** SHA-256 is available */ /** SHA-256 is available */
GIT_CERT_SSH_SHA256 = (1 << 2), GIT_CERT_SSH_SHA256 = (1 << 2),
/** Raw hostkey is available */ /** Raw hostkey is available */
GIT_CERT_SSH_RAW = (1 << 3), GIT_CERT_SSH_RAW = (1 << 3)
} git_cert_ssh_t; } git_cert_ssh_t;
typedef enum { typedef enum {

View File

@ -182,7 +182,10 @@ typedef enum {
* notifications; don't update the working directory or index. * notifications; don't update the working directory or index.
*/ */
GIT_CHECKOUT_DRY_RUN = (1u << 24), GIT_CHECKOUT_DRY_RUN = (1u << 24),
/** Include common ancestor data in zdiff3 format for conflicts */
GIT_CHECKOUT_CONFLICT_STYLE_ZDIFF3 = (1u << 25),
/** /**
* THE FOLLOWING OPTIONS ARE NOT YET IMPLEMENTED * THE FOLLOWING OPTIONS ARE NOT YET IMPLEMENTED
*/ */
@ -190,7 +193,7 @@ typedef enum {
/** Recursively checkout submodules with same options (NOT IMPLEMENTED) */ /** Recursively checkout submodules with same options (NOT IMPLEMENTED) */
GIT_CHECKOUT_UPDATE_SUBMODULES = (1u << 16), GIT_CHECKOUT_UPDATE_SUBMODULES = (1u << 16),
/** Recursively checkout submodules if HEAD moved in super repo (NOT IMPLEMENTED) */ /** 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; } git_checkout_strategy_t;

View File

@ -49,7 +49,7 @@ typedef enum {
* Bypass the git-aware transport, but do not try to use * Bypass the git-aware transport, but do not try to use
* hardlinks. * hardlinks.
*/ */
GIT_CLONE_LOCAL_NO_LINKS, GIT_CLONE_LOCAL_NO_LINKS
} git_clone_local_t; } git_clone_local_t;
/** /**
@ -74,8 +74,8 @@ typedef int GIT_CALLBACK(git_remote_create_cb)(
void *payload); void *payload);
/** /**
* The signature of a function matchin git_repository_init, with an * The signature of a function matching git_repository_init, with an
* aditional void * as callback payload. * additional void * as callback payload.
* *
* Callers of git_clone my provide a function matching this signature * Callers of git_clone my provide a function matching this signature
* to override the repository creation and customization process * to override the repository creation and customization process

View File

@ -479,6 +479,7 @@ GIT_EXTERN(int) git_commit_create_buffer(
* to the commit and write it into the given repository. * to the commit and write it into the given repository.
* *
* @param out the resulting commit id * @param out the resulting commit id
* @param repo the repository to create the commit in.
* @param commit_content the content of the unsigned commit object * @param commit_content the content of the unsigned commit object
* @param signature the signature to add to the commit. Leave `NULL` * @param signature the signature to add to the commit. Leave `NULL`
* to create a commit without adding a signature field. * to create a commit without adding a signature field.
@ -499,6 +500,7 @@ GIT_EXTERN(int) git_commit_create_with_signature(
* *
* @param out Pointer to store the copy of the commit * @param out Pointer to store the copy of the commit
* @param source Original commit to copy * @param source Original commit to copy
* @return 0
*/ */
GIT_EXTERN(int) git_commit_dup(git_commit **out, git_commit *source); GIT_EXTERN(int) git_commit_dup(git_commit **out, git_commit *source);

View File

@ -147,7 +147,7 @@ typedef enum {
* If set, libgit2 was built with support for sub-second resolution in file * If set, libgit2 was built with support for sub-second resolution in file
* modification times. * modification times.
*/ */
GIT_FEATURE_NSEC = (1 << 3), GIT_FEATURE_NSEC = (1 << 3)
} git_feature_t; } git_feature_t;
/** /**
@ -167,6 +167,9 @@ typedef enum {
* - GIT_FEATURE_SSH * - GIT_FEATURE_SSH
* Libgit2 supports the SSH protocol for network operations. This requires * Libgit2 supports the SSH protocol for network operations. This requires
* the libssh2 library to be found when compiling libgit2 * the libssh2 library to be found when compiling libgit2
*
* - GIT_FEATURE_NSEC
* Libgit2 supports the sub-second resolution in file modification times.
*/ */
GIT_EXTERN(int) git_libgit2_features(void); GIT_EXTERN(int) git_libgit2_features(void);
@ -211,7 +214,9 @@ typedef enum {
GIT_OPT_SET_ODB_PACKED_PRIORITY, GIT_OPT_SET_ODB_PACKED_PRIORITY,
GIT_OPT_SET_ODB_LOOSE_PRIORITY, GIT_OPT_SET_ODB_LOOSE_PRIORITY,
GIT_OPT_GET_EXTENSIONS, GIT_OPT_GET_EXTENSIONS,
GIT_OPT_SET_EXTENSIONS GIT_OPT_SET_EXTENSIONS,
GIT_OPT_GET_OWNER_VALIDATION,
GIT_OPT_SET_OWNER_VALIDATION
} git_libgit2_opt_t; } git_libgit2_opt_t;
/** /**
@ -449,6 +454,14 @@ typedef enum {
* > to support repositories with the `noop` extension but does want * > to support repositories with the `noop` extension but does want
* > to support repositories with the `newext` extension. * > to support repositories with the `newext` extension.
* *
* opts(GIT_OPT_GET_OWNER_VALIDATION, int *enabled)
* > Gets the owner validation setting for repository
* > directories.
*
* opts(GIT_OPT_SET_OWNER_VALIDATION, int enabled)
* > Set that repository directories should be owned by the current
* > user. The default is to validate ownership.
*
* @param option Option key * @param option Option key
* @param ... value to set the option * @param ... value to set the option
* @return 0 on success, <0 on failure * @return 0 on success, <0 on failure

View File

@ -55,7 +55,7 @@ typedef enum {
/** Represents the highest level available config file (i.e. the most /** Represents the highest level available config file (i.e. the most
* specific config file available that actually is loaded) * specific config file available that actually is loaded)
*/ */
GIT_CONFIG_HIGHEST_LEVEL = -1, GIT_CONFIG_HIGHEST_LEVEL = -1
} git_config_level_t; } git_config_level_t;
/** /**
@ -72,14 +72,17 @@ typedef struct git_config_entry {
/** /**
* Free a config entry * Free a config entry
*
* @param entry The entry to free.
*/ */
GIT_EXTERN(void) git_config_entry_free(git_config_entry *); GIT_EXTERN(void) git_config_entry_free(git_config_entry *entry);
/** /**
* A config enumeration callback * A config enumeration callback
* *
* @param entry the entry currently being enumerated * @param entry the entry currently being enumerated
* @param payload a user-specified pointer * @param payload a user-specified pointer
* @return non-zero to terminate the iteration.
*/ */
typedef int GIT_CALLBACK(git_config_foreach_cb)(const git_config_entry *entry, void *payload); typedef int GIT_CALLBACK(git_config_foreach_cb)(const git_config_entry *entry, void *payload);
@ -269,6 +272,7 @@ GIT_EXTERN(int) git_config_open_level(
* *
* @param out pointer in which to store the config object * @param out pointer in which to store the config object
* @param config the config object in which to look * @param config the config object in which to look
* @return 0 or an error code.
*/ */
GIT_EXTERN(int) git_config_open_global(git_config **out, git_config *config); GIT_EXTERN(int) git_config_open_global(git_config **out, git_config *config);
@ -422,6 +426,7 @@ GIT_EXTERN(int) git_config_get_string_buf(git_buf *out, const git_config *cfg, c
* interested in. Use NULL to indicate all * interested in. Use NULL to indicate all
* @param callback the function to be called on each value of the variable * @param callback the function to be called on each value of the variable
* @param payload opaque pointer to pass to the callback * @param payload opaque pointer to pass to the callback
* @return 0 or an error code.
*/ */
GIT_EXTERN(int) git_config_get_multivar_foreach(const git_config *cfg, const char *name, const char *regexp, git_config_foreach_cb callback, void *payload); GIT_EXTERN(int) git_config_get_multivar_foreach(const git_config *cfg, const char *name, const char *regexp, git_config_foreach_cb callback, void *payload);
@ -437,6 +442,7 @@ GIT_EXTERN(int) git_config_get_multivar_foreach(const git_config *cfg, const cha
* @param name the variable's name * @param name the variable's name
* @param regexp regular expression to filter which variables we're * @param regexp regular expression to filter which variables we're
* interested in. Use NULL to indicate all * interested in. Use NULL to indicate all
* @return 0 or an error code.
*/ */
GIT_EXTERN(int) git_config_multivar_iterator_new(git_config_iterator **out, const git_config *cfg, const char *name, const char *regexp); GIT_EXTERN(int) git_config_multivar_iterator_new(git_config_iterator **out, const git_config *cfg, const char *name, const char *regexp);
@ -515,6 +521,7 @@ GIT_EXTERN(int) git_config_set_string(git_config *cfg, const char *name, const c
* @param name the variable's name * @param name the variable's name
* @param regexp a regular expression to indicate which values to replace * @param regexp a regular expression to indicate which values to replace
* @param value the new value. * @param value the new value.
* @return 0 or an error code.
*/ */
GIT_EXTERN(int) git_config_set_multivar(git_config *cfg, const char *name, const char *regexp, const char *value); GIT_EXTERN(int) git_config_set_multivar(git_config *cfg, const char *name, const char *regexp, const char *value);
@ -524,6 +531,7 @@ GIT_EXTERN(int) git_config_set_multivar(git_config *cfg, const char *name, const
* *
* @param cfg the configuration * @param cfg the configuration
* @param name the variable to delete * @param name the variable to delete
* @return 0 or an error code.
*/ */
GIT_EXTERN(int) git_config_delete_entry(git_config *cfg, const char *name); GIT_EXTERN(int) git_config_delete_entry(git_config *cfg, const char *name);
@ -568,7 +576,8 @@ GIT_EXTERN(int) git_config_foreach(
* `git_config_iterator_free` when done. * `git_config_iterator_free` when done.
* *
* @param out pointer to store the iterator * @param out pointer to store the iterator
* @param cfg where to ge the variables from * @param cfg where to get the variables from
* @return 0 or an error code.
*/ */
GIT_EXTERN(int) git_config_iterator_new(git_config_iterator **out, const git_config *cfg); GIT_EXTERN(int) git_config_iterator_new(git_config_iterator **out, const git_config *cfg);
@ -585,6 +594,7 @@ GIT_EXTERN(int) git_config_iterator_new(git_config_iterator **out, const git_con
* @param out pointer to store the iterator * @param out pointer to store the iterator
* @param cfg where to ge the variables from * @param cfg where to ge the variables from
* @param regexp regular expression to match the names * @param regexp regular expression to match the names
* @return 0 or an error code.
*/ */
GIT_EXTERN(int) git_config_iterator_glob_new(git_config_iterator **out, const git_config *cfg, const char *regexp); GIT_EXTERN(int) git_config_iterator_glob_new(git_config_iterator **out, const git_config *cfg, const char *regexp);
@ -662,6 +672,7 @@ GIT_EXTERN(int) git_config_get_mapped(
* @param maps array of `git_configmap` objects specifying the possible mappings * @param maps array of `git_configmap` objects specifying the possible mappings
* @param map_n number of mapping objects in `maps` * @param map_n number of mapping objects in `maps`
* @param value value to parse * @param value value to parse
* @return 0 or an error code.
*/ */
GIT_EXTERN(int) git_config_lookup_map_value( GIT_EXTERN(int) git_config_lookup_map_value(
int *out, int *out,
@ -678,6 +689,7 @@ GIT_EXTERN(int) git_config_lookup_map_value(
* *
* @param out place to store the result of the parsing * @param out place to store the result of the parsing
* @param value value to parse * @param value value to parse
* @return 0 or an error code.
*/ */
GIT_EXTERN(int) git_config_parse_bool(int *out, const char *value); GIT_EXTERN(int) git_config_parse_bool(int *out, const char *value);
@ -690,6 +702,7 @@ GIT_EXTERN(int) git_config_parse_bool(int *out, const char *value);
* *
* @param out place to store the result of the parsing * @param out place to store the result of the parsing
* @param value value to parse * @param value value to parse
* @return 0 or an error code.
*/ */
GIT_EXTERN(int) git_config_parse_int32(int32_t *out, const char *value); GIT_EXTERN(int) git_config_parse_int32(int32_t *out, const char *value);
@ -702,6 +715,7 @@ GIT_EXTERN(int) git_config_parse_int32(int32_t *out, const char *value);
* *
* @param out place to store the result of the parsing * @param out place to store the result of the parsing
* @param value value to parse * @param value value to parse
* @return 0 or an error code.
*/ */
GIT_EXTERN(int) git_config_parse_int64(int64_t *out, const char *value); GIT_EXTERN(int) git_config_parse_int64(int64_t *out, const char *value);
@ -717,6 +731,7 @@ GIT_EXTERN(int) git_config_parse_int64(int64_t *out, const char *value);
* *
* @param out placae to store the result of parsing * @param out placae to store the result of parsing
* @param value the path to evaluate * @param value the path to evaluate
* @return 0 or an error code.
*/ */
GIT_EXTERN(int) git_config_parse_path(git_buf *out, const char *value); GIT_EXTERN(int) git_config_parse_path(git_buf *out, const char *value);
@ -735,6 +750,7 @@ GIT_EXTERN(int) git_config_parse_path(git_buf *out, const char *value);
* @param regexp regular expression to match against config names (can be NULL) * @param regexp regular expression to match against config names (can be NULL)
* @param callback the function to call on each variable * @param callback the function to call on each variable
* @param payload the data to pass to the callback * @param payload the data to pass to the callback
* @return 0 or an error code.
*/ */
GIT_EXTERN(int) git_config_backend_foreach_match( GIT_EXTERN(int) git_config_backend_foreach_match(
git_config_backend *backend, git_config_backend *backend,

View File

@ -75,7 +75,7 @@ typedef enum {
* *
* @see git_credential_ssh_key_memory_new * @see git_credential_ssh_key_memory_new
*/ */
GIT_CREDENTIAL_SSH_MEMORY = (1u << 6), GIT_CREDENTIAL_SSH_MEMORY = (1u << 6)
} git_credential_t; } git_credential_t;
/** /**
@ -254,6 +254,7 @@ typedef void GIT_CALLBACK(git_credential_ssh_interactive_cb)(
* Create a new ssh keyboard-interactive based credential object. * Create a new ssh keyboard-interactive based credential object.
* The supplied credential parameter will be internally duplicated. * The supplied credential parameter will be internally duplicated.
* *
* @param out The newly created credential object.
* @param username Username to use to authenticate. * @param username Username to use to authenticate.
* @param prompt_callback The callback method used for prompts. * @param prompt_callback The callback method used for prompts.
* @param payload Additional data to pass to the callback. * @param payload Additional data to pass to the callback.

View File

@ -39,6 +39,7 @@ typedef struct git_credential_userpass_payload {
* @param allowed_types A bitmask stating which credential types are OK to return. * @param allowed_types A bitmask stating which credential types are OK to return.
* @param payload The payload provided when specifying this callback. (This is * @param payload The payload provided when specifying this callback. (This is
* interpreted as a `git_credential_userpass_payload*`.) * interpreted as a `git_credential_userpass_payload*`.)
* @return 0 or an error code.
*/ */
GIT_EXTERN(int) git_credential_userpass( GIT_EXTERN(int) git_credential_userpass(
git_credential **out, git_credential **out,

View File

@ -313,7 +313,7 @@ typedef enum {
GIT_DIFF_FORMAT_EMAIL_NONE = 0, GIT_DIFF_FORMAT_EMAIL_NONE = 0,
/** Don't insert "[PATCH]" in the subject header*/ /** 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; } git_diff_format_email_flags_t;

View File

@ -30,7 +30,7 @@ GIT_BEGIN_DECL
typedef enum { typedef enum {
GIT_DESCRIBE_DEFAULT, GIT_DESCRIBE_DEFAULT,
GIT_DESCRIBE_TAGS, GIT_DESCRIBE_TAGS,
GIT_DESCRIBE_ALL, GIT_DESCRIBE_ALL
} git_describe_strategy_t; } git_describe_strategy_t;
/** /**
@ -142,6 +142,7 @@ typedef struct git_describe_result git_describe_result;
* you're done with it. * you're done with it.
* @param committish a committish to describe * @param committish a committish to describe
* @param opts the lookup options (or NULL for defaults) * @param opts the lookup options (or NULL for defaults)
* @return 0 or an error code.
*/ */
GIT_EXTERN(int) git_describe_commit( GIT_EXTERN(int) git_describe_commit(
git_describe_result **result, git_describe_result **result,
@ -152,13 +153,14 @@ GIT_EXTERN(int) git_describe_commit(
* Describe a commit * Describe a commit
* *
* Perform the describe operation on the current commit and the * Perform the describe operation on the current commit and the
* worktree. After peforming describe on HEAD, a status is run and the * worktree. After performing describe on HEAD, a status is run and the
* description is considered to be dirty if there are. * description is considered to be dirty if there are.
* *
* @param out pointer to store the result. You must free this once * @param out pointer to store the result. You must free this once
* you're done with it. * you're done with it.
* @param repo the repository in which to perform the describe * @param repo the repository in which to perform the describe
* @param opts the lookup options (or NULL for defaults) * @param opts the lookup options (or NULL for defaults)
* @return 0 or an error code.
*/ */
GIT_EXTERN(int) git_describe_workdir( GIT_EXTERN(int) git_describe_workdir(
git_describe_result **out, git_describe_result **out,
@ -172,6 +174,7 @@ GIT_EXTERN(int) git_describe_workdir(
* @param result the result from `git_describe_commit()` or * @param result the result from `git_describe_commit()` or
* `git_describe_workdir()`. * `git_describe_workdir()`.
* @param opts the formatting options (or NULL for defaults) * @param opts the formatting options (or NULL for defaults)
* @return 0 or an error code.
*/ */
GIT_EXTERN(int) git_describe_format( GIT_EXTERN(int) git_describe_format(
git_buf *out, git_buf *out,
@ -180,6 +183,8 @@ GIT_EXTERN(int) git_describe_format(
/** /**
* Free the describe result. * Free the describe result.
*
* @param result The result to free.
*/ */
GIT_EXTERN(void) git_describe_result_free(git_describe_result *result); GIT_EXTERN(void) git_describe_result_free(git_describe_result *result);

View File

@ -170,7 +170,7 @@ typedef enum {
/** Include the necessary deflate / delta information so that `git-apply` /** Include the necessary deflate / delta information so that `git-apply`
* can apply given diff information to binary files. * can apply given diff information to binary files.
*/ */
GIT_DIFF_SHOW_BINARY = (1u << 30), GIT_DIFF_SHOW_BINARY = (1u << 30)
} git_diff_option_t; } git_diff_option_t;
/** /**
@ -208,6 +208,7 @@ typedef enum {
GIT_DIFF_FLAG_NOT_BINARY = (1u << 1), /**< file(s) treated as text 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_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_VALID_SIZE = (1u << 4) /**< file size value is known correct */
} git_diff_flag_t; } git_diff_flag_t;
/** /**
@ -231,7 +232,7 @@ typedef enum {
GIT_DELTA_UNTRACKED = 7, /**< entry is untracked item in workdir */ GIT_DELTA_UNTRACKED = 7, /**< entry is untracked item in workdir */
GIT_DELTA_TYPECHANGE = 8, /**< type of entry changed between old and new */ GIT_DELTA_TYPECHANGE = 8, /**< type of entry changed between old and new */
GIT_DELTA_UNREADABLE = 9, /**< entry is unreadable */ 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; } git_delta_t;
/** /**
@ -497,7 +498,7 @@ typedef enum {
GIT_DIFF_BINARY_LITERAL, GIT_DIFF_BINARY_LITERAL,
/** The binary data is the delta from one side to the other. */ /** The binary data is the delta from one side to the other. */
GIT_DIFF_BINARY_DELTA, GIT_DIFF_BINARY_DELTA
} git_diff_binary_t; } git_diff_binary_t;
/** The contents of one of the files in a binary diff. */ /** The contents of one of the files in a binary diff. */
@ -706,7 +707,7 @@ typedef enum {
* GIT_DIFF_INCLUDE_UNMODIFIED flag. If you do not want UNMODIFIED * GIT_DIFF_INCLUDE_UNMODIFIED flag. If you do not want UNMODIFIED
* records in the final result, pass this flag to have them removed. * 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; } git_diff_find_t;
/** /**
@ -758,7 +759,7 @@ typedef struct {
uint16_t copy_threshold; uint16_t copy_threshold;
/** /**
* Treshold below which similar files will be split into a delete/add pair. * Threshold below which similar files will be split into a delete/add pair.
* This is equivalent to the last part of the -B option. Defaults to 60. * This is equivalent to the last part of the -B option. Defaults to 60.
*/ */
uint16_t break_rewrite_threshold; uint16_t break_rewrite_threshold;
@ -768,7 +769,7 @@ typedef struct {
* *
* This is a little different from the `-l` option from Git because we * This is a little different from the `-l` option from Git because we
* will still process up to this many matches before abandoning the search. * will still process up to this many matches before abandoning the search.
* Defaults to 200. * Defaults to 1000.
*/ */
size_t rename_limit; size_t rename_limit;
@ -831,6 +832,7 @@ GIT_EXTERN(void) git_diff_free(git_diff *diff);
* @param old_tree A git_tree object to diff from, or NULL for empty tree. * @param old_tree A git_tree object to diff from, or NULL for empty tree.
* @param new_tree A git_tree object to diff to, or NULL for empty tree. * @param new_tree A git_tree object to diff to, or NULL for empty tree.
* @param opts Structure with options to influence diff or NULL for defaults. * @param opts Structure with options to influence diff or NULL for defaults.
* @return 0 or an error code.
*/ */
GIT_EXTERN(int) git_diff_tree_to_tree( GIT_EXTERN(int) git_diff_tree_to_tree(
git_diff **diff, git_diff **diff,
@ -857,6 +859,7 @@ GIT_EXTERN(int) git_diff_tree_to_tree(
* @param old_tree A git_tree object to diff from, or NULL for empty tree. * @param old_tree A git_tree object to diff from, or NULL for empty tree.
* @param index The index to diff with; repo index used if NULL. * @param index The index to diff with; repo index used if NULL.
* @param opts Structure with options to influence diff or NULL for defaults. * @param opts Structure with options to influence diff or NULL for defaults.
* @return 0 or an error code.
*/ */
GIT_EXTERN(int) git_diff_tree_to_index( GIT_EXTERN(int) git_diff_tree_to_index(
git_diff **diff, git_diff **diff,
@ -884,6 +887,7 @@ GIT_EXTERN(int) git_diff_tree_to_index(
* @param repo The repository. * @param repo The repository.
* @param index The index to diff from; repo index used if NULL. * @param index The index to diff from; repo index used if NULL.
* @param opts Structure with options to influence diff or NULL for defaults. * @param opts Structure with options to influence diff or NULL for defaults.
* @return 0 or an error code.
*/ */
GIT_EXTERN(int) git_diff_index_to_workdir( GIT_EXTERN(int) git_diff_index_to_workdir(
git_diff **diff, git_diff **diff,
@ -913,6 +917,7 @@ GIT_EXTERN(int) git_diff_index_to_workdir(
* @param repo The repository containing the tree. * @param repo The repository containing the tree.
* @param old_tree A git_tree object to diff from, or NULL for empty tree. * @param old_tree A git_tree object to diff from, or NULL for empty tree.
* @param opts Structure with options to influence diff or NULL for defaults. * @param opts Structure with options to influence diff or NULL for defaults.
* @return 0 or an error code.
*/ */
GIT_EXTERN(int) git_diff_tree_to_workdir( GIT_EXTERN(int) git_diff_tree_to_workdir(
git_diff **diff, git_diff **diff,
@ -932,6 +937,7 @@ GIT_EXTERN(int) git_diff_tree_to_workdir(
* @param repo The repository containing the tree. * @param repo The repository containing the tree.
* @param old_tree A git_tree object to diff from, or NULL for empty tree. * @param old_tree A git_tree object to diff from, or NULL for empty tree.
* @param opts Structure with options to influence diff or NULL for defaults. * @param opts Structure with options to influence diff or NULL for defaults.
* @return 0 or an error code.
*/ */
GIT_EXTERN(int) git_diff_tree_to_workdir_with_index( GIT_EXTERN(int) git_diff_tree_to_workdir_with_index(
git_diff **diff, git_diff **diff,
@ -950,6 +956,7 @@ GIT_EXTERN(int) git_diff_tree_to_workdir_with_index(
* @param old_index A git_index object to diff from. * @param old_index A git_index object to diff from.
* @param new_index A git_index object to diff to. * @param new_index A git_index object to diff to.
* @param opts Structure with options to influence diff or NULL for defaults. * @param opts Structure with options to influence diff or NULL for defaults.
* @return 0 or an error code.
*/ */
GIT_EXTERN(int) git_diff_index_to_index( GIT_EXTERN(int) git_diff_index_to_index(
git_diff **diff, git_diff **diff,
@ -970,6 +977,7 @@ GIT_EXTERN(int) git_diff_index_to_index(
* *
* @param onto Diff to merge into. * @param onto Diff to merge into.
* @param from Diff to merge. * @param from Diff to merge.
* @return 0 or an error code.
*/ */
GIT_EXTERN(int) git_diff_merge( GIT_EXTERN(int) git_diff_merge(
git_diff *onto, git_diff *onto,
@ -1107,7 +1115,7 @@ typedef enum {
GIT_DIFF_FORMAT_RAW = 3u, /**< like git diff --raw */ GIT_DIFF_FORMAT_RAW = 3u, /**< like git diff --raw */
GIT_DIFF_FORMAT_NAME_ONLY = 4u, /**< like git diff --name-only */ 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_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; } git_diff_format_t;
/** /**
@ -1311,13 +1319,13 @@ typedef enum {
GIT_DIFF_STATS_NUMBER = (1u << 2), GIT_DIFF_STATS_NUMBER = (1u << 2),
/** Extended header information such as creations, renames and mode changes, equivalent of `--summary` */ /** 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; } git_diff_stats_format_t;
/** /**
* Accumulate diff statistics for all patches. * Accumulate diff statistics for all patches.
* *
* @param out Structure containg the diff statistics. * @param out Structure containing the diff statistics.
* @param diff A git_diff generated by one of the above functions. * @param diff A git_diff generated by one of the above functions.
* @return 0 on success; non-zero on error * @return 0 on success; non-zero on error
*/ */

View File

@ -34,7 +34,7 @@ typedef enum {
GIT_EMAIL_CREATE_ALWAYS_NUMBER = (1u << 1), GIT_EMAIL_CREATE_ALWAYS_NUMBER = (1u << 1),
/** Do not perform rename or similarity detection. */ /** 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; } git_email_create_flags_t;
/** /**

View File

@ -58,6 +58,7 @@ typedef enum {
GIT_EMISMATCH = -33, /**< Hashsum mismatch in object */ GIT_EMISMATCH = -33, /**< Hashsum mismatch in object */
GIT_EINDEXDIRTY = -34, /**< Unsaved changes in the index would be overwritten */ GIT_EINDEXDIRTY = -34, /**< Unsaved changes in the index would be overwritten */
GIT_EAPPLYFAIL = -35, /**< Patch application failed */ GIT_EAPPLYFAIL = -35, /**< Patch application failed */
GIT_EOWNER = -36 /**< The object is not owned by the current user */
} git_error_code; } git_error_code;
/** /**

View File

@ -32,7 +32,7 @@ typedef enum {
GIT_FILTER_TO_WORKTREE = 0, GIT_FILTER_TO_WORKTREE = 0,
GIT_FILTER_SMUDGE = GIT_FILTER_TO_WORKTREE, GIT_FILTER_SMUDGE = GIT_FILTER_TO_WORKTREE,
GIT_FILTER_TO_ODB = 1, GIT_FILTER_TO_ODB = 1,
GIT_FILTER_CLEAN = GIT_FILTER_TO_ODB, GIT_FILTER_CLEAN = GIT_FILTER_TO_ODB
} git_filter_mode_t; } git_filter_mode_t;
/** /**
@ -54,7 +54,7 @@ typedef enum {
* Load attributes from `.gitattributes` in a given commit. * Load attributes from `.gitattributes` in a given commit.
* This can only be specified in a `git_filter_options`. * 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; } git_filter_flag_t;
/** /**
@ -196,6 +196,7 @@ GIT_EXTERN(int) git_filter_list_apply_to_buffer(
* @param repo the repository in which to perform the filtering * @param repo the repository in which to perform the filtering
* @param path the path of the file to filter, a relative path will be * @param path the path of the file to filter, a relative path will be
* taken as relative to the workdir * taken as relative to the workdir
* @return 0 or an error code.
*/ */
GIT_EXTERN(int) git_filter_list_apply_to_file( GIT_EXTERN(int) git_filter_list_apply_to_file(
git_buf *out, git_buf *out,
@ -209,6 +210,7 @@ GIT_EXTERN(int) git_filter_list_apply_to_file(
* @param out buffer into which to store the filtered file * @param out buffer into which to store the filtered file
* @param filters the list of filters to apply * @param filters the list of filters to apply
* @param blob the blob to filter * @param blob the blob to filter
* @return 0 or an error code.
*/ */
GIT_EXTERN(int) git_filter_list_apply_to_blob( GIT_EXTERN(int) git_filter_list_apply_to_blob(
git_buf *out, git_buf *out,
@ -222,6 +224,7 @@ GIT_EXTERN(int) git_filter_list_apply_to_blob(
* @param buffer the buffer to filter * @param buffer the buffer to filter
* @param len the size of the buffer * @param len the size of the buffer
* @param target the stream into which the data will be written * @param target the stream into which the data will be written
* @return 0 or an error code.
*/ */
GIT_EXTERN(int) git_filter_list_stream_buffer( GIT_EXTERN(int) git_filter_list_stream_buffer(
git_filter_list *filters, git_filter_list *filters,
@ -237,6 +240,7 @@ GIT_EXTERN(int) git_filter_list_stream_buffer(
* @param path the path of the file to filter, a relative path will be * @param path the path of the file to filter, a relative path will be
* taken as relative to the workdir * taken as relative to the workdir
* @param target the stream into which the data will be written * @param target the stream into which the data will be written
* @return 0 or an error code.
*/ */
GIT_EXTERN(int) git_filter_list_stream_file( GIT_EXTERN(int) git_filter_list_stream_file(
git_filter_list *filters, git_filter_list *filters,
@ -250,6 +254,7 @@ GIT_EXTERN(int) git_filter_list_stream_file(
* @param filters the list of filters to apply * @param filters the list of filters to apply
* @param blob the blob to filter * @param blob the blob to filter
* @param target the stream into which the data will be written * @param target the stream into which the data will be written
* @return 0 or an error code.
*/ */
GIT_EXTERN(int) git_filter_list_stream_blob( GIT_EXTERN(int) git_filter_list_stream_blob(
git_filter_list *filters, git_filter_list *filters,

View File

@ -33,6 +33,7 @@ GIT_BEGIN_DECL
* @param repo the repository where the commits exist * @param repo the repository where the commits exist
* @param local the commit for local * @param local the commit for local
* @param upstream the commit for upstream * @param upstream the commit for upstream
* @return 0 or an error code.
*/ */
GIT_EXTERN(int) git_graph_ahead_behind(size_t *ahead, size_t *behind, git_repository *repo, const git_oid *local, const git_oid *upstream); GIT_EXTERN(int) git_graph_ahead_behind(size_t *ahead, size_t *behind, git_repository *repo, const git_oid *local, const git_oid *upstream);

View File

@ -29,7 +29,7 @@ GIT_BEGIN_DECL
* This would add three rules to the ignores. * This would add three rules to the ignores.
* *
* @param repo The repository to add ignore rules to. * @param repo The repository to add ignore rules to.
* @param rules Text of rules, a la the contents of a .gitignore file. * @param rules Text of rules, the contents to add on a .gitignore file.
* It is okay to have multiple rules in the text; if so, * It is okay to have multiple rules in the text; if so,
* each rule should be terminated with a newline. * each rule should be terminated with a newline.
* @return 0 on success * @return 0 on success

View File

@ -86,7 +86,7 @@ typedef struct git_index_entry {
*/ */
typedef enum { typedef enum {
GIT_INDEX_ENTRY_EXTENDED = (0x4000), GIT_INDEX_ENTRY_EXTENDED = (0x4000),
GIT_INDEX_ENTRY_VALID = (0x8000), GIT_INDEX_ENTRY_VALID = (0x8000)
} git_index_entry_flag_t; } git_index_entry_flag_t;
#define GIT_INDEX_ENTRY_STAGE(E) \ #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_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; } git_index_entry_extended_flag_t;
/** Capabilities of system that affect index actions. */ /** Capabilities of system that affect index actions. */
@ -127,7 +127,7 @@ typedef enum {
GIT_INDEX_CAPABILITY_IGNORE_CASE = 1, GIT_INDEX_CAPABILITY_IGNORE_CASE = 1,
GIT_INDEX_CAPABILITY_NO_FILEMODE = 2, GIT_INDEX_CAPABILITY_NO_FILEMODE = 2,
GIT_INDEX_CAPABILITY_NO_SYMLINKS = 4, GIT_INDEX_CAPABILITY_NO_SYMLINKS = 4,
GIT_INDEX_CAPABILITY_FROM_OWNER = -1, GIT_INDEX_CAPABILITY_FROM_OWNER = -1
} git_index_capability_t; } git_index_capability_t;
@ -140,7 +140,7 @@ typedef enum {
GIT_INDEX_ADD_DEFAULT = 0, GIT_INDEX_ADD_DEFAULT = 0,
GIT_INDEX_ADD_FORCE = (1u << 0), GIT_INDEX_ADD_FORCE = (1u << 0),
GIT_INDEX_ADD_DISABLE_PATHSPEC_MATCH = (1u << 1), 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_add_option_t;
/** Git index stage states */ /** Git index stage states */
@ -163,7 +163,7 @@ typedef enum {
GIT_INDEX_STAGE_OURS = 2, GIT_INDEX_STAGE_OURS = 2,
/** The "theirs" side of a conflict. */ /** The "theirs" side of a conflict. */
GIT_INDEX_STAGE_THEIRS = 3, GIT_INDEX_STAGE_THEIRS = 3
} git_index_stage_t; } git_index_stage_t;
/** /**
@ -296,6 +296,7 @@ GIT_EXTERN(int) git_index_write(git_index *index);
*/ */
GIT_EXTERN(const char *) git_index_path(const git_index *index); GIT_EXTERN(const char *) git_index_path(const git_index *index);
#ifndef GIT_DEPRECATE_HARD
/** /**
* Get the checksum of the index * Get the checksum of the index
* *
@ -303,10 +304,12 @@ GIT_EXTERN(const char *) git_index_path(const git_index *index);
* last 20 bytes which are the checksum itself). In cases where the * last 20 bytes which are the checksum itself). In cases where the
* index does not exist on-disk, it will be zeroed out. * index does not exist on-disk, it will be zeroed out.
* *
* @deprecated this function is deprecated with no replacement
* @param index an existing index object * @param index an existing index object
* @return a pointer to the checksum of the index * @return a pointer to the checksum of the index
*/ */
GIT_EXTERN(const git_oid *) git_index_checksum(git_index *index); GIT_EXTERN(const git_oid *) git_index_checksum(git_index *index);
#endif
/** /**
* Read a tree into the index file with stats * Read a tree into the index file with stats
@ -491,6 +494,7 @@ GIT_EXTERN(int) git_index_entry_is_conflict(const git_index_entry *entry);
* *
* @param iterator_out The newly created iterator * @param iterator_out The newly created iterator
* @param index The index to iterate * @param index The index to iterate
* @return 0 or an error code.
*/ */
GIT_EXTERN(int) git_index_iterator_new( GIT_EXTERN(int) git_index_iterator_new(
git_index_iterator **iterator_out, git_index_iterator **iterator_out,
@ -787,6 +791,7 @@ GIT_EXTERN(int) git_index_conflict_cleanup(git_index *index);
/** /**
* Determine if the index contains entries representing file conflicts. * Determine if the index contains entries representing file conflicts.
* *
* @param index An existing index object.
* @return 1 if at least one conflict is found, 0 otherwise. * @return 1 if at least one conflict is found, 0 otherwise.
*/ */
GIT_EXTERN(int) git_index_has_conflicts(const git_index *index); GIT_EXTERN(int) git_index_has_conflicts(const git_index *index);
@ -811,6 +816,7 @@ GIT_EXTERN(int) git_index_conflict_iterator_new(
* @param ancestor_out Pointer to store the ancestor side of the conflict * @param ancestor_out Pointer to store the ancestor side of the conflict
* @param our_out Pointer to store our side of the conflict * @param our_out Pointer to store our side of the conflict
* @param their_out Pointer to store their side of the conflict * @param their_out Pointer to store their side of the conflict
* @param iterator The conflict iterator.
* @return 0 (no error), GIT_ITEROVER (iteration is done) or an error code * @return 0 (no error), GIT_ITEROVER (iteration is done) or an error code
* (negative value) * (negative value)
*/ */

View File

@ -98,6 +98,7 @@ GIT_EXTERN(int) git_indexer_options_init(
* will be returned if there are bases missing) * will be returned if there are bases missing)
* @param opts Optional structure containing additional options. See * @param opts Optional structure containing additional options. See
* `git_indexer_options` above. * `git_indexer_options` above.
* @return 0 or an error code.
*/ */
GIT_EXTERN(int) git_indexer_new( GIT_EXTERN(int) git_indexer_new(
git_indexer **out, git_indexer **out,
@ -113,6 +114,7 @@ GIT_EXTERN(int) git_indexer_new(
* @param data the data to add * @param data the data to add
* @param size the size of the data in bytes * @param size the size of the data in bytes
* @param stats stat storage * @param stats stat storage
* @return 0 or an error code.
*/ */
GIT_EXTERN(int) git_indexer_append(git_indexer *idx, const void *data, size_t size, git_indexer_progress *stats); GIT_EXTERN(int) git_indexer_append(git_indexer *idx, const void *data, size_t size, git_indexer_progress *stats);
@ -122,18 +124,35 @@ GIT_EXTERN(int) git_indexer_append(git_indexer *idx, const void *data, size_t si
* Resolve any pending deltas and write out the index file * Resolve any pending deltas and write out the index file
* *
* @param idx the indexer * @param idx the indexer
* @param stats Stat storage.
* @return 0 or an error code.
*/ */
GIT_EXTERN(int) git_indexer_commit(git_indexer *idx, git_indexer_progress *stats); GIT_EXTERN(int) git_indexer_commit(git_indexer *idx, git_indexer_progress *stats);
#ifndef GIT_DEPRECATE_HARD
/** /**
* Get the packfile's hash * Get the packfile's hash
* *
* A packfile's name is derived from the sorted hashing of all object * A packfile's name is derived from the sorted hashing of all object
* names. This is only correct after the index has been finalized. * names. This is only correct after the index has been finalized.
* *
* @deprecated use git_indexer_name
* @param idx the indexer instance * @param idx the indexer instance
* @return the packfile's hash
*/ */
GIT_EXTERN(const git_oid *) git_indexer_hash(const git_indexer *idx); GIT_EXTERN(const git_oid *) git_indexer_hash(const git_indexer *idx);
#endif
/**
* Get the unique name for the resulting packfile.
*
* The packfile's name is derived from the packfile's content.
* This is only correct after the index has been finalized.
*
* @param idx the indexer instance
* @return a NUL terminated string for the packfile name
*/
GIT_EXTERN(const char *) git_indexer_name(const git_indexer *idx);
/** /**
* Free the indexer and its resources * Free the indexer and its resources

View File

@ -92,6 +92,14 @@ typedef enum {
* merge base to `git-merge-resolve`. * merge base to `git-merge-resolve`.
*/ */
GIT_MERGE_NO_RECURSIVE = (1 << 3), GIT_MERGE_NO_RECURSIVE = (1 << 3),
/**
* Treat this merge as if it is to produce the virtual base
* of a recursive merge. This will ensure that there are
* no conflicts, any conflicting regions will keep conflict
* markers in the merge result.
*/
GIT_MERGE_VIRTUAL_BASE = (1 << 4)
} git_merge_flag_t; } git_merge_flag_t;
/** /**
@ -127,7 +135,7 @@ typedef enum {
* which has the result of combining both files. The index will not * which has the result of combining both files. The index will not
* record a conflict. * record a conflict.
*/ */
GIT_MERGE_FILE_FAVOR_UNION = 3, GIT_MERGE_FILE_FAVOR_UNION = 3
} git_merge_file_favor_t; } git_merge_file_favor_t;
/** /**
@ -160,6 +168,16 @@ typedef enum {
/** Take extra time to find minimal diff */ /** Take extra time to find minimal diff */
GIT_MERGE_FILE_DIFF_MINIMAL = (1 << 7), GIT_MERGE_FILE_DIFF_MINIMAL = (1 << 7),
/** Create zdiff3 ("zealous diff3")-style files */
GIT_MERGE_FILE_STYLE_ZDIFF3 = (1 << 8),
/**
* Do not produce file conflicts when common regions have
* changed; keep the conflict markers in the file and accept
* that as the merge result.
*/
GIT_MERGE_FILE_ACCEPT_CONFLICTS = (1 << 9)
} git_merge_file_flag_t; } git_merge_file_flag_t;
#define GIT_MERGE_CONFLICT_MARKER_SIZE 7 #define GIT_MERGE_CONFLICT_MARKER_SIZE 7
@ -341,7 +359,7 @@ typedef enum {
* a valid commit. No merge can be performed, but the caller may wish * a valid commit. No merge can be performed, but the caller may wish
* to simply set HEAD to the target commit(s). * 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; } git_merge_analysis_t;
/** /**
@ -364,7 +382,7 @@ typedef enum {
* There is a `merge.ff=only` configuration setting, suggesting that * There is a `merge.ff=only` configuration setting, suggesting that
* the user only wants fast-forward merges. * 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; } git_merge_preference_t;
/** /**
@ -372,6 +390,7 @@ typedef enum {
* merging them into the HEAD of the repository. * merging them into the HEAD of the repository.
* *
* @param analysis_out analysis enumeration that the result is written into * @param analysis_out analysis enumeration that the result is written into
* @param preference_out One of the `git_merge_preference_t` flag.
* @param repo the repository to merge * @param repo the repository to merge
* @param their_heads the heads to merge into * @param their_heads the heads to merge into
* @param their_heads_len the number of heads to merge * @param their_heads_len the number of heads to merge
@ -389,6 +408,7 @@ GIT_EXTERN(int) git_merge_analysis(
* merging them into a reference. * merging them into a reference.
* *
* @param analysis_out analysis enumeration that the result is written into * @param analysis_out analysis enumeration that the result is written into
* @param preference_out One of the `git_merge_preference_t` flag.
* @param repo the repository to merge * @param repo the repository to merge
* @param our_ref the reference to perform the analysis from * @param our_ref the reference to perform the analysis from
* @param their_heads the heads to merge into * @param their_heads the heads to merge into

View File

@ -75,6 +75,8 @@ GIT_EXTERN(int) git_message_trailers(git_message_trailer_array *arr, const char
/** /**
* Clean's up any allocated memory in the git_message_trailer_array filled by * Clean's up any allocated memory in the git_message_trailer_array filled by
* a call to git_message_trailers. * a call to git_message_trailers.
*
* @param arr The trailer to free.
*/ */
GIT_EXTERN(void) git_message_trailer_array_free(git_message_trailer_array *arr); GIT_EXTERN(void) git_message_trailer_array_free(git_message_trailer_array *arr);

View File

@ -221,9 +221,32 @@ GIT_EXTERN(int) git_object_peel(
* *
* @param dest Pointer to store the copy of the object * @param dest Pointer to store the copy of the object
* @param source Original object to copy * @param source Original object to copy
* @return 0 or an error code
*/ */
GIT_EXTERN(int) git_object_dup(git_object **dest, git_object *source); GIT_EXTERN(int) git_object_dup(git_object **dest, git_object *source);
/**
* Analyzes a buffer of raw object content and determines its validity.
* Tree, commit, and tag objects will be parsed and ensured that they
* are valid, parseable content. (Blobs are always valid by definition.)
* An error message will be set with an informative message if the object
* is not valid.
*
* @warning This function is experimental and its signature may change in
* the future.
*
* @param valid Output pointer to set with validity of the object content
* @param buf The contents to validate
* @param len The length of the buffer
* @param type The type of the object in the buffer
* @return 0 on success or an error code
*/
GIT_EXTERN(int) git_object_rawcontent_is_valid(
int *valid,
const char *buf,
size_t len,
git_object_t type);
/** @} */ /** @} */
GIT_END_DECL GIT_END_DECL

View File

@ -22,6 +22,17 @@
*/ */
GIT_BEGIN_DECL 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. * Function type for callbacks from git_odb_foreach.
*/ */
@ -155,6 +166,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); 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 * Determine if an object can be found in the object database by an
* abbreviated object ID. * abbreviated object ID.
@ -192,12 +214,13 @@ typedef struct git_odb_expand_id {
/** /**
* Determine if one or more objects can be found in the object database * Determine if one or more objects can be found in the object database
* by their abbreviated object ID and type. The given array will be * by their abbreviated object ID and type.
* updated in place: for each abbreviated ID that is unique in the *
* database, and of the given type (if specified), the full object ID, * The given array will be updated in place: for each abbreviated ID that is
* object ID length (`GIT_OID_HEXSZ`) and type will be written back to * unique in the database, and of the given type (if specified),
* the array. For IDs that are not found (or are ambiguous), the * the full object ID, object ID length (`GIT_OID_HEXSZ`) and type will be
* array entry will be zeroed. * written back to the array. For IDs that are not found (or are ambiguous),
* the array entry will be zeroed.
* *
* Note that since this function operates on multiple objects, the * Note that since this function operates on multiple objects, the
* underlying database will not be asked to be reloaded if an object is * underlying database will not be asked to be reloaded if an object is
@ -323,6 +346,11 @@ GIT_EXTERN(int) git_odb_stream_finalize_write(git_oid *out, git_odb_stream *stre
* Read from an odb stream * Read from an odb stream
* *
* Most backends don't implement streaming reads * Most backends don't implement streaming reads
*
* @param stream the stream
* @param buffer a user-allocated buffer to store the data in.
* @param len the buffer's length
* @return 0 if the read succeeded, error code otherwise
*/ */
GIT_EXTERN(int) git_odb_stream_read(git_odb_stream *stream, char *buffer, size_t len); GIT_EXTERN(int) git_odb_stream_read(git_odb_stream *stream, char *buffer, size_t len);
@ -383,6 +411,7 @@ GIT_EXTERN(int) git_odb_open_rstream(
* Be aware that this is called inline with network and indexing operations, * Be aware that this is called inline with network and indexing operations,
* so performance may be affected. * so performance may be affected.
* @param progress_payload payload for the progress callback * @param progress_payload payload for the progress callback
* @return 0 or an error code.
*/ */
GIT_EXTERN(int) git_odb_write_pack( GIT_EXTERN(int) git_odb_write_pack(
git_odb_writepack **out, git_odb_writepack **out,
@ -400,6 +429,7 @@ GIT_EXTERN(int) git_odb_write_pack(
* exist). * exist).
* *
* @param db object database where the `multi-pack-index` file will be written. * @param db object database where the `multi-pack-index` file will be written.
* @return 0 or an error code.
*/ */
GIT_EXTERN(int) git_odb_write_multi_pack_index( GIT_EXTERN(int) git_odb_write_multi_pack_index(
git_odb *db); git_odb *db);
@ -556,7 +586,7 @@ GIT_EXTERN(int) git_odb_get_backend(git_odb_backend **out, git_odb *odb, size_t
/** /**
* Set the git commit-graph for the ODB. * Set the git commit-graph for the ODB.
* *
* After a successfull call, the ownership of the cgraph parameter will be * After a successful call, the ownership of the cgraph parameter will be
* transferred to libgit2, and the caller should not free it. * transferred to libgit2, and the caller should not free it.
* *
* The commit-graph can also be unset by explicitly passing NULL as the cgraph * The commit-graph can also be unset by explicitly passing NULL as the cgraph

View File

@ -71,7 +71,7 @@ GIT_EXTERN(int) git_odb_backend_one_pack(git_odb_backend **out, const char *inde
typedef enum { typedef enum {
GIT_STREAM_RDONLY = (1 << 1), GIT_STREAM_RDONLY = (1 << 1),
GIT_STREAM_WRONLY = (1 << 2), 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; } git_odb_stream_t;
/** /**

View File

@ -51,7 +51,7 @@ GIT_BEGIN_DECL
*/ */
typedef enum { typedef enum {
GIT_PACKBUILDER_ADDING_OBJECTS = 0, GIT_PACKBUILDER_ADDING_OBJECTS = 0,
GIT_PACKBUILDER_DELTAFICATION = 1, GIT_PACKBUILDER_DELTAFICATION = 1
} git_packbuilder_stage_t; } git_packbuilder_stage_t;
/** /**
@ -148,6 +148,7 @@ GIT_EXTERN(int) git_packbuilder_insert_recur(git_packbuilder *pb, const git_oid
* *
* @param buf Buffer where to write the packfile * @param buf Buffer where to write the packfile
* @param pb The packbuilder * @param pb The packbuilder
* @return 0 or an error code
*/ */
GIT_EXTERN(int) git_packbuilder_write_buf(git_buf *buf, git_packbuilder *pb); GIT_EXTERN(int) git_packbuilder_write_buf(git_buf *buf, git_packbuilder *pb);
@ -169,15 +170,30 @@ GIT_EXTERN(int) git_packbuilder_write(
git_indexer_progress_cb progress_cb, git_indexer_progress_cb progress_cb,
void *progress_cb_payload); void *progress_cb_payload);
#ifndef GIT_DEPRECATE_HARD
/** /**
* Get the packfile's hash * Get the packfile's hash
* *
* A packfile's name is derived from the sorted hashing of all object * A packfile's name is derived from the sorted hashing of all object
* names. This is only correct after the packfile has been written. * names. This is only correct after the packfile has been written.
* *
* @param pb The packbuilder object * @deprecated use git_packbuilder_name
*/ * @param pb The packbuilder object
* @return 0 or an error code
*/
GIT_EXTERN(const git_oid *) git_packbuilder_hash(git_packbuilder *pb); GIT_EXTERN(const git_oid *) git_packbuilder_hash(git_packbuilder *pb);
#endif
/**
* Get the unique name for the resulting packfile.
*
* The packfile's name is derived from the packfile's content.
* This is only correct after the packfile has been written.
*
* @param pb the packbuilder instance
* @return a NUL terminated string for the packfile name
*/
GIT_EXTERN(const char *) git_packbuilder_name(git_packbuilder *pb);
/** /**
* Callback used to iterate over packed objects * Callback used to iterate over packed objects

View File

@ -139,17 +139,25 @@ GIT_EXTERN(int) git_patch_from_buffers(
/** /**
* Free a git_patch object. * Free a git_patch object.
*
* @param patch The patch to free.
*/ */
GIT_EXTERN(void) git_patch_free(git_patch *patch); GIT_EXTERN(void) git_patch_free(git_patch *patch);
/** /**
* Get the delta associated with a patch. This delta points to internal * Get the delta associated with a patch. This delta points to internal
* data and you do not have to release it when you are done with it. * data and you do not have to release it when you are done with it.
*
* @param patch The patch in which to get the delta.
* @return The delta associated with the patch.
*/ */
GIT_EXTERN(const git_diff_delta *) git_patch_get_delta(const git_patch *patch); GIT_EXTERN(const git_diff_delta *) git_patch_get_delta(const git_patch *patch);
/** /**
* Get the number of hunks in a patch * Get the number of hunks in a patch
*
* @param patch The patch in which to get the number of hunks.
* @return The number of hunks of the patch.
*/ */
GIT_EXTERN(size_t) git_patch_num_hunks(const git_patch *patch); GIT_EXTERN(size_t) git_patch_num_hunks(const git_patch *patch);

View File

@ -69,7 +69,7 @@ typedef enum {
* just test if there were any matches at all or in combination with * just test if there were any matches at all or in combination with
* GIT_PATHSPEC_FIND_FAILURES to validate a pathspec. * GIT_PATHSPEC_FIND_FAILURES to validate a pathspec.
*/ */
GIT_PATHSPEC_FAILURES_ONLY = (1u << 5), GIT_PATHSPEC_FAILURES_ONLY = (1u << 5)
} git_pathspec_flag_t; } git_pathspec_flag_t;
/** /**

View File

@ -32,7 +32,7 @@ typedef enum {
/** /**
* Connect via the URL given in the options * Connect via the URL given in the options
*/ */
GIT_PROXY_SPECIFIED, GIT_PROXY_SPECIFIED
} git_proxy_t; } git_proxy_t;
/** /**

View File

@ -152,7 +152,7 @@ typedef enum {
* No commit will be cherry-picked. The client should run the given * No commit will be cherry-picked. The client should run the given
* command and (if successful) continue. * command and (if successful) continue.
*/ */
GIT_REBASE_OPERATION_EXEC, GIT_REBASE_OPERATION_EXEC
} git_rebase_operation_t; } git_rebase_operation_t;
#define GIT_REBASE_OPTIONS_VERSION 1 #define GIT_REBASE_OPTIONS_VERSION 1
@ -242,6 +242,7 @@ GIT_EXTERN(int) git_rebase_open(
/** /**
* Gets the original `HEAD` ref name for merge rebases. * Gets the original `HEAD` ref name for merge rebases.
* *
* @param rebase The in-progress rebase.
* @return The original `HEAD` ref name * @return The original `HEAD` ref name
*/ */
GIT_EXTERN(const char *) git_rebase_orig_head_name(git_rebase *rebase); GIT_EXTERN(const char *) git_rebase_orig_head_name(git_rebase *rebase);
@ -249,6 +250,7 @@ GIT_EXTERN(const char *) git_rebase_orig_head_name(git_rebase *rebase);
/** /**
* Gets the original `HEAD` id for merge rebases. * Gets the original `HEAD` id for merge rebases.
* *
* @param rebase The in-progress rebase.
* @return The original `HEAD` id * @return The original `HEAD` id
*/ */
GIT_EXTERN(const git_oid *) git_rebase_orig_head_id(git_rebase *rebase); GIT_EXTERN(const git_oid *) git_rebase_orig_head_id(git_rebase *rebase);
@ -256,6 +258,7 @@ GIT_EXTERN(const git_oid *) git_rebase_orig_head_id(git_rebase *rebase);
/** /**
* Gets the `onto` ref name for merge rebases. * Gets the `onto` ref name for merge rebases.
* *
* @param rebase The in-progress rebase.
* @return The `onto` ref name * @return The `onto` ref name
*/ */
GIT_EXTERN(const char *) git_rebase_onto_name(git_rebase *rebase); GIT_EXTERN(const char *) git_rebase_onto_name(git_rebase *rebase);
@ -263,6 +266,7 @@ GIT_EXTERN(const char *) git_rebase_onto_name(git_rebase *rebase);
/** /**
* Gets the `onto` id for merge rebases. * Gets the `onto` id for merge rebases.
* *
* @param rebase The in-progress rebase.
* @return The `onto` id * @return The `onto` id
*/ */
GIT_EXTERN(const git_oid *) git_rebase_onto_id(git_rebase *rebase); GIT_EXTERN(const git_oid *) git_rebase_onto_id(git_rebase *rebase);
@ -322,6 +326,10 @@ GIT_EXTERN(int) git_rebase_next(
* This is only applicable for in-memory rebases; for rebases within * This is only applicable for in-memory rebases; for rebases within
* a working directory, the changes were applied to the repository's * a working directory, the changes were applied to the repository's
* index. * index.
*
* @param index The result index of the last operation.
* @param rebase The in-progress rebase.
* @return 0 or an error code
*/ */
GIT_EXTERN(int) git_rebase_inmemory_index( GIT_EXTERN(int) git_rebase_inmemory_index(
git_index **index, git_index **index,

View File

@ -52,6 +52,9 @@ GIT_EXTERN(int) git_refdb_open(git_refdb **out, git_repository *repo);
* Suggests that the given refdb compress or optimize its references. * Suggests that the given refdb compress or optimize its references.
* This mechanism is implementation specific. For on-disk reference * This mechanism is implementation specific. For on-disk reference
* databases, for example, this may pack all loose references. * databases, for example, this may pack all loose references.
*
* @param refdb The reference database to optimize.
* @return 0 or an error code.
*/ */
GIT_EXTERN(int) git_refdb_compress(git_refdb *refdb); GIT_EXTERN(int) git_refdb_compress(git_refdb *refdb);

Some files were not shown because too many files have changed in this diff Show More