mirror of
https://git.proxmox.com/git/libgit2
synced 2025-04-30 23:20:20 +00:00
New upstream version 0.28.1+dfsg.1
This commit is contained in:
parent
6c7cee4230
commit
ac3d33df5d
@ -12,3 +12,4 @@ insert_final_newline = true
|
||||
[*.md]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
trim_trailing_whitespace = false
|
||||
|
13
.github/ISSUE_TEMPLATE
vendored
13
.github/ISSUE_TEMPLATE
vendored
@ -1,7 +1,12 @@
|
||||
You are opening a _bug report_ against the libgit2 project. If you have a
|
||||
question about an API or usage, please ask on StackOverflow:
|
||||
http://stackoverflow.com/questions/tagged/libgit2. Please fill out the
|
||||
reproduction steps (below) and delete this introductory paragraph. Thanks!
|
||||
You are opening a _bug report_ against the libgit2 project: we use
|
||||
GitHub Issues for tracking bug reports and feature requests. If you
|
||||
have a question about an API or usage, please ask on StackOverflow:
|
||||
http://stackoverflow.com/questions/tagged/libgit2. If you want to
|
||||
have high-level discussions about the libgit2 project itself, visit
|
||||
https://github.com/libgit2/discussions.
|
||||
|
||||
Otherwise, to report a bug, please fill out the reproduction steps
|
||||
(below) and delete these introductory paragraphs. Thanks!
|
||||
|
||||
### Reproduction steps
|
||||
|
||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -31,3 +31,5 @@ msvc/Release/
|
||||
.*.swp
|
||||
tags
|
||||
mkmf.log
|
||||
*.profdata
|
||||
*.profraw
|
||||
|
4
.mailmap
4
.mailmap
@ -16,7 +16,7 @@ Xavier L. <xavier.l@afrosoft.tk> <xavier.l@afrosoft.tk>
|
||||
Sascha Cunz <sascha@babbelbox.org> <Sascha@BabbelBox.org>
|
||||
Authmillenon <authmillenon@googlemail.com> <martin@ucsmail.de>
|
||||
Authmillenon <authmillenon@googlemail.com> <authmillenon@googlemail.com>
|
||||
Edward Thomson <ethomson@github.com> <ethomson@microsoft.com>
|
||||
Edward Thomson <ethomson@github.com> <ethomson@edwardthomson.com>
|
||||
Edward Thomson <ethomson@edwardthomson.com> <ethomson@microsoft.com>
|
||||
Edward Thomson <ethomson@edwardthomson.com> <ethomson@github.com>
|
||||
J. David Ibáñez <jdavid.ibp@gmail.com> <jdavid@itaapy.com>
|
||||
Russell Belfer <rb@github.com> <arrbee@arrbee.com>
|
||||
|
116
CMakeLists.txt
116
CMakeLists.txt
@ -14,12 +14,15 @@
|
||||
PROJECT(libgit2 C)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11)
|
||||
CMAKE_POLICY(SET CMP0015 NEW)
|
||||
IF (POLICY CMP0051)
|
||||
IF(POLICY CMP0051)
|
||||
CMAKE_POLICY(SET CMP0051 NEW)
|
||||
ENDIF()
|
||||
IF (POLICY CMP0042)
|
||||
IF(POLICY CMP0042)
|
||||
CMAKE_POLICY(SET CMP0042 NEW)
|
||||
ENDIF()
|
||||
IF(POLICY CMP0054)
|
||||
CMAKE_POLICY(SET CMP0054 NEW)
|
||||
ENDIF()
|
||||
|
||||
# Add find modules to the path
|
||||
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${libgit2_SOURCE_DIR}/cmake/Modules/")
|
||||
@ -39,63 +42,58 @@ INCLUDE(EnableWarnings)
|
||||
|
||||
# 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( TAGS "Generate tags" OFF )
|
||||
OPTION( PROFILE "Generate profiling information" OFF )
|
||||
OPTION( ENABLE_TRACE "Enables tracing support" OFF )
|
||||
OPTION( LIBGIT2_FILENAME "Name of the produced binary" OFF )
|
||||
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(TAGS "Generate tags" OFF)
|
||||
OPTION(PROFILE "Generate profiling information" OFF)
|
||||
OPTION(ENABLE_TRACE "Enables tracing support" OFF)
|
||||
OPTION(LIBGIT2_FILENAME "Name of the produced binary" OFF)
|
||||
|
||||
SET(SHA1_BACKEND "CollisionDetection" CACHE STRING "Backend to use for SHA1. One of Generic, OpenSSL, Win32, CommonCrypto, CollisionDetection. ")
|
||||
OPTION( USE_SSH "Link with libssh to enable SSH support" ON )
|
||||
OPTION( USE_HTTPS "Enable HTTPS support. Can be set to a specific backend" ON )
|
||||
OPTION( USE_GSSAPI "Link with libgssapi for SPNEGO auth" OFF )
|
||||
OPTION( VALGRIND "Configure build for valgrind" OFF )
|
||||
OPTION( CURL "Use curl for HTTP if available" ON)
|
||||
OPTION( USE_EXT_HTTP_PARSER "Use system HTTP_Parser if available" ON)
|
||||
OPTION( DEBUG_POOL "Enable debug pool allocator" OFF )
|
||||
OPTION( ENABLE_WERROR "Enable compilation with -Werror" OFF )
|
||||
OPTION( USE_BUNDLED_ZLIB "Use the bundled version of zlib" OFF )
|
||||
SET(SHA1_BACKEND "CollisionDetection" CACHE STRING
|
||||
"Backend to use for SHA1. One of Generic, OpenSSL, Win32, CommonCrypto, mbedTLS, CollisionDetection.")
|
||||
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_GSSAPI "Link with libgssapi for SPNEGO auth" OFF)
|
||||
OPTION(USE_STANDALONE_FUZZERS "Enable standalone fuzzers (compatible with gcc)" OFF)
|
||||
OPTION(VALGRIND "Configure build for valgrind" OFF)
|
||||
OPTION(USE_EXT_HTTP_PARSER "Use system HTTP_Parser if available" ON)
|
||||
OPTION(DEBUG_POOL "Enable debug pool allocator" OFF)
|
||||
OPTION(ENABLE_WERROR "Enable compilation with -Werror" OFF)
|
||||
OPTION(USE_BUNDLED_ZLIB "Use the bundled version of zlib" OFF)
|
||||
OPTION(DEPRECATE_HARD "Do not include deprecated functions in the library" OFF)
|
||||
|
||||
IF (UNIX AND NOT APPLE)
|
||||
OPTION( ENABLE_REPRODUCIBLE_BUILDS "Enable reproducible builds" OFF )
|
||||
OPTION(ENABLE_REPRODUCIBLE_BUILDS "Enable reproducible builds" OFF)
|
||||
ENDIF()
|
||||
|
||||
IF (APPLE)
|
||||
OPTION( USE_ICONV "Link with and use iconv library" ON )
|
||||
OPTION(USE_ICONV "Link with and use iconv library" ON)
|
||||
ENDIF()
|
||||
|
||||
IF(MSVC)
|
||||
# This option is only available when building with MSVC. By default, libgit2
|
||||
# is build using the cdecl calling convention, which is useful if you're
|
||||
# writing C. However, the CLR and Win32 API both expect stdcall.
|
||||
#
|
||||
# If you are writing a CLR program and want to link to libgit2, you'll want
|
||||
# to turn this on by invoking CMake with the "-DSTDCALL=ON" argument.
|
||||
OPTION( STDCALL "Build libgit2 with the __stdcall convention" OFF )
|
||||
|
||||
# This option must match the settings used in your program, in particular if you
|
||||
# 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
|
||||
# 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 )
|
||||
OPTION(WINHTTP "Use Win32 WinHTTP routines" ON)
|
||||
ENDIF()
|
||||
|
||||
IF(MSVC)
|
||||
# Enable MSVC CRTDBG memory leak reporting when in debug mode.
|
||||
OPTION(MSVC_CRTDBG "Enable CRTDBG memory leak reporting" OFF)
|
||||
OPTION(MSVC_CRTDBG "Enable CRTDBG memory leak reporting" OFF)
|
||||
ENDIF()
|
||||
|
||||
FILE(STRINGS "${libgit2_SOURCE_DIR}/include/git2/version.h" GIT2_HEADER REGEX "^#define LIBGIT2_VERSION \"[^\"]*\"$")
|
||||
@ -108,8 +106,16 @@ SET(LIBGIT2_VERSION_STRING "${LIBGIT2_VERSION_MAJOR}.${LIBGIT2_VERSION_MINOR}.${
|
||||
FILE(STRINGS "${libgit2_SOURCE_DIR}/include/git2/version.h" GIT2_HEADER_SOVERSION REGEX "^#define LIBGIT2_SOVERSION [0-9]+$")
|
||||
STRING(REGEX REPLACE "^.*LIBGIT2_SOVERSION ([0-9]+)$" "\\1" LIBGIT2_SOVERSION "${GIT2_HEADER_SOVERSION}")
|
||||
|
||||
IF (DEPRECATE_HARD)
|
||||
ADD_DEFINITIONS(-DGIT_DEPRECATE_HARD)
|
||||
ENDIF()
|
||||
|
||||
# Platform specific compilation flags
|
||||
IF (MSVC)
|
||||
IF (STDCALL)
|
||||
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)
|
||||
@ -120,10 +126,8 @@ IF (MSVC)
|
||||
# /MP - Parallel build
|
||||
SET(CMAKE_C_FLAGS "/GF /MP /nologo ${CMAKE_C_FLAGS}")
|
||||
|
||||
IF (STDCALL)
|
||||
# /Gz - stdcall calling convention
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Gz")
|
||||
ENDIF ()
|
||||
# /Gd - explicitly set cdecl calling convention
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Gd")
|
||||
|
||||
IF (STATIC_CRT)
|
||||
SET(CRT_FLAG_DEBUG "/MTd")
|
||||
@ -162,6 +166,9 @@ IF (MSVC)
|
||||
# /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
|
||||
@ -197,7 +204,7 @@ ELSE ()
|
||||
ENABLE_WARNINGS(extra)
|
||||
|
||||
IF (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
|
||||
SET(CMAKE_C_FLAGS "-std=c99 -D_POSIX_C_SOURCE=200112L -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS ${CMAKE_C_FLAGS}")
|
||||
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")
|
||||
@ -223,15 +230,12 @@ ELSE ()
|
||||
ENABLE_WARNINGS(strict-prototypes)
|
||||
ENABLE_WARNINGS(declaration-after-statement)
|
||||
ENABLE_WARNINGS(shift-count-overflow)
|
||||
DISABLE_WARNINGS(unused-const-variable)
|
||||
DISABLE_WARNINGS(unused-function)
|
||||
ENABLE_WARNINGS(unused-const-variable)
|
||||
ENABLE_WARNINGS(unused-function)
|
||||
ENABLE_WARNINGS(format)
|
||||
ENABLE_WARNINGS(format-security)
|
||||
ENABLE_WARNINGS(int-conversion)
|
||||
|
||||
IF (APPLE) # Apple deprecated OpenSSL
|
||||
DISABLE_WARNINGS(deprecated-declarations)
|
||||
ENDIF()
|
||||
DISABLE_WARNINGS(documentation-deprecated-sync)
|
||||
|
||||
IF (PROFILE)
|
||||
SET(CMAKE_C_FLAGS "-pg ${CMAKE_C_FLAGS}")
|
||||
@ -249,6 +253,14 @@ ELSE()
|
||||
# that uses CMAKE_CONFIGURATION_TYPES and not CMAKE_BUILD_TYPE
|
||||
ENDIF()
|
||||
|
||||
IF(BUILD_FUZZERS AND NOT USE_STANDALONE_FUZZERS)
|
||||
# The actual sanitizer link target will be added when linking the fuzz
|
||||
# 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
|
||||
@ -286,6 +298,18 @@ 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()
|
||||
|
||||
IF(CMAKE_VERSION VERSION_GREATER 3)
|
||||
FEATURE_SUMMARY(WHAT ENABLED_FEATURES DESCRIPTION "Enabled features:")
|
||||
FEATURE_SUMMARY(WHAT DISABLED_FEATURES DESCRIPTION "Disabled features:")
|
||||
|
56
README.md
56
README.md
@ -1,8 +1,13 @@
|
||||
libgit2 - the Git linkable library
|
||||
==================================
|
||||
|
||||
[](https://dev.azure.com/libgit2/libgit2/_build/latest?definitionId=7)
|
||||
[](https://scan.coverity.com/projects/639)
|
||||
| Build Status | |
|
||||
| ------------ | - |
|
||||
| **master** branch CI builds | [](https://dev.azure.com/libgit2/libgit2/_build/latest?definitionId=7&branchName=master) |
|
||||
| **v0.28 branch** CI builds | [](https://dev.azure.com/libgit2/libgit2/_build/latest?definitionId=7&branchName=maint/v0.28) |
|
||||
| **v0.27 branch** CI builds | [](https://dev.azure.com/libgit2/libgit2/_build/latest?definitionId=7&branchName=maint/v0.27) |
|
||||
| **v0.26 branch** CI builds | [](https://dev.azure.com/libgit2/libgit2/_build/latest?definitionId=7&branchName=maint/v0.26) |
|
||||
| **Nightly** builds | [](https://libgit2.visualstudio.com/libgit2/_build/latest?definitionId=9&branchName=master) [](https://dev.azure.com/libgit2/libgit2/_build/latest?definitionId=21?branchName=master) [](https://scan.coverity.com/projects/639) |
|
||||
|
||||
`libgit2` is a portable, pure C implementation of the Git core methods
|
||||
provided as a linkable library with a solid API, allowing to build Git
|
||||
@ -26,6 +31,27 @@ with any kind of software without having to release its source code.
|
||||
Additionally, the example code has been released to the public domain (see the
|
||||
[separate license](examples/COPYING) for more information).
|
||||
|
||||
Table of Contents
|
||||
=================
|
||||
|
||||
* [Quick Start](#quick-start)
|
||||
* [Getting Help](#getting-help)
|
||||
* [What It Can Do](#what-it-can-do)
|
||||
* [Optional dependencies](#optional-dependencies)
|
||||
* [Initialization](#initialization)
|
||||
* [Threading](#threading)
|
||||
* [Conventions](#conventions)
|
||||
* [Building libgit2 - Using CMake](#building-libgit2---using-cmake)
|
||||
* [Building](#building)
|
||||
* [Installation](#installation)
|
||||
* [Advanced Usage](#advanced-usage)
|
||||
* [Compiler and linker options](#compiler-and-linker-options)
|
||||
* [MacOS X](#macos-x)
|
||||
* [Android](#android)
|
||||
* [Language Bindings](#language-bindings)
|
||||
* [How Can I Contribute?](#how-can-i-contribute)
|
||||
* [License](#license)
|
||||
|
||||
Quick Start
|
||||
===========
|
||||
|
||||
@ -47,8 +73,8 @@ Quick Start
|
||||
2. Create the cmake build environment: `cmake ..`
|
||||
3. Build libgit2: `cmake --build .`
|
||||
|
||||
Trouble with these steps? Read `TROUBLESHOOTING.md`. More detailed build
|
||||
guidance is available below.
|
||||
Trouble with these steps? Read our (troubleshooting guide)[docs/troubleshooting.md].
|
||||
More detailed build guidance is available below.
|
||||
|
||||
Getting Help
|
||||
============
|
||||
@ -148,12 +174,12 @@ require assistance coordinating this, simply have the worker threads call
|
||||
Threading
|
||||
=========
|
||||
|
||||
See [THREADING](THREADING.md) for information
|
||||
See [threading](docs/threading.md) for information
|
||||
|
||||
Conventions
|
||||
===========
|
||||
|
||||
See [CONVENTIONS](CONVENTIONS.md) for an overview of the external
|
||||
See [conventions](docs/conventions.md) for an overview of the external
|
||||
and internal API/coding conventions we use.
|
||||
|
||||
Building libgit2 - Using CMake
|
||||
@ -195,7 +221,7 @@ run the index tests:
|
||||
$ ./libgit2_clar -sindex
|
||||
|
||||
To run a single test named `index::racy::diff`, which corresponds to the test
|
||||
function (`test_index_racy__diff`)[https://github.com/libgit2/libgit2/blob/master/tests/index/racy.c#L23]:
|
||||
function [`test_index_racy__diff`](https://github.com/libgit2/libgit2/blob/master/tests/index/racy.c#L23):
|
||||
|
||||
$ ./libgit2_clar -sindex::racy::diff
|
||||
|
||||
@ -230,7 +256,15 @@ The following CMake variables are declared:
|
||||
- `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)
|
||||
- `THREADSAFE`: Build libgit2 with threading support (defaults to ON)
|
||||
- `STDCALL`: Build libgit2 as `stdcall`. Turn off for `cdecl` (Windows; defaults to ON)
|
||||
|
||||
To list all build options and their current value, you can do the
|
||||
following:
|
||||
|
||||
# Create and set up a build directory
|
||||
$ mkdir build
|
||||
$ cmake ..
|
||||
# List all build options and their values
|
||||
$ cmake -L
|
||||
|
||||
Compiler and linker options
|
||||
---------------------------
|
||||
@ -342,10 +376,10 @@ We welcome new contributors! We have a number of issues marked as
|
||||
and
|
||||
["easy fix"](https://github.com/libgit2/libgit2/issues?utf8=✓&q=is%3Aissue+is%3Aopen+label%3A%22easy+fix%22)
|
||||
that are good places to jump in and get started. There's much more detailed
|
||||
information in our list of [outstanding projects](PROJECTS.md).
|
||||
information in our list of [outstanding projects](docs/projects.md).
|
||||
|
||||
Please be sure to check the [contribution guidelines](CONTRIBUTING.md) to
|
||||
understand our workflow, and the libgit2 [coding conventions](CONVENTIONS.md).
|
||||
Please be sure to check the [contribution guidelines](docs/contributing.md) to
|
||||
understand our workflow, and the libgit2 [coding conventions](docs/conventions.md).
|
||||
|
||||
License
|
||||
==================================
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "libgit2",
|
||||
"github": "libgit2/libgit2",
|
||||
"input": "include/git2",
|
||||
"input": "include",
|
||||
"prefix": "git_",
|
||||
"output": "docs",
|
||||
"branch": "gh-pages",
|
||||
|
@ -6,28 +6,56 @@ trigger:
|
||||
- maint/*
|
||||
|
||||
jobs:
|
||||
- job: linux_trusty_gcc_openssl
|
||||
displayName: 'Linux (Trusty; GCC; OpenSSL)'
|
||||
- job: linux_amd64_trusty_gcc_openssl
|
||||
displayName: 'Linux (amd64; Trusty; GCC; OpenSSL)'
|
||||
pool:
|
||||
vmImage: 'Ubuntu 16.04'
|
||||
steps:
|
||||
- template: ci/docker.yml
|
||||
- template: azure-pipelines/docker.yml
|
||||
parameters:
|
||||
imageName: 'libgit2/trusty-openssl:latest'
|
||||
imageName: 'libgit2/trusty-amd64:latest'
|
||||
environmentVariables: |
|
||||
CC=gcc
|
||||
CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON
|
||||
LEAK_CHECK=valgrind
|
||||
|
||||
- job: linux_trusty_clang_openssl
|
||||
displayName: 'Linux (Trusty; Clang; OpenSSL)'
|
||||
- job: linux_amd64_trusty_gcc_mbedtls
|
||||
displayName: 'Linux (amd64; Trusty; GCC; mbedTLS)'
|
||||
pool:
|
||||
vmImage: 'Ubuntu 16.04'
|
||||
steps:
|
||||
- template: ci/docker.yml
|
||||
- template: azure-pipelines/docker.yml
|
||||
parameters:
|
||||
imageName: 'libgit2/trusty-openssl:latest'
|
||||
imageName: 'libgit2/trusty-amd64:latest'
|
||||
environmentVariables: |
|
||||
CC=gcc
|
||||
CMAKE_OPTIONS=-DUSE_HTTPS=mbedTLS -DSHA1_BACKEND=mbedTLS -DDEPRECATE_HARD=ON
|
||||
LEAK_CHECK=valgrind
|
||||
|
||||
- job: linux_amd64_trusty_clang_openssl
|
||||
displayName: 'Linux (amd64; Trusty; Clang; OpenSSL)'
|
||||
pool:
|
||||
vmImage: 'Ubuntu 16.04'
|
||||
steps:
|
||||
- template: azure-pipelines/docker.yml
|
||||
parameters:
|
||||
imageName: 'libgit2/trusty-amd64:latest'
|
||||
environmentVariables: |
|
||||
CC=clang
|
||||
CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON
|
||||
LEAK_CHECK=valgrind
|
||||
|
||||
- job: linux_amd64_trusty_clang_mbedtls
|
||||
displayName: 'Linux (amd64; Trusty; Clang; mbedTLS)'
|
||||
pool:
|
||||
vmImage: 'Ubuntu 16.04'
|
||||
steps:
|
||||
- template: azure-pipelines/docker.yml
|
||||
parameters:
|
||||
imageName: 'libgit2/trusty-amd64:latest'
|
||||
environmentVariables: |
|
||||
CC=clang
|
||||
CMAKE_OPTIONS=-DUSE_HTTPS=mbedTLS -DSHA1_BACKEND=mbedTLS -DDEPRECATE_HARD=ON
|
||||
LEAK_CHECK=valgrind
|
||||
|
||||
- job: macos
|
||||
@ -37,33 +65,35 @@ jobs:
|
||||
steps:
|
||||
- bash: . '$(Build.SourcesDirectory)/ci/setup-osx.sh'
|
||||
displayName: Setup
|
||||
- template: ci/bash.yml
|
||||
- template: azure-pipelines/bash.yml
|
||||
parameters:
|
||||
environmentVariables:
|
||||
TMPDIR: $(Agent.TempDirectory)
|
||||
PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig
|
||||
LEAK_CHECK: leaks
|
||||
CMAKE_OPTIONS: -G Ninja -DDEPRECATE_HARD=ON
|
||||
SKIP_SSH_TESTS: true
|
||||
|
||||
- job: windows_vs_amd64
|
||||
displayName: 'Windows (Visual Studio; amd64)'
|
||||
displayName: 'Windows (amd64; Visual Studio)'
|
||||
pool: Hosted
|
||||
steps:
|
||||
- template: ci/powershell.yml
|
||||
- template: azure-pipelines/powershell.yml
|
||||
parameters:
|
||||
environmentVariables:
|
||||
CMAKE_OPTIONS: -DMSVC_CRTDBG=ON -G"Visual Studio 12 2013 Win64"
|
||||
CMAKE_OPTIONS: -DMSVC_CRTDBG=ON -G"Visual Studio 12 2013 Win64" -DDEPRECATE_HARD=ON
|
||||
|
||||
- job: windows_vs_x86
|
||||
displayName: 'Windows (Visual Studio; x86)'
|
||||
displayName: 'Windows (x86; Visual Studio)'
|
||||
pool: Hosted
|
||||
steps:
|
||||
- template: ci/powershell.yml
|
||||
- template: azure-pipelines/powershell.yml
|
||||
parameters:
|
||||
environmentVariables:
|
||||
CMAKE_OPTIONS: -DMSVC_CRTDBG=ON -G"Visual Studio 12 2013"
|
||||
CMAKE_OPTIONS: -DMSVC_CRTDBG=ON -G"Visual Studio 12 2013" -DDEPRECATE_HARD=ON
|
||||
|
||||
- job: windows_mingw_amd64
|
||||
displayName: 'Windows (MinGW; amd64)'
|
||||
displayName: 'Windows (amd64; MinGW)'
|
||||
pool: Hosted
|
||||
steps:
|
||||
- powershell: . '$(Build.SourcesDirectory)\ci\setup-mingw.ps1'
|
||||
@ -71,14 +101,14 @@ jobs:
|
||||
env:
|
||||
TEMP: $(Agent.TempDirectory)
|
||||
ARCH: amd64
|
||||
- template: ci/powershell.yml
|
||||
- template: azure-pipelines/powershell.yml
|
||||
parameters:
|
||||
environmentVariables:
|
||||
CMAKE_OPTIONS: -G"MinGW Makefiles"
|
||||
CMAKE_OPTIONS: -G"MinGW Makefiles" -DDEPRECATE_HARD=ON
|
||||
PATH: $(Agent.TempDirectory)\mingw64\bin;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\CMake\bin
|
||||
|
||||
- job: windows_mingw_x86
|
||||
displayName: 'Windows (MinGW; x86)'
|
||||
displayName: 'Windows (x86; MinGW)'
|
||||
pool: Hosted
|
||||
steps:
|
||||
- powershell: . '$(Build.SourcesDirectory)\ci\setup-mingw.ps1'
|
||||
@ -87,8 +117,31 @@ jobs:
|
||||
env:
|
||||
TEMP: $(Agent.TempDirectory)
|
||||
ARCH: x86
|
||||
- template: ci/powershell.yml
|
||||
- template: azure-pipelines/powershell.yml
|
||||
parameters:
|
||||
environmentVariables:
|
||||
CMAKE_OPTIONS: -G"MinGW Makefiles"
|
||||
CMAKE_OPTIONS: -G"MinGW Makefiles" -DDEPRECATE_HARD=ON
|
||||
PATH: $(Agent.TempDirectory)\mingw32\bin;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\CMake\bin
|
||||
|
||||
- job: documentation
|
||||
displayName: 'Generate Documentation'
|
||||
pool:
|
||||
vmImage: 'Ubuntu 16.04'
|
||||
steps:
|
||||
- script: |
|
||||
git config user.name 'Documentation Generation'
|
||||
git config user.email 'noreply@libgit2.org'
|
||||
docker run --rm -v /home/vsts/work/1/s:/src -w /src libgit2/docurium:test cm doc api.docurium
|
||||
git checkout gh-pages
|
||||
cp -R * '$(Build.BinariesDirectory)'
|
||||
- task: archivefiles@2
|
||||
displayName: 'Archive Documentation'
|
||||
inputs:
|
||||
rootFolderOrFile: '$(Build.BinariesDirectory)'
|
||||
includeRootFolder: false
|
||||
archiveFile: '$(Build.ArtifactStagingDirectory)/api-documentation.zip'
|
||||
- task: publishbuildartifacts@1
|
||||
displayName: 'Upload Documentation'
|
||||
inputs:
|
||||
pathToPublish: '$(Build.ArtifactStagingDirectory)'
|
||||
artifactName: 'docs'
|
||||
|
36
azure-pipelines/coverity.yml
Normal file
36
azure-pipelines/coverity.yml
Normal file
@ -0,0 +1,36 @@
|
||||
resources:
|
||||
- repo: self
|
||||
|
||||
jobs:
|
||||
- job: coverity
|
||||
displayName: 'Coverity'
|
||||
pool:
|
||||
vmImage: 'Ubuntu 16.04'
|
||||
steps:
|
||||
- task: Docker@0
|
||||
displayName: Build
|
||||
inputs:
|
||||
action: 'Run an image'
|
||||
imageName: 'libgit2/trusty-openssl:latest'
|
||||
volumes: |
|
||||
$(Build.SourcesDirectory):/src
|
||||
$(Build.BinariesDirectory):/build
|
||||
envVars: |
|
||||
COVERITY_TOKEN=$(COVERITY_TOKEN)
|
||||
workDir: '/build'
|
||||
containerCommand: '/src/ci/coverity-build.sh'
|
||||
detached: false
|
||||
- task: Docker@0
|
||||
displayName: Publish
|
||||
inputs:
|
||||
action: 'Run an image'
|
||||
imageName: 'libgit2/trusty-openssl:latest'
|
||||
volumes: |
|
||||
$(Build.SourcesDirectory):/src
|
||||
$(Build.BinariesDirectory):/build
|
||||
envVars: |
|
||||
COVERITY_TOKEN=$(COVERITY_TOKEN)
|
||||
workDir: '/build'
|
||||
containerCommand: '/src/ci/coverity-publish.sh'
|
||||
detached: false
|
||||
continueOnError: true
|
@ -1,5 +1,9 @@
|
||||
# These are the steps used in a container-based build in VSTS.
|
||||
steps:
|
||||
- ${{ if eq(parameters.qemu, 'true') }}:
|
||||
- script: docker run --rm --privileged multiarch/qemu-user-static:register --reset
|
||||
displayName: 'Register Docker QEMU'
|
||||
|
||||
- task: docker@0
|
||||
displayName: Build
|
||||
inputs:
|
189
azure-pipelines/nightly.yml
Normal file
189
azure-pipelines/nightly.yml
Normal file
@ -0,0 +1,189 @@
|
||||
resources:
|
||||
- repo: self
|
||||
|
||||
jobs:
|
||||
- job: linux_amd64_trusty_gcc_openssl
|
||||
displayName: 'Linux (amd64; Trusty; GCC; OpenSSL)'
|
||||
pool:
|
||||
vmImage: 'Ubuntu 16.04'
|
||||
steps:
|
||||
- template: docker.yml
|
||||
parameters:
|
||||
imageName: 'libgit2/trusty-amd64:latest'
|
||||
environmentVariables: |
|
||||
CC=gcc
|
||||
CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON
|
||||
LEAK_CHECK=valgrind
|
||||
RUN_INVASIVE_TESTS=true
|
||||
|
||||
- job: linux_amd64_trusty_gcc_mbedtls
|
||||
displayName: 'Linux (amd64; Trusty; GCC; mbedTLS)'
|
||||
pool:
|
||||
vmImage: 'Ubuntu 16.04'
|
||||
steps:
|
||||
- template: docker.yml
|
||||
parameters:
|
||||
imageName: 'libgit2/trusty-amd64:latest'
|
||||
environmentVariables: |
|
||||
CC=gcc
|
||||
CMAKE_OPTIONS=-DUSE_HTTPS=mbedTLS -DSHA1_BACKEND=mbedTLS -DDEPRECATE_HARD=ON
|
||||
LEAK_CHECK=valgrind
|
||||
RUN_INVASIVE_TESTS=true
|
||||
|
||||
- job: linux_amd64_trusty_clang_openssl
|
||||
displayName: 'Linux (amd64; Trusty; Clang; OpenSSL)'
|
||||
pool:
|
||||
vmImage: 'Ubuntu 16.04'
|
||||
steps:
|
||||
- template: docker.yml
|
||||
parameters:
|
||||
imageName: 'libgit2/trusty-amd64:latest'
|
||||
environmentVariables: |
|
||||
CC=clang
|
||||
CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON
|
||||
LEAK_CHECK=valgrind
|
||||
RUN_INVASIVE_TESTS=true
|
||||
|
||||
- job: linux_amd64_trusty_clang_mbedtls
|
||||
displayName: 'Linux (amd64; Trusty; Clang; mbedTLS)'
|
||||
pool:
|
||||
vmImage: 'Ubuntu 16.04'
|
||||
steps:
|
||||
- template: docker.yml
|
||||
parameters:
|
||||
imageName: 'libgit2/trusty-amd64:latest'
|
||||
environmentVariables: |
|
||||
CC=clang
|
||||
CMAKE_OPTIONS=-DUSE_HTTPS=mbedTLS -DSHA1_BACKEND=mbedTLS -DDEPRECATE_HARD=ON
|
||||
LEAK_CHECK=valgrind
|
||||
RUN_INVASIVE_TESTS=true
|
||||
|
||||
- job: macos
|
||||
displayName: 'macOS'
|
||||
pool:
|
||||
vmImage: 'macOS 10.13'
|
||||
steps:
|
||||
- bash: . '$(Build.SourcesDirectory)/ci/setup-osx.sh'
|
||||
displayName: Setup
|
||||
- template: bash.yml
|
||||
parameters:
|
||||
environmentVariables:
|
||||
TMPDIR: $(Agent.TempDirectory)
|
||||
PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig
|
||||
LEAK_CHECK: leaks
|
||||
CMAKE_OPTIONS: -G Ninja -DDEPRECATE_HARD=ON
|
||||
RUN_INVASIVE_TESTS: true
|
||||
SKIP_SSH_TESTS: true
|
||||
|
||||
- job: windows_vs_amd64
|
||||
displayName: 'Windows (amd64; Visual Studio)'
|
||||
pool: Hosted
|
||||
steps:
|
||||
- template: powershell.yml
|
||||
parameters:
|
||||
environmentVariables:
|
||||
CMAKE_OPTIONS: -DMSVC_CRTDBG=ON -G"Visual Studio 12 2013 Win64" -DDEPRECATE_HARD=ON
|
||||
RUN_INVASIVE_TESTS: true
|
||||
|
||||
- job: windows_vs_x86
|
||||
displayName: 'Windows (x86; Visual Studio)'
|
||||
pool: Hosted
|
||||
steps:
|
||||
- template: powershell.yml
|
||||
parameters:
|
||||
environmentVariables:
|
||||
CMAKE_OPTIONS: -DMSVC_CRTDBG=ON -G"Visual Studio 12 2013" -DDEPRECATE_HARD=ON
|
||||
RUN_INVASIVE_TESTS: true
|
||||
|
||||
- job: windows_mingw_amd64
|
||||
displayName: 'Windows (amd64; MinGW)'
|
||||
pool: Hosted
|
||||
steps:
|
||||
- powershell: . '$(Build.SourcesDirectory)\ci\setup-mingw.ps1'
|
||||
displayName: Setup
|
||||
env:
|
||||
TEMP: $(Agent.TempDirectory)
|
||||
ARCH: amd64
|
||||
- template: powershell.yml
|
||||
parameters:
|
||||
environmentVariables:
|
||||
CMAKE_OPTIONS: -G"MinGW Makefiles" -DDEPRECATE_HARD=ON
|
||||
PATH: $(Agent.TempDirectory)\mingw64\bin;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\CMake\bin
|
||||
RUN_INVASIVE_TESTS: true
|
||||
|
||||
- job: windows_mingw_x86
|
||||
displayName: 'Windows (x86; MinGW)'
|
||||
pool: Hosted
|
||||
steps:
|
||||
- powershell: . '$(Build.SourcesDirectory)\ci\setup-mingw.ps1'
|
||||
displayName: Setup
|
||||
workingDirectory: '$(Build.BinariesDirectory)'
|
||||
env:
|
||||
TEMP: $(Agent.TempDirectory)
|
||||
ARCH: x86
|
||||
- template: powershell.yml
|
||||
parameters:
|
||||
environmentVariables:
|
||||
CMAKE_OPTIONS: -G"MinGW Makefiles" -DDEPRECATE_HARD=ON
|
||||
PATH: $(Agent.TempDirectory)\mingw32\bin;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\CMake\bin
|
||||
RUN_INVASIVE_TESTS: true
|
||||
|
||||
- job: linux_x86_bionic_gcc_openssl
|
||||
displayName: 'Linux (x86; Bionic; GCC; OpenSSL)'
|
||||
pool:
|
||||
vmImage: 'Ubuntu 16.04'
|
||||
steps:
|
||||
- template: docker.yml
|
||||
parameters:
|
||||
qemu: 'true'
|
||||
imageName: 'libgit2/bionic-x86:latest'
|
||||
environmentVariables: |
|
||||
CC=gcc
|
||||
CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON
|
||||
LEAK_CHECK=valgrind
|
||||
RUN_INVASIVE_TESTS=true
|
||||
|
||||
- job: linux_x86_bionic_clang_openssl
|
||||
displayName: 'Linux (x86; Bionic; Clang; OpenSSL)'
|
||||
pool:
|
||||
vmImage: 'Ubuntu 16.04'
|
||||
steps:
|
||||
- template: docker.yml
|
||||
parameters:
|
||||
qemu: 'true'
|
||||
imageName: 'libgit2/bionic-x86:latest'
|
||||
environmentVariables: |
|
||||
CC=clang
|
||||
CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON
|
||||
LEAK_CHECK=valgrind
|
||||
RUN_INVASIVE_TESTS=true
|
||||
|
||||
- job: linux_arm32_bionic_gcc_openssl
|
||||
displayName: 'Linux (arm32; Bionic; GCC; OpenSSL)'
|
||||
pool:
|
||||
vmImage: 'Ubuntu 16.04'
|
||||
steps:
|
||||
- template: docker.yml
|
||||
parameters:
|
||||
qemu: 'true'
|
||||
imageName: 'libgit2/bionic-arm32:latest'
|
||||
environmentVariables: |
|
||||
CC=gcc
|
||||
CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON
|
||||
RUN_INVASIVE_TESTS=true
|
||||
SKIP_PROXY_TESTS=true
|
||||
|
||||
- job: linux_arm64_bionic_gcc_openssl
|
||||
displayName: 'Linux (arm64; Bionic; GCC; OpenSSL)'
|
||||
pool:
|
||||
vmImage: 'Ubuntu 16.04'
|
||||
steps:
|
||||
- template: docker.yml
|
||||
parameters:
|
||||
qemu: 'true'
|
||||
imageName: 'libgit2/bionic-arm64:latest'
|
||||
environmentVariables: |
|
||||
CC=gcc
|
||||
CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON
|
||||
RUN_INVASIVE_TESTS=true
|
||||
SKIP_PROXY_TESTS=true
|
18
ci/build.sh
18
ci/build.sh
@ -16,8 +16,20 @@ indent() { sed "s/^/ /"; }
|
||||
echo "Source directory: ${SOURCE_DIR}"
|
||||
echo "Build directory: ${BUILD_DIR}"
|
||||
echo ""
|
||||
echo "Operating system version:"
|
||||
|
||||
if [ "$(uname -s)" = "Darwin" ]; then
|
||||
echo "macOS version:"
|
||||
sw_vers | indent
|
||||
fi
|
||||
|
||||
if [ -f "/etc/debian_version" ]; then
|
||||
echo "Debian version:"
|
||||
lsb_release -a | indent
|
||||
fi
|
||||
|
||||
echo "Kernel version:"
|
||||
uname -a 2>&1 | indent
|
||||
|
||||
echo "CMake version:"
|
||||
cmake --version 2>&1 | indent
|
||||
echo "Compiler version:"
|
||||
@ -28,8 +40,8 @@ echo "##########################################################################
|
||||
echo "## Configuring build environment"
|
||||
echo "##############################################################################"
|
||||
|
||||
echo cmake ${SOURCE_DIR} -DENABLE_WERROR=ON -DBUILD_EXAMPLES=ON ${CMAKE_OPTIONS}
|
||||
cmake ${SOURCE_DIR} -DENABLE_WERROR=ON -DBUILD_EXAMPLES=ON ${CMAKE_OPTIONS}
|
||||
echo cmake ${SOURCE_DIR} -DENABLE_WERROR=ON -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON ${CMAKE_OPTIONS}
|
||||
cmake ${SOURCE_DIR} -DENABLE_WERROR=ON -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON ${CMAKE_OPTIONS}
|
||||
|
||||
echo ""
|
||||
echo "##############################################################################"
|
||||
|
@ -39,27 +39,3 @@ COVERITY_UNSUPPORTED=1 \
|
||||
$COV_BUILD --dir cov-int \
|
||||
cmake --build .
|
||||
|
||||
# Upload results
|
||||
tar czf libgit2.tgz cov-int
|
||||
SHA=$(cd ${SOURCE_DIR} && git rev-parse --short HEAD)
|
||||
|
||||
HTML="$(curl \
|
||||
--silent \
|
||||
--write-out "\n%{http_code}" \
|
||||
--form token="$COVERITY_TOKEN" \
|
||||
--form email=libgit2@gmail.com \
|
||||
--form file=@libgit2.tgz \
|
||||
--form version="$SHA" \
|
||||
--form description="libgit2 build" \
|
||||
https://scan.coverity.com/builds?project=libgit2)"
|
||||
# Body is everything up to the last line
|
||||
BODY="$(echo "$HTML" | head -n-1)"
|
||||
# Status code is the last line
|
||||
STATUS_CODE="$(echo "$HTML" | tail -n1)"
|
||||
|
||||
echo "${BODY}"
|
||||
|
||||
if [ "${STATUS_CODE}" != "200" -a "${STATUS_CODE}" != "201" ]; then
|
||||
echo "Received error code ${STATUS_CODE} from Coverity"
|
||||
exit 1
|
||||
fi
|
33
ci/coverity-publish.sh
Executable file
33
ci/coverity-publish.sh
Executable file
@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
# Results check
|
||||
[ ! -d "cov-int" ] && echo "Coverity directory not found" && exit 1
|
||||
|
||||
# Upload results
|
||||
tar czf libgit2.tgz cov-int
|
||||
|
||||
SOURCE_DIR=${SOURCE_DIR:-$( cd "$( dirname "${BASH_SOURCE[0]}" )" && dirname $( pwd ) )}
|
||||
SHA=$(cd ${SOURCE_DIR} && git rev-parse --short HEAD)
|
||||
|
||||
HTML="$(curl \
|
||||
--silent \
|
||||
--write-out "\n%{http_code}" \
|
||||
--form token="$COVERITY_TOKEN" \
|
||||
--form email=libgit2@gmail.com \
|
||||
--form file=@libgit2.tgz \
|
||||
--form version="$SHA" \
|
||||
--form description="libgit2 build" \
|
||||
https://scan.coverity.com/builds?project=libgit2)"
|
||||
|
||||
# Body is everything up to the last line
|
||||
BODY="$(echo "$HTML" | head -n-1)"
|
||||
|
||||
# Status code is the last line
|
||||
STATUS_CODE="$(echo "$HTML" | tail -n1)"
|
||||
|
||||
if [ "${STATUS_CODE}" != "200" -a "${STATUS_CODE}" != "201" ]; then
|
||||
echo "Received error code ${STATUS_CODE} from Coverity"
|
||||
exit 1
|
||||
fi
|
@ -1,22 +0,0 @@
|
||||
resources:
|
||||
- repo: self
|
||||
|
||||
jobs:
|
||||
- job: coverity
|
||||
displayName: 'Coverity'
|
||||
pool:
|
||||
vmImage: 'Ubuntu 16.04'
|
||||
steps:
|
||||
- task: Docker@0
|
||||
displayName: Build
|
||||
inputs:
|
||||
action: 'Run an image'
|
||||
imageName: 'libgit2/trusty-openssl:latest'
|
||||
volumes: |
|
||||
$(Build.SourcesDirectory):/src
|
||||
$(Build.BinariesDirectory):/build
|
||||
envVars: |
|
||||
COVERITY_TOKEN=$(COVERITY_TOKEN)
|
||||
workDir: '/build'
|
||||
containerCommand: '/src/ci/coverity.sh'
|
||||
detached: false
|
@ -11,3 +11,17 @@ if [ -z "$SKIP_APT" ]; then
|
||||
fi
|
||||
|
||||
mkdir -p /var/run/sshd
|
||||
|
||||
if [ "$MBEDTLS" ]; then
|
||||
MBEDTLS_DIR=${MBEDTLS_DIR:-$(mktemp -d ${TMPDIR}/mbedtls.XXXXXXXX)}
|
||||
|
||||
git clone --depth 10 --single-branch --branch mbedtls-2.6.1 https://github.com/ARMmbed/mbedtls.git ${MBEDTLS_DIR}
|
||||
cd ${MBEDTLS_DIR}
|
||||
|
||||
CFLAGS=-fPIC cmake -DENABLE_PROGRAMS=OFF -DENABLE_TESTING=OFF -DUSE_SHARED_MBEDTLS_LIBRARY=OFF -DUSE_STATIC_MBEDTLS_LIBRARY=ON .
|
||||
cmake --build .
|
||||
|
||||
if [ -z "$SKIP_MBEDTLS_INSTALL" ]; then
|
||||
make install
|
||||
fi
|
||||
fi
|
||||
|
@ -3,6 +3,6 @@
|
||||
set -x
|
||||
|
||||
brew update
|
||||
brew install pkgconfig zlib curl openssl libssh2
|
||||
brew install pkgconfig zlib curl openssl libssh2 ninja
|
||||
|
||||
ln -s /Applications/Xcode.app/Contents/Developer/usr/lib/libLeaksAtExit.dylib /usr/local/lib
|
||||
|
34
ci/test.ps1
34
ci/test.ps1
@ -19,12 +19,17 @@ if ($Env:SKIP_TESTS) { exit }
|
||||
function run_test {
|
||||
$TestName = $args[0]
|
||||
|
||||
$TestCommand = (ctest -N -V -R "^$TestName$") -join "`n"
|
||||
|
||||
if (-Not ($TestCommand -match "(?ms).*\n^[0-9]*: Test command: ")) {
|
||||
echo "Could not find tests: $TestName"
|
||||
exit
|
||||
}
|
||||
|
||||
$TestCommand = (ctest -N -V -R "^$TestName$") -join "`n" -replace "(?ms).*\n^[0-9]*: Test command: ","" -replace "\n.*",""
|
||||
$TestCommand += " -r${BuildDir}\results_${TestName}.xml"
|
||||
|
||||
Write-Host $TestCommand
|
||||
Invoke-Expression $TestCommand
|
||||
|
||||
if ($LastExitCode -ne 0) { $global:Success = $false }
|
||||
}
|
||||
|
||||
@ -35,8 +40,8 @@ Write-Host "####################################################################
|
||||
if (-not $Env:SKIP_PROXY_TESTS) {
|
||||
Write-Host ""
|
||||
Write-Host "Starting HTTP proxy..."
|
||||
Invoke-WebRequest -Method GET -Uri https://github.com/ethomson/poxyproxy/releases/download/v0.1.0/poxyproxy-0.1.0.jar -OutFile poxyproxy.jar
|
||||
javaw -jar poxyproxy.jar -d --port 8080 --credentials foo:bar
|
||||
Invoke-WebRequest -Method GET -Uri https://github.com/ethomson/poxyproxy/releases/download/v0.4.0/poxyproxy-0.4.0.jar -OutFile poxyproxy.jar
|
||||
javaw -jar poxyproxy.jar -d --port 8080 --credentials foo:bar --quiet
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
@ -46,6 +51,21 @@ Write-Host "####################################################################
|
||||
|
||||
run_test offline
|
||||
|
||||
if ($Env:RUN_INVASIVE_TESTS) {
|
||||
Write-Host ""
|
||||
Write-Host "##############################################################################"
|
||||
Write-Host "## Running (invasive) tests"
|
||||
Write-Host "##############################################################################"
|
||||
|
||||
$Env:GITTEST_INVASIVE_FS_SIZE=1
|
||||
$Env:GITTEST_INVASIVE_MEMORY=1
|
||||
$Env:GITTEST_INVASIVE_SPEED=1
|
||||
run_test invasive
|
||||
$Env:GITTEST_INVASIVE_FS_SIZE=$null
|
||||
$Env:GITTEST_INVASIVE_MEMORY=$null
|
||||
$Env:GITTEST_INVASIVE_SPEED=$null
|
||||
}
|
||||
|
||||
if (-not $Env:SKIP_ONLINE_TESTS) {
|
||||
Write-Host ""
|
||||
Write-Host "##############################################################################"
|
||||
@ -60,12 +80,16 @@ if (-not $Env:SKIP_PROXY_TESTS) {
|
||||
Write-Host "Running proxy tests"
|
||||
Write-Host ""
|
||||
|
||||
$Env:GITTEST_REMOTE_PROXY_URL="localhost:8080"
|
||||
$Env:GITTEST_REMOTE_PROXY_HOST="localhost:8080"
|
||||
$Env:GITTEST_REMOTE_PROXY_USER="foo"
|
||||
$Env:GITTEST_REMOTE_PROXY_PASS="bar"
|
||||
|
||||
run_test proxy
|
||||
|
||||
$Env:GITTEST_REMOTE_PROXY_HOST=$null
|
||||
$Env:GITTEST_REMOTE_PROXY_USER=$null
|
||||
$Env:GITTEST_REMOTE_PROXY_PASS=$null
|
||||
|
||||
taskkill /F /IM javaw.exe
|
||||
}
|
||||
|
||||
|
41
ci/test.sh
41
ci/test.sh
@ -14,7 +14,7 @@ USER=${USER:-$(whoami)}
|
||||
SUCCESS=1
|
||||
|
||||
VALGRIND="valgrind --leak-check=full --show-reachable=yes --error-exitcode=125 --num-callers=50 --suppressions=\"$SOURCE_DIR/libgit2_clar.supp\""
|
||||
LEAKS="MallocStackLogging=1 MallocScribble=1 leaks -quiet -atExit -- nohup"
|
||||
LEAKS="MallocStackLogging=1 MallocScribble=1 MallocLogFile=/dev/null CLAR_AT_EXIT=\"leaks -quiet \$PPID\""
|
||||
|
||||
cleanup() {
|
||||
echo "Cleaning up..."
|
||||
@ -44,6 +44,12 @@ failure() {
|
||||
# JUnit-style XML files.
|
||||
run_test() {
|
||||
TEST_CMD=$(ctest -N -V -R "^${1}$" | sed -n 's/^[0-9]*: Test command: //p')
|
||||
|
||||
if [ -z "$TEST_CMD" ]; then
|
||||
echo "Could not find tests: $1"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TEST_CMD="${TEST_CMD} -r${BUILD_DIR}/results_${1}.xml"
|
||||
|
||||
if [ "$LEAK_CHECK" = "valgrind" ]; then
|
||||
@ -73,8 +79,8 @@ fi
|
||||
|
||||
if [ -z "$SKIP_PROXY_TESTS" ]; then
|
||||
echo "Starting HTTP proxy..."
|
||||
curl -L https://github.com/ethomson/poxyproxy/releases/download/v0.1.0/poxyproxy-0.1.0.jar >poxyproxy.jar
|
||||
java -jar poxyproxy.jar -d --port 8080 --credentials foo:bar >/dev/null 2>&1 &
|
||||
curl -L https://github.com/ethomson/poxyproxy/releases/download/v0.4.0/poxyproxy-0.4.0.jar >poxyproxy.jar
|
||||
java -jar poxyproxy.jar -d --address 127.0.0.1 --port 8080 --credentials foo:bar --quiet &
|
||||
fi
|
||||
|
||||
if [ -z "$SKIP_SSH_TESTS" ]; then
|
||||
@ -130,6 +136,20 @@ if [ -z "$SKIP_OFFLINE_TESTS" ]; then
|
||||
run_test offline
|
||||
fi
|
||||
|
||||
if [ -n "$RUN_INVASIVE_TESTS" ]; then
|
||||
echo ""
|
||||
echo "Running invasive tests"
|
||||
echo ""
|
||||
|
||||
export GITTEST_INVASIVE_FS_SIZE=1
|
||||
export GITTEST_INVASIVE_MEMORY=1
|
||||
export GITTEST_INVASIVE_SPEED=1
|
||||
run_test invasive
|
||||
unset GITTEST_INVASIVE_FS_SIZE
|
||||
unset GITTEST_INVASIVE_MEMORY
|
||||
unset GITTEST_INVASIVE_SPEED
|
||||
fi
|
||||
|
||||
if [ -z "$SKIP_ONLINE_TESTS" ]; then
|
||||
# Run the various online tests. The "online" test suite only includes the
|
||||
# default online tests that do not require additional configuration. The
|
||||
@ -158,11 +178,11 @@ if [ -z "$SKIP_PROXY_TESTS" ]; then
|
||||
echo "Running proxy tests"
|
||||
echo ""
|
||||
|
||||
export GITTEST_REMOTE_PROXY_URL="localhost:8080"
|
||||
export GITTEST_REMOTE_PROXY_HOST="localhost:8080"
|
||||
export GITTEST_REMOTE_PROXY_USER="foo"
|
||||
export GITTEST_REMOTE_PROXY_PASS="bar"
|
||||
run_test proxy
|
||||
unset GITTEST_REMOTE_PROXY_URL
|
||||
unset GITTEST_REMOTE_PROXY_HOST
|
||||
unset GITTEST_REMOTE_PROXY_USER
|
||||
unset GITTEST_REMOTE_PROXY_PASS
|
||||
fi
|
||||
@ -187,6 +207,17 @@ if [ -z "$SKIP_SSH_TESTS" ]; then
|
||||
unset GITTEST_REMOTE_SSH_FINGERPRINT
|
||||
fi
|
||||
|
||||
if [ -z "$SKIP_FUZZERS" ]; then
|
||||
echo ""
|
||||
echo "##############################################################################"
|
||||
echo "## Running fuzzers"
|
||||
echo "##############################################################################"
|
||||
|
||||
for fuzzer in fuzzers/*_fuzzer; do
|
||||
"${fuzzer}" "${SOURCE_DIR}/fuzzers/corpora/$(basename "${fuzzer%_fuzzer}")" || failure
|
||||
done
|
||||
fi
|
||||
|
||||
cleanup
|
||||
|
||||
if [ "$SUCCESS" -ne "1" ]; then
|
||||
|
@ -5,9 +5,23 @@
|
||||
|
||||
INCLUDE(CheckCCompilerFlag)
|
||||
|
||||
MACRO(ADD_C_FLAG _FLAG)
|
||||
STRING(TOUPPER ${_FLAG} UPCASE)
|
||||
STRING(REGEX REPLACE "[-=]" "_" UPCASE_PRETTY ${UPCASE})
|
||||
STRING(REGEX REPLACE "^_+" "" UPCASE_PRETTY ${UPCASE_PRETTY})
|
||||
CHECK_C_COMPILER_FLAG(${_FLAG} IS_${UPCASE_PRETTY}_SUPPORTED)
|
||||
|
||||
IF(IS_${UPCASE_PRETTY}_SUPPORTED)
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_FLAG}")
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR "Required flag ${_FLAG} is not supported")
|
||||
ENDIF()
|
||||
ENDMACRO()
|
||||
|
||||
MACRO(ADD_C_FLAG_IF_SUPPORTED _FLAG)
|
||||
STRING(TOUPPER ${_FLAG} UPCASE)
|
||||
STRING(REGEX REPLACE "^-" "" UPCASE_PRETTY ${UPCASE})
|
||||
STRING(REGEX REPLACE "[-=]" "_" UPCASE_PRETTY ${UPCASE})
|
||||
STRING(REGEX REPLACE "^_+" "" UPCASE_PRETTY ${UPCASE_PRETTY})
|
||||
CHECK_C_COMPILER_FLAG(${_FLAG} IS_${UPCASE_PRETTY}_SUPPORTED)
|
||||
|
||||
IF(IS_${UPCASE_PRETTY}_SUPPORTED)
|
||||
|
@ -1,14 +1,11 @@
|
||||
MACRO(ENABLE_WARNINGS flag)
|
||||
IF(ENABLE_WERROR)
|
||||
ADD_C_FLAG_IF_SUPPORTED(-Werror=${flag})
|
||||
ELSE()
|
||||
ADD_C_FLAG_IF_SUPPORTED(-W${flag})
|
||||
ENDIF()
|
||||
ADD_C_FLAG_IF_SUPPORTED(-W${flag})
|
||||
ENDMACRO()
|
||||
|
||||
MACRO(DISABLE_WARNINGS flag)
|
||||
ADD_C_FLAG_IF_SUPPORTED(-Wno-${flag})
|
||||
IF(ENABLE_WERROR)
|
||||
ADD_C_FLAG_IF_SUPPORTED(-Wno-error=${flag})
|
||||
ENDIF()
|
||||
ENDMACRO()
|
||||
|
||||
IF(ENABLE_WERROR)
|
||||
ADD_C_FLAG_IF_SUPPORTED(-Werror)
|
||||
ENDIF()
|
||||
|
93
cmake/Modules/FindmbedTLS.cmake
Normal file
93
cmake/Modules/FindmbedTLS.cmake
Normal file
@ -0,0 +1,93 @@
|
||||
# - Try to find mbedTLS
|
||||
# Once done this will define
|
||||
#
|
||||
# Read-Only variables
|
||||
# MBEDTLS_FOUND - system has mbedTLS
|
||||
# MBEDTLS_INCLUDE_DIR - the mbedTLS include directory
|
||||
# MBEDTLS_LIBRARY_DIR - the mbedTLS library directory
|
||||
# MBEDTLS_LIBRARIES - Link these to use mbedTLS
|
||||
# MBEDTLS_LIBRARY - path to mbedTLS library
|
||||
# MBEDX509_LIBRARY - path to mbedTLS X.509 library
|
||||
# MBEDCRYPTO_LIBRARY - path to mbedTLS Crypto library
|
||||
#
|
||||
# Hint
|
||||
# MBEDTLS_ROOT_DIR can be pointed to a local mbedTLS installation.
|
||||
|
||||
SET(_MBEDTLS_ROOT_HINTS
|
||||
${MBEDTLS_ROOT_DIR}
|
||||
ENV MBEDTLS_ROOT_DIR
|
||||
)
|
||||
|
||||
SET(_MBEDTLS_ROOT_HINTS_AND_PATHS
|
||||
HINTS ${_MBEDTLS_ROOT_HINTS}
|
||||
PATHS ${_MBEDTLS_ROOT_PATHS}
|
||||
)
|
||||
|
||||
FIND_PATH(MBEDTLS_INCLUDE_DIR
|
||||
NAMES mbedtls/version.h
|
||||
${_MBEDTLS_ROOT_HINTS_AND_PATHS}
|
||||
PATH_SUFFIXES include
|
||||
)
|
||||
|
||||
IF(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARIES)
|
||||
# Already in cache, be silent
|
||||
SET(MBEDTLS_FIND_QUIETLY TRUE)
|
||||
ENDIF()
|
||||
|
||||
FIND_LIBRARY(MBEDTLS_LIBRARY
|
||||
NAMES mbedtls libmbedtls
|
||||
${_MBEDTLS_ROOT_HINTS_AND_PATHS}
|
||||
PATH_SUFFIXES library
|
||||
)
|
||||
FIND_LIBRARY(MBEDX509_LIBRARY
|
||||
NAMES mbedx509 libmbedx509
|
||||
${_MBEDTLS_ROOT_HINTS_AND_PATHS}
|
||||
PATH_SUFFIXES library
|
||||
)
|
||||
FIND_LIBRARY(MBEDCRYPTO_LIBRARY
|
||||
NAMES mbedcrypto libmbedcrypto
|
||||
${_MBEDTLS_ROOT_HINTS_AND_PATHS}
|
||||
PATH_SUFFIXES library
|
||||
)
|
||||
|
||||
IF(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARY AND MBEDX509_LIBRARY AND MBEDCRYPTO_LIBRARY)
|
||||
SET(MBEDTLS_FOUND TRUE)
|
||||
ENDIF()
|
||||
|
||||
IF(MBEDTLS_FOUND)
|
||||
# split mbedTLS into -L and -l linker options, so we can set them for pkg-config
|
||||
GET_FILENAME_COMPONENT(MBEDTLS_LIBRARY_DIR ${MBEDTLS_LIBRARY} PATH)
|
||||
GET_FILENAME_COMPONENT(MBEDTLS_LIBRARY_FILE ${MBEDTLS_LIBRARY} NAME_WE)
|
||||
GET_FILENAME_COMPONENT(MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY} NAME_WE)
|
||||
GET_FILENAME_COMPONENT(MBEDCRYPTO_LIBRARY_FILE ${MBEDCRYPTO_LIBRARY} NAME_WE)
|
||||
STRING(REGEX REPLACE "^lib" "" MBEDTLS_LIBRARY_FILE ${MBEDTLS_LIBRARY_FILE})
|
||||
STRING(REGEX REPLACE "^lib" "" MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY_FILE})
|
||||
STRING(REGEX REPLACE "^lib" "" MBEDCRYPTO_LIBRARY_FILE ${MBEDCRYPTO_LIBRARY_FILE})
|
||||
SET(MBEDTLS_LIBRARIES "-L${MBEDTLS_LIBRARY_DIR} -l${MBEDTLS_LIBRARY_FILE} -l${MBEDX509_LIBRARY_FILE} -l${MBEDCRYPTO_LIBRARY_FILE}")
|
||||
|
||||
IF(NOT MBEDTLS_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "Found mbedTLS:")
|
||||
FILE(READ ${MBEDTLS_INCLUDE_DIR}/mbedtls/version.h MBEDTLSCONTENT)
|
||||
STRING(REGEX MATCH "MBEDTLS_VERSION_STRING +\"[0-9|.]+\"" MBEDTLSMATCH ${MBEDTLSCONTENT})
|
||||
IF (MBEDTLSMATCH)
|
||||
STRING(REGEX REPLACE "MBEDTLS_VERSION_STRING +\"([0-9|.]+)\"" "\\1" MBEDTLS_VERSION ${MBEDTLSMATCH})
|
||||
MESSAGE(STATUS " version ${MBEDTLS_VERSION}")
|
||||
ENDIF(MBEDTLSMATCH)
|
||||
MESSAGE(STATUS " TLS: ${MBEDTLS_LIBRARY}")
|
||||
MESSAGE(STATUS " X509: ${MBEDX509_LIBRARY}")
|
||||
MESSAGE(STATUS " Crypto: ${MBEDCRYPTO_LIBRARY}")
|
||||
ENDIF(NOT MBEDTLS_FIND_QUIETLY)
|
||||
ELSE(MBEDTLS_FOUND)
|
||||
IF(MBEDTLS_FIND_REQUIRED)
|
||||
MESSAGE(FATAL_ERROR "Could not find mbedTLS")
|
||||
ENDIF(MBEDTLS_FIND_REQUIRED)
|
||||
ENDIF(MBEDTLS_FOUND)
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
MBEDTLS_INCLUDE_DIR
|
||||
MBEDTLS_LIBRARY_DIR
|
||||
MBEDTLS_LIBRARIES
|
||||
MBEDTLS_LIBRARY
|
||||
MBEDX509_LIBRARY
|
||||
MBEDCRYPTO_LIBRARY
|
||||
)
|
@ -1,228 +1,160 @@
|
||||
v0.27.7
|
||||
v0.28.1
|
||||
-------
|
||||
|
||||
This is a bugfix release with the following changes or improvements:
|
||||
This is a bugfix release with the following change:
|
||||
|
||||
- Our continuous integration environment has switched from Travis and
|
||||
AppVeyor to Azure Pipelines CI.
|
||||
* The deprecated functions (`git_buf_free` and the `giterr_` family of
|
||||
functions) are now exported properly. In the v0.28 release, they were
|
||||
not given the correct external attributes and they did not have the
|
||||
correct linkage visibility in the v0.28 library.
|
||||
|
||||
- Fix adding worktrees for bare repositories.
|
||||
|
||||
- Fix parsed patches not computing the old respectively new line
|
||||
numbers correctly.
|
||||
|
||||
- Fix parsing configuration variables which do not have a section.
|
||||
|
||||
- Fix a zero-byte allocation when trying to detect file renames and
|
||||
copies of a diff without any hunks.
|
||||
|
||||
- Fix a zero-byte allocation when trying to resize or duplicate
|
||||
vectors.
|
||||
|
||||
- Fix return value when trying to unlock worktrees which aren't
|
||||
locked.
|
||||
|
||||
- Fix returning an unitialized error code when preparing a revision
|
||||
walk without any pushed commits.
|
||||
|
||||
- Fix return value of `git_remote_lookup` when lookup of
|
||||
"remote.$remote.tagopt" fails.
|
||||
|
||||
- Fix the revision walk always labelling commits as interesting due
|
||||
to a mishandling of the commit date.
|
||||
|
||||
- Fix the packbuilder inserting uninteresting blobs when adding a
|
||||
tree containing references to such blobs.
|
||||
|
||||
- Ignore unsupported authentication schemes in HTTP transport.
|
||||
|
||||
- Improve performane of `git_remote_prune`.
|
||||
|
||||
- Fix detection of whether `qsort_r` has a BSD or GNU function
|
||||
signature.
|
||||
|
||||
- Fix detection of iconv if it is provided by libc.
|
||||
|
||||
v0.27.6
|
||||
-------
|
||||
|
||||
This as a security release fixing the following list of issues:
|
||||
|
||||
- The function family `git__strtol` is used to parse integers
|
||||
from a buffer. As the functions do not take a buffer length as
|
||||
argument, they will scan either until the end of the current
|
||||
number or until a NUL byte is encountered. Many callers have
|
||||
been misusing the function and called it on potentially
|
||||
non-NUL-terminated buffers, resulting in possible out-of-bounds
|
||||
reads. Callers have been fixed to use `git__strntol` functions
|
||||
instead and `git__strtol` functions were removed.
|
||||
|
||||
- The function `git__strntol64` relied on the undefined behavior
|
||||
of signed integer overflows. While the code tried to detect
|
||||
such overflows after they have happened, this is unspecified
|
||||
behavior and may lead to weird behavior on uncommon platforms.
|
||||
|
||||
- In the case where `git__strntol32` was unable to parse an
|
||||
integer because it doesn't fit into an `int32_t`, it printed an
|
||||
error message containing the string that is currently being
|
||||
parsed. The code didn't truncate the string though, which
|
||||
caused it to print the complete string until a NUL byte is
|
||||
encountered and not only the currently parsed number. In case
|
||||
where the string was not NUL terminated, this could have lead
|
||||
to an out-of-bounds read.
|
||||
|
||||
- When parsing tags, all unknown fields that appear before the
|
||||
tag message are skipped. This skipping is done by using a plain
|
||||
`strstr(buffer, "\n\n")` to search for the two newlines that
|
||||
separate tag fields from tag message. As it is not possible to
|
||||
supply a buffer length to `strstr`, this call may skip over the
|
||||
buffer's end and thus result in an out of bounds read. As
|
||||
`strstr` may return a pointer that is out of bounds, the
|
||||
following computation of `buffer_end - buffer` will overflow
|
||||
and result in an allocation of an invalid length. Note that
|
||||
when reading objects from the object database, we make sure to
|
||||
always NUL terminate them, making the use of `strstr` safe.
|
||||
|
||||
- When parsing the "encoding" field of a commit, we may perform
|
||||
an out of bounds read due to using `git__prefixcmp` instead of
|
||||
`git__prefixncmp`. This can result in the parsed commit object
|
||||
containing uninitialized data in both its message encoding and
|
||||
message fields. Note that when reading objects from the object
|
||||
database, we make sure to always NUL terminate them, making the
|
||||
use of `strstr` safe.
|
||||
|
||||
v0.27.5
|
||||
-------
|
||||
|
||||
This is a security release fixing the following list of issues:
|
||||
|
||||
- Submodule URLs and paths with a leading "-" are now ignored.
|
||||
This is due to the recently discovered CVE-2018-17456, which
|
||||
can lead to arbitrary code execution in upstream git. While
|
||||
libgit2 itself is not vulnerable, it can be used to inject
|
||||
options in an implementation which performs a recursive clone
|
||||
by executing an external command.
|
||||
|
||||
- When running repack while doing repo writes,
|
||||
`packfile_load__cb()` could see some temporary files in the
|
||||
directory that were bigger than the usual, and makes `memcmp`
|
||||
overflow on the `p->pack_name` string. This issue was reported
|
||||
and fixed by bisho.
|
||||
|
||||
- The configuration file parser used unbounded recursion to parse
|
||||
multiline variables, which could lead to a stack overflow. The
|
||||
issue was reported by the oss-fuzz project, issue 10048 and
|
||||
fixed by Nelson Elhage.
|
||||
|
||||
- The fix to the unbounded recursion introduced a memory leak in
|
||||
the config parser. While this leak was never in a public
|
||||
release, the oss-fuzz project reported this as issue 10127. The
|
||||
fix was implemented by Nelson Elhage and Patrick Steinhardt.
|
||||
|
||||
- When parsing "ok" packets received via the smart protocol, our
|
||||
parsing code did not correctly verify the bounds of the
|
||||
packets, which could result in a heap-buffer overflow. The
|
||||
issue was reported by the oss-fuzz project, issue 9749 and
|
||||
fixed by Patrick Steinhardt.
|
||||
|
||||
- The parsing code for the smart protocol has been tightened in
|
||||
general, fixing heap-buffer overflows when parsing the packet
|
||||
type as well as for "ACK" and "unpack" packets. The issue was
|
||||
discovered and fixed by Patrick Steinhardt.
|
||||
|
||||
- Fixed potential integer overflows on platforms with 16 bit
|
||||
integers when parsing packets for the smart protocol. The issue
|
||||
was discovered and fixed by Patrick Steinhardt.
|
||||
|
||||
- Fixed potential NULL pointer dereference when parsing
|
||||
configuration files which have "include.path" or
|
||||
"includeIf..path" statements without a value.
|
||||
|
||||
v0.27.4
|
||||
-------
|
||||
|
||||
This is a security release fixing out-of-bounds reads when
|
||||
processing smart-protocol "ng" packets.
|
||||
|
||||
When parsing an "ng" packet, we keep track of both the current position
|
||||
as well as the remaining length of the packet itself. But instead of
|
||||
taking care not to exceed the length, we pass the current pointer's
|
||||
position to `strchr`, which will search for a certain character until
|
||||
hitting NUL. It is thus possible to create a crafted packet which
|
||||
doesn't contain a NUL byte to trigger an out-of-bounds read.
|
||||
|
||||
The issue was discovered by the oss-fuzz project, issue 9406.
|
||||
|
||||
v0.27.3
|
||||
-------
|
||||
|
||||
This is a security release fixing out-of-bounds reads when
|
||||
reading objects from a packfile. This corresponds to
|
||||
CVE-2018-10887 and CVE-2018-10888, which were both reported by
|
||||
Riccardo Schirone.
|
||||
|
||||
When packing objects into a single so-called packfile, objects
|
||||
may not get stored as complete copies but instead as deltas
|
||||
against another object "base". A specially crafted delta object
|
||||
could trigger an integer overflow and thus bypass our input
|
||||
validation, which may result in copying memory before or after
|
||||
the base object into the final deflated object. This may lead to
|
||||
objects containing copies of system memory being written into the
|
||||
object database. As the hash of those objects cannot be easily
|
||||
controlled by the attacker, it is unlikely that any of those
|
||||
objects will be valid and referenced by the commit graph.
|
||||
|
||||
Note that the error could also be triggered by the function
|
||||
`git_apply__patch`. But as this function is not in use outside of
|
||||
our test suite, it is not a possible attack vector.
|
||||
|
||||
v0.27.2
|
||||
---------
|
||||
v0.28
|
||||
-----
|
||||
|
||||
### Changes or improvements
|
||||
|
||||
* Fix builds with LibreSSL 2.7.
|
||||
* The library is now always built with cdecl calling conventions on
|
||||
Windows; the ability to build a stdcall library has been removed.
|
||||
|
||||
* Fix for `git_diff_status_char()` not returning the correct mapping for
|
||||
`GIT_DELTA_TYPECHANGE`.
|
||||
* Reference log creation now honors `core.logallrefupdates=always`.
|
||||
|
||||
* Fix for the submodules API not reporting errors when parsing the ".gitmodules"
|
||||
file.
|
||||
* Fix some issues with the error-reporting in the OpenSSL backend.
|
||||
|
||||
* Fix for accepting a ".gitmodules" file where two submodules have the same
|
||||
path.
|
||||
* HTTP proxy support is now builtin; libcurl is no longer used to support
|
||||
proxies and is removed as a dependency.
|
||||
|
||||
* Fix for hiding references in a graph walk not always limiting the graph
|
||||
correctly.
|
||||
* Certificate and credential callbacks can now return `GIT_PASSTHROUGH`
|
||||
to decline to act; libgit2 will behave as if there was no callback set
|
||||
in the first place.
|
||||
|
||||
* Fix for directory patterns with trailing spaces in attribute files not being
|
||||
handled correctly.
|
||||
* The line-ending filtering logic - when checking out files - has been
|
||||
updated to match newer git (>= git 2.9) for proper interoperability.
|
||||
|
||||
* Fix SSH transports not properly disconnecting from the server.
|
||||
* Symbolic links are now supported on Windows when `core.symlinks` is set
|
||||
to `true`.
|
||||
|
||||
* Fix reading HEAD reflog in worktrees.
|
||||
* Submodules with names which attempt to perform path traversal now have their
|
||||
configuration ignored. Such names were blindly appended to the
|
||||
`$GIT_DIR/modules` and a malicious name could lead to an attacker writing to
|
||||
an arbitrary location. This matches git's handling of CVE-2018-11235.
|
||||
|
||||
* Update our copy of SHA1DC to fix errors with endianess on some platforms.
|
||||
* Object validation is now performed during tree creation in the
|
||||
`git_index_write_tree_to` API.
|
||||
|
||||
v0.27.1
|
||||
---------
|
||||
* Configuration variable may now be specified on the same line as a section
|
||||
header; previously this was erroneously a parser error.
|
||||
|
||||
This is a security release fixing insufficient validation of submodule names
|
||||
(CVE-2018-11235, reported by Etienne Stalmans) and disallows `.gitmodules` files
|
||||
as symlinks.
|
||||
* When an HTTP server supports both NTLM and Negotiate authentication
|
||||
mechanisms, we would previously fail to authenticate with any mechanism.
|
||||
|
||||
While submodule names come from the untrusted ".gitmodules" file, we blindly
|
||||
append the name to "$GIT_DIR/modules" to construct the final path of the
|
||||
submodule repository. In case the name contains e.g. "../", an adversary would
|
||||
be able to escape your repository and write data at arbitrary paths. In
|
||||
accordance with git, we now enforce some rules for submodule names which will
|
||||
cause libgit2 to ignore these malicious names.
|
||||
* The `GIT_OPT_SET_PACK_MAX_OBJECTS` option can now set the maximum
|
||||
number of objects allowed in a packfile being downloaded; this can help
|
||||
limit the maximum memory used when fetching from an untrusted remote.
|
||||
|
||||
Adding a symlink as `.gitmodules` into the index from the workdir or checking
|
||||
out such files is not allowed as this can make a Git implementation write
|
||||
outside of the repository and bypass the `fsck` checks for CVE-2018-11235.
|
||||
* Line numbers in diffs loaded from patch files were not being populated;
|
||||
they are now included in the results.
|
||||
|
||||
libgit2 is not susceptible to CVE-2018-11233.
|
||||
* The repository's index is reloaded from disk at the beginning of
|
||||
`git_merge` operations to ensure that it is up-to-date.
|
||||
|
||||
* Mailmap handling APIs have been introduced, and the new commit APIs
|
||||
`git_commit_committer_with_mailmap` and `git_commit_author_with_mailmap`
|
||||
will use the mailmap to resolve the committer and author information.
|
||||
In addition, blame will use the mailmap given when the
|
||||
`GIT_BLAME_USE_MAILMAP` option.
|
||||
|
||||
* Ignore handling for files in ignored folders would be ignored.
|
||||
|
||||
* Worktrees can now be backed by bare repositories.
|
||||
|
||||
* Trailing spaces are supported in `.gitignore` files, these spaces were
|
||||
previously (and erroneously) treated as part of the pattern.
|
||||
|
||||
* The library can now be built with mbedTLS support for HTTPS.
|
||||
|
||||
* The diff status character 'T' will now be presented by the
|
||||
`git_diff_status_char` API for diff entries that change type.
|
||||
|
||||
* Revision walks previously would sometimes include commits that should
|
||||
have been ignored; this is corrected.
|
||||
|
||||
* Revision walks are now more efficient when the output is unsorted;
|
||||
we now avoid walking all the way to the beginning of history unnecessarily.
|
||||
|
||||
* Error-handling around index extension loading has been fixed. We were
|
||||
previously always misreporting a truncated index (#4858).
|
||||
|
||||
### API additions
|
||||
|
||||
* The index may now be iterated atomically using `git_index_iterator`.
|
||||
|
||||
* Remote objects can now be created with extended options using the
|
||||
`git_remote_create_with_opts` API.
|
||||
|
||||
* Diff objects can now be applied as changes to the working directory,
|
||||
index or both, emulating the `git apply` command. Additionally,
|
||||
`git_apply_to_tree` can apply those changes to a tree object as a
|
||||
fully in-memory operation.
|
||||
|
||||
* You can now swap out memory allocators via the
|
||||
`GIT_OPT_SET_ALLOCATOR` option with `git_libgit2_opts()`.
|
||||
|
||||
* You can now ensure that functions do not discard unwritten changes to the
|
||||
index via the `GIT_OPT_ENABLE_UNSAVED_INDEX_SAFETY` option to
|
||||
`git_libgit2_opts()`. This will cause functions that implicitly re-read
|
||||
the index (eg, `git_checkout`) to fail if you have staged changes to the
|
||||
index but you have not written the index to disk. (Unless the checkout
|
||||
has the FORCE flag specified.)
|
||||
|
||||
At present, this defaults to off, but we intend to enable this more
|
||||
broadly in the future, as a warning or error. We encourage you to
|
||||
examine your code to ensure that you are not relying on the current
|
||||
behavior that implicitly removes staged changes.
|
||||
|
||||
* Reference specifications can be parsed from an arbitrary string with
|
||||
the `git_refspec_parse` API.
|
||||
|
||||
* You can now get the name and path of worktrees using the
|
||||
`git_worktree_name` and `git_worktree_path` APIs, respectively.
|
||||
|
||||
* The `ref` field has been added to `git_worktree_add_options` to enable
|
||||
the creation of a worktree from a pre-existing branch.
|
||||
|
||||
* It's now possible to analyze merge relationships between any two
|
||||
references, not just against `HEAD`, using `git_merge_analysis_for_ref`.
|
||||
|
||||
### API removals
|
||||
|
||||
* The `git_buf_free` API is deprecated; it has been renamed to
|
||||
`git_buf_dispose` for consistency. The `git_buf_free` API will be
|
||||
retained for backward compatibility for the foreseeable future.
|
||||
|
||||
* The `git_otype` enumeration and its members are deprecated and have
|
||||
been renamed for consistency. The `GIT_OBJ_` enumeration values are
|
||||
now prefixed with `GIT_OBJECT_`. The old enumerations and macros
|
||||
will be retained for backward compatibility for the foreseeable future.
|
||||
|
||||
* Several index-related APIs have been renamed for consistency. The
|
||||
`GIT_IDXENTRY_` enumeration values and macros have been renamed to
|
||||
be prefixed with `GIT_INDEX_ENTRY_`. The `GIT_INDEXCAP` enumeration
|
||||
values are now prefixed with `GIT_INDEX_CAPABILITY_`. The old
|
||||
enumerations and macros will be retained for backward compatibility
|
||||
for the foreseeable future.
|
||||
|
||||
* The error functions and enumeration values have been renamed for
|
||||
consistency. The `giterr_` functions and values prefix have been
|
||||
renamed to be prefixed with `git_error_`; similarly, the `GITERR_`
|
||||
constants have been renamed to be prefixed with `GIT_ERROR_`.
|
||||
The old enumerations and macros will be retained for backward
|
||||
compatibility for the foreseeable future.
|
||||
|
||||
### Breaking API changes
|
||||
|
||||
* The default checkout strategy changed from `DRY_RUN` to `SAFE` (#4531).
|
||||
|
||||
* Adding a symlink as .gitmodules into the index from the workdir or checking
|
||||
out such files is not allowed as this can make a Git implementation write
|
||||
outside of the repository and bypass the fsck checks for CVE-2018-11235.
|
||||
|
||||
v0.27
|
||||
---------
|
@ -6,13 +6,22 @@ your help.
|
||||
## Licensing
|
||||
|
||||
By contributing to libgit2, you agree to release your contribution under
|
||||
the terms of the license. Except for the `examples` directory, all code
|
||||
is released under the [GPL v2 with linking exception](COPYING).
|
||||
the terms of the license. Except for the `examples` and the
|
||||
`deps` directories, all code is released under the [GPL v2 with
|
||||
linking exception](../COPYING).
|
||||
|
||||
The `examples` code is governed by the
|
||||
[CC0 Public Domain Dedication](examples/COPYING), so that you may copy
|
||||
[CC0 Public Domain Dedication](../examples/COPYING), so that you may copy
|
||||
from them into your own application.
|
||||
|
||||
The bundled dependencies in the `deps` directories are governed
|
||||
by the following licenses:
|
||||
|
||||
- http-parser is licensed under [MIT license](../deps/http-parser/COPYING)
|
||||
- regex is governed by [LGPL v2.1+ license](../deps/regex/COPYING)
|
||||
- winhttp is governed by [LGPL v2.1+](../deps/winhttp/COPYING.LGPL) and [GPL v2 with linking exception](../deps/winhttp/COPYING.GPL)
|
||||
- zlib is governed by [zlib license](../deps/zlib/COPYING)
|
||||
|
||||
## Discussion & Chat
|
||||
|
||||
We hang out in the
|
||||
@ -97,7 +106,7 @@ Before wrapping up a PR, you should be sure to:
|
||||
|
||||
* Write tests to cover any functional changes
|
||||
* Update documentation for any changed public APIs
|
||||
* Add to the [`CHANGELOG.md`](CHANGELOG.md) file describing any major changes
|
||||
* Add to the [`changelog.md`](changelog.md) file describing any major changes
|
||||
|
||||
## Unit Tests
|
||||
|
||||
@ -168,10 +177,8 @@ function and type naming, code formatting, and testing.
|
||||
|
||||
We like to keep the source code consistent and easy to read. Maintaining
|
||||
this takes some discipline, but it's been more than worth it. Take a look
|
||||
at the [conventions
|
||||
file](https://github.com/libgit2/libgit2/blob/development/CONVENTIONS.md).
|
||||
at the [conventions file](conventions.md).
|
||||
|
||||
## Starter Projects
|
||||
|
||||
See our [projects
|
||||
list](https://github.com/libgit2/libgit2/blob/development/PROJECTS.md).
|
||||
See our [projects list](projects.md).
|
@ -136,11 +136,11 @@ Check
|
||||
[`include/git2/errors.h`](https://github.com/libgit2/libgit2/blob/development/include/git2/errors.h)
|
||||
for the return codes already defined.
|
||||
|
||||
In your implementation, use `giterr_set()` to provide extended error
|
||||
In your implementation, use `git_error_set()` to provide extended error
|
||||
information to callers.
|
||||
|
||||
If a `libgit2` function internally invokes another function that reports an
|
||||
error, but the error is not propagated up, use `giterr_clear()` to prevent
|
||||
error, but the error is not propagated up, use `git_error_clear()` to prevent
|
||||
callers from getting the wrong error message later on.
|
||||
|
||||
|
||||
@ -156,8 +156,8 @@ typedef struct git_odb git_odb;
|
||||
the library, and not within the application. This allows the type
|
||||
to grow (or shrink) in size without rebuilding client code.
|
||||
|
||||
To preserve ABI compatibility, include an `int version` field in all opaque
|
||||
structures, and initialize to the latest version in the construction call.
|
||||
To preserve ABI compatibility, include an `int version` field in all transparent
|
||||
structures, and initialize to the latest version in the constructor call.
|
||||
Increment the "latest" version whenever the structure changes, and try to only
|
||||
append to the end of the structure.
|
||||
|
||||
@ -199,7 +199,7 @@ GIT_EXTERN(int) git_foo_id(
|
||||
int b);
|
||||
```
|
||||
|
||||
Indent with tabs; set your editor's tab width to 4 for best effect.
|
||||
Indent with tabs; set your editor's tab width to eight for best effect.
|
||||
|
||||
Avoid trailing whitespace and only commit Unix-style newlines (i.e. no CRLF
|
||||
in the repository - just set `core.autocrlf` to true if you are writing code
|
27
docs/differences-from-git.md
Normal file
27
docs/differences-from-git.md
Normal file
@ -0,0 +1,27 @@
|
||||
# Differences from Git
|
||||
|
||||
In some instances, the functionality of libgit2 deviates slightly from Git. This can be because of technical limitations when developing a library, licensing limitations when converting functionality from Git to libgit2, or various other reasons.
|
||||
|
||||
Repository and Workdir Path Reporting
|
||||
-------------------------------------
|
||||
|
||||
When asking Git for the absolute path of a repository via `git rev-parse --absolute-git-dir`, it will output the path to the ".git" folder without a trailing slash. In contrast to that, the call `git_repository_path(repo)` will return the path with a trailing slash:
|
||||
|
||||
```
|
||||
git rev-parse --absolute-git-dir -> /home/user/projects/libgit2/.git
|
||||
git_repository_path(repo) -> /home/user/projects/libgit2/.git/
|
||||
```
|
||||
|
||||
The same difference exists when listing worktrees:
|
||||
|
||||
```
|
||||
git worktree list -> /home/user/projects/libgit2
|
||||
git_repository_workdir(repo) -> /home/user/projects/libgit2/
|
||||
```
|
||||
|
||||
Windows Junction Points
|
||||
-----------------------
|
||||
|
||||
In libgit2, junction points are treated like symbolic links. They're handled specially in `git_win32__file_attribute_to_stat` in `src/win/w32_util.h`. This means that libgit2 tracks the directory itself as a link.
|
||||
|
||||
In Git for Windows, junction points are treated like regular directories. This means that Git for Windows tracks the contents of the directory.
|
@ -9,7 +9,7 @@ and a generic error code (-1) for all critical or non-specific failures
|
||||
(e.g. running out of memory or system corruption).
|
||||
|
||||
When a negative value is returned, an error message is also set. The
|
||||
message can be accessed via the `giterr_last` function which will return a
|
||||
message can be accessed via the `git_error_last` function which will return a
|
||||
pointer to a `git_error` structure containing the error message text and
|
||||
the class of error (i.e. what part of the library generated the error).
|
||||
|
||||
@ -51,7 +51,7 @@ look at the error message that was generated.
|
||||
int error = git_repository_open(&repo, "path/to/repo");
|
||||
|
||||
if (error < 0) {
|
||||
fprintf(stderr, "Could not open repository: %s\n", giterr_last()->message);
|
||||
fprintf(stderr, "Could not open repository: %s\n", git_error_last()->message);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -75,7 +75,7 @@ at the specific error values to decide what to do.
|
||||
fprintf(stderr, "Could not find repository at path '%s'\n", path);
|
||||
else
|
||||
fprintf(stderr, "Unable to open repository: %s\n",
|
||||
giterr_last()->message);
|
||||
git_error_last()->message);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ at the specific error values to decide what to do.
|
||||
Some of the higher-level language bindings may use a range of information
|
||||
from libgit2 to convert error return codes into exceptions, including the
|
||||
specific error return codes and even the class of error and the error
|
||||
message returned by `giterr_last`, but the full range of that logic is
|
||||
message returned by `git_error_last`, but the full range of that logic is
|
||||
beyond the scope of this document.
|
||||
|
||||
Example internal implementation
|
||||
@ -102,7 +102,7 @@ int git_repository_open(git_repository **repository, const char *path)
|
||||
{
|
||||
/* perform some logic to open the repository */
|
||||
if (p_exists(path) < 0) {
|
||||
giterr_set(GITERR_REPOSITORY, "The path '%s' doesn't exist", path);
|
||||
git_error_set(GIT_ERROR_REPOSITORY, "The path '%s' doesn't exist", path);
|
||||
return GIT_ENOTFOUND;
|
||||
}
|
||||
|
||||
@ -110,13 +110,27 @@ int git_repository_open(git_repository **repository, const char *path)
|
||||
}
|
||||
~~~
|
||||
|
||||
Note that some error codes have been defined with a specific meaning in the
|
||||
context of callbacks:
|
||||
- `GIT_EUSER` provides a way to bubble up a non libgit2-related failure, which
|
||||
allows it to be preserved all the way up to the initial function call (a `git_cred`
|
||||
setup trying to access an unavailable LDAP server for instance).
|
||||
- `GIT_EPASSTHROUGH` provides a way to tell libgit2 that it should behave as if
|
||||
no callback was provided. This is of special interest to bindings, which would
|
||||
always provide a C function as a "trampoline", and decide at runtime what to do.
|
||||
|
||||
The public error API
|
||||
--------------------
|
||||
|
||||
- `const git_error *giterr_last(void)`: The main function used to look up
|
||||
- `const git_error *git_error_last(void)`: The main function used to look up
|
||||
the last error. This may return NULL if no error has occurred.
|
||||
Otherwise this should return a `git_error` object indicating the class
|
||||
of error and the error message that was generated by the library.
|
||||
Do not use this function unless the prior call to a libgit2 API
|
||||
returned an error, as it can otherwise give misleading results.
|
||||
libgit2's error strings are not cleared aggressively,
|
||||
and this function may return an error string that reflects a prior error,
|
||||
possibly even reflecting internal state.
|
||||
|
||||
The last error is stored in thread-local storage when libgit2 is
|
||||
compiled with thread support, so you do not have to worry about another
|
||||
@ -128,7 +142,7 @@ The public error API
|
||||
bugs, but in the meantime, please code defensively and check for NULL
|
||||
when calling this function.
|
||||
|
||||
- `void giterr_clear(void)`: This function clears the last error. The
|
||||
- `void git_error_clear(void)`: This function clears the last error. The
|
||||
library will call this when an error is generated by low level function
|
||||
and the higher level function handles the error.
|
||||
|
||||
@ -136,14 +150,14 @@ The public error API
|
||||
function's error message is not cleared by higher level code that
|
||||
handles the error and returns zero. Please report these as bugs, but in
|
||||
the meantime, a zero return value from a libgit2 API does not guarantee
|
||||
that `giterr_last()` will return NULL.
|
||||
that `git_error_last()` will return NULL.
|
||||
|
||||
- `void giterr_set_str(int error_class, const char *message)`: This
|
||||
- `void git_error_set(int error_class, const char *message)`: This
|
||||
function can be used when writing a custom backend module to set the
|
||||
libgit2 error message. See the documentation on this function for its
|
||||
use. Normal usage of libgit2 will probably never need to call this API.
|
||||
|
||||
- `void giterr_set_oom(void)`: This is a standard function for reporting
|
||||
- `void git_error_set_oom(void)`: This is a standard function for reporting
|
||||
an out-of-memory error. It is written in a manner that it doesn't have
|
||||
to allocate any extra memory in order to record the error, so this is
|
||||
the best way to report that scenario.
|
||||
@ -177,18 +191,18 @@ There are some known bugs in the library where some functions may return a
|
||||
negative value but not set an error message and some other functions may
|
||||
return zero (no error) and yet leave an error message set. Please report
|
||||
these cases as issues and they will be fixed. In the meanwhile, please
|
||||
code defensively, checking that the return value of `giterr_last` is not
|
||||
NULL before using it, and not relying on `giterr_last` to return NULL when
|
||||
code defensively, checking that the return value of `git_error_last` is not
|
||||
NULL before using it, and not relying on `git_error_last` to return NULL when
|
||||
a function returns 0 for success.
|
||||
|
||||
The internal error API
|
||||
----------------------
|
||||
|
||||
- `void giterr_set(int error_class, const char *fmt, ...)`: This is the
|
||||
- `void git_error_set(int error_class, const char *fmt, ...)`: This is the
|
||||
main internal function for setting an error. It works like `printf` to
|
||||
format the error message. See the notes of `giterr_set_str` for a
|
||||
format the error message. See the notes of `git_error_set_str` for a
|
||||
general description of how error messages are stored (and also about
|
||||
special handling for `error_class` of `GITERR_OS`).
|
||||
special handling for `error_class` of `GIT_ERROR_OS`).
|
||||
|
||||
Writing error messages
|
||||
----------------------
|
||||
@ -243,7 +257,7 @@ General guidelines for error reporting
|
||||
...
|
||||
|
||||
if (git_commit_lookup(parent, repo, parent_id) < 0) {
|
||||
giterr_set(GITERR_COMMIT, "Overwrite lookup error message");
|
||||
git_error_set(GIT_ERROR_COMMIT, "Overwrite lookup error message");
|
||||
return -1; /* mask error code */
|
||||
}
|
||||
|
||||
|
71
docs/fuzzing.md
Normal file
71
docs/fuzzing.md
Normal file
@ -0,0 +1,71 @@
|
||||
# Fuzzing
|
||||
|
||||
libgit2 is currently using [libFuzzer](https://libfuzzer.info) to perform
|
||||
automated fuzz testing. libFuzzer only works with clang.
|
||||
|
||||
## Prerequisites** for building fuzz targets:
|
||||
|
||||
1. All the prerequisites for [building libgit2](https://github.com/libgit2/libgit2).
|
||||
2. A recent version of clang. 6.0 is preferred. [pre-build Debian/Ubuntu
|
||||
packages](https://github.com/libgit2/libgit2)
|
||||
|
||||
## Build
|
||||
|
||||
1. Create a build directory beneath the libgit2 source directory, and change
|
||||
into it: `mkdir build && cd build`
|
||||
2. Choose one sanitizers to add. The currently supported sanitizers are
|
||||
[`address`](https://clang.llvm.org/docs/AddressSanitizer.html),
|
||||
[`undefined`](https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html),
|
||||
and [`leak`/`address,leak`](https://clang.llvm.org/docs/LeakSanitizer.html).
|
||||
3. Create the cmake build environment and configure the build with the
|
||||
sanitizer chosen: `CC=/usr/bin/clang-6.0 CFLAGS="-fsanitize=address" cmake
|
||||
-DBUILD_CLAR=OFF -DBUILD_FUZZERS=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo ..`.
|
||||
Note that building the fuzzer targets is incompatible with the
|
||||
tests and examples.
|
||||
4. Build libgit2: `cmake --build .`
|
||||
5. Exit the cmake build environment: `cd ..`
|
||||
|
||||
## Run the fuzz targets
|
||||
|
||||
1. `ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolize-6.0
|
||||
LSAN_OPTIONS=allocator_may_return_null=1
|
||||
ASAN_OPTIONS=allocator_may_return_null=1 ./build/fuzz/fuzz_packfile_raw
|
||||
fuzz/corpora/fuzz_packfile_raw/`
|
||||
|
||||
The `LSAN_OPTIONS` and `ASAN_OPTIONS` are there to allow `malloc(3)` to return
|
||||
`NULL`. The `LLVM_PROFILE_FILE` is there to override the path where libFuzzer
|
||||
will write the coverage report.
|
||||
|
||||
## Get coverage
|
||||
|
||||
In order to get coverage information, you need to add the "-fcoverage-mapping"
|
||||
and "-fprofile-instr-generate CFLAGS, and then run the fuzz target with
|
||||
`-runs=0`. That will produce a file called `default.profraw` (this behavior can
|
||||
be overridden by setting the `LLVM_PROFILE_FILE="yourfile.profraw"` environment
|
||||
variable).
|
||||
|
||||
1. `llvm-profdata-6.0 merge -sparse default.profraw -o
|
||||
fuzz_packfile_raw.profdata` transforms the data from a sparse representation
|
||||
into a format that can be used by the other tools.
|
||||
2. `llvm-cov-6.0 report ./build/fuzz/fuzz_packfile_raw
|
||||
-instr-profile=fuzz_packfile_raw.profdata` shows a high-level per-file
|
||||
coverage report.
|
||||
3. `llvm-cov-6.0 show ./build/fuzz/fuzz_packfile_raw
|
||||
-instr-profile=fuzz_packfile_raw.profdata [source file]` shows a line-by-line
|
||||
coverage analysis of all the codebase (or a single source file).
|
||||
|
||||
## Standalone mode
|
||||
|
||||
In order to ensure that there are no regresions, each fuzzer target can be run
|
||||
in a standalone mode. This can be done by passing `-DUSE_STANDALONE_FUZZERS=ON`.
|
||||
This makes it compatible with gcc. This does not use the fuzzing engine, but
|
||||
just invokes every file in the chosen corpus.
|
||||
|
||||
In order to get full coverage, though, you might want to also enable one of the
|
||||
sanitizers. You might need a recent version of clang to get full support.
|
||||
|
||||
## References
|
||||
|
||||
* [libFuzzer](https://llvm.org/docs/LibFuzzer.html) documentation.
|
||||
* [Source-based Code
|
||||
Coverage](https://clang.llvm.org/docs/SourceBasedCodeCoverage.html).
|
@ -10,8 +10,8 @@ ideas that no one is actively working on.
|
||||
|
||||
## Before You Start
|
||||
|
||||
Please start by reading the [README.md](README.md),
|
||||
[CONTRIBUTING.md](CONTRIBUTING.md), and [CONVENTIONS.md](CONVENTIONS.md)
|
||||
Please start by reading the [README.md](../README.md),
|
||||
[contributing.md](contributing.md), and [conventions.md](conventions.md)
|
||||
files before diving into one of these projects. Those explain our work
|
||||
flow and coding conventions to help ensure that your work will be easily
|
||||
integrated into libgit2.
|
@ -10,12 +10,13 @@ We aim to release once every six months. We start the process by opening an issu
|
||||
|
||||
Let's release v0.X, codenamed: <something witty>
|
||||
|
||||
- [ ] Bump the versions in the headers
|
||||
- [ ] Bump the versions in the headers (`include/git2/version.h`)
|
||||
- [ ] Bump the versions in the clib manifest (`package.json`)
|
||||
- [ ] Make a release candidate
|
||||
- [ ] Plug any final leaks
|
||||
- [ ] Fix any last-minute issues
|
||||
- [ ] Make sure CHANGELOG reflects everything worth discussing
|
||||
- [ ] Update the version in CHANGELOG and the header
|
||||
- [ ] Make sure changelog.md reflects everything worth discussing
|
||||
- [ ] Update the version in changelog.md and the header
|
||||
- [ ] Produce a release candidate
|
||||
- [ ] Tag
|
||||
- [ ] Create maint/v0.X
|
||||
@ -25,12 +26,13 @@ We tag at least one release candidate. This RC must carry the new version in the
|
||||
|
||||
Preparing the first release candidate includes updating the version number of libgit2 to the new version number. To do so, a pull request shall be submitted that adjusts the version number in the following places:
|
||||
|
||||
- CHANGELOG.md
|
||||
- docs/changelog.md
|
||||
- include/git2/version.h
|
||||
- package.json
|
||||
|
||||
As soon as the pull request is merged, the merge commit shall be tagged with a lightweight tag.
|
||||
|
||||
The tagging happens via GitHub's "releases" tab which lets us attach release notes to a particular tag. In the description we include the changes in `CHANGELOG.md` between the last full release. Use the following as a base for the release notes
|
||||
The tagging happens via GitHub's "releases" tab which lets us attach release notes to a particular tag. In the description we include the changes in `docs/changelog.md` between the last full release. Use the following as a base for the release notes
|
||||
|
||||
This is the first release of the v0.X series, <codename>. The changelog follows.
|
||||
|
||||
|
@ -22,7 +22,7 @@ snapshots.
|
||||
Error messages
|
||||
--------------
|
||||
|
||||
The error message is thread-local. The `giterr_last()` call must
|
||||
The error message is thread-local. The `git_error_last()` call must
|
||||
happen on the same thread as the error in order to get the
|
||||
message. Often this will be the case regardless, but if you use
|
||||
something like the [GCD](http://en.wikipedia.org/wiki/Grand_Central_Dispatch)
|
@ -1,7 +1,13 @@
|
||||
INCLUDE_DIRECTORIES(${LIBGIT2_INCLUDES})
|
||||
INCLUDE_DIRECTORIES(SYSTEM ${LIBGIT2_SYSTEM_INCLUDES})
|
||||
|
||||
FILE(GLOB_RECURSE SRC_EXAMPLE_GIT2 network/*.c network/*.h common.?)
|
||||
ADD_EXECUTABLE(cgit2 ${SRC_EXAMPLE_GIT2})
|
||||
SET_TARGET_PROPERTIES(cgit2 PROPERTIES C_STANDARD 90)
|
||||
|
||||
# Ensure that we do not use deprecated functions internally
|
||||
ADD_DEFINITIONS(-DGIT_DEPRECATE_HARD)
|
||||
|
||||
IF(WIN32 OR ANDROID)
|
||||
TARGET_LINK_LIBRARIES(cgit2 git2)
|
||||
ELSE()
|
||||
@ -14,5 +20,6 @@ FOREACH(src_app ${SRC_EXAMPLE_APPS})
|
||||
IF(NOT ${app_name} STREQUAL "common")
|
||||
ADD_EXECUTABLE(${app_name} ${src_app} "common.c")
|
||||
TARGET_LINK_LIBRARIES(${app_name} git2)
|
||||
SET_TARGET_PROPERTIES(${app_name} PROPERTIES C_STANDARD 90)
|
||||
ENDIF()
|
||||
ENDFOREACH()
|
||||
|
@ -168,16 +168,16 @@ int main(int argc, char *argv[])
|
||||
case SHOW_PRETTY:
|
||||
|
||||
switch (git_object_type(obj)) {
|
||||
case GIT_OBJ_BLOB:
|
||||
case GIT_OBJECT_BLOB:
|
||||
show_blob((const git_blob *)obj);
|
||||
break;
|
||||
case GIT_OBJ_COMMIT:
|
||||
case GIT_OBJECT_COMMIT:
|
||||
show_commit((const git_commit *)obj);
|
||||
break;
|
||||
case GIT_OBJ_TREE:
|
||||
case GIT_OBJECT_TREE:
|
||||
show_tree((const git_tree *)obj);
|
||||
break;
|
||||
case GIT_OBJ_TAG:
|
||||
case GIT_OBJECT_TAG:
|
||||
show_tag((const git_tag *)obj);
|
||||
break;
|
||||
default:
|
||||
|
235
examples/checkout.c
Normal file
235
examples/checkout.c
Normal file
@ -0,0 +1,235 @@
|
||||
/*
|
||||
* libgit2 "checkout" example - shows how to perform checkouts
|
||||
*
|
||||
* Written by the libgit2 contributors
|
||||
*
|
||||
* To the extent possible under law, the author(s) have dedicated all copyright
|
||||
* and related and neighboring rights to this software to the public domain
|
||||
* worldwide. This software is distributed without any warranty.
|
||||
*
|
||||
* You should have received a copy of the CC0 Public Domain Dedication along
|
||||
* with this software. If not, see
|
||||
* <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include <assert.h>
|
||||
|
||||
/* Define the printf format specifer to use for size_t output */
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
# define PRIuZ "Iu"
|
||||
# define PRIxZ "Ix"
|
||||
# define PRIdZ "Id"
|
||||
#else
|
||||
# define PRIuZ "zu"
|
||||
# define PRIxZ "zx"
|
||||
# define PRIdZ "zd"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The following example demonstrates how to do checkouts with libgit2.
|
||||
*
|
||||
* Recognized options are :
|
||||
* --force: force the checkout to happen.
|
||||
* --[no-]progress: show checkout progress, on by default.
|
||||
* --perf: show performance data.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
int force : 1;
|
||||
int progress : 1;
|
||||
int perf : 1;
|
||||
} checkout_options;
|
||||
|
||||
static void print_usage(void)
|
||||
{
|
||||
fprintf(stderr, "usage: checkout [options] <branch>\n"
|
||||
"Options are :\n"
|
||||
" --git-dir: use the following git repository.\n"
|
||||
" --force: force the checkout.\n"
|
||||
" --[no-]progress: show checkout progress.\n"
|
||||
" --perf: show performance data.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void parse_options(const char **repo_path, checkout_options *opts, struct args_info *args)
|
||||
{
|
||||
if (args->argc <= 1)
|
||||
print_usage();
|
||||
|
||||
memset(opts, 0, sizeof(*opts));
|
||||
|
||||
/* Default values */
|
||||
opts->progress = 1;
|
||||
|
||||
for (args->pos = 1; args->pos < args->argc; ++args->pos) {
|
||||
const char *curr = args->argv[args->pos];
|
||||
int bool_arg;
|
||||
|
||||
if (strcmp(curr, "--") == 0) {
|
||||
break;
|
||||
} else if (!strcmp(curr, "--force")) {
|
||||
opts->force = 1;
|
||||
} else if (match_bool_arg(&bool_arg, args, "--progress")) {
|
||||
opts->progress = bool_arg;
|
||||
} else if (match_bool_arg(&bool_arg, args, "--perf")) {
|
||||
opts->perf = bool_arg;
|
||||
} else if (match_str_arg(repo_path, args, "--git-dir")) {
|
||||
continue;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is called to report progression, ie. it's called once with
|
||||
* a NULL path and the number of total steps, then for each subsequent path,
|
||||
* the current completed_step value.
|
||||
*/
|
||||
static void print_checkout_progress(const char *path, size_t completed_steps, size_t total_steps, void *payload)
|
||||
{
|
||||
(void)payload;
|
||||
if (path == NULL) {
|
||||
printf("checkout started: %" PRIuZ " steps\n", total_steps);
|
||||
} else {
|
||||
printf("checkout: %s %" PRIuZ "/%" PRIuZ "\n", path, completed_steps, total_steps);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is called when the checkout completes, and is used to report the
|
||||
* number of syscalls performed.
|
||||
*/
|
||||
static void print_perf_data(const git_checkout_perfdata *perfdata, void *payload)
|
||||
{
|
||||
(void)payload;
|
||||
printf("perf: stat: %" PRIuZ " mkdir: %" PRIuZ " chmod: %" PRIuZ "\n",
|
||||
perfdata->stat_calls, perfdata->mkdir_calls, perfdata->chmod_calls);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the main "checkout <branch>" function, responsible for performing
|
||||
* a branch-based checkout.
|
||||
*/
|
||||
static int perform_checkout_ref(git_repository *repo, git_annotated_commit *target, checkout_options *opts)
|
||||
{
|
||||
git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
|
||||
git_commit *target_commit = NULL;
|
||||
int err;
|
||||
|
||||
/** Setup our checkout options from the parsed options */
|
||||
checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE;
|
||||
if (opts->force)
|
||||
checkout_opts.checkout_strategy = GIT_CHECKOUT_FORCE;
|
||||
|
||||
if (opts->progress)
|
||||
checkout_opts.progress_cb = print_checkout_progress;
|
||||
|
||||
if (opts->perf)
|
||||
checkout_opts.perfdata_cb = print_perf_data;
|
||||
|
||||
/** Grab the commit we're interested to move to */
|
||||
err = git_commit_lookup(&target_commit, repo, git_annotated_commit_id(target));
|
||||
if (err != 0) {
|
||||
fprintf(stderr, "failed to lookup commit: %s\n", git_error_last()->message);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform the checkout so the workdir corresponds to what target_commit
|
||||
* contains.
|
||||
*
|
||||
* Note that it's okay to pass a git_commit here, because it will be
|
||||
* peeled to a tree.
|
||||
*/
|
||||
err = git_checkout_tree(repo, (const git_object *)target_commit, &checkout_opts);
|
||||
if (err != 0) {
|
||||
fprintf(stderr, "failed to checkout tree: %s\n", git_error_last()->message);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Now that the checkout has completed, we have to update HEAD.
|
||||
*
|
||||
* Depending on the "origin" of target (ie. it's an OID or a branch name),
|
||||
* we might need to detach HEAD.
|
||||
*/
|
||||
if (git_annotated_commit_ref(target)) {
|
||||
err = git_repository_set_head(repo, git_annotated_commit_ref(target));
|
||||
} else {
|
||||
err = git_repository_set_head_detached_from_annotated(repo, target);
|
||||
}
|
||||
if (err != 0) {
|
||||
fprintf(stderr, "failed to update HEAD reference: %s\n", git_error_last()->message);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
git_commit_free(target_commit);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
/** That example's entry point */
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
git_repository *repo = NULL;
|
||||
struct args_info args = ARGS_INFO_INIT;
|
||||
checkout_options opts;
|
||||
git_repository_state_t state;
|
||||
git_annotated_commit *checkout_target = NULL;
|
||||
int err = 0;
|
||||
const char *path = ".";
|
||||
|
||||
/** Parse our command line options */
|
||||
parse_options(&path, &opts, &args);
|
||||
|
||||
/** Initialize the library */
|
||||
err = git_libgit2_init();
|
||||
if (!err)
|
||||
check_lg2(err, "Failed to initialize libgit2", NULL);
|
||||
|
||||
/** Open the repository corresponding to the options */
|
||||
check_lg2(git_repository_open_ext(&repo, path, 0, NULL),
|
||||
"Could not open repository", NULL);
|
||||
|
||||
/** Make sure we're not about to checkout while something else is going on */
|
||||
state = git_repository_state(repo);
|
||||
if (state != GIT_REPOSITORY_STATE_NONE) {
|
||||
fprintf(stderr, "repository is in unexpected state %d\n", state);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (args.pos >= args.argc) {
|
||||
fprintf(stderr, "unhandled\n");
|
||||
err = -1;
|
||||
goto cleanup;
|
||||
} else if (strcmp("--", args.argv[args.pos])) {
|
||||
/**
|
||||
* Try to checkout the given path
|
||||
*/
|
||||
|
||||
fprintf(stderr, "unhandled path-based checkout\n");
|
||||
err = 1;
|
||||
goto cleanup;
|
||||
} else {
|
||||
/**
|
||||
* Try to resolve a "refish" argument to a target libgit2 can use
|
||||
*/
|
||||
err = resolve_refish(&checkout_target, repo, args.argv[args.pos]);
|
||||
if (err != 0) {
|
||||
fprintf(stderr, "failed to resolve %s: %s\n", args.argv[args.pos], git_error_last()->message);
|
||||
goto cleanup;
|
||||
}
|
||||
err = perform_checkout_ref(repo, checkout_target, &opts);
|
||||
}
|
||||
|
||||
cleanup:
|
||||
git_annotated_commit_free(checkout_target);
|
||||
|
||||
git_repository_free(repo);
|
||||
git_libgit2_shutdown();
|
||||
|
||||
return err;
|
||||
}
|
@ -12,6 +12,8 @@
|
||||
* <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
void check_lg2(int error, const char *message, const char *extra)
|
||||
@ -22,7 +24,7 @@ void check_lg2(int error, const char *message, const char *extra)
|
||||
if (!error)
|
||||
return;
|
||||
|
||||
if ((lg2err = giterr_last()) != NULL && lg2err->message != NULL) {
|
||||
if ((lg2err = git_error_last()) != NULL && lg2err->message != NULL) {
|
||||
lg2msg = lg2err->message;
|
||||
lg2spacer = " - ";
|
||||
}
|
||||
@ -182,6 +184,25 @@ static int match_int_internal(
|
||||
return 1;
|
||||
}
|
||||
|
||||
int match_bool_arg(int *out, struct args_info *args, const char *opt)
|
||||
{
|
||||
const char *found = args->argv[args->pos];
|
||||
|
||||
if (!strcmp(found, opt)) {
|
||||
*out = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!strncmp(found, "--no-", strlen("--no-")) &&
|
||||
!strcmp(found + strlen("--no-"), opt + 2)) {
|
||||
*out = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
*out = -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int is_integer(int *out, const char *str, int allow_negative)
|
||||
{
|
||||
return match_int_internal(out, str, allow_negative, NULL);
|
||||
@ -229,7 +250,7 @@ void treeish_to_tree(
|
||||
"looking up object", treeish);
|
||||
|
||||
check_lg2(
|
||||
git_object_peel((git_object **)out, obj, GIT_OBJ_TREE),
|
||||
git_object_peel((git_object **)out, obj, GIT_OBJECT_TREE),
|
||||
"resolving object to tree", treeish);
|
||||
|
||||
git_object_free(obj);
|
||||
@ -245,3 +266,26 @@ void *xrealloc(void *oldp, size_t newsz)
|
||||
return p;
|
||||
}
|
||||
|
||||
int resolve_refish(git_annotated_commit **commit, git_repository *repo, const char *refish)
|
||||
{
|
||||
git_reference *ref;
|
||||
git_object *obj;
|
||||
int err = 0;
|
||||
|
||||
assert(commit != NULL);
|
||||
|
||||
err = git_reference_dwim(&ref, repo, refish);
|
||||
if (err == GIT_OK) {
|
||||
git_annotated_commit_from_ref(commit, repo, ref);
|
||||
git_reference_free(ref);
|
||||
return 0;
|
||||
}
|
||||
|
||||
err = git_revparse_single(&obj, repo, refish);
|
||||
if (err == GIT_OK) {
|
||||
err = git_annotated_commit_lookup(commit, repo, git_object_id(obj));
|
||||
git_object_free(obj);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
@ -90,6 +90,15 @@ extern int match_uint32_arg(
|
||||
extern int match_int_arg(
|
||||
int *out, struct args_info *args, const char *opt, int allow_negative);
|
||||
|
||||
/**
|
||||
* Check current `args` entry against a "bool" `opt` (ie. --[no-]progress).
|
||||
* If `opt` matches positively, out will be set to 1, or if `opt` matches
|
||||
* negatively, out will be set to 0, and in both cases 1 will be returned.
|
||||
* If neither the positive or the negative form of opt matched, out will be -1,
|
||||
* and 0 will be returned.
|
||||
*/
|
||||
extern int match_bool_arg(int *out, struct args_info *args, const char *opt);
|
||||
|
||||
/**
|
||||
* Basic output function for plain text diff output
|
||||
* Pass `FILE*` such as `stdout` or `stderr` as payload (or NULL == `stdout`)
|
||||
@ -108,3 +117,8 @@ extern void treeish_to_tree(
|
||||
* A realloc that exits on failure
|
||||
*/
|
||||
extern void *xrealloc(void *oldp, size_t newsz);
|
||||
|
||||
/**
|
||||
* Convert a refish to an annotated commit.
|
||||
*/
|
||||
extern int resolve_refish(git_annotated_commit **commit, git_repository *repo, const char *refish);
|
||||
|
@ -332,6 +332,6 @@ static void diff_print_stats(git_diff *diff, struct opts *o)
|
||||
|
||||
fputs(b.ptr, stdout);
|
||||
|
||||
git_buf_free(&b);
|
||||
git_buf_dispose(&b);
|
||||
git_diff_stats_free(stats);
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ static int show_ref(git_reference *ref, void *data)
|
||||
const git_oid *oid;
|
||||
git_object *obj;
|
||||
|
||||
if (git_reference_type(ref) == GIT_REF_SYMBOLIC)
|
||||
if (git_reference_type(ref) == GIT_REFERENCE_SYMBOLIC)
|
||||
check_lg2(git_reference_resolve(&resolved, ref),
|
||||
"Unable to resolve symbolic reference",
|
||||
git_reference_name(ref));
|
||||
@ -18,7 +18,7 @@ static int show_ref(git_reference *ref, void *data)
|
||||
oid = git_reference_target(resolved ? resolved : ref);
|
||||
git_oid_fmt(hex, oid);
|
||||
hex[GIT_OID_HEXSZ] = 0;
|
||||
check_lg2(git_object_lookup(&obj, repo, oid, GIT_OBJ_ANY),
|
||||
check_lg2(git_object_lookup(&obj, repo, oid, GIT_OBJECT_ANY),
|
||||
"Unable to lookup object", hex);
|
||||
|
||||
printf("%s %-6s\t%s\n",
|
||||
|
@ -66,7 +66,7 @@ static void config_files(const char *repo_path, git_repository *repo);
|
||||
*/
|
||||
static void check_error(int error_code, const char *action)
|
||||
{
|
||||
const git_error *error = giterr_last();
|
||||
const git_error *error = git_error_last();
|
||||
if (!error_code)
|
||||
return;
|
||||
|
||||
@ -145,11 +145,13 @@ static void oid_parsing(git_oid *oid)
|
||||
*/
|
||||
git_oid_fromstr(oid, hex);
|
||||
|
||||
// Once we've converted the string into the oid value, we can get the raw
|
||||
// value of the SHA by accessing `oid.id`
|
||||
|
||||
// Next we will convert the 20 byte raw SHA1 value to a human readable 40
|
||||
// char hex value.
|
||||
/*
|
||||
* Once we've converted the string into the oid value, we can get the raw
|
||||
* value of the SHA by accessing `oid.id`
|
||||
*
|
||||
* Next we will convert the 20 byte raw SHA1 value to a human readable 40
|
||||
* char hex value.
|
||||
*/
|
||||
printf("\n*Raw to Hex*\n");
|
||||
out[GIT_OID_HEXSZ] = '\0';
|
||||
|
||||
@ -183,7 +185,7 @@ static void object_database(git_repository *repo, git_oid *oid)
|
||||
int error;
|
||||
git_odb_object *obj;
|
||||
git_odb *odb;
|
||||
git_otype otype;
|
||||
git_object_t otype;
|
||||
|
||||
git_repository_odb(&odb, repo);
|
||||
|
||||
@ -239,7 +241,7 @@ static void object_database(git_repository *repo, git_oid *oid)
|
||||
* we'll write a new blob object that just contains a simple string.
|
||||
* Notice that we have to specify the object type as the `git_otype` enum.
|
||||
*/
|
||||
git_odb_write(oid, odb, "test data", sizeof("test data") - 1, GIT_OBJ_BLOB);
|
||||
git_odb_write(oid, odb, "test data", sizeof("test data") - 1, GIT_OBJECT_BLOB);
|
||||
|
||||
/**
|
||||
* Now that we've written the object, we can check out what SHA1 was
|
||||
@ -414,7 +416,7 @@ static void commit_parsing(git_repository *repo)
|
||||
static void tag_parsing(git_repository *repo)
|
||||
{
|
||||
git_commit *commit;
|
||||
git_otype type;
|
||||
git_object_t type;
|
||||
git_tag *tag;
|
||||
git_oid oid;
|
||||
const char *name, *message;
|
||||
@ -439,7 +441,7 @@ static void tag_parsing(git_repository *repo)
|
||||
*/
|
||||
git_tag_target((git_object **)&commit, tag);
|
||||
name = git_tag_name(tag); /* "test" */
|
||||
type = git_tag_target_type(tag); /* GIT_OBJ_COMMIT (otype enum) */
|
||||
type = git_tag_target_type(tag); /* GIT_OBJECT_COMMIT (object_t enum) */
|
||||
message = git_tag_message(tag); /* "tag message\n" */
|
||||
printf("Tag Name: %s\nTag Type: %s\nTag Message: %s\n",
|
||||
name, git_object_type2string(type), message);
|
||||
@ -690,12 +692,12 @@ static void reference_listing(git_repository *repo)
|
||||
git_reference_lookup(&ref, repo, refname);
|
||||
|
||||
switch (git_reference_type(ref)) {
|
||||
case GIT_REF_OID:
|
||||
case GIT_REFERENCE_DIRECT:
|
||||
git_oid_fmt(oid_hex, git_reference_target(ref));
|
||||
printf("%s [%s]\n", refname, oid_hex);
|
||||
break;
|
||||
|
||||
case GIT_REF_SYMBOLIC:
|
||||
case GIT_REFERENCE_SYMBOLIC:
|
||||
printf("%s => %s\n", refname, git_reference_symbolic_target(ref));
|
||||
break;
|
||||
default:
|
||||
|
@ -275,7 +275,7 @@ static int add_revision(struct log_state *s, const char *revstr)
|
||||
git_object_id(revs.from), git_object_id(revs.to)),
|
||||
"Could not find merge base", revstr);
|
||||
check_lg2(
|
||||
git_object_lookup(&revs.to, s->repo, &base, GIT_OBJ_COMMIT),
|
||||
git_object_lookup(&revs.to, s->repo, &base, GIT_OBJECT_COMMIT),
|
||||
"Could not find merge base commit", NULL);
|
||||
|
||||
push_rev(s, revs.to, hide);
|
||||
|
140
examples/ls-files.c
Normal file
140
examples/ls-files.c
Normal file
@ -0,0 +1,140 @@
|
||||
/*
|
||||
* libgit2 "ls-files" example - shows how to view all files currently in the index
|
||||
*
|
||||
* Written by the libgit2 contributors
|
||||
*
|
||||
* To the extent possible under law, the author(s) have dedicated all copyright
|
||||
* and related and neighboring rights to this software to the public domain
|
||||
* worldwide. This software is distributed without any warranty.
|
||||
*
|
||||
* You should have received a copy of the CC0 Public Domain Dedication along
|
||||
* with this software. If not, see
|
||||
* <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "array.h"
|
||||
|
||||
/**
|
||||
* This example demonstrates the libgit2 index APIs to roughly
|
||||
* simulate the output of `git ls-files`.
|
||||
* `git ls-files` has many options and this currently does not show them.
|
||||
*
|
||||
* `git ls-files` base command shows all paths in the index at that time.
|
||||
* This includes staged and committed files, but unstaged files will not display.
|
||||
*
|
||||
* This currently supports the default behavior and the `--error-unmatch` option.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
int error_unmatch;
|
||||
char *files[1024];
|
||||
size_t file_count;
|
||||
} ls_options;
|
||||
|
||||
static void usage(const char *message, const char *arg)
|
||||
{
|
||||
if (message && arg)
|
||||
fprintf(stderr, "%s: %s\n", message, arg);
|
||||
else if (message)
|
||||
fprintf(stderr, "%s\n", message);
|
||||
fprintf(stderr, "usage: ls-files [--error-unmatch] [--] [<file>...]\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static int parse_options(ls_options *opts, int argc, char *argv[])
|
||||
{
|
||||
int parsing_files = 0;
|
||||
int i;
|
||||
|
||||
memset(opts, 0, sizeof(ls_options));
|
||||
|
||||
if (argc < 2)
|
||||
return 0;
|
||||
|
||||
for (i = 1; i < argc; ++i) {
|
||||
char *a = argv[i];
|
||||
|
||||
/* if it doesn't start with a '-' or is after the '--' then it is a file */
|
||||
if (a[0] != '-' || parsing_files) {
|
||||
parsing_files = 1;
|
||||
|
||||
/* watch for overflows (just in case) */
|
||||
if (opts->file_count == 1024) {
|
||||
fprintf(stderr, "ls-files can only support 1024 files at this time.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
opts->files[opts->file_count++] = a;
|
||||
} else if (!strcmp(a, "--")) {
|
||||
parsing_files = 1;
|
||||
} else if (!strcmp(a, "--error-unmatch")) {
|
||||
opts->error_unmatch = 1;
|
||||
} else {
|
||||
usage("Unsupported argument", a);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int print_paths(ls_options *opts, git_index *index)
|
||||
{
|
||||
size_t i;
|
||||
const git_index_entry *entry;
|
||||
|
||||
/* if there are no files explicitly listed by the user print all entries in the index */
|
||||
if (opts->file_count == 0) {
|
||||
size_t entry_count = git_index_entrycount(index);
|
||||
|
||||
for (i = 0; i < entry_count; i++) {
|
||||
entry = git_index_get_byindex(index, i);
|
||||
puts(entry->path);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* loop through the files found in the args and print them if they exist */
|
||||
for (i = 0; i < opts->file_count; ++i) {
|
||||
const char *path = opts->files[i];
|
||||
|
||||
if ((entry = git_index_get_bypath(index, path, GIT_INDEX_STAGE_NORMAL)) != NULL) {
|
||||
puts(path);
|
||||
} else if (opts->error_unmatch) {
|
||||
fprintf(stderr, "error: pathspec '%s' did not match any file(s) known to git.\n", path);
|
||||
fprintf(stderr, "Did you forget to 'git add'?\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
ls_options opts;
|
||||
git_repository *repo = NULL;
|
||||
git_index *index = NULL;
|
||||
int error;
|
||||
|
||||
if ((error = parse_options(&opts, argc, argv)) < 0)
|
||||
return error;
|
||||
|
||||
git_libgit2_init();
|
||||
|
||||
if ((error = git_repository_open_ext(&repo, ".", 0, NULL)) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if ((error = git_repository_index(&index, repo)) < 0)
|
||||
goto cleanup;
|
||||
|
||||
error = print_paths(&opts, index);
|
||||
|
||||
cleanup:
|
||||
git_index_free(index);
|
||||
git_repository_free(repo);
|
||||
git_libgit2_shutdown();
|
||||
|
||||
return error;
|
||||
}
|
@ -87,29 +87,6 @@ static void parse_options(const char **repo_path, merge_options *opts, int argc,
|
||||
}
|
||||
}
|
||||
|
||||
static int resolve_refish(git_annotated_commit **commit, git_repository *repo, const char *refish)
|
||||
{
|
||||
git_reference *ref;
|
||||
int err = 0;
|
||||
git_oid oid;
|
||||
|
||||
assert(commit != NULL);
|
||||
|
||||
err = git_reference_dwim(&ref, repo, refish);
|
||||
if (err == GIT_OK) {
|
||||
git_annotated_commit_from_ref(commit, repo, ref);
|
||||
git_reference_free(ref);
|
||||
return 0;
|
||||
}
|
||||
|
||||
err = git_oid_fromstr(&oid, refish);
|
||||
if (err == GIT_OK) {
|
||||
err = git_annotated_commit_lookup(commit, repo, &oid);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static int resolve_heads(git_repository *repo, merge_options *opts)
|
||||
{
|
||||
git_annotated_commit **annotated = calloc(opts->heads_count, sizeof(git_annotated_commit *));
|
||||
@ -119,7 +96,7 @@ static int resolve_heads(git_repository *repo, merge_options *opts)
|
||||
for (i = 0; i < opts->heads_count; i++) {
|
||||
err = resolve_refish(&annotated[annotated_count++], repo, opts->heads[i]);
|
||||
if (err != 0) {
|
||||
fprintf(stderr, "failed to resolve refish %s: %s\n", opts->heads[i], giterr_last()->message);
|
||||
fprintf(stderr, "failed to resolve refish %s: %s\n", opts->heads[i], git_error_last()->message);
|
||||
annotated_count--;
|
||||
continue;
|
||||
}
|
||||
@ -176,7 +153,7 @@ static int perform_fastforward(git_repository *repo, const git_oid *target_oid,
|
||||
}
|
||||
|
||||
/* Lookup the target object */
|
||||
err = git_object_lookup(&target, repo, target_oid, GIT_OBJ_COMMIT);
|
||||
err = git_object_lookup(&target, repo, target_oid, GIT_OBJECT_COMMIT);
|
||||
if (err != 0) {
|
||||
fprintf(stderr, "failed to lookup OID %s\n", git_oid_tostr_s(target_oid));
|
||||
return -1;
|
||||
@ -252,7 +229,7 @@ static int create_merge_commit(git_repository *repo, git_index *index, merge_opt
|
||||
|
||||
/* Maybe that's a ref, so DWIM it */
|
||||
err = git_reference_dwim(&merge_ref, repo, opts->heads[0]);
|
||||
check_lg2(err, "failed to DWIM reference", giterr_last()->message);
|
||||
check_lg2(err, "failed to DWIM reference", git_error_last()->message);
|
||||
|
||||
/* Grab a signature */
|
||||
check_lg2(git_signature_now(&sign, "Me", "me@example.com"), "failed to create signature", NULL);
|
||||
@ -274,7 +251,7 @@ static int create_merge_commit(git_repository *repo, git_index *index, merge_opt
|
||||
if (err < 0) goto cleanup;
|
||||
|
||||
/* Setup our parent commits */
|
||||
err = git_reference_peel((git_object **)&parents[0], head_ref, GIT_OBJ_COMMIT);
|
||||
err = git_reference_peel((git_object **)&parents[0], head_ref, GIT_OBJECT_COMMIT);
|
||||
check_lg2(err, "failed to peel head reference", NULL);
|
||||
for (i = 0; i < opts->annotated_count; i++) {
|
||||
git_commit_lookup(&parents[i + 1], repo, git_annotated_commit_id(opts->annotated[i]));
|
||||
|
@ -48,7 +48,7 @@ static void print_progress(const progress_data *pd)
|
||||
|
||||
static int sideband_progress(const char *str, int len, void *payload)
|
||||
{
|
||||
(void)payload; // unused
|
||||
(void)payload; /* unused */
|
||||
|
||||
printf("remote: %.*s", len, str);
|
||||
fflush(stdout);
|
||||
@ -82,15 +82,15 @@ int do_clone(git_repository *repo, int argc, char **argv)
|
||||
const char *path = argv[2];
|
||||
int error;
|
||||
|
||||
(void)repo; // unused
|
||||
(void)repo; /* unused */
|
||||
|
||||
// Validate args
|
||||
/* Validate args */
|
||||
if (argc < 3) {
|
||||
printf ("USAGE: %s <url> <path>\n", argv[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Set up options
|
||||
/* Set up options */
|
||||
checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE;
|
||||
checkout_opts.progress_cb = checkout_progress;
|
||||
checkout_opts.progress_payload = &pd;
|
||||
@ -100,11 +100,11 @@ int do_clone(git_repository *repo, int argc, char **argv)
|
||||
clone_opts.fetch_opts.callbacks.credentials = cred_acquire_cb;
|
||||
clone_opts.fetch_opts.callbacks.payload = &pd;
|
||||
|
||||
// Do the clone
|
||||
/* Do the clone */
|
||||
error = git_clone(&cloned_repo, url, path, &clone_opts);
|
||||
printf("\n");
|
||||
if (error != 0) {
|
||||
const git_error *err = giterr_last();
|
||||
const git_error *err = git_error_last();
|
||||
if (err) printf("ERROR %d: %s\n", err->klass, err->message);
|
||||
else printf("ERROR %d: no detailed info\n", error);
|
||||
}
|
||||
|
@ -26,10 +26,10 @@ static int run_command(git_cb fn, git_repository *repo, struct args_info args)
|
||||
/* Run the command. If something goes wrong, print the error message to stderr */
|
||||
error = fn(repo, args.argc - args.pos, &args.argv[args.pos]);
|
||||
if (error < 0) {
|
||||
if (giterr_last() == NULL)
|
||||
if (git_error_last() == NULL)
|
||||
fprintf(stderr, "Error without message");
|
||||
else
|
||||
fprintf(stderr, "Bad news:\n %s\n", giterr_last()->message);
|
||||
fprintf(stderr, "Bad news:\n %s\n", git_error_last()->message);
|
||||
}
|
||||
|
||||
return !!error;
|
||||
|
@ -19,8 +19,10 @@
|
||||
#endif
|
||||
#include "common.h"
|
||||
|
||||
// This could be run in the main loop whilst the application waits for
|
||||
// the indexing to finish in a worker thread
|
||||
/*
|
||||
* This could be run in the main loop whilst the application waits for
|
||||
* the indexing to finish in a worker thread
|
||||
*/
|
||||
static int index_cb(const git_transfer_progress *stats, void *data)
|
||||
{
|
||||
(void)data;
|
||||
@ -46,7 +48,7 @@ int index_pack(git_repository *repo, int argc, char **argv)
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (git_indexer_new(&idx, ".", 0, NULL, NULL, NULL) < 0) {
|
||||
if (git_indexer_new(&idx, ".", 0, NULL, NULL) < 0) {
|
||||
puts("bad idx");
|
||||
return -1;
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ static int use_remote(git_repository *repo, char *name)
|
||||
size_t refs_len, i;
|
||||
git_remote_callbacks callbacks = GIT_REMOTE_CALLBACKS_INIT;
|
||||
|
||||
// Find the remote by name
|
||||
/* Find the remote by name */
|
||||
error = git_remote_lookup(&remote, repo, name);
|
||||
if (error < 0) {
|
||||
error = git_remote_create_anonymous(&remote, repo, name);
|
||||
|
@ -64,7 +64,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
check_lg2(git_repository_open(&repo, buf.ptr),
|
||||
"Could not open repository", NULL);
|
||||
git_buf_free(&buf);
|
||||
git_buf_dispose(&buf);
|
||||
|
||||
switch (opt.cmd)
|
||||
{
|
||||
|
@ -135,10 +135,10 @@ static int each_tag(const char *name, tag_state *state)
|
||||
"Failed to lookup rev", name);
|
||||
|
||||
switch (git_object_type(obj)) {
|
||||
case GIT_OBJ_TAG:
|
||||
case GIT_OBJECT_TAG:
|
||||
print_tag((git_tag *) obj, state);
|
||||
break;
|
||||
case GIT_OBJ_COMMIT:
|
||||
case GIT_OBJECT_COMMIT:
|
||||
print_commit((git_commit *) obj, name, state);
|
||||
break;
|
||||
default:
|
||||
@ -184,7 +184,7 @@ static void action_delete_tag(tag_state *state)
|
||||
|
||||
printf("Deleted tag '%s' (was %s)\n", opts->tag_name, abbrev_oid.ptr);
|
||||
|
||||
git_buf_free(&abbrev_oid);
|
||||
git_buf_dispose(&abbrev_oid);
|
||||
git_object_free(obj);
|
||||
}
|
||||
|
||||
|
18
fuzzers/CMakeLists.txt
Normal file
18
fuzzers/CMakeLists.txt
Normal file
@ -0,0 +1,18 @@
|
||||
LINK_DIRECTORIES(${LIBGIT2_LIBDIRS})
|
||||
INCLUDE_DIRECTORIES(${LIBGIT2_INCLUDES})
|
||||
|
||||
IF(BUILD_FUZZERS AND NOT USE_STANDALONE_FUZZERS)
|
||||
ADD_C_FLAG(-fsanitize=fuzzer)
|
||||
ENDIF ()
|
||||
|
||||
FILE(GLOB SRC_FUZZ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *_fuzzer.c)
|
||||
FOREACH(fuzz_target_src ${SRC_FUZZ})
|
||||
STRING(REPLACE ".c" "" fuzz_target_name ${fuzz_target_src})
|
||||
SET(${fuzz_target_name}_SOURCES ${fuzz_target_src} ${LIBGIT2_OBJECTS})
|
||||
IF(USE_STANDALONE_FUZZERS)
|
||||
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})
|
||||
ENDFOREACH()
|
65
fuzzers/config_file_fuzzer.c
Normal file
65
fuzzers/config_file_fuzzer.c
Normal file
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* libgit2 config file parser fuzz target.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <git2.h>
|
||||
#include "config_backend.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define UNUSED(x) (void)(x)
|
||||
|
||||
int foreach_cb(const git_config_entry *entry, void *payload)
|
||||
{
|
||||
UNUSED(entry);
|
||||
UNUSED(payload);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LLVMFuzzerInitialize(int *argc, char ***argv)
|
||||
{
|
||||
UNUSED(argc);
|
||||
UNUSED(argv);
|
||||
|
||||
if (git_libgit2_init() < 0)
|
||||
abort();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
git_config *cfg = NULL;
|
||||
git_config_backend *backend = NULL;
|
||||
int err = 0;
|
||||
|
||||
if ((err = git_config_new(&cfg)) != 0) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
if ((err = git_config_backend_from_string(&backend, (const char*)data, size)) != 0) {
|
||||
goto out;
|
||||
}
|
||||
if ((err = git_config_add_backend(cfg, backend, 0, NULL, 0)) != 0) {
|
||||
goto out;
|
||||
}
|
||||
/* Now owned by the config */
|
||||
backend = NULL;
|
||||
|
||||
git_config_foreach(cfg, foreach_cb, NULL);
|
||||
out:
|
||||
git_config_backend_free(backend);
|
||||
git_config_free(cfg);
|
||||
|
||||
return 0;
|
||||
}
|
11
fuzzers/corpora/config_file/git2.dat
Normal file
11
fuzzers/corpora/config_file/git2.dat
Normal file
@ -0,0 +1,11 @@
|
||||
[core]
|
||||
repositoryformatversion = 0
|
||||
filemode = true
|
||||
bare = false
|
||||
logallrefupdates = true
|
||||
[remote "origin"]
|
||||
url = git@github.com:libgit2/libgit2
|
||||
fetch = +refs/heads/*:refs/remotes/origin/*
|
||||
[branch "master"]
|
||||
remote = origin
|
||||
merge = refs/heads/master
|
BIN
fuzzers/corpora/download_refs/clone.dat
Normal file
BIN
fuzzers/corpora/download_refs/clone.dat
Normal file
Binary file not shown.
359
fuzzers/corpora/objects/blob
Normal file
359
fuzzers/corpora/objects/blob
Normal file
@ -0,0 +1,359 @@
|
||||
libgit2 - the Git linkable library
|
||||
==================================
|
||||
|
||||
[](http://travis-ci.org/libgit2/libgit2)
|
||||
[](https://ci.appveyor.com/project/libgit2/libgit2/branch/master)
|
||||
[](https://scan.coverity.com/projects/639)
|
||||
|
||||
`libgit2` is a portable, pure C implementation of the Git core methods
|
||||
provided as a linkable library with a solid API, allowing to build Git
|
||||
functionality into your application. Language bindings like
|
||||
[Rugged](https://github.com/libgit2/rugged) (Ruby),
|
||||
[LibGit2Sharp](https://github.com/libgit2/libgit2sharp) (.NET),
|
||||
[pygit2](http://www.pygit2.org/) (Python) and
|
||||
[NodeGit](http://nodegit.org) (Node) allow you to build Git tooling
|
||||
in your favorite language.
|
||||
|
||||
`libgit2` is used to power Git GUI clients like
|
||||
[GitKraken](https://gitkraken.com/) and [gmaster](https://gmaster.io/)
|
||||
and on Git hosting providers like [GitHub](https://github.com/),
|
||||
[GitLab](https://gitlab.com/) and
|
||||
[Visual Studio Team Services](https://visualstudio.com/team-services/).
|
||||
We perform the merge every time you click "merge pull request".
|
||||
|
||||
`libgit2` is licensed under a **very permissive license** (GPLv2 with a special
|
||||
Linking Exception). This basically means that you can link it (unmodified)
|
||||
with any kind of software without having to release its source code.
|
||||
Additionally, the example code has been released to the public domain (see the
|
||||
[separate license](examples/COPYING) for more information).
|
||||
|
||||
Quick Start
|
||||
===========
|
||||
|
||||
**Prerequisites** for building libgit2:
|
||||
|
||||
1. [CMake](https://cmake.org/), and is recommended to be installed into
|
||||
your `PATH`.
|
||||
2. [Python](https://www.python.org) is used by our test framework, and
|
||||
should be installed into your `PATH`.
|
||||
3. C compiler: libgit2 is C90 and should compile on most compilers.
|
||||
* Windows: Visual Studio is recommended
|
||||
* Mac: Xcode is recommended
|
||||
* Unix: gcc or clang is recommended.
|
||||
|
||||
**Build**
|
||||
|
||||
1. Create a build directory beneath the libgit2 source directory, and change
|
||||
into it: `mkdir build && cd build`
|
||||
2. Create the cmake build environment: `cmake ..`
|
||||
3. Build libgit2: `cmake --build .`
|
||||
|
||||
Trouble with these steps? Read `TROUBLESHOOTING.md`. More detailed build
|
||||
guidance is available below.
|
||||
|
||||
Getting Help
|
||||
============
|
||||
|
||||
**Join us on Slack**
|
||||
|
||||
Visit [slack.libgit2.org](http://slack.libgit2.org/) to sign up, then join
|
||||
us in `#libgit2`. If you prefer IRC, you can also point your client to our
|
||||
slack channel once you've registered.
|
||||
|
||||
**Getting Help**
|
||||
|
||||
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
|
||||
questions, reach out to us on Slack or post a question on
|
||||
[StackOverflow](http://stackoverflow.com/questions/tagged/libgit2) (with the `libgit2` tag).
|
||||
|
||||
**Reporting Bugs**
|
||||
|
||||
Please open a [GitHub Issue](https://github.com/libgit2/libgit2/issues) and
|
||||
include as much information as possible. If possible, provide sample code
|
||||
that illustrates the problem you're seeing. If you're seeing a bug only
|
||||
on a specific repository, please provide a link to it if possible.
|
||||
|
||||
We ask that you not open a GitHub Issue for help, only for bug reports.
|
||||
|
||||
**Reporting Security Issues**
|
||||
|
||||
In case you think to have found a security issue with libgit2, please do not
|
||||
open a public issue. Instead, you can report the issue to the private mailing
|
||||
list [security@libgit2.com](mailto:security@libgit2.com).
|
||||
|
||||
What It Can Do
|
||||
==============
|
||||
|
||||
libgit2 provides you with the ability to manage Git repositories in the
|
||||
programming language of your choice. It's used in production to power many
|
||||
applications including GitHub.com, Plastic SCM and Visual Studio Team Services.
|
||||
|
||||
It does not aim to replace the git tool or its user-facing commands. Some APIs
|
||||
resemble the plumbing commands as those align closely with the concepts of the
|
||||
Git system, but most commands a user would type are out of scope for this
|
||||
library to implement directly.
|
||||
|
||||
The library provides:
|
||||
|
||||
* SHA conversions, formatting and shortening
|
||||
* abstracted ODB backend system
|
||||
* commit, tag, tree and blob parsing, editing, and write-back
|
||||
* tree traversal
|
||||
* revision walking
|
||||
* index file (staging area) manipulation
|
||||
* reference management (including packed references)
|
||||
* config file management
|
||||
* high level repository management
|
||||
* thread safety and reentrancy
|
||||
* descriptive and detailed error messages
|
||||
* ...and more (over 175 different API calls)
|
||||
|
||||
As libgit2 is purely a consumer of the Git system, we have to
|
||||
adjust to changes made upstream. This has two major consequences:
|
||||
|
||||
* Some changes may require us to change provided interfaces. While we try to
|
||||
implement functions in a generic way so that no future changes are required,
|
||||
we cannot promise a completely stable API.
|
||||
* As we have to keep up with changes in behavior made upstream, we may lag
|
||||
behind in some areas. We usually to document these incompatibilities in our
|
||||
issue tracker with the label "git change".
|
||||
|
||||
Optional dependencies
|
||||
=====================
|
||||
|
||||
While the library provides git functionality without the need for
|
||||
dependencies, it can make use of a few libraries to add to it:
|
||||
|
||||
- pthreads (non-Windows) to enable threadsafe access as well as multi-threaded pack generation
|
||||
- OpenSSL (non-Windows) to talk over HTTPS and provide the SHA-1 functions
|
||||
- LibSSH2 to enable the SSH transport
|
||||
- iconv (OSX) to handle the HFS+ path encoding peculiarities
|
||||
|
||||
Initialization
|
||||
===============
|
||||
|
||||
The library needs to keep track of some global state. Call
|
||||
|
||||
git_libgit2_init();
|
||||
|
||||
before calling any other libgit2 functions. You can call this function many times. A matching number of calls to
|
||||
|
||||
git_libgit2_shutdown();
|
||||
|
||||
will free the resources. Note that if you have worker threads, you should
|
||||
call `git_libgit2_shutdown` *after* those threads have exited. If you
|
||||
require assistance coordinating this, simply have the worker threads call
|
||||
`git_libgit2_init` at startup and `git_libgit2_shutdown` at shutdown.
|
||||
|
||||
Threading
|
||||
=========
|
||||
|
||||
See [THREADING](THREADING.md) for information
|
||||
|
||||
Conventions
|
||||
===========
|
||||
|
||||
See [CONVENTIONS](CONVENTIONS.md) for an overview of the external
|
||||
and internal API/coding conventions we use.
|
||||
|
||||
Building libgit2 - Using CMake
|
||||
==============================
|
||||
|
||||
Building
|
||||
--------
|
||||
|
||||
`libgit2` builds cleanly on most platforms without any external dependencies.
|
||||
Under Unix-like systems, like Linux, \*BSD and Mac OS X, libgit2 expects `pthreads` to be available;
|
||||
they should be installed by default on all systems. Under Windows, libgit2 uses the native Windows API
|
||||
for threading.
|
||||
|
||||
The `libgit2` library is built using [CMake](<https://cmake.org/>) (version 2.8 or newer) on all platforms.
|
||||
|
||||
On most systems you can build the library using the following commands
|
||||
|
||||
$ mkdir build && cd build
|
||||
$ cmake ..
|
||||
$ cmake --build .
|
||||
|
||||
Alternatively you can point the CMake GUI tool to the CMakeLists.txt file and generate platform specific build project or IDE workspace.
|
||||
|
||||
Running Tests
|
||||
-------------
|
||||
|
||||
Once built, you can run the tests from the `build` directory with the command
|
||||
|
||||
$ ctest -V
|
||||
|
||||
Alternatively you can run the test suite directly using,
|
||||
|
||||
$ ./libgit2_clar
|
||||
|
||||
Invoking the test suite directly is useful because it allows you to execute
|
||||
individual tests, or groups of tests using the `-s` flag. For example, to
|
||||
run the index tests:
|
||||
|
||||
$ ./libgit2_clar -sindex
|
||||
|
||||
To run a single test named `index::racy::diff`, which corresponds to the test
|
||||
function (`test_index_racy__diff`)[https://github.com/libgit2/libgit2/blob/master/tests/index/racy.c#L23]:
|
||||
|
||||
$ ./libgit2_clar -sindex::racy::diff
|
||||
|
||||
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
|
||||
applicable to your platform or is particularly expensive.
|
||||
|
||||
**Note:** There should be _no_ failing tests when you build an unmodified
|
||||
source tree from a [release](https://github.com/libgit2/libgit2/releases),
|
||||
or from the [master branch](https://github.com/libgit2/libgit2/tree/master).
|
||||
Please contact us or [open an issue](https://github.com/libgit2/libgit2/issues)
|
||||
if you see test failures.
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
To install the library you can specify the install prefix by setting:
|
||||
|
||||
$ cmake .. -DCMAKE_INSTALL_PREFIX=/install/prefix
|
||||
$ cmake --build . --target install
|
||||
|
||||
Advanced Usage
|
||||
--------------
|
||||
|
||||
For more advanced use or questions about CMake please read <https://cmake.org/Wiki/CMake_FAQ>.
|
||||
|
||||
The following CMake variables are declared:
|
||||
|
||||
- `BIN_INSTALL_DIR`: Where to install binaries to.
|
||||
- `LIB_INSTALL_DIR`: Where to install libraries to.
|
||||
- `INCLUDE_INSTALL_DIR`: Where to install headers to.
|
||||
- `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)
|
||||
- `THREADSAFE`: Build libgit2 with threading support (defaults to ON)
|
||||
- `STDCALL`: Build libgit2 as `stdcall`. Turn off for `cdecl` (Windows; defaults to ON)
|
||||
|
||||
Compiler and linker options
|
||||
---------------------------
|
||||
|
||||
CMake lets you specify a few variables to control the behavior of the
|
||||
compiler and linker. These flags are rarely used but can be useful for
|
||||
64-bit to 32-bit cross-compilation.
|
||||
|
||||
- `CMAKE_C_FLAGS`: Set your own compiler flags
|
||||
- `CMAKE_FIND_ROOT_PATH`: Override the search path for libraries
|
||||
- `ZLIB_LIBRARY`, `OPENSSL_SSL_LIBRARY` AND `OPENSSL_CRYPTO_LIBRARY`:
|
||||
Tell CMake where to find those specific libraries
|
||||
|
||||
MacOS X
|
||||
-------
|
||||
|
||||
If you want to build a universal binary for Mac OS X, CMake sets it
|
||||
all up for you if you use `-DCMAKE_OSX_ARCHITECTURES="i386;x86_64"`
|
||||
when configuring.
|
||||
|
||||
Android
|
||||
-------
|
||||
|
||||
Extract toolchain from NDK using, `make-standalone-toolchain.sh` script.
|
||||
Optionally, crosscompile and install OpenSSL inside of it. Then create CMake
|
||||
toolchain file that configures paths to your crosscompiler (substitute `{PATH}`
|
||||
with full path to the toolchain):
|
||||
|
||||
SET(CMAKE_SYSTEM_NAME Linux)
|
||||
SET(CMAKE_SYSTEM_VERSION Android)
|
||||
|
||||
SET(CMAKE_C_COMPILER {PATH}/bin/arm-linux-androideabi-gcc)
|
||||
SET(CMAKE_CXX_COMPILER {PATH}/bin/arm-linux-androideabi-g++)
|
||||
SET(CMAKE_FIND_ROOT_PATH {PATH}/sysroot/)
|
||||
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
|
||||
Add `-DCMAKE_TOOLCHAIN_FILE={pathToToolchainFile}` to cmake command
|
||||
when configuring.
|
||||
|
||||
Language Bindings
|
||||
==================================
|
||||
|
||||
Here are the bindings to libgit2 that are currently available:
|
||||
|
||||
* C++
|
||||
* libqgit2, Qt bindings <https://projects.kde.org/projects/playground/libs/libqgit2/repository/>
|
||||
* Chicken Scheme
|
||||
* chicken-git <https://wiki.call-cc.org/egg/git>
|
||||
* D
|
||||
* dlibgit <https://github.com/s-ludwig/dlibgit>
|
||||
* Delphi
|
||||
* GitForDelphi <https://github.com/libgit2/GitForDelphi>
|
||||
* Erlang
|
||||
* Geef <https://github.com/carlosmn/geef>
|
||||
* Go
|
||||
* git2go <https://github.com/libgit2/git2go>
|
||||
* GObject
|
||||
* libgit2-glib <https://wiki.gnome.org/Projects/Libgit2-glib>
|
||||
* Guile
|
||||
* Guile-Git <https://gitlab.com/guile-git/guile-git>
|
||||
* Haskell
|
||||
* hgit2 <https://github.com/jwiegley/gitlib>
|
||||
* Java
|
||||
* Jagged <https://github.com/ethomson/jagged>
|
||||
* Julia
|
||||
* LibGit2.jl <https://github.com/jakebolewski/LibGit2.jl>
|
||||
* Lua
|
||||
* luagit2 <https://github.com/libgit2/luagit2>
|
||||
* .NET
|
||||
* libgit2sharp <https://github.com/libgit2/libgit2sharp>
|
||||
* Node.js
|
||||
* nodegit <https://github.com/nodegit/nodegit>
|
||||
* Objective-C
|
||||
* objective-git <https://github.com/libgit2/objective-git>
|
||||
* OCaml
|
||||
* ocaml-libgit2 <https://github.com/fxfactorial/ocaml-libgit2>
|
||||
* Parrot Virtual Machine
|
||||
* parrot-libgit2 <https://github.com/letolabs/parrot-libgit2>
|
||||
* Perl
|
||||
* Git-Raw <https://github.com/jacquesg/p5-Git-Raw>
|
||||
* PHP
|
||||
* php-git <https://github.com/libgit2/php-git>
|
||||
* PowerShell
|
||||
* PSGit <https://github.com/PoshCode/PSGit>
|
||||
* Python
|
||||
* pygit2 <https://github.com/libgit2/pygit2>
|
||||
* R
|
||||
* git2r <https://github.com/ropensci/git2r>
|
||||
* Ruby
|
||||
* Rugged <https://github.com/libgit2/rugged>
|
||||
* Rust
|
||||
* git2-rs <https://github.com/alexcrichton/git2-rs>
|
||||
* Swift
|
||||
* SwiftGit2 <https://github.com/SwiftGit2/SwiftGit2>
|
||||
* Vala
|
||||
* libgit2.vapi <https://github.com/apmasell/vapis/blob/master/libgit2.vapi>
|
||||
|
||||
If you start another language binding to libgit2, please let us know so
|
||||
we can add it to the list.
|
||||
|
||||
How Can I Contribute?
|
||||
==================================
|
||||
|
||||
We welcome new contributors! We have a number of issues marked as
|
||||
["up for grabs"](https://github.com/libgit2/libgit2/issues?q=is%3Aissue+is%3Aopen+label%3A%22up+for+grabs%22)
|
||||
and
|
||||
["easy fix"](https://github.com/libgit2/libgit2/issues?utf8=✓&q=is%3Aissue+is%3Aopen+label%3A%22easy+fix%22)
|
||||
that are good places to jump in and get started. There's much more detailed
|
||||
information in our list of [outstanding projects](PROJECTS.md).
|
||||
|
||||
Please be sure to check the [contribution guidelines](CONTRIBUTING.md) to
|
||||
understand our workflow, and the libgit2 [coding conventions](CONVENTIONS.md).
|
||||
|
||||
License
|
||||
==================================
|
||||
|
||||
`libgit2` is under GPL2 **with linking exception**. This means you can link to
|
||||
and use the library from any program, proprietary or open source; paid or
|
||||
gratis. However, if you modify libgit2 itself, you must distribute the
|
||||
source to your modified version of libgit2.
|
||||
|
||||
See the [COPYING file](COPYING) for the full license text.
|
20
fuzzers/corpora/objects/commit
Normal file
20
fuzzers/corpora/objects/commit
Normal file
@ -0,0 +1,20 @@
|
||||
tree 3e7ac388cadae960fe7e22175ce0da878afe9d18
|
||||
parent 8b89f362a34fcccdf1c6c5f3445895b71d9c6d56
|
||||
parent c590b41fe4057a84a9bd31a5605ceef2c309b0f8
|
||||
author Patrick Steinhardt <ps@pks.im> 1538760730 +0200
|
||||
committer GitHub <noreply@github.com> 1538760730 +0200
|
||||
gpgsig -----BEGIN PGP SIGNATURE-----
|
||||
|
||||
wsBcBAABCAAQBQJbt6AaCRBK7hj4Ov3rIwAAdHIIAKZGIpS0dAirVRt5NVFj3ZtC
|
||||
o2Q3ADC0XpYLKkEsClhG7pVtr7MRZZ8+qaJpbxn9j9WZZ4UtEeDjseos+pMNn9Mf
|
||||
OQQntNzGAbHSw0apyYT+mTUKaVONPev4fw9Lnc/RJ/iWwHx+4gmgNqLwV3foaCW9
|
||||
w1JzCL+BVJyZI80jrEehihhUnpIUOuMBwGjzSt54Zn5JqviC4cIldF2sXFGQqvsq
|
||||
3WDNnEUYanU6cLAdb9Pd6bVBI1EJnRLxehSeYiSaRPmLhQyhkH8KZ5lSi8iuH1C4
|
||||
bjA6HaEUwCeq0k9Le6BUu93BExEOFcuu8+zEKCrwCdSwdEQ3Iakv8dh7XlT9iUY=
|
||||
=nGP0
|
||||
-----END PGP SIGNATURE-----
|
||||
|
||||
|
||||
Merge pull request #4834 from pks-t/pks/v0.27.5
|
||||
|
||||
Security release v0.27.5
|
6
fuzzers/corpora/objects/tag
Normal file
6
fuzzers/corpora/objects/tag
Normal file
@ -0,0 +1,6 @@
|
||||
object a8d447f68076d1520f69649bb52629941be7031f
|
||||
type commit
|
||||
tag testtag
|
||||
tagger Patrick Steinhardt <ps@pks.im> 1539253015 +0200
|
||||
|
||||
Tag message
|
BIN
fuzzers/corpora/objects/tree
Normal file
BIN
fuzzers/corpora/objects/tree
Normal file
Binary file not shown.
@ -0,0 +1 @@
|
||||
ミPACK
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1 @@
|
||||
i
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1 @@
|
||||
<EFBFBD>
|
@ -0,0 +1 @@
|
||||
R
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1 @@
|
||||
\
|
@ -0,0 +1 @@
|
||||
<0F>
|
@ -0,0 +1 @@
|
||||
9
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1 @@
|
||||
ミPACK<05><>
|
@ -0,0 +1 @@
|
||||
x
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user