diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 000000000..29507c8f0 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,244 @@ +# Continuous integration and pull request validation builds for the +# master and maintenance branches. +name: CI Build + +on: + push: + branches: [ master, maint/* ] + pull_request: + branches: [ master, maint/* ] + +env: + docker-registry: docker.pkg.github.com + docker-config-path: azure-pipelines/docker + +jobs: + # Build the docker container images that we will use for our Linux + # builds. This will identify the last commit to the repository that + # updated the docker images, and try to download the image tagged with + # that sha. If it does not exist, we'll do a docker build and push + # the image up to GitHub Packages for the actual CI/CD runs. We tag + # with both the sha and "latest" so that the subsequent runs need not + # know the sha. Only do this on CI builds (when the event is a "push") + # because PR builds from forks lack permission to write packages. + build_containers: + name: Create docker image + strategy: + matrix: + container: + - xenial + - bionic + - focal + - docurium + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v2 + with: + fetch-depth: 0 + if: github.event_name == 'push' + - name: Download existing container + run: azure-pipelines/getcontainer.sh ${{ env.docker-config-path }}/${{ matrix.container }} + env: + DOCKER_REGISTRY: ${{ env.docker-registry }} + GITHUB_TOKEN: ${{ secrets.github_token }} + if: github.event_name == 'push' + - name: Build and publish image + run: | + docker build -t ${{ env.docker-registry-container-sha }} --build-arg BASE=${{ matrix.container.base }} -f ${{ matrix.container }} . + docker push ${{ env.docker-registry-container-sha }} + working-directory: ${{ env.docker-config-path }} + if: github.event_name == 'push' && env.docker-container-exists != 'true' + + # Run our CI/CD builds. We build a matrix with the various build targets + # and their details. Then we build either in a docker container (Linux) + # or on the actual hosts (macOS, Windows). + build: + name: Build + needs: [build_containers] + strategy: + matrix: + platform: + - # Xenial, GCC, OpenSSL + image: xenial + env: + CC: gcc + CMAKE_GENERATOR: Ninja + CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DREGEX_BACKEND=builtin -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON + os: ubuntu-latest + - # Xenial, GCC, mbedTLS + image: xenial + env: + CC: gcc + CMAKE_GENERATOR: Ninja + CMAKE_OPTIONS: -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON + os: ubuntu-latest + - # Xenial, Clang, OpenSSL + image: xenial + env: + CC: clang + CMAKE_GENERATOR: Ninja + CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON + os: ubuntu-latest + - # Xenial, Clang, mbedTLS + image: xenial + env: + CC: clang + CMAKE_OPTIONS: -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON + CMAKE_GENERATOR: Ninja + os: ubuntu-latest + - # Focal, Clang 10, mbedTLS, MemorySanitizer + image: focal + env: + CC: clang-10 + CFLAGS: -fsanitize=memory -fsanitize-memory-track-origins=2 -fsanitize-blacklist=/home/libgit2/source/script/sanitizers.supp -fno-optimize-sibling-calls -fno-omit-frame-pointer + CMAKE_OPTIONS: -DCMAKE_PREFIX_PATH=/usr/local/msan -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_BUNDLED_ZLIB=ON + CMAKE_GENERATOR: Ninja + SKIP_SSH_TESTS: true + SKIP_NEGOTIATE_TESTS: true + ASAN_SYMBOLIZER_PATH: /usr/bin/llvm-symbolizer-10 + os: ubuntu-latest + - # Focal, Clang 10, OpenSSL, UndefinedBehaviorSanitizer + image: focal + env: + CC: clang-10 + CFLAGS: -fsanitize=undefined,nullability -fno-sanitize-recover=undefined,nullability -fsanitize-blacklist=/home/libgit2/source/script/sanitizers.supp -fno-optimize-sibling-calls -fno-omit-frame-pointer + CMAKE_OPTIONS: -DCMAKE_PREFIX_PATH=/usr/local -DUSE_HTTPS=OpenSSL -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_BUNDLED_ZLIB=ON + CMAKE_GENERATOR: Ninja + SKIP_SSH_TESTS: true + SKIP_NEGOTIATE_TESTS: true + ASAN_SYMBOLIZER_PATH: /usr/bin/llvm-symbolizer-10 + os: ubuntu-latest + - # macOS + os: macos-10.15 + env: + CC: clang + CMAKE_OPTIONS: -DREGEX_BACKEND=regcomp_l -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=leaks -DUSE_GSSAPI=ON + CMAKE_GENERATOR: Ninja + PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig + SKIP_SSH_TESTS: true + SKIP_NEGOTIATE_TESTS: true + setup-script: osx + - # Windows amd64 Visual Studio + os: windows-2019 + env: + ARCH: amd64 + CMAKE_GENERATOR: Visual Studio 16 2019 + CMAKE_OPTIONS: -A x64 -DMSVC_CRTDBG=ON -DDEPRECATE_HARD=ON + SKIP_SSH_TESTS: true + SKIP_NEGOTIATE_TESTS: true + - # Windows x86 Visual Studio + os: windows-2019 + env: + ARCH: x86 + CMAKE_GENERATOR: Visual Studio 16 2019 + CMAKE_OPTIONS: -A Win32 -DMSVC_CRTDBG=ON -DDEPRECATE_HARD=ON -DUSE_SHA1=HTTPS -DUSE_BUNDLED_ZLIB=ON + SKIP_SSH_TESTS: true + SKIP_NEGOTIATE_TESTS: true + - # Windows amd64 mingw + os: windows-2019 + setup-script: mingw + env: + ARCH: amd64 + CMAKE_GENERATOR: MinGW Makefiles + CMAKE_OPTIONS: -DDEPRECATE_HARD=ON + BUILD_TEMP: D:\Temp + BUILD_PATH: D:\Temp\mingw64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin + SKIP_SSH_TESTS: true + SKIP_NEGOTIATE_TESTS: true + - # Windows x86 mingw + os: windows-2019 + setup-script: mingw + env: + ARCH: x86 + CMAKE_GENERATOR: MinGW Makefiles + CMAKE_OPTIONS: -DDEPRECATE_HARD=ON + BUILD_TEMP: D:\Temp + BUILD_PATH: D:\Temp\mingw32\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin + SKIP_SSH_TESTS: true + SKIP_NEGOTIATE_TESTS: true + fail-fast: false + env: ${{ matrix.platform.env }} + runs-on: ${{ matrix.platform.os }} + steps: + - name: Check out repository + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set up build environment + run: azure-pipelines/setup-${{ matrix.platform.setup-script }}.sh + shell: bash + if: matrix.platform.setup-script != '' + - name: Download container + run: azure-pipelines/getcontainer.sh ${{ env.docker-config-path }}/${{ matrix.platform.image }} + env: + DOCKER_REGISTRY: ${{ env.docker-registry }} + GITHUB_TOKEN: ${{ secrets.github_token }} + if: matrix.platform.image != '' + - name: Create container + run: docker build -t ${{ env.docker-registry-container-sha }} -f ${{ matrix.platform.image }} . + working-directory: ${{ env.docker-config-path }} + if: matrix.platform.image != '' && env.docker-container-exists != 'true' + - name: Build and test + run: | + export GITTEST_NEGOTIATE_PASSWORD="${{ secrets.GITTEST_NEGOTIATE_PASSWORD }}" + + if [ -n "${{ matrix.platform.image }}" ]; then + docker run \ + --rm \ + -v "$(pwd):/home/libgit2/source" \ + -w /home/libgit2/source \ + -e ASAN_SYMBOLIZER_PATH \ + -e CC \ + -e CFLAGS \ + -e CMAKE_GENERATOR \ + -e CMAKE_OPTIONS \ + -e GITTEST_NEGOTIATE_PASSWORD \ + -e PKG_CONFIG_PATH \ + -e SKIP_NEGOTIATE_TESTS \ + -e SKIP_SSH_TESTS \ + ${{ env.docker-registry-container-sha }} \ + /bin/bash -c "mkdir build && cd build && ../azure-pipelines/build.sh && ../azure-pipelines/test.sh" + else + mkdir build && cd build + ../azure-pipelines/build.sh + ../azure-pipelines/test.sh + fi + shell: bash + + # Generate documentation using docurium. We'll upload the documentation + # as a build artifact so that it can be reviewed as part of a pull + # request or in a forked build. For CI builds in the main repository's + # master branch, we'll push the gh-pages branch back up so that it is + # published to our documentation site. + documentation: + name: Generate documentation + needs: [build_containers] + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Generate documentation + run: | + git config user.name 'Documentation Generation' + git config user.email 'libgit2@users.noreply.github.com' + git branch gh-pages origin/gh-pages + docker login https://${{ env.docker-registry }} -u ${{ github.actor }} -p ${{ github.token }} + docker run \ + --rm \ + -v "$(pwd):/home/libgit2/source" \ + -w /home/libgit2/source \ + ${{ env.docker-registry }}/${{ github.repository }}/docurium:latest \ + cm doc api.docurium + git checkout gh-pages + zip --exclude .git/\* --exclude .gitignore --exclude .gitattributes -r api-documentation.zip . + - uses: actions/upload-artifact@v2 + name: Upload artifact + with: + name: api-documentation + path: api-documentation.zip + - name: Push documentation branch + run: git push origin gh-pages + if: github.event_name == 'push' && github.repository == 'libgit2/libgit2' diff --git a/.gitignore b/.gitignore index dec3dca06..b38b7e16e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,37 +1,7 @@ -/tests/clar.suite -/tests/clar.suite.rule -/tests/.clarcache -/apidocs -/trash-*.exe -/libgit2.pc -/config.mak -*.o -*.a -*.exe -*.gcda -*.gcno -*.gcov -.lock-wafbuild -.waf* build/ -build-amiga/ -tests/tmp/ -msvc/Debug/ -msvc/Release/ -*.sln -*.suo -*.vc*proj* -*.sdf -*.opensdf -*.aps -*.cmake -!cmake/Modules/*.cmake .DS_Store *~ .*.swp tags -mkmf.log -*.profdata -*.profraw CMakeSettings.json .vs diff --git a/CMakeLists.txt b/CMakeLists.txt index 826415893..b6f23cf6b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,21 +11,12 @@ # Install: # > cmake --build . --target install -PROJECT(libgit2 C) CMAKE_MINIMUM_REQUIRED(VERSION 3.5.1) -CMAKE_POLICY(SET CMP0015 NEW) -IF(POLICY CMP0051) - CMAKE_POLICY(SET CMP0051 NEW) -ENDIF() -IF(POLICY CMP0042) - CMAKE_POLICY(SET CMP0042 NEW) -ENDIF() -IF(POLICY CMP0054) - CMAKE_POLICY(SET CMP0054 NEW) -ENDIF() + +project(libgit2 VERSION "1.1.0" LANGUAGES C) # Add find modules to the path -SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${libgit2_SOURCE_DIR}/cmake/Modules/") +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${libgit2_SOURCE_DIR}/cmake/") INCLUDE(CheckLibraryExists) INCLUDE(CheckFunctionExists) @@ -49,8 +40,6 @@ 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" ON) OPTION(LIBGIT2_FILENAME "Name of the produced binary" OFF) OPTION(USE_SSH "Link with libssh2 to enable SSH support" ON) @@ -104,16 +93,6 @@ IF(MSVC) 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 \"[^\"]*\"$") - -STRING(REGEX REPLACE "^.*LIBGIT2_VERSION \"([0-9]+).*$" "\\1" LIBGIT2_VERSION_MAJOR "${GIT2_HEADER}") -STRING(REGEX REPLACE "^.*LIBGIT2_VERSION \"[0-9]+\\.([0-9]+).*$" "\\1" LIBGIT2_VERSION_MINOR "${GIT2_HEADER}") -STRING(REGEX REPLACE "^.*LIBGIT2_VERSION \"[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" LIBGIT2_VERSION_REV "${GIT2_HEADER}") -SET(LIBGIT2_VERSION_STRING "${LIBGIT2_VERSION_MAJOR}.${LIBGIT2_VERSION_MINOR}.${LIBGIT2_VERSION_REV}") - -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() @@ -137,6 +116,11 @@ IF (MSVC) # /Gd - explicitly set cdecl calling convention SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Gd") + IF (NOT (MSVC_VERSION LESS 1900)) + # /guard:cf - Enable Control Flow Guard + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /guard:cf") + ENDIF() + IF (STATIC_CRT) SET(CRT_FLAG_DEBUG "/MTd") SET(CRT_FLAG_RELEASE "/MT") @@ -181,7 +165,12 @@ IF (MSVC) # /NXCOMPAT - Data execution prevention (DEP) # /LARGEADDRESSAWARE - >2GB user address space on x86 # /VERSION - Embed version information in PE header - SET(CMAKE_EXE_LINKER_FLAGS "/DYNAMICBASE /NXCOMPAT /LARGEADDRESSAWARE /VERSION:${LIBGIT2_VERSION_MAJOR}.${LIBGIT2_VERSION_MINOR}") + SET(CMAKE_EXE_LINKER_FLAGS "/DYNAMICBASE /NXCOMPAT /LARGEADDRESSAWARE /VERSION:${libgit2_VERSION_MAJOR}.${libgit2_VERSION_MINOR}") + + IF (NOT (MSVC_VERSION LESS 1900)) + # /GUARD:CF - Enable Control Flow Guard + SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /GUARD:CF") + ENDIF() # /DEBUG - Create a PDB # /LTCG - Link time code generation (whole program optimization) @@ -232,35 +221,27 @@ ELSE () ADD_DEFINITIONS(-D__USE_MINGW_ANSI_STDIO=1) ENDIF () - ENABLE_WARNINGS(documentation) - DISABLE_WARNINGS(missing-field-initializers) - ENABLE_WARNINGS(strict-aliasing) - ENABLE_WARNINGS(strict-prototypes) - ENABLE_WARNINGS(declaration-after-statement) - ENABLE_WARNINGS(shift-count-overflow) - ENABLE_WARNINGS(unused-const-variable) - ENABLE_WARNINGS(unused-function) - ENABLE_WARNINGS(int-conversion) + enable_warnings(documentation) + disable_warnings(documentation-deprecated-sync) + disable_warnings(missing-field-initializers) + enable_warnings(strict-aliasing) + enable_warnings(strict-prototypes) + enable_warnings(declaration-after-statement) + enable_warnings(shift-count-overflow) + enable_warnings(unused-const-variable) + enable_warnings(unused-function) + enable_warnings(int-conversion) # MinGW uses gcc, which expects POSIX formatting for printf, but # uses the Windows C library, which uses its own format specifiers. # Disable format specifier warnings. - IF(MINGW) - DISABLE_WARNINGS(format) - DISABLE_WARNINGS(format-security) - ELSE() - ENABLE_WARNINGS(format) - ENABLE_WARNINGS(format-security) - ENDIF() - - IF("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") - DISABLE_WARNINGS(documentation-deprecated-sync) - ENDIF() - - IF (PROFILE) - SET(CMAKE_C_FLAGS "-pg ${CMAKE_C_FLAGS}") - SET(CMAKE_EXE_LINKER_FLAGS "-pg ${CMAKE_EXE_LINKER_FLAGS}") - ENDIF () + if(MINGW) + disable_warnings(format) + disable_warnings(format-security) + else() + enable_warnings(format) + enable_warnings(format-security) + endif() ENDIF() # Ensure that MinGW provides the correct header files. @@ -300,25 +281,6 @@ IF (BUILD_CLAR) ADD_SUBDIRECTORY(tests) ENDIF () -IF (TAGS) - FIND_PROGRAM(CTAGS ctags) - IF (NOT CTAGS) - MESSAGE(FATAL_ERROR "Could not find ctags command") - ENDIF () - - FILE(GLOB_RECURSE SRC_ALL *.[ch]) - - ADD_CUSTOM_COMMAND( - OUTPUT tags - COMMAND ${CTAGS} -a ${SRC_ALL} - DEPENDS ${SRC_ALL} - ) - ADD_CUSTOM_TARGET( - do_tags ALL - DEPENDS tags - ) -ENDIF () - IF (BUILD_EXAMPLES) ADD_SUBDIRECTORY(examples) ENDIF () diff --git a/README.md b/README.md index b5f04403b..a91f16067 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ libgit2 - the Git linkable library | Build Status | | | ------------ | - | | **master** branch CI builds | [![Azure Pipelines Build Status](https://dev.azure.com/libgit2/libgit2/_apis/build/status/libgit2?branchName=master)](https://dev.azure.com/libgit2/libgit2/_build/latest?definitionId=7&branchName=master) | -| **v0.99 branch** CI builds | [![Azure Pipelines Build Status](https://dev.azure.com/libgit2/libgit2/_apis/build/status/libgit2?branchName=maint/v0.99)](https://dev.azure.com/libgit2/libgit2/_build/latest?definitionId=7&branchName=maint/v0.99) | +| **v1.0 branch** CI builds | [![Azure Pipelines Build Status](https://dev.azure.com/libgit2/libgit2/_apis/build/status/libgit2?branchName=maint/v1.0)](https://dev.azure.com/libgit2/libgit2/_build/latest?definitionId=7&branchName=maint/v1.0) | | **v0.28 branch** CI builds | [![Azure Pipelines Build Status](https://dev.azure.com/libgit2/libgit2/_apis/build/status/libgit2?branchName=maint/v0.28)](https://dev.azure.com/libgit2/libgit2/_build/latest?definitionId=7&branchName=maint/v0.28) | | **Nightly** builds | [![Azure Pipelines Build Status](https://libgit2.visualstudio.com/libgit2/_apis/build/status/nightly?branchName=master&label=Full+Build)](https://libgit2.visualstudio.com/libgit2/_build/latest?definitionId=9&branchName=master) [![Coverity Build Status](https://dev.azure.com/libgit2/libgit2/_apis/build/status/coverity?branchName=master&label=Coverity+Build)](https://dev.azure.com/libgit2/libgit2/_build/latest?definitionId=21?branchName=master) [![Coverity Scan Build Status](https://scan.coverity.com/projects/639/badge.svg)](https://scan.coverity.com/projects/639) | @@ -47,6 +47,7 @@ Table of Contents * [Compiler and linker options](#compiler-and-linker-options) * [MacOS X](#macos-x) * [Android](#android) + * [MinGW](#mingw) * [Language Bindings](#language-bindings) * [How Can I Contribute?](#how-can-i-contribute) * [License](#license) @@ -304,6 +305,20 @@ with full path to the toolchain): Add `-DCMAKE_TOOLCHAIN_FILE={pathToToolchainFile}` to cmake command when configuring. +MinGW +----- + +If you want to build the library in MinGW environment with SSH support enabled, +you may need to pass `-DCMAKE_LIBRARY_PATH="${MINGW_PREFIX}/${MINGW_CHOST}/lib/"` flag +to CMake when configuring. This is because CMake cannot find the Win32 libraries in +MinGW folders by default and you might see an error message stating that CMake +could not resolve `ws2_32` library during configuration. + +Another option would be to install `msys2-w32api-runtime` package before configuring. +This package installs the Win32 libraries into `/usr/lib` folder which is by default +recognized as the library path by CMake. Please note though that this package is meant +for MSYS subsystem which is different from MinGW. + Language Bindings ================================== diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 20335b33a..f3690b8ec 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -96,7 +96,7 @@ jobs: parameters: environmentVariables: CMAKE_GENERATOR: Visual Studio 15 2017 - CMAKE_OPTIONS: -A x64 -DMSVC_CRTDBG=ON -DDEPRECATE_HARD=ON + CMAKE_OPTIONS: -A x64 -DMSVC_CRTDBG=ON -DDEPRECATE_HARD=ON -DUSE_BUNDLED_ZLIB=ON SKIP_SSH_TESTS: true SKIP_NEGOTIATE_TESTS: true @@ -109,7 +109,7 @@ jobs: parameters: environmentVariables: CMAKE_GENERATOR: Visual Studio 15 2017 - CMAKE_OPTIONS: -A Win32 -DMSVC_CRTDBG=ON -DDEPRECATE_HARD=ON -DUSE_SHA1=HTTPS + CMAKE_OPTIONS: -A Win32 -DMSVC_CRTDBG=ON -DDEPRECATE_HARD=ON -DUSE_SHA1=HTTPS -DUSE_BUNDLED_ZLIB=ON SKIP_SSH_TESTS: true SKIP_NEGOTIATE_TESTS: true @@ -151,40 +151,3 @@ jobs: CMAKE_OPTIONS: -DDEPRECATE_HARD=ON SKIP_SSH_TESTS: true SKIP_NEGOTIATE_TESTS: true - -- job: documentation - displayName: 'Generate Documentation' - pool: - vmImage: 'ubuntu-18.04' - steps: - - script: | - cd $(Build.SourcesDirectory)/azure-pipelines/docker - docker build -t libgit2/docurium --build-arg BASE=ubuntu:trusty -f docurium . - displayName: 'Build Docker image' - - script: | - git config user.name 'Documentation Generation' - git config user.email 'libgit2@users.noreply.github.com' - git branch gh-pages origin/gh-pages - docker run --rm -v $(Build.SourcesDirectory):/home/libgit2/source -w /home/libgit2/source libgit2/docurium:latest cm doc api.docurium - git checkout gh-pages - cp -R * '$(Build.BinariesDirectory)' - displayName: 'Generate Documentation' - - task: archivefiles@2 - displayName: 'Archive Documentation' - inputs: - rootFolderOrFile: '$(Build.BinariesDirectory)' - includeRootFolder: false - archiveFile: '$(Build.ArtifactStagingDirectory)/api-documentation.zip' - - task: publishbuildartifacts@1 - displayName: 'Upload Documentation Artifact' - inputs: - pathToPublish: '$(Build.ArtifactStagingDirectory)' - artifactName: 'docs' - - script: | - git remote -v - echo 'machine github.com' > ~/.netrc - echo 'login $(GITHUB_USERNAME)' >> ~/.netrc - echo 'password $(GITHUB_PAT)' >> ~/.netrc - git push origin gh-pages - displayName: 'Publish Documentation' - condition: and(eq(variables['Build.Repository.Name'], 'libgit2/libgit2'), eq(variables['Build.Reason'], 'IndividualCI')) diff --git a/azure-pipelines/build.sh b/azure-pipelines/build.sh index 27e2f3e38..c230e67d6 100755 --- a/azure-pipelines/build.sh +++ b/azure-pipelines/build.sh @@ -13,6 +13,10 @@ BUILD_PATH=${BUILD_PATH:=$PATH} CMAKE=$(which cmake) CMAKE_GENERATOR=${CMAKE_GENERATOR:-Unix Makefiles} +if [[ "$(uname -s)" == MINGW* ]]; then + BUILD_PATH=$(cygpath "$BUILD_PATH") +fi + indent() { sed "s/^/ /"; } echo "Source directory: ${SOURCE_DIR}" @@ -33,11 +37,18 @@ echo "Kernel version:" uname -a 2>&1 | indent echo "CMake version:" -env PATH="$BUILD_PATH" "$CMAKE" --version 2>&1 | indent +env PATH="${BUILD_PATH}" "${CMAKE}" --version 2>&1 | indent -if test -n "$CC"; then +if test -n "${CC}"; then echo "Compiler version:" - "$CC" --version 2>&1 | indent + "${CC}" --version 2>&1 | indent +fi +echo "Environment:" +if test -n "${CC}"; then + echo "CC=${CC}" | indent +fi +if test -n "${CFLAGS}"; then + echo "CFLAGS=${CFLAGS}" | indent fi echo "" @@ -45,12 +56,12 @@ echo "########################################################################## echo "## Configuring build environment" echo "##############################################################################" -echo cmake ${SOURCE_DIR} -DENABLE_WERROR=ON -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON -G \"${CMAKE_GENERATOR}\" ${CMAKE_OPTIONS} -env PATH="$BUILD_PATH" "$CMAKE" ${SOURCE_DIR} -DENABLE_WERROR=ON -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON -G "${CMAKE_GENERATOR}" ${CMAKE_OPTIONS} +echo cmake -DENABLE_WERROR=ON -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON -G \"${CMAKE_GENERATOR}\" ${CMAKE_OPTIONS} -S \"${SOURCE_DIR}\" +env PATH="${BUILD_PATH}" "${CMAKE}" -DENABLE_WERROR=ON -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON -G "${CMAKE_GENERATOR}" ${CMAKE_OPTIONS} -S "${SOURCE_DIR}" echo "" echo "##############################################################################" echo "## Building libgit2" echo "##############################################################################" -env PATH="$BUILD_PATH" "$CMAKE" --build . +env PATH="${BUILD_PATH}" "${CMAKE}" --build . diff --git a/azure-pipelines/docker/bionic b/azure-pipelines/docker/bionic index 65a14063a..5918584dc 100644 --- a/azure-pipelines/docker/bionic +++ b/azure-pipelines/docker/bionic @@ -1,5 +1,4 @@ -ARG BASE -FROM $BASE AS apt +FROM ubuntu:bionic AS apt RUN apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ clang \ diff --git a/azure-pipelines/docker/focal b/azure-pipelines/docker/focal new file mode 100644 index 000000000..c75e85a4c --- /dev/null +++ b/azure-pipelines/docker/focal @@ -0,0 +1,79 @@ +FROM ubuntu:focal AS apt +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + bzip2 \ + clang-10 \ + cmake \ + curl \ + gcc-10 \ + git \ + krb5-user \ + libcurl4-gnutls-dev \ + libgcrypt20-dev \ + libkrb5-dev \ + libpcre3-dev \ + libssl-dev \ + libz-dev \ + llvm-10 \ + make \ + ninja-build \ + openjdk-8-jre-headless \ + openssh-server \ + openssl \ + pkgconf \ + python \ + sudo \ + valgrind \ + && \ + rm -rf /var/lib/apt/lists/* && \ + mkdir /usr/local/msan + +FROM apt AS mbedtls +RUN cd /tmp && \ + curl --location --silent --show-error https://tls.mbed.org/download/mbedtls-2.16.2-apache.tgz | \ + tar -xz && \ + cd mbedtls-2.16.2 && \ + scripts/config.pl unset MBEDTLS_AESNI_C && \ + scripts/config.pl set MBEDTLS_MD4_C 1 && \ + mkdir build build-msan && \ + cd build && \ + CC=clang-10 CFLAGS="-fPIC" cmake -G Ninja -DENABLE_PROGRAMS=OFF -DENABLE_TESTING=OFF -DUSE_SHARED_MBEDTLS_LIBRARY=ON -DUSE_STATIC_MBEDTLS_LIBRARY=OFF -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=/usr/local -DCMAKE_INSTALL_PREFIX=/usr/local .. && \ + ninja install && \ + cd ../build-msan && \ + CC=clang-10 CFLAGS="-fPIC" cmake -G Ninja -DENABLE_PROGRAMS=OFF -DENABLE_TESTING=OFF -DUSE_SHARED_MBEDTLS_LIBRARY=ON -DUSE_STATIC_MBEDTLS_LIBRARY=OFF -DCMAKE_BUILD_TYPE=MemSanDbg -DCMAKE_INSTALL_PREFIX=/usr/local/msan .. && \ + ninja install && \ + cd .. && \ + rm -rf mbedtls-2.16.2 + +FROM mbedtls AS libssh2 +RUN cd /tmp && \ + curl --insecure --location --silent --show-error https://www.libssh2.org/download/libssh2-1.8.2.tar.gz | \ + tar -xz && \ + cd libssh2-1.8.2 && \ + mkdir build build-msan && \ + cd build && \ + CC=clang-10 CFLAGS="-fPIC" cmake -G Ninja -DBUILD_SHARED_LIBS=ON -DCRYPTO_BACKEND=Libgcrypt -DCMAKE_PREFIX_PATH=/usr/local -DCMAKE_INSTALL_PREFIX=/usr/local .. && \ + ninja install && \ + cd ../build-msan && \ + CC=clang-10 CFLAGS="-fPIC -fsanitize=memory -fno-optimize-sibling-calls -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer" LDFLAGS="-fsanitize=memory" cmake -G Ninja -DBUILD_SHARED_LIBS=ON -DCRYPTO_BACKEND=mbedTLS -DCMAKE_PREFIX_PATH=/usr/local/msan -DCMAKE_INSTALL_PREFIX=/usr/local/msan .. && \ + ninja install && \ + cd .. && \ + rm -rf libssh2-1.8.2 + +FROM libssh2 AS valgrind +RUN cd /tmp && \ + curl --insecure --location --silent --show-error https://sourceware.org/pub/valgrind/valgrind-3.15.0.tar.bz2 | \ + tar -xj && \ + cd valgrind-3.15.0 && \ + CC=clang-10 ./configure && \ + make MAKEFLAGS="-j -l$(grep -c ^processor /proc/cpuinfo)" && \ + make install && \ + cd .. && \ + rm -rf valgrind-3.15.0 + +FROM valgrind AS configure +COPY entrypoint.sh /usr/local/bin/entrypoint.sh +RUN chmod a+x /usr/local/bin/entrypoint.sh +RUN mkdir /var/run/sshd + +ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] diff --git a/azure-pipelines/docker/xenial b/azure-pipelines/docker/xenial index bfb96d9db..67867edc6 100644 --- a/azure-pipelines/docker/xenial +++ b/azure-pipelines/docker/xenial @@ -1,5 +1,4 @@ -ARG BASE -FROM $BASE AS apt +FROM ubuntu:xenial AS apt RUN apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ bzip2 \ diff --git a/azure-pipelines/getcontainer.sh b/azure-pipelines/getcontainer.sh new file mode 100755 index 000000000..bc93f4919 --- /dev/null +++ b/azure-pipelines/getcontainer.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +set -e + +DOCKERFILE_PATH=$1 + +if [ "${DOCKERFILE_PATH}" = "" ]; then + echo "usage: $0 dockerfile" + exit 1 +fi + +if [ "${DOCKER_REGISTRY}" = "" ]; then + echo "DOCKER_REGISTRY environment variable is unset." + echo "Not running inside GitHub Actions or misconfigured?" + exit 1 +fi + +DOCKER_CONTAINER="${GITHUB_REPOSITORY}/$(basename ${DOCKERFILE_PATH})" +DOCKER_REGISTRY_CONTAINER="${DOCKER_REGISTRY}/${DOCKER_CONTAINER}" + +echo "::set-env name=docker-container::${DOCKER_CONTAINER}" +echo "::set-env name=docker-registry-container::${DOCKER_REGISTRY_CONTAINER}" + +# Identify the last git commit that touched the Dockerfiles +# Use this as a hash to identify the resulting docker containers +DOCKER_SHA=$(git log -1 --pretty=format:"%h" -- "${DOCKERFILE_PATH}") +echo "::set-env name=docker-sha::${DOCKER_SHA}" + +DOCKER_REGISTRY_CONTAINER_SHA="${DOCKER_REGISTRY_CONTAINER}:${DOCKER_SHA}" + +echo "::set-env name=docker-registry-container-sha::${DOCKER_REGISTRY_CONTAINER_SHA}" +echo "::set-env name=docker-registry-container-latest::${DOCKER_REGISTRY_CONTAINER}:latest" + +exists="true" +docker login https://${DOCKER_REGISTRY} -u ${GITHUB_ACTOR} -p ${GITHUB_TOKEN} || exists="false" + +if [ "${exists}" != "false" ]; then + docker pull ${DOCKER_REGISTRY_CONTAINER_SHA} || exists="false" +fi + +if [ "${exists}" = "true" ]; then + echo "::set-env name=docker-container-exists::true" +else + echo "::set-env name=docker-container-exists::false" +fi diff --git a/azure-pipelines/setup-mingw.sh b/azure-pipelines/setup-mingw.sh index 1172c2077..d500da058 100755 --- a/azure-pipelines/setup-mingw.sh +++ b/azure-pipelines/setup-mingw.sh @@ -4,6 +4,9 @@ echo "########################################################################## echo "## Downloading mingw" echo "##############################################################################" +BUILD_TEMP=${BUILD_TEMP:=$TEMP} +BUILD_TEMP=$(cygpath $BUILD_TEMP) + case "$ARCH" in amd64) MINGW_URI="https://bintray.com/libgit2/build-dependencies/download_file?file_path=mingw-w64-x86_64-8.1.0-release-win32-seh-rt_v6-rev0.zip";; @@ -11,5 +14,12 @@ case "$ARCH" in MINGW_URI="https://bintray.com/libgit2/build-dependencies/download_file?file_path=mingw-w64-i686-8.1.0-release-win32-sjlj-rt_v6-rev0.zip";; esac -curl -s -L "$MINGW_URI" -o "$TEMP"/mingw-"$ARCH".zip -unzip -q "$TEMP"/mingw-"$ARCH".zip -d "$TEMP" +if [ -z "$MINGW_URI" ]; then + echo "No URL" + exit 1 +fi + +mkdir -p "$BUILD_TEMP" + +curl -s -L "$MINGW_URI" -o "$BUILD_TEMP"/mingw-"$ARCH".zip +unzip -q "$BUILD_TEMP"/mingw-"$ARCH".zip -d "$BUILD_TEMP" diff --git a/cmake/Modules/AddCFlagIfSupported.cmake b/cmake/AddCFlagIfSupported.cmake similarity index 100% rename from cmake/Modules/AddCFlagIfSupported.cmake rename to cmake/AddCFlagIfSupported.cmake diff --git a/cmake/Modules/EnableWarnings.cmake b/cmake/EnableWarnings.cmake similarity index 100% rename from cmake/Modules/EnableWarnings.cmake rename to cmake/EnableWarnings.cmake diff --git a/cmake/Modules/FindCoreFoundation.cmake b/cmake/FindCoreFoundation.cmake similarity index 100% rename from cmake/Modules/FindCoreFoundation.cmake rename to cmake/FindCoreFoundation.cmake diff --git a/cmake/Modules/FindGSSAPI.cmake b/cmake/FindGSSAPI.cmake similarity index 100% rename from cmake/Modules/FindGSSAPI.cmake rename to cmake/FindGSSAPI.cmake diff --git a/cmake/Modules/FindGSSFramework.cmake b/cmake/FindGSSFramework.cmake similarity index 100% rename from cmake/Modules/FindGSSFramework.cmake rename to cmake/FindGSSFramework.cmake diff --git a/cmake/Modules/FindHTTP_Parser.cmake b/cmake/FindHTTP_Parser.cmake similarity index 100% rename from cmake/Modules/FindHTTP_Parser.cmake rename to cmake/FindHTTP_Parser.cmake diff --git a/cmake/Modules/FindIconv.cmake b/cmake/FindIconv.cmake similarity index 100% rename from cmake/Modules/FindIconv.cmake rename to cmake/FindIconv.cmake diff --git a/cmake/Modules/FindPCRE.cmake b/cmake/FindPCRE.cmake similarity index 100% rename from cmake/Modules/FindPCRE.cmake rename to cmake/FindPCRE.cmake diff --git a/cmake/Modules/FindPCRE2.cmake b/cmake/FindPCRE2.cmake similarity index 100% rename from cmake/Modules/FindPCRE2.cmake rename to cmake/FindPCRE2.cmake diff --git a/cmake/Modules/FindPkgLibraries.cmake b/cmake/FindPkgLibraries.cmake similarity index 100% rename from cmake/Modules/FindPkgLibraries.cmake rename to cmake/FindPkgLibraries.cmake diff --git a/cmake/Modules/FindSecurity.cmake b/cmake/FindSecurity.cmake similarity index 100% rename from cmake/Modules/FindSecurity.cmake rename to cmake/FindSecurity.cmake diff --git a/cmake/Modules/FindStatNsec.cmake b/cmake/FindStatNsec.cmake similarity index 100% rename from cmake/Modules/FindStatNsec.cmake rename to cmake/FindStatNsec.cmake diff --git a/cmake/Modules/FindmbedTLS.cmake b/cmake/FindmbedTLS.cmake similarity index 100% rename from cmake/Modules/FindmbedTLS.cmake rename to cmake/FindmbedTLS.cmake diff --git a/cmake/Modules/IdeSplitSources.cmake b/cmake/IdeSplitSources.cmake similarity index 100% rename from cmake/Modules/IdeSplitSources.cmake rename to cmake/IdeSplitSources.cmake diff --git a/cmake/Modules/CheckPrototypeDefinition.c.in b/cmake/Modules/CheckPrototypeDefinition.c.in deleted file mode 100644 index a97344ac3..000000000 --- a/cmake/Modules/CheckPrototypeDefinition.c.in +++ /dev/null @@ -1,29 +0,0 @@ -@CHECK_PROTOTYPE_DEFINITION_HEADER@ - -static void cmakeRequireSymbol(int dummy, ...) { - (void) dummy; -} - -static void checkSymbol(void) { -#ifndef @CHECK_PROTOTYPE_DEFINITION_SYMBOL@ - cmakeRequireSymbol(0, &@CHECK_PROTOTYPE_DEFINITION_SYMBOL@); -#endif -} - -@CHECK_PROTOTYPE_DEFINITION_PROTO@ { - return @CHECK_PROTOTYPE_DEFINITION_RETURN@; -} - -#ifdef __CLASSIC_C__ -int main() { - int ac; - char*av[]; -#else -int main(int ac, char *av[]) { -#endif - checkSymbol(); - if (ac > 1000) { - return *av[0]; - } - return 0; -} diff --git a/cmake/Modules/CheckPrototypeDefinition.cmake b/cmake/Modules/CheckPrototypeDefinition.cmake deleted file mode 100644 index 244b9b53b..000000000 --- a/cmake/Modules/CheckPrototypeDefinition.cmake +++ /dev/null @@ -1,96 +0,0 @@ -# - Check if the protoype we expect is correct. -# check_prototype_definition(FUNCTION PROTOTYPE RETURN HEADER VARIABLE) -# FUNCTION - The name of the function (used to check if prototype exists) -# PROTOTYPE- The prototype to check. -# RETURN - The return value of the function. -# HEADER - The header files required. -# VARIABLE - The variable to store the result. -# Example: -# check_prototype_definition(getpwent_r -# "struct passwd *getpwent_r(struct passwd *src, char *buf, int buflen)" -# "NULL" -# "unistd.h;pwd.h" -# SOLARIS_GETPWENT_R) -# The following variables may be set before calling this macro to -# modify the way the check is run: -# -# CMAKE_REQUIRED_FLAGS = string of compile command line flags -# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) -# CMAKE_REQUIRED_INCLUDES = list of include directories -# CMAKE_REQUIRED_LIBRARIES = list of libraries to link - -#============================================================================= -# Copyright 2005-2009 Kitware, Inc. -# Copyright 2010-2011 Andreas Schneider -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) -# - -get_filename_component(__check_proto_def_dir "${CMAKE_CURRENT_LIST_FILE}" PATH) - -function(CHECK_PROTOTYPE_DEFINITION _FUNCTION _PROTOTYPE _RETURN _HEADER _VARIABLE) - - if ("${_VARIABLE}" MATCHES "^${_VARIABLE}$") - set(CHECK_PROTOTYPE_DEFINITION_CONTENT "/* */\n") - - set(CHECK_PROTOTYPE_DEFINITION_FLAGS ${CMAKE_REQUIRED_FLAGS}) - if (CMAKE_REQUIRED_LIBRARIES) - set(CHECK_PROTOTYPE_DEFINITION_LIBS - "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") - else(CMAKE_REQUIRED_LIBRARIES) - set(CHECK_PROTOTYPE_DEFINITION_LIBS) - endif(CMAKE_REQUIRED_LIBRARIES) - if (CMAKE_REQUIRED_INCLUDES) - set(CMAKE_SYMBOL_EXISTS_INCLUDES - "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}") - else(CMAKE_REQUIRED_INCLUDES) - set(CMAKE_SYMBOL_EXISTS_INCLUDES) - endif(CMAKE_REQUIRED_INCLUDES) - - foreach(_FILE ${_HEADER}) - set(CHECK_PROTOTYPE_DEFINITION_HEADER - "${CHECK_PROTOTYPE_DEFINITION_HEADER}#include <${_FILE}>\n") - endforeach(_FILE) - - set(CHECK_PROTOTYPE_DEFINITION_SYMBOL ${_FUNCTION}) - set(CHECK_PROTOTYPE_DEFINITION_PROTO ${_PROTOTYPE}) - set(CHECK_PROTOTYPE_DEFINITION_RETURN ${_RETURN}) - - configure_file("${__check_proto_def_dir}/CheckPrototypeDefinition.c.in" - "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c" @ONLY) - - file(READ ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c _SOURCE) - - try_compile(${_VARIABLE} - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c - COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} - CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${CHECK_PROTOTYPE_DEFINITION_FLAGS} - "${CHECK_PROTOTYPE_DEFINITION_LIBS}" - "${CMAKE_SYMBOL_EXISTS_INCLUDES}" - OUTPUT_VARIABLE OUTPUT) - - if (${_VARIABLE}) - set(${_VARIABLE} 1 CACHE INTERNAL "Have correct prototype for ${_FUNCTION}") - message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - True") - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Determining if the prototype ${_FUNCTION} exists for ${_VARIABLE} passed with the following output:\n" - "${OUTPUT}\n\n") - else (${_VARIABLE}) - message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - False") - set(${_VARIABLE} 0 CACHE INTERNAL "Have correct prototype for ${_FUNCTION}") - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Determining if the prototype ${_FUNCTION} exists for ${_VARIABLE} failed with the following output:\n" - "${OUTPUT}\n\n${_SOURCE}\n\n") - endif (${_VARIABLE}) - endif("${_VARIABLE}" MATCHES "^${_VARIABLE}$") - -endfunction(CHECK_PROTOTYPE_DEFINITION) diff --git a/cmake/Modules/PkgBuildConfig.cmake b/cmake/PkgBuildConfig.cmake similarity index 100% rename from cmake/Modules/PkgBuildConfig.cmake rename to cmake/PkgBuildConfig.cmake diff --git a/cmake/Modules/SanitizeBool.cmake b/cmake/SanitizeBool.cmake similarity index 100% rename from cmake/Modules/SanitizeBool.cmake rename to cmake/SanitizeBool.cmake diff --git a/cmake/Modules/SelectGSSAPI.cmake b/cmake/SelectGSSAPI.cmake similarity index 55% rename from cmake/Modules/SelectGSSAPI.cmake rename to cmake/SelectGSSAPI.cmake index 9b2bb1fc5..0a42eeefd 100644 --- a/cmake/Modules/SelectGSSAPI.cmake +++ b/cmake/SelectGSSAPI.cmake @@ -1,35 +1,27 @@ -# Select the backend to use - -# We try to find any packages our backends might use - INCLUDE(SanitizeBool) +# We try to find any packages our backends might use FIND_PACKAGE(GSSAPI) IF (CMAKE_SYSTEM_NAME MATCHES "Darwin") INCLUDE(FindGSSFramework) ENDIF() -# Auto-select GSS backend -SanitizeBool(USE_GSSAPI) -IF (USE_GSSAPI STREQUAL ON) - IF (GSSFRAMEWORK_FOUND) - SET(GSS_BACKEND "GSS.framework") - ELSEIF(GSSAPI_FOUND) - SET(GSS_BACKEND "gssapi") - ELSE() - MESSAGE(FATAL_ERROR "Unable to autodetect a usable GSS backend." - "Please pass the backend name explicitly (-DUSE_GSS=backend)") +IF(USE_GSSAPI) + # Auto-select GSS backend + SanitizeBool(USE_GSSAPI) + IF (USE_GSSAPI STREQUAL ON) + IF (GSSFRAMEWORK_FOUND) + SET(USE_GSSAPI "GSS.framework") + ELSEIF(GSSAPI_FOUND) + SET(USE_GSSAPI "gssapi") + ELSE() + MESSAGE(FATAL_ERROR "Unable to autodetect a usable GSS backend." + "Please pass the backend name explicitly (-DUSE_GSS=backend)") + ENDIF() ENDIF() -ELSEIF(USE_GSSAPI) - # Backend was explicitly set - SET(GSS_BACKEND ${USE_GSSAPI}) -ELSE() - SET(GSS_BACKEND NO) -ENDIF() -IF(GSS_BACKEND) # Check that we can find what's required for the selected backend - IF (GSS_BACKEND STREQUAL "GSS.framework") + IF (USE_GSSAPI STREQUAL "GSS.framework") IF (NOT GSSFRAMEWORK_FOUND) MESSAGE(FATAL_ERROR "Asked for GSS.framework backend, but it wasn't found") ENDIF() @@ -37,8 +29,8 @@ IF(GSS_BACKEND) LIST(APPEND LIBGIT2_LIBS ${GSSFRAMEWORK_LIBRARIES}) SET(GIT_GSSFRAMEWORK 1) - ADD_FEATURE_INFO(SPNEGO GIT_GSSFRAMEWORK "SPNEGO authentication support (${GSS_BACKEND})") - ELSEIF (GSS_BACKEND STREQUAL "gssapi") + ADD_FEATURE_INFO(SPNEGO GIT_GSSFRAMEWORK "SPNEGO authentication support (${USE_GSSAPI})") + ELSEIF (USE_GSSAPI STREQUAL "gssapi") IF (NOT GSSAPI_FOUND) MESSAGE(FATAL_ERROR "Asked for gssapi GSS backend, but it wasn't found") ENDIF() @@ -46,9 +38,9 @@ IF(GSS_BACKEND) LIST(APPEND LIBGIT2_LIBS ${GSSAPI_LIBRARIES}) SET(GIT_GSSAPI 1) - ADD_FEATURE_INFO(SPNEGO GIT_GSSAPI "SPNEGO authentication support (${GSS_BACKEND})") + ADD_FEATURE_INFO(SPNEGO GIT_GSSAPI "SPNEGO authentication support (${USE_GSSAPI})") ELSE() - MESSAGE(FATAL_ERROR "Asked for backend ${GSS_BACKEND} but it wasn't found") + MESSAGE(FATAL_ERROR "Asked for backend ${USE_GSSAPI} but it wasn't found") ENDIF() ELSE() SET(GIT_GSSAPI 0) diff --git a/cmake/Modules/SelectHTTPSBackend.cmake b/cmake/SelectHTTPSBackend.cmake similarity index 75% rename from cmake/Modules/SelectHTTPSBackend.cmake rename to cmake/SelectHTTPSBackend.cmake index f9b0b1cdc..afbeac424 100644 --- a/cmake/Modules/SelectHTTPSBackend.cmake +++ b/cmake/SelectHTTPSBackend.cmake @@ -1,5 +1,3 @@ -# Select the backend to use - INCLUDE(SanitizeBool) # We try to find any packages our backends might use @@ -10,36 +8,31 @@ IF (CMAKE_SYSTEM_NAME MATCHES "Darwin") FIND_PACKAGE(CoreFoundation) ENDIF() -# Auto-select TLS backend -SanitizeBool(USE_HTTPS) -IF (USE_HTTPS STREQUAL ON) - IF (SECURITY_FOUND) - IF (SECURITY_HAS_SSLCREATECONTEXT) - SET(HTTPS_BACKEND "SecureTransport") +IF(USE_HTTPS) + # Auto-select TLS backend + SanitizeBool(USE_HTTPS) + IF (USE_HTTPS STREQUAL ON) + IF (SECURITY_FOUND) + IF (SECURITY_HAS_SSLCREATECONTEXT) + SET(USE_HTTPS "SecureTransport") + ELSE() + MESSAGE(STATUS "Security framework is too old, falling back to OpenSSL") + SET(USE_HTTPS "OpenSSL") + ENDIF() + ELSEIF (WINHTTP) + SET(USE_HTTPS "WinHTTP") + ELSEIF(OPENSSL_FOUND) + SET(USE_HTTPS "OpenSSL") + ELSEIF(MBEDTLS_FOUND) + SET(USE_HTTPS "mbedTLS") ELSE() - MESSAGE(STATUS "Security framework is too old, falling back to OpenSSL") - SET(HTTPS_BACKEND "OpenSSL") + MESSAGE(FATAL_ERROR "Unable to autodetect a usable HTTPS backend." + "Please pass the backend name explicitly (-DUSE_HTTPS=backend)") ENDIF() - ELSEIF (WINHTTP) - SET(HTTPS_BACKEND "WinHTTP") - ELSEIF(OPENSSL_FOUND) - SET(HTTPS_BACKEND "OpenSSL") - ELSEIF(MBEDTLS_FOUND) - SET(HTTPS_BACKEND "mbedTLS") - ELSE() - MESSAGE(FATAL_ERROR "Unable to autodetect a usable HTTPS backend." - "Please pass the backend name explicitly (-DUSE_HTTPS=backend)") ENDIF() -ELSEIF(USE_HTTPS) - # HTTPS backend was explicitly set - SET(HTTPS_BACKEND ${USE_HTTPS}) -ELSE() - SET(HTTPS_BACKEND NO) -ENDIF() -IF(HTTPS_BACKEND) # Check that we can find what's required for the selected backend - IF (HTTPS_BACKEND STREQUAL "SecureTransport") + IF (USE_HTTPS STREQUAL "SecureTransport") IF (NOT COREFOUNDATION_FOUND) MESSAGE(FATAL_ERROR "Cannot use SecureTransport backend, CoreFoundation.framework not found") ENDIF() @@ -54,7 +47,7 @@ IF(HTTPS_BACKEND) LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${SECURITY_INCLUDE_DIR}) LIST(APPEND LIBGIT2_LIBS ${COREFOUNDATION_LDFLAGS} ${SECURITY_LDFLAGS}) LIST(APPEND LIBGIT2_PC_LIBS ${COREFOUNDATION_LDFLAGS} ${SECURITY_LDFLAGS}) - ELSEIF (HTTPS_BACKEND STREQUAL "OpenSSL") + ELSEIF (USE_HTTPS STREQUAL "OpenSSL") IF (NOT OPENSSL_FOUND) MESSAGE(FATAL_ERROR "Asked for OpenSSL TLS backend, but it wasn't found") ENDIF() @@ -64,7 +57,7 @@ IF(HTTPS_BACKEND) LIST(APPEND LIBGIT2_LIBS ${OPENSSL_LIBRARIES}) LIST(APPEND LIBGIT2_PC_LIBS ${OPENSSL_LDFLAGS}) LIST(APPEND LIBGIT2_PC_REQUIRES "openssl") - ELSEIF(HTTPS_BACKEND STREQUAL "mbedTLS") + ELSEIF(USE_HTTPS STREQUAL "mbedTLS") IF (NOT MBEDTLS_FOUND) MESSAGE(FATAL_ERROR "Asked for mbedTLS backend, but it wasn't found") ENDIF() @@ -113,14 +106,14 @@ IF(HTTPS_BACKEND) # https://github.com/ARMmbed/mbedtls/issues/228 # For now, pass its link flags as our own LIST(APPEND LIBGIT2_PC_LIBS ${MBEDTLS_LIBRARIES}) - ELSEIF (HTTPS_BACKEND STREQUAL "WinHTTP") + ELSEIF (USE_HTTPS STREQUAL "WinHTTP") # WinHTTP setup was handled in the WinHTTP-specific block above ELSE() - MESSAGE(FATAL_ERROR "Asked for backend ${HTTPS_BACKEND} but it wasn't found") + MESSAGE(FATAL_ERROR "Asked for backend ${USE_HTTPS} but it wasn't found") ENDIF() SET(GIT_HTTPS 1) - ADD_FEATURE_INFO(HTTPS GIT_HTTPS "using ${HTTPS_BACKEND}") + ADD_FEATURE_INFO(HTTPS GIT_HTTPS "using ${USE_HTTPS}") ELSE() SET(GIT_HTTPS 0) ADD_FEATURE_INFO(HTTPS NO "") diff --git a/cmake/Modules/SelectHashes.cmake b/cmake/SelectHashes.cmake similarity index 54% rename from cmake/Modules/SelectHashes.cmake rename to cmake/SelectHashes.cmake index a1339c173..06672ab03 100644 --- a/cmake/Modules/SelectHashes.cmake +++ b/cmake/SelectHashes.cmake @@ -5,37 +5,28 @@ INCLUDE(SanitizeBool) # USE_SHA1=CollisionDetection(ON)/HTTPS/Generic/OFF SanitizeBool(USE_SHA1) -IF(USE_SHA1 STREQUAL ON OR USE_SHA1 STREQUAL "CollisionDetection") - SET(SHA1_BACKEND "CollisionDetection") +IF(USE_SHA1 STREQUAL ON) + SET(USE_SHA1 "CollisionDetection") ELSEIF(USE_SHA1 STREQUAL "HTTPS") - message(STATUS "Checking HTTPS backend… ${HTTPS_BACKEND}") - IF(HTTPS_BACKEND STREQUAL "SecureTransport") - SET(SHA1_BACKEND "CommonCrypto") - ELSEIF(HTTPS_BACKEND STREQUAL "WinHTTP") - SET(SHA1_BACKEND "Win32") - ELSEIF(HTTPS_BACKEND) - SET(SHA1_BACKEND ${HTTPS_BACKEND}) + IF(USE_HTTPS STREQUAL "SecureTransport") + SET(USE_SHA1 "CommonCrypto") + ELSEIF(USE_HTTPS STREQUAL "WinHTTP") + SET(USE_SHA1 "Win32") + ELSEIF(USE_HTTPS) + SET(USE_SHA1 ${USE_HTTPS}) ELSE() + SET(USE_SHA1 "CollisionDetection") ENDIF() - IF(NOT HTTPS_BACKEND) - SET(SHA1_BACKEND "CollisionDetection") - ENDIF() - message(STATUS "Using SHA1 backend ${SHA1_BACKEND}") -ELSEIF(USE_SHA1 STREQUAL "Generic") - SET(SHA1_BACKEND "Generic") -# ELSEIF(NOT USE_SHA1) -ELSE() - MESSAGE(FATAL_ERROR "Invalid value for USE_SHA1: ${USE_SHA1}") ENDIF() -IF(SHA1_BACKEND STREQUAL "CollisionDetection") +IF(USE_SHA1 STREQUAL "CollisionDetection") SET(GIT_SHA1_COLLISIONDETECT 1) ADD_DEFINITIONS(-DSHA1DC_NO_STANDARD_INCLUDES=1) ADD_DEFINITIONS(-DSHA1DC_CUSTOM_INCLUDE_SHA1_C=\"common.h\") ADD_DEFINITIONS(-DSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C=\"common.h\") FILE(GLOB SRC_SHA1 hash/sha1/collisiondetect.* hash/sha1/sha1dc/*) -ELSEIF(SHA1_BACKEND STREQUAL "OpenSSL") - # OPENSSL_FOUND should already be set, we're checking HTTPS_BACKEND +ELSEIF(USE_SHA1 STREQUAL "OpenSSL") + # OPENSSL_FOUND should already be set, we're checking USE_HTTPS SET(GIT_SHA1_OPENSSL 1) IF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") @@ -44,10 +35,10 @@ ELSEIF(SHA1_BACKEND STREQUAL "OpenSSL") LIST(APPEND LIBGIT2_PC_REQUIRES "openssl") ENDIF() FILE(GLOB SRC_SHA1 hash/sha1/openssl.*) -ELSEIF(SHA1_BACKEND STREQUAL "CommonCrypto") +ELSEIF(USE_SHA1 STREQUAL "CommonCrypto") SET(GIT_SHA1_COMMON_CRYPTO 1) FILE(GLOB SRC_SHA1 hash/sha1/common_crypto.*) -ELSEIF(SHA1_BACKEND STREQUAL "mbedTLS") +ELSEIF(USE_SHA1 STREQUAL "mbedTLS") SET(GIT_SHA1_MBEDTLS 1) FILE(GLOB SRC_SHA1 hash/sha1/mbedtls.*) LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${MBEDTLS_INCLUDE_DIR}) @@ -56,14 +47,15 @@ ELSEIF(SHA1_BACKEND STREQUAL "mbedTLS") # https://github.com/ARMmbed/mbedtls/issues/228 # For now, pass its link flags as our own LIST(APPEND LIBGIT2_PC_LIBS ${MBEDTLS_LIBRARIES}) -ELSEIF(SHA1_BACKEND STREQUAL "Win32") +ELSEIF(USE_SHA1 STREQUAL "Win32") SET(GIT_SHA1_WIN32 1) FILE(GLOB SRC_SHA1 hash/sha1/win32.*) -ELSEIF(SHA1_BACKEND STREQUAL "Generic") +ELSEIF(USE_SHA1 STREQUAL "Generic") FILE(GLOB SRC_SHA1 hash/sha1/generic.*) -# ELSEIF(NOT USE_SHA1) ELSE() - MESSAGE(FATAL_ERROR "Asked for unknown SHA1 backend: ${SHA1_BACKEND}") + MESSAGE(FATAL_ERROR "Asked for unknown SHA1 backend: ${USE_SHA1}") ENDIF() -ADD_FEATURE_INFO(SHA ON "using ${SHA1_BACKEND}") +list(SORT SRC_SHA1) + +ADD_FEATURE_INFO(SHA ON "using ${USE_SHA1}") diff --git a/docs/changelog.md b/docs/changelog.md index c2423c338..288ef2d11 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,3 +1,62 @@ +v1.1 +---- + +This is release v1.1, "Fernweh". + +### Changes or improvements + +* Our bundled PCRE dependency has been updated to 8.44. + +* The `refs/remotes/origin/HEAD` file will be created at clone time to + point to the origin's default branch. + +* libgit2 now uses the `__atomic_` intrinsics instead of `__sync_` + intrinsics on supported gcc and clang versions. + +* The `init.defaultBranch` setting is now respected and `master` is + no longer the hardcoded as the default branch name. + +* Patch files that do not contain an `index` line can now be parsed. + +* Configuration files with multi-line values can now contain quotes + split across multiple lines. + +* Windows clients now attempt to use TLS1.3 when available. + +* Servers that request an upgrade to a newer HTTP version are + silently ignored instead of erroneously failing. + +* Users can pass `NULL` to the options argument to + `git_describe_commit`. + +* Clones and fetches of very large packfiles now succeeds on 32-bit + platforms. + +* Custom reference database backends can now handle the repository's + `HEAD` correctly. + +* Repositories with a large number of packfiles no longer exhaust the + number of file descriptors. + +* The test framework now supports TAP output when the `-t` flag is + specified. + +* The test framework can now specify an exact match to a test + function using a trailing `$`. + +* All checkout types support `GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH`. + +* `git_blame` now can ignore whitespace changes using the option + `GIT_BLAME_IGNORE_WHITESPACE`. + +* Several new examples have been created, including an examples for + commit, add and push. + +* Mode changes during rename are now supported in patch application. + +* `git_checkout_head` now correctly removes untracked files in a + subdirectory when the `FORCE | REMOVE_UNTRACKED` options are specified. + v1.0.1 ------ diff --git a/docs/coding-style.md b/docs/coding-style.md new file mode 100644 index 000000000..d5188f0bc --- /dev/null +++ b/docs/coding-style.md @@ -0,0 +1,364 @@ +# libgit2 Coding Style + +This documentation describes the preferred coding style for the libgit2 project. +While not all parts of our code base conform to this coding style, the outlined +rules are what we aim for. + +Note that in no case do we accept changes that convert huge parts of the code +base to use our coding style. Instead, it is encouraged to modernize small parts +of code you're going to modify anyway for a given change you want to introduce. +A good rule to follow is the Boy Scout Rule: "Leave the campground cleaner than +you found it." + +## C Coding Style + +The following sections define the coding style for all code files and headers. + +### Indentation and Alignment + +Code is indented by tabs, where a tab is 8 spaces. Each opening scope increases +the indentation level. + +```c +int foobar(int void) +{ + if (condition) + doit(); + /* Body */ +} +``` + +Switch statements have their `case`s aligned with the `switch` keyword. Case +bodies are indented by an additional level. Case bodies should not open their +own scope to declare variables. + +```c +switch (c) { +case 'a': +case 'b': + return 0; +default: + return -1; +} +``` + +Multi-line conditions should be aligned with the opening brace of the current +statement: + +```c +if (one_very_long_condition(c) && + another_very_long_condition(c)) + doit(); +``` + +### Spaces + +There must be no space between the function and its arguments, arguments must be +separated by a space: + +```c +int doit(int first_arg, int second_arg); +doit(1, 2); +``` + +For any binary or ternary operators, the arguments and separator must be +separated by a space: + +```c +1 + 2; +x ? x : NULL; +``` + +Unary operators do not have a space between them and the argument they refer to: + +```c +*c +&c +``` + +The `sizeof` operator always must not have a space and must use braces around +the type: + +``` +sizeof(int) +``` + +There must be a space after the keywords `if`, `switch`, `case`, `do` and +`while`. + +### Braces + +Functions must have their opening brace on the following line: + +```c +void foobar(void) +{ + doit(); +} +``` + +For conditions, braces should be placed on the same line as the condition: + +```c +if (condition(c)) { + doit(); + dothat(); +} + +while (true) { + doit(); +} +``` + +In case a condition's body has a single line, only, it's allowed to omit braces, +except if any of its `else if` or `else` branches has more than one line: + +```c +if (condition(c)) + doit(); + +if (condition(c)) + doit(); +else if (other_condition(c)) + doit(); + +/* This example must use braces as the `else if` requires them. */ +if (condition(c)) { + doit(); +} else if (other_condition(c)) { + doit(); + dothat(); +} else { + abort(); +} +``` + +### Comments + +Comments must use C-style `/* */` comments. C++-style `// `comments are not +allowed in our codebase. This is a strict requirement as libgit2 tries to be +compliant with the ISO C90 standard, which only allows C-style comments. + +Single-line comments may have their opening and closing tag on the same line: + +```c +/* This is a short comment. */ +``` + +For multi-line comments, the opening and closing tag should be empty: + +```c +/* + * This is a rather long and potentially really unwiedly but informative + * multiline comment that helps quite a lot. + */ +``` + +Public functions must have documentation that explain their usage, internal +functions should have a comment. We use Docurium to generate documentation +derived from these comments, which uses syntax similar to Doxygen. The first +line should be a short summary of what the function does. More in-depth +explanation should be separated from that first line by an empty line. +Parameters and return values should be documented via `@return` and `@param` +tags: + +```c +/* + * Froznicate the string. + * + * Froznicate the string by foobaring its internal structure into a more obvious + * translation. Note that the returned string is a newly allocated string that + * shall be `free`d by the caller. + * + * @param s String to froznicate + * @return A newly allocated string or `NULL` in case an error occurred. + * / +char *froznicate(const char *s); +``` + +### Variables + +Variables must be declared at the beginning of their scope. This is a strict +requirement as libgit2 tries to be compliant with the ISO C90 standard, which +forbids mixed declarations and code: + +```c +void foobar(void) +{ + char *c = NULL; + int a, b; + + a = 0; + b = 1; + + return c; +} +``` + +### Naming + +Variables must have all-lowercase names. In case a variable name has multiple +words, words should be separated by an underscore `_` character. While +recommended to use descriptive naming, common variable names like `i` for +indices are allowed. + +All public functions must have a `git` prefix as well as a prefix indicating +their respective subsystem. E.g. a function that opens a repository should be +called `git_repository_open()`. Functions that are not public but declared in +an internal header file for use by other subsystems should follow the same +naming pattern. File-local static functions must not have a `git` prefix, but +should have a prefix indicating their respective subsystem. + +All structures declared in the libgit2 project must have a `typedef`, we do not +use `struct type` variables. Type names follow the same schema as functions. + +### Error Handling + +The libgit2 project mostly uses error codes to indicate errors. Error codes are +always of type `int`, where `0` indicates success and a negative error code +indicates an error case. In some cases, positive error codes may be used to +indicate special cases. Returned values that are not an error code should be +returned via an out parameter. Out parameters must always come first in the list +of arguments. + +```c +int doit(const char **out, int arg) +{ + if (!arg) + return -1; + *out = "Got an argument"; + return 0; +} +``` + +To avoid repetitive and fragile error handling in case a function has resources +that need to be free'd, we use `goto out`s: + +```c +int doit(char **out, int arg) +{ + int error = 0; + char *c; + + c = malloc(strlen("Got an argument") + 1); + if (!c) { + error = -1; + goto out; + } + + if (!arg) { + error = -1; + goto out; + } + + strcpy(c, "Got an argument") + *out = c; + +out: + if (error) + free(c); + return error; +} +``` + +When calling functions that return an error code, you should assign the error +code to an `error` variable and, in case an error case is indicated and no +custom error handling is required, return that error code: + +```c +int foobar(void) +{ + int error; + + if ((error = doit()) < 0) + return error; + + return 0; +} +``` + +When doing multiple function calls where all of the functions return an error +code, it's common practice to chain these calls together: + +```c +int doit(void) +{ + int error; + + if ((error = dothis()) < 0 || + (error = dothat()) < 0) + return error; + + return 0; +} +``` + +## CMake Coding Style + +The following section defines the coding style for our CMake build system. + +### Indentation + +Code is indented by tabs, where a tab is 8 spaces. Each opening scope increases +the indentation level. + +```cmake +if(CONDITION) + doit() +endif() +``` + +### Spaces + +There must be no space between keywords and their opening brace. While this is +the same as in our C codebase for function calls, this also applies to +conditional keywords. This is done to avoid the awkward-looking `else ()` +statement. + +```cmake +if(CONDITION) + doit() +else() + dothat() +endif() +``` + +### Case + +While CMake is completely case-insensitive when it comes to function calls, we +want to agree on a common coding style for this. To reduce the danger of +repetitive strain injuries, all function calls should be lower-case (NB: this is +not currently the case yet, but introduced as a new coding style by this +document). + +Variables are written all-uppercase. In contrast to functions, variables are +case-sensitive in CMake. As CMake itself uses upper-case variables in all +places, we should follow suit and do the same. + +Control flow keywords must be all lowercase. In contrast to that, test keywords +must be all uppercase: + +```cmake +if(NOT CONDITION) + doit() +elseif(FOO AND BAR) + dothat() +endif() +``` + +### Targets + +CMake code should not use functions that modify the global scope but prefer +their targeted equivalents, instead. E.g. instead of using +`include_directories()`, you must use `target_include_directories()`. An +exception to this rule is setting up global compiler flags like warnings or +flags required to set up the build type. + +### Dependencies + +Dependencies should not be discovered or set up in the main "CMakeLists.txt" +module. Instead, they should either have their own module in our top-level +"cmake/" directory or have a "CMakeLists.txt" in their respective "deps/" +directory in case it is a vendored library. All dependencies should expose +interface library targets that can be linked against with +`target_link_libraries()`. diff --git a/examples/add.c b/examples/add.c index 6e3c239fc..542360ea9 100644 --- a/examples/add.c +++ b/examples/add.c @@ -48,9 +48,11 @@ int lg2_add(git_repository *repo, int argc, char **argv) git_index_matched_path_cb matched_cb = NULL; git_index *index; git_strarray array = {0}; - struct index_options options; + struct index_options options = {0}; struct args_info args = ARGS_INFO_INIT; + options.mode = INDEX_ADD; + /* Parse the options & arguments. */ parse_opts(NULL, &options, &args); strarray_from_args(&array, &args); diff --git a/examples/checkout.c b/examples/checkout.c index 897c42f3f..204b58d88 100644 --- a/examples/checkout.c +++ b/examples/checkout.c @@ -239,7 +239,7 @@ next: out: git_reference_free(remote_ref); - git_strarray_free(&remotes); + git_strarray_dispose(&remotes); return error; } diff --git a/examples/commit.c b/examples/commit.c new file mode 100644 index 000000000..cd9782de1 --- /dev/null +++ b/examples/commit.c @@ -0,0 +1,84 @@ +/* + * libgit2 "commit" example - shows how to create a git commit + * + * 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 + * . + */ + +#include "common.h" + +/** + * This example demonstrates the libgit2 commit APIs to roughly + * simulate `git commit` with the commit message argument. + * + * This does not have: + * + * - Robust error handling + * - Most of the `git commit` options + * + * This does have: + * + * - Example of performing a git commit with a comment + * + */ +int lg2_commit(git_repository *repo, int argc, char **argv) +{ + const char *opt = argv[1]; + const char *comment = argv[2]; + int error; + + git_oid commit_oid,tree_oid; + git_tree *tree; + git_index *index; + git_object *parent = NULL; + git_reference *ref = NULL; + git_signature *signature; + + /* Validate args */ + if (argc < 3 || strcmp(opt, "-m") != 0) { + printf ("USAGE: %s -m \n", argv[0]); + return -1; + } + + error = git_revparse_ext(&parent, &ref, repo, "HEAD"); + if (error == GIT_ENOTFOUND) { + printf("HEAD not found. Creating first commit\n"); + error = 0; + } else if (error != 0) { + 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); + } + + check_lg2(git_repository_index(&index, repo), "Could not open repository index", NULL); + check_lg2(git_index_write_tree(&tree_oid, index), "Could not write tree", NULL);; + check_lg2(git_index_write(index), "Could not write index", NULL);; + + check_lg2(git_tree_lookup(&tree, repo, &tree_oid), "Error looking up tree", NULL); + + check_lg2(git_signature_default(&signature, repo), "Error creating signature", NULL); + + check_lg2(git_commit_create_v( + &commit_oid, + repo, + "HEAD", + signature, + signature, + NULL, + comment, + tree, + parent ? 1 : 0, parent), "Error creating commit", NULL); + + git_index_free(index); + git_signature_free(signature); + git_tree_free(tree); + + return error; +} diff --git a/examples/common.h b/examples/common.h index c01561b48..0126568ab 100644 --- a/examples/common.h +++ b/examples/common.h @@ -59,6 +59,7 @@ extern int lg2_blame(git_repository *repo, int argc, char **argv); extern int lg2_cat_file(git_repository *repo, int argc, char **argv); extern int lg2_checkout(git_repository *repo, int argc, char **argv); extern int lg2_clone(git_repository *repo, int argc, char **argv); +extern int lg2_commit(git_repository *repo, int argc, char **argv); extern int lg2_config(git_repository *repo, int argc, char **argv); extern int lg2_describe(git_repository *repo, int argc, char **argv); extern int lg2_diff(git_repository *repo, int argc, char **argv); @@ -71,6 +72,7 @@ extern int lg2_log(git_repository *repo, int argc, char **argv); extern int lg2_ls_files(git_repository *repo, int argc, char **argv); extern int lg2_ls_remote(git_repository *repo, int argc, char **argv); extern int lg2_merge(git_repository *repo, int argc, char **argv); +extern int lg2_push(git_repository *repo, int argc, char **argv); extern int lg2_remote(git_repository *repo, int argc, char **argv); extern int lg2_rev_list(git_repository *repo, int argc, char **argv); extern int lg2_rev_parse(git_repository *repo, int argc, char **argv); diff --git a/examples/general.c b/examples/general.c index ddc53c3e8..1622ff8b0 100644 --- a/examples/general.c +++ b/examples/general.c @@ -707,7 +707,7 @@ static void reference_listing(git_repository *repo) git_reference_free(ref); } - git_strarray_free(&ref_list); + git_strarray_dispose(&ref_list); } /** diff --git a/examples/lg2.c b/examples/lg2.c index a3987c34d..7946bc215 100644 --- a/examples/lg2.c +++ b/examples/lg2.c @@ -15,6 +15,7 @@ struct { { "cat-file", lg2_cat_file, 1 }, { "checkout", lg2_checkout, 1 }, { "clone", lg2_clone, 0 }, + { "commit", lg2_commit, 1 }, { "config", lg2_config, 1 }, { "describe", lg2_describe, 1 }, { "diff", lg2_diff, 1 }, @@ -27,6 +28,7 @@ struct { { "ls-files", lg2_ls_files, 1 }, { "ls-remote", lg2_ls_remote, 1 }, { "merge", lg2_merge, 1 }, + { "push", lg2_push, 1 }, { "remote", lg2_remote, 1 }, { "rev-list", lg2_rev_list, 1 }, { "rev-parse", lg2_rev_parse, 1 }, diff --git a/examples/log.c b/examples/log.c index 3eee7d421..ee18df542 100644 --- a/examples/log.c +++ b/examples/log.c @@ -434,21 +434,28 @@ static int parse_options( else if (!strcmp(a, "--reverse")) set_sorting(s, GIT_SORT_REVERSE); else if (match_str_arg(&opt->author, &args, "--author")) - /** Found valid --author */; + /** Found valid --author */ + ; else if (match_str_arg(&opt->committer, &args, "--committer")) - /** Found valid --committer */; + /** Found valid --committer */ + ; else if (match_str_arg(&opt->grep, &args, "--grep")) - /** Found valid --grep */; + /** Found valid --grep */ + ; else if (match_str_arg(&s->repodir, &args, "--git-dir")) - /** Found git-dir. */; + /** Found git-dir. */ + ; else if (match_int_arg(&opt->skip, &args, "--skip", 0)) - /** Found valid --skip. */; + /** Found valid --skip. */ + ; else if (match_int_arg(&opt->limit, &args, "--max-count", 0)) - /** Found valid --max-count. */; + /** Found valid --max-count. */ + ; else if (a[1] >= '0' && a[1] <= '9') is_integer(&opt->limit, a + 1, 0); else if (match_int_arg(&opt->limit, &args, "-n", 0)) - /** Found valid -n. */; + /** Found valid -n. */ + ; else if (!strcmp(a, "--merges")) opt->min_parents = 2; else if (!strcmp(a, "--no-merges")) @@ -458,9 +465,11 @@ static int parse_options( else if (!strcmp(a, "--no-max-parents")) opt->max_parents = -1; else if (match_int_arg(&opt->max_parents, &args, "--max-parents=", 1)) - /** Found valid --max-parents. */; + /** Found valid --max-parents. */ + ; else if (match_int_arg(&opt->min_parents, &args, "--min-parents=", 0)) - /** Found valid --min_parents. */; + /** Found valid --min_parents. */ + ; else if (!strcmp(a, "-p") || !strcmp(a, "-u") || !strcmp(a, "--patch")) opt->show_diff = 1; else if (!strcmp(a, "--log-size")) diff --git a/examples/push.c b/examples/push.c new file mode 100644 index 000000000..bcf307607 --- /dev/null +++ b/examples/push.c @@ -0,0 +1,56 @@ +/* + * libgit2 "push" example - shows how to push to remote + * + * 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 + * . + */ + +#include "common.h" + +/** + * This example demonstrates the libgit2 push API to roughly + * simulate `git push`. + * + * This does not have: + * + * - Robust error handling + * - Any of the `git push` options + * + * This does have: + * + * - Example of push to origin/master + * + */ + +/** Entry point for this command */ +int lg2_push(git_repository *repo, int argc, char **argv) { + git_push_options options; + git_remote* remote = NULL; + char *refspec = "refs/heads/master"; + const git_strarray refspecs = { + &refspec, + 1 + }; + + /* Validate args */ + if (argc > 1) { + printf ("USAGE: %s\n\nsorry, no arguments supported yet\n", argv[0]); + return -1; + } + + check_lg2(git_remote_lookup(&remote, repo, "origin" ), "Unable to lookup remote", NULL); + + check_lg2(git_push_options_init(&options, GIT_PUSH_OPTIONS_VERSION ), "Error initializing push", NULL); + + check_lg2(git_remote_push(remote, &refspecs, &options), "Error pushing", NULL); + + printf("pushed\n"); + return 0; +} diff --git a/examples/remote.c b/examples/remote.c index 34d886526..57f758c6c 100644 --- a/examples/remote.c +++ b/examples/remote.c @@ -129,7 +129,7 @@ static int cmd_rename(git_repository *repo, struct remote_opts *o) puts(problems.strings[0]); } - git_strarray_free(&problems); + git_strarray_dispose(&problems); return retval; } @@ -207,7 +207,7 @@ static int cmd_show(git_repository *repo, struct remote_opts *o) git_remote_free(remote); } - git_strarray_free(&remotes); + git_strarray_dispose(&remotes); return 0; } diff --git a/examples/tag.c b/examples/tag.c index 440829419..03d9c2bf9 100644 --- a/examples/tag.c +++ b/examples/tag.c @@ -162,7 +162,7 @@ static void action_list_tags(tag_state *state) each_tag(tag_names.strings[i], state); } - git_strarray_free(&tag_names); + git_strarray_dispose(&tag_names); } static void action_delete_tag(tag_state *state) diff --git a/fuzzers/corpora/midx/037cbbe0dc03807dd9d9e8629f1712d7df34ee18 b/fuzzers/corpora/midx/037cbbe0dc03807dd9d9e8629f1712d7df34ee18 new file mode 100644 index 000000000..2e5bda8c6 Binary files /dev/null and b/fuzzers/corpora/midx/037cbbe0dc03807dd9d9e8629f1712d7df34ee18 differ diff --git a/fuzzers/corpora/midx/039ee34fef8f323ed618a10abc0109df123d0cb5 b/fuzzers/corpora/midx/039ee34fef8f323ed618a10abc0109df123d0cb5 new file mode 100644 index 000000000..0c97a38f5 Binary files /dev/null and b/fuzzers/corpora/midx/039ee34fef8f323ed618a10abc0109df123d0cb5 differ diff --git a/fuzzers/corpora/midx/054ee2c82bdb6a170106eb5d35f21bde2119d584 b/fuzzers/corpora/midx/054ee2c82bdb6a170106eb5d35f21bde2119d584 new file mode 100644 index 000000000..f7711e496 --- /dev/null +++ b/fuzzers/corpora/midx/054ee2c82bdb6a170106eb5d35f21bde2119d584 @@ -0,0 +1 @@ +ăM˙ăa \ No newline at end of file diff --git a/fuzzers/corpora/midx/055ca4cbc961ebf5fd5c922b4f73880d3fbfe39d b/fuzzers/corpora/midx/055ca4cbc961ebf5fd5c922b4f73880d3fbfe39d new file mode 100644 index 000000000..adb91f935 Binary files /dev/null and b/fuzzers/corpora/midx/055ca4cbc961ebf5fd5c922b4f73880d3fbfe39d differ diff --git a/fuzzers/corpora/midx/05c4e5eb1b97bc9b6973921fcb30d4c5e2eb79e4 b/fuzzers/corpora/midx/05c4e5eb1b97bc9b6973921fcb30d4c5e2eb79e4 new file mode 100644 index 000000000..1a53734a2 Binary files /dev/null and b/fuzzers/corpora/midx/05c4e5eb1b97bc9b6973921fcb30d4c5e2eb79e4 differ diff --git a/fuzzers/corpora/midx/0672eeda541a191cfc68d521a3c7ac0aac4057a6 b/fuzzers/corpora/midx/0672eeda541a191cfc68d521a3c7ac0aac4057a6 new file mode 100644 index 000000000..5b6495587 Binary files /dev/null and b/fuzzers/corpora/midx/0672eeda541a191cfc68d521a3c7ac0aac4057a6 differ diff --git a/fuzzers/corpora/midx/06a58d1bd5562a668ebf01ef297fd774e0e587a6 b/fuzzers/corpora/midx/06a58d1bd5562a668ebf01ef297fd774e0e587a6 new file mode 100644 index 000000000..30e454a42 Binary files /dev/null and b/fuzzers/corpora/midx/06a58d1bd5562a668ebf01ef297fd774e0e587a6 differ diff --git a/fuzzers/corpora/midx/06bf7c2461ae1049030f31b83ae76babfcc20c83 b/fuzzers/corpora/midx/06bf7c2461ae1049030f31b83ae76babfcc20c83 new file mode 100644 index 000000000..10751dc37 Binary files /dev/null and b/fuzzers/corpora/midx/06bf7c2461ae1049030f31b83ae76babfcc20c83 differ diff --git a/fuzzers/corpora/midx/06c2db67ea65758d971346bfd6beaa61ed12f22c b/fuzzers/corpora/midx/06c2db67ea65758d971346bfd6beaa61ed12f22c new file mode 100644 index 000000000..5641570e1 Binary files /dev/null and b/fuzzers/corpora/midx/06c2db67ea65758d971346bfd6beaa61ed12f22c differ diff --git a/fuzzers/corpora/midx/07f88eefaf12609b7370fe78b82be2955f1b41fd b/fuzzers/corpora/midx/07f88eefaf12609b7370fe78b82be2955f1b41fd new file mode 100644 index 000000000..8e09bb462 Binary files /dev/null and b/fuzzers/corpora/midx/07f88eefaf12609b7370fe78b82be2955f1b41fd differ diff --git a/fuzzers/corpora/midx/08495c5f3828a56c167de870d385c46ffdce03c5 b/fuzzers/corpora/midx/08495c5f3828a56c167de870d385c46ffdce03c5 new file mode 100644 index 000000000..b4f569772 Binary files /dev/null and b/fuzzers/corpora/midx/08495c5f3828a56c167de870d385c46ffdce03c5 differ diff --git a/fuzzers/corpora/midx/08ec8594e5b35fb9e8e0726584f720154f0b2b5d b/fuzzers/corpora/midx/08ec8594e5b35fb9e8e0726584f720154f0b2b5d new file mode 100644 index 000000000..772b4fd4f Binary files /dev/null and b/fuzzers/corpora/midx/08ec8594e5b35fb9e8e0726584f720154f0b2b5d differ diff --git a/fuzzers/corpora/midx/0903e378a493c596298074d6bff8de7f9ac25aa7 b/fuzzers/corpora/midx/0903e378a493c596298074d6bff8de7f9ac25aa7 new file mode 100644 index 000000000..34f5f3b25 --- /dev/null +++ b/fuzzers/corpora/midx/0903e378a493c596298074d6bff8de7f9ac25aa7 @@ -0,0 +1 @@ +ăü7 \ No newline at end of file diff --git a/fuzzers/corpora/midx/09144a846f90f894049ef8a0ed0cc7ab4588dc6c b/fuzzers/corpora/midx/09144a846f90f894049ef8a0ed0cc7ab4588dc6c new file mode 100644 index 000000000..ce7a43d9c --- /dev/null +++ b/fuzzers/corpora/midx/09144a846f90f894049ef8a0ed0cc7ab4588dc6c @@ -0,0 +1 @@ +ĂŘseed \ No newline at end of file diff --git a/fuzzers/corpora/midx/09b40dd618373bfe4d3f2838f686a70f645e640b b/fuzzers/corpora/midx/09b40dd618373bfe4d3f2838f686a70f645e640b new file mode 100644 index 000000000..09473b7de Binary files /dev/null and b/fuzzers/corpora/midx/09b40dd618373bfe4d3f2838f686a70f645e640b differ diff --git a/fuzzers/corpora/midx/0a00ef44d234c18d365ec41724dbf4f21b09d0c5 b/fuzzers/corpora/midx/0a00ef44d234c18d365ec41724dbf4f21b09d0c5 new file mode 100644 index 000000000..861a9869a Binary files /dev/null and b/fuzzers/corpora/midx/0a00ef44d234c18d365ec41724dbf4f21b09d0c5 differ diff --git a/fuzzers/corpora/midx/0a94e9f4a9b8cf56d52a9e3e7f2fa9a0a5c80d30 b/fuzzers/corpora/midx/0a94e9f4a9b8cf56d52a9e3e7f2fa9a0a5c80d30 new file mode 100644 index 000000000..11f08c02d Binary files /dev/null and b/fuzzers/corpora/midx/0a94e9f4a9b8cf56d52a9e3e7f2fa9a0a5c80d30 differ diff --git a/fuzzers/corpora/midx/0b35a123104b7872a7f15a710a23ef3594ace04d b/fuzzers/corpora/midx/0b35a123104b7872a7f15a710a23ef3594ace04d new file mode 100644 index 000000000..eac151bd6 Binary files /dev/null and b/fuzzers/corpora/midx/0b35a123104b7872a7f15a710a23ef3594ace04d differ diff --git a/fuzzers/corpora/midx/0c3d7e6be32c014ea873440b0f095961d391af1a b/fuzzers/corpora/midx/0c3d7e6be32c014ea873440b0f095961d391af1a new file mode 100644 index 000000000..e9c66219d Binary files /dev/null and b/fuzzers/corpora/midx/0c3d7e6be32c014ea873440b0f095961d391af1a differ diff --git a/fuzzers/corpora/midx/0c65de477b89afc312a7e89cde06f8a17f65bd54 b/fuzzers/corpora/midx/0c65de477b89afc312a7e89cde06f8a17f65bd54 new file mode 100644 index 000000000..8f4b25ca5 Binary files /dev/null and b/fuzzers/corpora/midx/0c65de477b89afc312a7e89cde06f8a17f65bd54 differ diff --git a/fuzzers/corpora/midx/0c81d0f368e979d2a0eb4598cbf1c9283936ba0c b/fuzzers/corpora/midx/0c81d0f368e979d2a0eb4598cbf1c9283936ba0c new file mode 100644 index 000000000..a2dd1636c Binary files /dev/null and b/fuzzers/corpora/midx/0c81d0f368e979d2a0eb4598cbf1c9283936ba0c differ diff --git a/fuzzers/corpora/midx/0c95a44ae995070a5279a2991c36de2251081460 b/fuzzers/corpora/midx/0c95a44ae995070a5279a2991c36de2251081460 new file mode 100644 index 000000000..821b07bc9 Binary files /dev/null and b/fuzzers/corpora/midx/0c95a44ae995070a5279a2991c36de2251081460 differ diff --git a/fuzzers/corpora/midx/0de38e2cb13167df7d5a882570633596f64bc4f4 b/fuzzers/corpora/midx/0de38e2cb13167df7d5a882570633596f64bc4f4 new file mode 100644 index 000000000..80a27f682 Binary files /dev/null and b/fuzzers/corpora/midx/0de38e2cb13167df7d5a882570633596f64bc4f4 differ diff --git a/fuzzers/corpora/midx/0de96aa193045315457ade63c2614610c503db9e b/fuzzers/corpora/midx/0de96aa193045315457ade63c2614610c503db9e new file mode 100644 index 000000000..342c6c9a6 Binary files /dev/null and b/fuzzers/corpora/midx/0de96aa193045315457ade63c2614610c503db9e differ diff --git a/fuzzers/corpora/midx/0e02deca2b16d71f8637933bd56dc8592ed9fdff b/fuzzers/corpora/midx/0e02deca2b16d71f8637933bd56dc8592ed9fdff new file mode 100644 index 000000000..d3b5fe27f --- /dev/null +++ b/fuzzers/corpora/midx/0e02deca2b16d71f8637933bd56dc8592ed9fdff @@ -0,0 +1 @@ +ăH \ No newline at end of file diff --git a/fuzzers/corpora/midx/0e44fc9176fe2c1bae4209369da5bc057f54b2d2 b/fuzzers/corpora/midx/0e44fc9176fe2c1bae4209369da5bc057f54b2d2 new file mode 100644 index 000000000..74690025f Binary files /dev/null and b/fuzzers/corpora/midx/0e44fc9176fe2c1bae4209369da5bc057f54b2d2 differ diff --git a/fuzzers/corpora/midx/0f6c5fc9b6a68835364bbef8937560ee5a481938 b/fuzzers/corpora/midx/0f6c5fc9b6a68835364bbef8937560ee5a481938 new file mode 100644 index 000000000..309e2d84f --- /dev/null +++ b/fuzzers/corpora/midx/0f6c5fc9b6a68835364bbef8937560ee5a481938 @@ -0,0 +1 @@ +©* \ No newline at end of file diff --git a/fuzzers/corpora/midx/10d542d5c7da060a5f0664e21478a0d598e29844 b/fuzzers/corpora/midx/10d542d5c7da060a5f0664e21478a0d598e29844 new file mode 100644 index 000000000..777d32aa0 Binary files /dev/null and b/fuzzers/corpora/midx/10d542d5c7da060a5f0664e21478a0d598e29844 differ diff --git a/fuzzers/corpora/midx/118735f7786ae6b4c2f6b36314ab1f2cafe9c3c8 b/fuzzers/corpora/midx/118735f7786ae6b4c2f6b36314ab1f2cafe9c3c8 new file mode 100644 index 000000000..a91dbc912 --- /dev/null +++ b/fuzzers/corpora/midx/118735f7786ae6b4c2f6b36314ab1f2cafe9c3c8 @@ -0,0 +1 @@ +ăŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŠŰŰŰŰŰŰŰŰŰŰËŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰËŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰ \ No newline at end of file diff --git a/fuzzers/corpora/midx/119b58eb353aa344264005016297fb911510ea0d b/fuzzers/corpora/midx/119b58eb353aa344264005016297fb911510ea0d new file mode 100644 index 000000000..b4883c29c Binary files /dev/null and b/fuzzers/corpora/midx/119b58eb353aa344264005016297fb911510ea0d differ diff --git a/fuzzers/corpora/midx/127626832c30d6d94bb29384c0fde7ac6bca75ec b/fuzzers/corpora/midx/127626832c30d6d94bb29384c0fde7ac6bca75ec new file mode 100644 index 000000000..3a0fe06c9 Binary files /dev/null and b/fuzzers/corpora/midx/127626832c30d6d94bb29384c0fde7ac6bca75ec differ diff --git a/fuzzers/corpora/midx/1284f1a162588d4de87ca17149474644a0863b27 b/fuzzers/corpora/midx/1284f1a162588d4de87ca17149474644a0863b27 new file mode 100644 index 000000000..03a9f9779 Binary files /dev/null and b/fuzzers/corpora/midx/1284f1a162588d4de87ca17149474644a0863b27 differ diff --git a/fuzzers/corpora/midx/1458599f19f1a967c787562bf8ec3e67677da9c8 b/fuzzers/corpora/midx/1458599f19f1a967c787562bf8ec3e67677da9c8 new file mode 100644 index 000000000..e9dc36e96 Binary files /dev/null and b/fuzzers/corpora/midx/1458599f19f1a967c787562bf8ec3e67677da9c8 differ diff --git a/fuzzers/corpora/midx/14ba6c1ddd05b22c6f2eae5f894721cd3efcbb16 b/fuzzers/corpora/midx/14ba6c1ddd05b22c6f2eae5f894721cd3efcbb16 new file mode 100644 index 000000000..e0f281c6f Binary files /dev/null and b/fuzzers/corpora/midx/14ba6c1ddd05b22c6f2eae5f894721cd3efcbb16 differ diff --git a/fuzzers/corpora/midx/158cdc0a5aa005f167a8588d0beed9eee4aa36f2 b/fuzzers/corpora/midx/158cdc0a5aa005f167a8588d0beed9eee4aa36f2 new file mode 100644 index 000000000..98de253d8 Binary files /dev/null and b/fuzzers/corpora/midx/158cdc0a5aa005f167a8588d0beed9eee4aa36f2 differ diff --git a/fuzzers/corpora/midx/15dafc6fa800327f694b5eb2fc4ebf007be9c117 b/fuzzers/corpora/midx/15dafc6fa800327f694b5eb2fc4ebf007be9c117 new file mode 100644 index 000000000..ff07ca2bd Binary files /dev/null and b/fuzzers/corpora/midx/15dafc6fa800327f694b5eb2fc4ebf007be9c117 differ diff --git a/fuzzers/corpora/midx/1613ed4b2e909871f8897fd6354ff80a4ac12f87 b/fuzzers/corpora/midx/1613ed4b2e909871f8897fd6354ff80a4ac12f87 new file mode 100644 index 000000000..1afb32e28 Binary files /dev/null and b/fuzzers/corpora/midx/1613ed4b2e909871f8897fd6354ff80a4ac12f87 differ diff --git a/fuzzers/corpora/midx/16daf4cb967bb47cf4566e9be7d96d3125bd2e12 b/fuzzers/corpora/midx/16daf4cb967bb47cf4566e9be7d96d3125bd2e12 new file mode 100644 index 000000000..729b22a63 Binary files /dev/null and b/fuzzers/corpora/midx/16daf4cb967bb47cf4566e9be7d96d3125bd2e12 differ diff --git a/fuzzers/corpora/midx/177783dce78efee878f6d6020fd87ab107bb11a1 b/fuzzers/corpora/midx/177783dce78efee878f6d6020fd87ab107bb11a1 new file mode 100644 index 000000000..cc1810e6c Binary files /dev/null and b/fuzzers/corpora/midx/177783dce78efee878f6d6020fd87ab107bb11a1 differ diff --git a/fuzzers/corpora/midx/17a5090400a1fedc45070e4b530a26f320a89097 b/fuzzers/corpora/midx/17a5090400a1fedc45070e4b530a26f320a89097 new file mode 100644 index 000000000..7255c8577 Binary files /dev/null and b/fuzzers/corpora/midx/17a5090400a1fedc45070e4b530a26f320a89097 differ diff --git a/fuzzers/corpora/midx/17dea5cfa498f4d54384289a1daed0d15a85e7cc b/fuzzers/corpora/midx/17dea5cfa498f4d54384289a1daed0d15a85e7cc new file mode 100644 index 000000000..00572bbea Binary files /dev/null and b/fuzzers/corpora/midx/17dea5cfa498f4d54384289a1daed0d15a85e7cc differ diff --git a/fuzzers/corpora/midx/17e76ae5b54316679981113f52c27edc87dbcdea b/fuzzers/corpora/midx/17e76ae5b54316679981113f52c27edc87dbcdea new file mode 100644 index 000000000..5f0e0d56c Binary files /dev/null and b/fuzzers/corpora/midx/17e76ae5b54316679981113f52c27edc87dbcdea differ diff --git a/fuzzers/corpora/midx/191ed5e9334693c53fc843f692dbc3c2c63e8241 b/fuzzers/corpora/midx/191ed5e9334693c53fc843f692dbc3c2c63e8241 new file mode 100644 index 000000000..17fddd8d1 Binary files /dev/null and b/fuzzers/corpora/midx/191ed5e9334693c53fc843f692dbc3c2c63e8241 differ diff --git a/fuzzers/corpora/midx/196a0ba4edb5bbfd66c1cda669abf0496573cf0e b/fuzzers/corpora/midx/196a0ba4edb5bbfd66c1cda669abf0496573cf0e new file mode 100644 index 000000000..4d685869b Binary files /dev/null and b/fuzzers/corpora/midx/196a0ba4edb5bbfd66c1cda669abf0496573cf0e differ diff --git a/fuzzers/corpora/midx/19742b6cee79fa5bf9b27dcbe367c82d0a399904 b/fuzzers/corpora/midx/19742b6cee79fa5bf9b27dcbe367c82d0a399904 new file mode 100644 index 000000000..39e705417 Binary files /dev/null and b/fuzzers/corpora/midx/19742b6cee79fa5bf9b27dcbe367c82d0a399904 differ diff --git a/fuzzers/corpora/midx/1a21d7581d3b0a8d67934d48e91d45bd818836e8 b/fuzzers/corpora/midx/1a21d7581d3b0a8d67934d48e91d45bd818836e8 new file mode 100644 index 000000000..616b808d9 Binary files /dev/null and b/fuzzers/corpora/midx/1a21d7581d3b0a8d67934d48e91d45bd818836e8 differ diff --git a/fuzzers/corpora/midx/1b2f96c5d75c7ca09b1012be4e6c3a7b248ed924 b/fuzzers/corpora/midx/1b2f96c5d75c7ca09b1012be4e6c3a7b248ed924 new file mode 100644 index 000000000..148aad968 Binary files /dev/null and b/fuzzers/corpora/midx/1b2f96c5d75c7ca09b1012be4e6c3a7b248ed924 differ diff --git a/fuzzers/corpora/midx/1b604ff0683d0e23dc7945431f6514ba30d6ca0d b/fuzzers/corpora/midx/1b604ff0683d0e23dc7945431f6514ba30d6ca0d new file mode 100644 index 000000000..1456048ac Binary files /dev/null and b/fuzzers/corpora/midx/1b604ff0683d0e23dc7945431f6514ba30d6ca0d differ diff --git a/fuzzers/corpora/midx/1b771dd5bd3ae2b1c42c4efe6c896c83b88a4f91 b/fuzzers/corpora/midx/1b771dd5bd3ae2b1c42c4efe6c896c83b88a4f91 new file mode 100644 index 000000000..92f637662 Binary files /dev/null and b/fuzzers/corpora/midx/1b771dd5bd3ae2b1c42c4efe6c896c83b88a4f91 differ diff --git a/fuzzers/corpora/midx/1b793a4ee73fa8bf423da70fca5f39ef32a8d288 b/fuzzers/corpora/midx/1b793a4ee73fa8bf423da70fca5f39ef32a8d288 new file mode 100644 index 000000000..8c4478cfc Binary files /dev/null and b/fuzzers/corpora/midx/1b793a4ee73fa8bf423da70fca5f39ef32a8d288 differ diff --git a/fuzzers/corpora/midx/1c9599ce00978780519272be279f508c402e3268 b/fuzzers/corpora/midx/1c9599ce00978780519272be279f508c402e3268 new file mode 100644 index 000000000..c70f12828 --- /dev/null +++ b/fuzzers/corpora/midx/1c9599ce00978780519272be279f508c402e3268 @@ -0,0 +1 @@ +ă˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ĎĎĎĎĎĎĎĎĎĎĎĎĎĎĎĎĎĎĎĎĎĎĎĎĎĎĎĎĎ \ No newline at end of file diff --git a/fuzzers/corpora/midx/1cc0068f9f63b12dc8fdd38f9ebfb96c42664e95 b/fuzzers/corpora/midx/1cc0068f9f63b12dc8fdd38f9ebfb96c42664e95 new file mode 100644 index 000000000..c41e6a879 Binary files /dev/null and b/fuzzers/corpora/midx/1cc0068f9f63b12dc8fdd38f9ebfb96c42664e95 differ diff --git a/fuzzers/corpora/midx/1de6e1f5579da6e5c40f4ee23ac62e29e4f90541 b/fuzzers/corpora/midx/1de6e1f5579da6e5c40f4ee23ac62e29e4f90541 new file mode 100644 index 000000000..d8c3fbf0a Binary files /dev/null and b/fuzzers/corpora/midx/1de6e1f5579da6e5c40f4ee23ac62e29e4f90541 differ diff --git a/fuzzers/corpora/midx/1eec93083260ebfab5f4c6d13119cf27c374b7e9 b/fuzzers/corpora/midx/1eec93083260ebfab5f4c6d13119cf27c374b7e9 new file mode 100644 index 000000000..5f9c27fac Binary files /dev/null and b/fuzzers/corpora/midx/1eec93083260ebfab5f4c6d13119cf27c374b7e9 differ diff --git a/fuzzers/corpora/midx/1f0f574addd363d1fed131289f301c5c033aaa8f b/fuzzers/corpora/midx/1f0f574addd363d1fed131289f301c5c033aaa8f new file mode 100644 index 000000000..12cbb60c2 Binary files /dev/null and b/fuzzers/corpora/midx/1f0f574addd363d1fed131289f301c5c033aaa8f differ diff --git a/fuzzers/corpora/midx/1f3e85cffdb545c1ba7c8bbe1ca18ec13e341038 b/fuzzers/corpora/midx/1f3e85cffdb545c1ba7c8bbe1ca18ec13e341038 new file mode 100644 index 000000000..36b2d5ea2 Binary files /dev/null and b/fuzzers/corpora/midx/1f3e85cffdb545c1ba7c8bbe1ca18ec13e341038 differ diff --git a/fuzzers/corpora/midx/1f6a66a92d5f083a73a82280a0a1ae0800e56ae5 b/fuzzers/corpora/midx/1f6a66a92d5f083a73a82280a0a1ae0800e56ae5 new file mode 100644 index 000000000..ea50ac7be Binary files /dev/null and b/fuzzers/corpora/midx/1f6a66a92d5f083a73a82280a0a1ae0800e56ae5 differ diff --git a/fuzzers/corpora/midx/208e422322052efcdaeb1a09bbf06c5f476b8efc b/fuzzers/corpora/midx/208e422322052efcdaeb1a09bbf06c5f476b8efc new file mode 100644 index 000000000..ce98394b3 Binary files /dev/null and b/fuzzers/corpora/midx/208e422322052efcdaeb1a09bbf06c5f476b8efc differ diff --git a/fuzzers/corpora/midx/22d75b2c3937957b14eded621b638283ce7fe1fe b/fuzzers/corpora/midx/22d75b2c3937957b14eded621b638283ce7fe1fe new file mode 100644 index 000000000..0aa34c4ef Binary files /dev/null and b/fuzzers/corpora/midx/22d75b2c3937957b14eded621b638283ce7fe1fe differ diff --git a/fuzzers/corpora/midx/22f90ff68166a409acf8f89bf60a31ad2c64ab37 b/fuzzers/corpora/midx/22f90ff68166a409acf8f89bf60a31ad2c64ab37 new file mode 100644 index 000000000..cdecbb60c Binary files /dev/null and b/fuzzers/corpora/midx/22f90ff68166a409acf8f89bf60a31ad2c64ab37 differ diff --git a/fuzzers/corpora/midx/236ebad449d432b039d6ace1f250ef1fa2aa364d b/fuzzers/corpora/midx/236ebad449d432b039d6ace1f250ef1fa2aa364d new file mode 100644 index 000000000..0e213a171 Binary files /dev/null and b/fuzzers/corpora/midx/236ebad449d432b039d6ace1f250ef1fa2aa364d differ diff --git a/fuzzers/corpora/midx/252a4e4bf7fb21792ec2f305fd88fa7c9168505f b/fuzzers/corpora/midx/252a4e4bf7fb21792ec2f305fd88fa7c9168505f new file mode 100644 index 000000000..b23555c93 Binary files /dev/null and b/fuzzers/corpora/midx/252a4e4bf7fb21792ec2f305fd88fa7c9168505f differ diff --git a/fuzzers/corpora/midx/259e1faf7b7f12250062d36ded1193a9dbcae0f5 b/fuzzers/corpora/midx/259e1faf7b7f12250062d36ded1193a9dbcae0f5 new file mode 100644 index 000000000..f2f1de5c6 Binary files /dev/null and b/fuzzers/corpora/midx/259e1faf7b7f12250062d36ded1193a9dbcae0f5 differ diff --git a/fuzzers/corpora/midx/25ad3dfb655ab4c853d0d277872310d9579c8e83 b/fuzzers/corpora/midx/25ad3dfb655ab4c853d0d277872310d9579c8e83 new file mode 100644 index 000000000..325c38585 Binary files /dev/null and b/fuzzers/corpora/midx/25ad3dfb655ab4c853d0d277872310d9579c8e83 differ diff --git a/fuzzers/corpora/midx/26210f5b8fdbf81b312feea48659ec6e2e083c0b b/fuzzers/corpora/midx/26210f5b8fdbf81b312feea48659ec6e2e083c0b new file mode 100644 index 000000000..479a291fa Binary files /dev/null and b/fuzzers/corpora/midx/26210f5b8fdbf81b312feea48659ec6e2e083c0b differ diff --git a/fuzzers/corpora/midx/263a2a0915be36d8cb2bc30774e37e0344262347 b/fuzzers/corpora/midx/263a2a0915be36d8cb2bc30774e37e0344262347 new file mode 100644 index 000000000..8a9076140 Binary files /dev/null and b/fuzzers/corpora/midx/263a2a0915be36d8cb2bc30774e37e0344262347 differ diff --git a/fuzzers/corpora/midx/2679bfbc2f4f7c10a304245da4e156e235377b63 b/fuzzers/corpora/midx/2679bfbc2f4f7c10a304245da4e156e235377b63 new file mode 100644 index 000000000..dbf598d81 Binary files /dev/null and b/fuzzers/corpora/midx/2679bfbc2f4f7c10a304245da4e156e235377b63 differ diff --git a/fuzzers/corpora/midx/270b7b567a63dd94bb2a90448bbbc2e2bbc4a261 b/fuzzers/corpora/midx/270b7b567a63dd94bb2a90448bbbc2e2bbc4a261 new file mode 100644 index 000000000..0c08b8c13 Binary files /dev/null and b/fuzzers/corpora/midx/270b7b567a63dd94bb2a90448bbbc2e2bbc4a261 differ diff --git a/fuzzers/corpora/midx/271cd5c5e254a293d115588ee130040ef26b59e8 b/fuzzers/corpora/midx/271cd5c5e254a293d115588ee130040ef26b59e8 new file mode 100644 index 000000000..89309dc1a Binary files /dev/null and b/fuzzers/corpora/midx/271cd5c5e254a293d115588ee130040ef26b59e8 differ diff --git a/fuzzers/corpora/midx/27839a8035b48f8c19ab073808a03a95b6a90cc3 b/fuzzers/corpora/midx/27839a8035b48f8c19ab073808a03a95b6a90cc3 new file mode 100644 index 000000000..459506950 Binary files /dev/null and b/fuzzers/corpora/midx/27839a8035b48f8c19ab073808a03a95b6a90cc3 differ diff --git a/fuzzers/corpora/midx/2810c385c9285cbdb65bcdab5175999fe547cbad b/fuzzers/corpora/midx/2810c385c9285cbdb65bcdab5175999fe547cbad new file mode 100644 index 000000000..0d3fc30b8 Binary files /dev/null and b/fuzzers/corpora/midx/2810c385c9285cbdb65bcdab5175999fe547cbad differ diff --git a/fuzzers/corpora/midx/28afaf4ab4b092ccf987661e58009f96126bba63 b/fuzzers/corpora/midx/28afaf4ab4b092ccf987661e58009f96126bba63 new file mode 100644 index 000000000..6a29fb12c Binary files /dev/null and b/fuzzers/corpora/midx/28afaf4ab4b092ccf987661e58009f96126bba63 differ diff --git a/fuzzers/corpora/midx/29f842e86a891cff9f0b44c8aec19f7e23a47000 b/fuzzers/corpora/midx/29f842e86a891cff9f0b44c8aec19f7e23a47000 new file mode 100644 index 000000000..5644eb8af Binary files /dev/null and b/fuzzers/corpora/midx/29f842e86a891cff9f0b44c8aec19f7e23a47000 differ diff --git a/fuzzers/corpora/midx/2aa2549f617f19402d1feac61d4ca1af3545cc8a b/fuzzers/corpora/midx/2aa2549f617f19402d1feac61d4ca1af3545cc8a new file mode 100644 index 000000000..77045850a Binary files /dev/null and b/fuzzers/corpora/midx/2aa2549f617f19402d1feac61d4ca1af3545cc8a differ diff --git a/fuzzers/corpora/midx/2b73c2902eda6da41321493601003b29c3445713 b/fuzzers/corpora/midx/2b73c2902eda6da41321493601003b29c3445713 new file mode 100644 index 000000000..402d06647 Binary files /dev/null and b/fuzzers/corpora/midx/2b73c2902eda6da41321493601003b29c3445713 differ diff --git a/fuzzers/corpora/midx/2bcec1274c5e7b2d7a581d851c016ef5b553fabe b/fuzzers/corpora/midx/2bcec1274c5e7b2d7a581d851c016ef5b553fabe new file mode 100644 index 000000000..43e18c8cc Binary files /dev/null and b/fuzzers/corpora/midx/2bcec1274c5e7b2d7a581d851c016ef5b553fabe differ diff --git a/fuzzers/corpora/midx/2dd9a328b6d4e29e42684347be5c4b7cd7dc1a66 b/fuzzers/corpora/midx/2dd9a328b6d4e29e42684347be5c4b7cd7dc1a66 new file mode 100644 index 000000000..a3e6da55c Binary files /dev/null and b/fuzzers/corpora/midx/2dd9a328b6d4e29e42684347be5c4b7cd7dc1a66 differ diff --git a/fuzzers/corpora/midx/2ddc17ee7ee89bb7dbc673328d5f3e55c76e686e b/fuzzers/corpora/midx/2ddc17ee7ee89bb7dbc673328d5f3e55c76e686e new file mode 100644 index 000000000..7b789f304 Binary files /dev/null and b/fuzzers/corpora/midx/2ddc17ee7ee89bb7dbc673328d5f3e55c76e686e differ diff --git a/fuzzers/corpora/midx/2f71d5e99dc93618ed99fdb7c244a8f5e4a7eb4a b/fuzzers/corpora/midx/2f71d5e99dc93618ed99fdb7c244a8f5e4a7eb4a new file mode 100644 index 000000000..7d2f004ba Binary files /dev/null and b/fuzzers/corpora/midx/2f71d5e99dc93618ed99fdb7c244a8f5e4a7eb4a differ diff --git a/fuzzers/corpora/midx/2f7cd0154d71a83e7b104670b2a77fbd285ffde2 b/fuzzers/corpora/midx/2f7cd0154d71a83e7b104670b2a77fbd285ffde2 new file mode 100644 index 000000000..645a39bff Binary files /dev/null and b/fuzzers/corpora/midx/2f7cd0154d71a83e7b104670b2a77fbd285ffde2 differ diff --git a/fuzzers/corpora/midx/2f9d40ef790f5213234e95d123dce942b2d1d389 b/fuzzers/corpora/midx/2f9d40ef790f5213234e95d123dce942b2d1d389 new file mode 100644 index 000000000..bca234806 Binary files /dev/null and b/fuzzers/corpora/midx/2f9d40ef790f5213234e95d123dce942b2d1d389 differ diff --git a/fuzzers/corpora/midx/31577bacbca7017308d2a0c9ebfdd4fce513bbe4 b/fuzzers/corpora/midx/31577bacbca7017308d2a0c9ebfdd4fce513bbe4 new file mode 100644 index 000000000..72972b16b Binary files /dev/null and b/fuzzers/corpora/midx/31577bacbca7017308d2a0c9ebfdd4fce513bbe4 differ diff --git a/fuzzers/corpora/midx/3278f1bab88b80597d0066812d49f8bd3c7b1dcf b/fuzzers/corpora/midx/3278f1bab88b80597d0066812d49f8bd3c7b1dcf new file mode 100644 index 000000000..4177febbb Binary files /dev/null and b/fuzzers/corpora/midx/3278f1bab88b80597d0066812d49f8bd3c7b1dcf differ diff --git a/fuzzers/corpora/midx/328160cae6235605ff70951a2f6ac669ba7bb397 b/fuzzers/corpora/midx/328160cae6235605ff70951a2f6ac669ba7bb397 new file mode 100644 index 000000000..1585907e0 Binary files /dev/null and b/fuzzers/corpora/midx/328160cae6235605ff70951a2f6ac669ba7bb397 differ diff --git a/fuzzers/corpora/midx/337ed1bf91701a4c8926840259077e55938c6efc b/fuzzers/corpora/midx/337ed1bf91701a4c8926840259077e55938c6efc new file mode 100644 index 000000000..915128f16 Binary files /dev/null and b/fuzzers/corpora/midx/337ed1bf91701a4c8926840259077e55938c6efc differ diff --git a/fuzzers/corpora/midx/33a97d83ff7a774797b1751ea4bffbb4a22c58d9 b/fuzzers/corpora/midx/33a97d83ff7a774797b1751ea4bffbb4a22c58d9 new file mode 100644 index 000000000..852d8dc19 Binary files /dev/null and b/fuzzers/corpora/midx/33a97d83ff7a774797b1751ea4bffbb4a22c58d9 differ diff --git a/fuzzers/corpora/midx/341021da9516401cf364ed2b7dfdda346db04f2f b/fuzzers/corpora/midx/341021da9516401cf364ed2b7dfdda346db04f2f new file mode 100644 index 000000000..13c21ab3c Binary files /dev/null and b/fuzzers/corpora/midx/341021da9516401cf364ed2b7dfdda346db04f2f differ diff --git a/fuzzers/corpora/midx/341773a439cdecc58f55fb205ac584cd93ffe0f2 b/fuzzers/corpora/midx/341773a439cdecc58f55fb205ac584cd93ffe0f2 new file mode 100644 index 000000000..0446a8866 --- /dev/null +++ b/fuzzers/corpora/midx/341773a439cdecc58f55fb205ac584cd93ffe0f2 @@ -0,0 +1 @@ +ăyyyyyššyyyyyyyyĹĹ \ No newline at end of file diff --git a/fuzzers/corpora/midx/366091157510e40bca08fc2102b9018ccf4697de b/fuzzers/corpora/midx/366091157510e40bca08fc2102b9018ccf4697de new file mode 100644 index 000000000..f2148a165 Binary files /dev/null and b/fuzzers/corpora/midx/366091157510e40bca08fc2102b9018ccf4697de differ diff --git a/fuzzers/corpora/midx/37096157e2f9f2ec8e0b97b21d335bd653f3edbd b/fuzzers/corpora/midx/37096157e2f9f2ec8e0b97b21d335bd653f3edbd new file mode 100644 index 000000000..03600aa65 Binary files /dev/null and b/fuzzers/corpora/midx/37096157e2f9f2ec8e0b97b21d335bd653f3edbd differ diff --git a/fuzzers/corpora/midx/373a74b8613d09babcb567f91047e7b556a8de90 b/fuzzers/corpora/midx/373a74b8613d09babcb567f91047e7b556a8de90 new file mode 100644 index 000000000..9427eb0c7 Binary files /dev/null and b/fuzzers/corpora/midx/373a74b8613d09babcb567f91047e7b556a8de90 differ diff --git a/fuzzers/corpora/midx/3748b07ee7bec7bdd202ee14222cefca182417d1 b/fuzzers/corpora/midx/3748b07ee7bec7bdd202ee14222cefca182417d1 new file mode 100644 index 000000000..9699411c0 Binary files /dev/null and b/fuzzers/corpora/midx/3748b07ee7bec7bdd202ee14222cefca182417d1 differ diff --git a/fuzzers/corpora/midx/38b7906b9f956dca01dc92d0a901388ec1cbc8b1 b/fuzzers/corpora/midx/38b7906b9f956dca01dc92d0a901388ec1cbc8b1 new file mode 100644 index 000000000..d7b26a331 Binary files /dev/null and b/fuzzers/corpora/midx/38b7906b9f956dca01dc92d0a901388ec1cbc8b1 differ diff --git a/fuzzers/corpora/midx/38ddf3424559f1a6e7687eff8469a358184b833b b/fuzzers/corpora/midx/38ddf3424559f1a6e7687eff8469a358184b833b new file mode 100644 index 000000000..972dd750d --- /dev/null +++ b/fuzzers/corpora/midx/38ddf3424559f1a6e7687eff8469a358184b833b @@ -0,0 +1 @@ +đă˝D \ No newline at end of file diff --git a/fuzzers/corpora/midx/38e31d0a7dcc3835ce1a4afeeda8446fb3d7ed73 b/fuzzers/corpora/midx/38e31d0a7dcc3835ce1a4afeeda8446fb3d7ed73 new file mode 100644 index 000000000..2afdc8fb5 Binary files /dev/null and b/fuzzers/corpora/midx/38e31d0a7dcc3835ce1a4afeeda8446fb3d7ed73 differ diff --git a/fuzzers/corpora/midx/3955ec4497b226391ef9eb40f38af6dee4fa26b7 b/fuzzers/corpora/midx/3955ec4497b226391ef9eb40f38af6dee4fa26b7 new file mode 100644 index 000000000..cff10d886 Binary files /dev/null and b/fuzzers/corpora/midx/3955ec4497b226391ef9eb40f38af6dee4fa26b7 differ diff --git a/fuzzers/corpora/midx/3b6b424342133feb0f587f22bcd8f21595c004e5 b/fuzzers/corpora/midx/3b6b424342133feb0f587f22bcd8f21595c004e5 new file mode 100644 index 000000000..9f2bea4f5 Binary files /dev/null and b/fuzzers/corpora/midx/3b6b424342133feb0f587f22bcd8f21595c004e5 differ diff --git a/fuzzers/corpora/midx/3bb71f41200e0ebf8d19532e7d6e384c48aa2d03 b/fuzzers/corpora/midx/3bb71f41200e0ebf8d19532e7d6e384c48aa2d03 new file mode 100644 index 000000000..28fa1334e Binary files /dev/null and b/fuzzers/corpora/midx/3bb71f41200e0ebf8d19532e7d6e384c48aa2d03 differ diff --git a/fuzzers/corpora/midx/3c5a6063797aba9ffe5ea9903bbfcf87193652d3 b/fuzzers/corpora/midx/3c5a6063797aba9ffe5ea9903bbfcf87193652d3 new file mode 100644 index 000000000..4a5725e81 Binary files /dev/null and b/fuzzers/corpora/midx/3c5a6063797aba9ffe5ea9903bbfcf87193652d3 differ diff --git a/fuzzers/corpora/midx/3dfb9927d959f2462f6944a32d080b60a265abfe b/fuzzers/corpora/midx/3dfb9927d959f2462f6944a32d080b60a265abfe new file mode 100644 index 000000000..c234cd149 Binary files /dev/null and b/fuzzers/corpora/midx/3dfb9927d959f2462f6944a32d080b60a265abfe differ diff --git a/fuzzers/corpora/midx/3e19242a63ec92a0c3f7138ebbc31bfe7cbd40cd b/fuzzers/corpora/midx/3e19242a63ec92a0c3f7138ebbc31bfe7cbd40cd new file mode 100644 index 000000000..c0e1b1d4a Binary files /dev/null and b/fuzzers/corpora/midx/3e19242a63ec92a0c3f7138ebbc31bfe7cbd40cd differ diff --git a/fuzzers/corpora/midx/3ec53ce4ea1f41f040a3c2beed929572af95dd43 b/fuzzers/corpora/midx/3ec53ce4ea1f41f040a3c2beed929572af95dd43 new file mode 100644 index 000000000..9a7ec6f79 Binary files /dev/null and b/fuzzers/corpora/midx/3ec53ce4ea1f41f040a3c2beed929572af95dd43 differ diff --git a/fuzzers/corpora/midx/3f0762fdf49a58c0d8fd6683964a85caddee391b b/fuzzers/corpora/midx/3f0762fdf49a58c0d8fd6683964a85caddee391b new file mode 100644 index 000000000..aec9b3d42 Binary files /dev/null and b/fuzzers/corpora/midx/3f0762fdf49a58c0d8fd6683964a85caddee391b differ diff --git a/fuzzers/corpora/midx/3f71ae863c4e9bac98e49a554b8ec4d78b17492d b/fuzzers/corpora/midx/3f71ae863c4e9bac98e49a554b8ec4d78b17492d new file mode 100644 index 000000000..a9e06c79d --- /dev/null +++ b/fuzzers/corpora/midx/3f71ae863c4e9bac98e49a554b8ec4d78b17492d @@ -0,0 +1 @@ +ăďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďď*ďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďéďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďď \ No newline at end of file diff --git a/fuzzers/corpora/midx/3f9df30bfb66a28fbe6f1951ef7ae4ca9f19fdf2 b/fuzzers/corpora/midx/3f9df30bfb66a28fbe6f1951ef7ae4ca9f19fdf2 new file mode 100644 index 000000000..ebb1cde86 Binary files /dev/null and b/fuzzers/corpora/midx/3f9df30bfb66a28fbe6f1951ef7ae4ca9f19fdf2 differ diff --git a/fuzzers/corpora/midx/3fabb14670c008c22094c1d7cd7b1e23b4c48b3d b/fuzzers/corpora/midx/3fabb14670c008c22094c1d7cd7b1e23b4c48b3d new file mode 100644 index 000000000..1d2d0828c Binary files /dev/null and b/fuzzers/corpora/midx/3fabb14670c008c22094c1d7cd7b1e23b4c48b3d differ diff --git a/fuzzers/corpora/midx/408fba9c66c5d1deb31e4c69f1dd0677844dbc1b b/fuzzers/corpora/midx/408fba9c66c5d1deb31e4c69f1dd0677844dbc1b new file mode 100644 index 000000000..1cded0704 Binary files /dev/null and b/fuzzers/corpora/midx/408fba9c66c5d1deb31e4c69f1dd0677844dbc1b differ diff --git a/fuzzers/corpora/midx/40ca8645081087e950ad61bccf8d43450366356e b/fuzzers/corpora/midx/40ca8645081087e950ad61bccf8d43450366356e new file mode 100644 index 000000000..834daf8c9 Binary files /dev/null and b/fuzzers/corpora/midx/40ca8645081087e950ad61bccf8d43450366356e differ diff --git a/fuzzers/corpora/midx/412faec949b9d04498de939561664ee559a583a7 b/fuzzers/corpora/midx/412faec949b9d04498de939561664ee559a583a7 new file mode 100644 index 000000000..f15b10e73 --- /dev/null +++ b/fuzzers/corpora/midx/412faec949b9d04498de939561664ee559a583a7 @@ -0,0 +1 @@ +ďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďńďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďçďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďď˙˙˙˙ \ No newline at end of file diff --git a/fuzzers/corpora/midx/4148bd5336f89e73b2a5416c67d491c0ec4a2b7d b/fuzzers/corpora/midx/4148bd5336f89e73b2a5416c67d491c0ec4a2b7d new file mode 100644 index 000000000..894ac62ea Binary files /dev/null and b/fuzzers/corpora/midx/4148bd5336f89e73b2a5416c67d491c0ec4a2b7d differ diff --git a/fuzzers/corpora/midx/41933e61fa20fbe2b190f9ae7ceae4a4b1220021 b/fuzzers/corpora/midx/41933e61fa20fbe2b190f9ae7ceae4a4b1220021 new file mode 100644 index 000000000..727789d6c Binary files /dev/null and b/fuzzers/corpora/midx/41933e61fa20fbe2b190f9ae7ceae4a4b1220021 differ diff --git a/fuzzers/corpora/midx/423d90f3fc7ddc146095ec5a4b4f455aa876b69b b/fuzzers/corpora/midx/423d90f3fc7ddc146095ec5a4b4f455aa876b69b new file mode 100644 index 000000000..fc73bd07f Binary files /dev/null and b/fuzzers/corpora/midx/423d90f3fc7ddc146095ec5a4b4f455aa876b69b differ diff --git a/fuzzers/corpora/midx/42a6c52249aa12cfef1db1bf302a483a01c972f3 b/fuzzers/corpora/midx/42a6c52249aa12cfef1db1bf302a483a01c972f3 new file mode 100644 index 000000000..e35ab98be Binary files /dev/null and b/fuzzers/corpora/midx/42a6c52249aa12cfef1db1bf302a483a01c972f3 differ diff --git a/fuzzers/corpora/midx/42a82726f0e70da9b87b6c52bc1b3415576025f2 b/fuzzers/corpora/midx/42a82726f0e70da9b87b6c52bc1b3415576025f2 new file mode 100644 index 000000000..46117b4a9 Binary files /dev/null and b/fuzzers/corpora/midx/42a82726f0e70da9b87b6c52bc1b3415576025f2 differ diff --git a/fuzzers/corpora/midx/4458e19f99e38c61ad9792b0b3bf8ac79f8236f1 b/fuzzers/corpora/midx/4458e19f99e38c61ad9792b0b3bf8ac79f8236f1 new file mode 100644 index 000000000..80407ab45 --- /dev/null +++ b/fuzzers/corpora/midx/4458e19f99e38c61ad9792b0b3bf8ac79f8236f1 @@ -0,0 +1 @@ +ă]]˙˙˙˙˙˙s4 \ No newline at end of file diff --git a/fuzzers/corpora/midx/44a4411a8d6ed67ee3ea61d91d2afafe89295b0f b/fuzzers/corpora/midx/44a4411a8d6ed67ee3ea61d91d2afafe89295b0f new file mode 100644 index 000000000..e9933b1fa Binary files /dev/null and b/fuzzers/corpora/midx/44a4411a8d6ed67ee3ea61d91d2afafe89295b0f differ diff --git a/fuzzers/corpora/midx/44e04754d1b6c0c045e05509dd7033d19a926b10 b/fuzzers/corpora/midx/44e04754d1b6c0c045e05509dd7033d19a926b10 new file mode 100644 index 000000000..5fe8e2e84 Binary files /dev/null and b/fuzzers/corpora/midx/44e04754d1b6c0c045e05509dd7033d19a926b10 differ diff --git a/fuzzers/corpora/midx/45259e9f0a2cc7739a94eccaafb37c1570f73884 b/fuzzers/corpora/midx/45259e9f0a2cc7739a94eccaafb37c1570f73884 new file mode 100644 index 000000000..90134d1da Binary files /dev/null and b/fuzzers/corpora/midx/45259e9f0a2cc7739a94eccaafb37c1570f73884 differ diff --git a/fuzzers/corpora/midx/46c0d7e952200cabc08b9cd776a9f6759f4208c3 b/fuzzers/corpora/midx/46c0d7e952200cabc08b9cd776a9f6759f4208c3 new file mode 100644 index 000000000..e3a7a837b Binary files /dev/null and b/fuzzers/corpora/midx/46c0d7e952200cabc08b9cd776a9f6759f4208c3 differ diff --git a/fuzzers/corpora/midx/46deac8631633ea3c32005124e20a2bc2bbabade b/fuzzers/corpora/midx/46deac8631633ea3c32005124e20a2bc2bbabade new file mode 100644 index 000000000..5f54eacd6 Binary files /dev/null and b/fuzzers/corpora/midx/46deac8631633ea3c32005124e20a2bc2bbabade differ diff --git a/fuzzers/corpora/midx/46e7edf6e9d6cbcdabde3b48f1c4efd93be40348 b/fuzzers/corpora/midx/46e7edf6e9d6cbcdabde3b48f1c4efd93be40348 new file mode 100644 index 000000000..0314f2c23 Binary files /dev/null and b/fuzzers/corpora/midx/46e7edf6e9d6cbcdabde3b48f1c4efd93be40348 differ diff --git a/fuzzers/corpora/midx/46fe9556c28c94f7321baa2519a3cbeabbd54d09 b/fuzzers/corpora/midx/46fe9556c28c94f7321baa2519a3cbeabbd54d09 new file mode 100644 index 000000000..75e8e6fa7 Binary files /dev/null and b/fuzzers/corpora/midx/46fe9556c28c94f7321baa2519a3cbeabbd54d09 differ diff --git a/fuzzers/corpora/midx/49223681729e73b48b26a2262e4a66b2ba00e176 b/fuzzers/corpora/midx/49223681729e73b48b26a2262e4a66b2ba00e176 new file mode 100644 index 000000000..3068c356c Binary files /dev/null and b/fuzzers/corpora/midx/49223681729e73b48b26a2262e4a66b2ba00e176 differ diff --git a/fuzzers/corpora/midx/499e61b689f6cc7e4efb0631684739c2a6f97c7d b/fuzzers/corpora/midx/499e61b689f6cc7e4efb0631684739c2a6f97c7d new file mode 100644 index 000000000..d3c735b3b Binary files /dev/null and b/fuzzers/corpora/midx/499e61b689f6cc7e4efb0631684739c2a6f97c7d differ diff --git a/fuzzers/corpora/midx/4a06ad8c4d717bd048a7a1315a3d609d70f0162d b/fuzzers/corpora/midx/4a06ad8c4d717bd048a7a1315a3d609d70f0162d new file mode 100644 index 000000000..caef1688b Binary files /dev/null and b/fuzzers/corpora/midx/4a06ad8c4d717bd048a7a1315a3d609d70f0162d differ diff --git a/fuzzers/corpora/midx/4adb7d4791a4c6370478dff2eb987d715554bf09 b/fuzzers/corpora/midx/4adb7d4791a4c6370478dff2eb987d715554bf09 new file mode 100644 index 000000000..ced147746 Binary files /dev/null and b/fuzzers/corpora/midx/4adb7d4791a4c6370478dff2eb987d715554bf09 differ diff --git a/fuzzers/corpora/midx/4b01c479cdc9b750a31d5e7ac5004309222d218d b/fuzzers/corpora/midx/4b01c479cdc9b750a31d5e7ac5004309222d218d new file mode 100644 index 000000000..4ea5a8800 Binary files /dev/null and b/fuzzers/corpora/midx/4b01c479cdc9b750a31d5e7ac5004309222d218d differ diff --git a/fuzzers/corpora/midx/4bce7460a6becba6d26984bb438d7d3aa4e4fc56 b/fuzzers/corpora/midx/4bce7460a6becba6d26984bb438d7d3aa4e4fc56 new file mode 100644 index 000000000..41c7c3ace Binary files /dev/null and b/fuzzers/corpora/midx/4bce7460a6becba6d26984bb438d7d3aa4e4fc56 differ diff --git a/fuzzers/corpora/midx/4cc96483b6800dda296f00887b12a35154115090 b/fuzzers/corpora/midx/4cc96483b6800dda296f00887b12a35154115090 new file mode 100644 index 000000000..4f0179da8 Binary files /dev/null and b/fuzzers/corpora/midx/4cc96483b6800dda296f00887b12a35154115090 differ diff --git a/fuzzers/corpora/midx/4f3aa59bae0619c9a06b631d9cb7767591810ab0 b/fuzzers/corpora/midx/4f3aa59bae0619c9a06b631d9cb7767591810ab0 new file mode 100644 index 000000000..0a677236c Binary files /dev/null and b/fuzzers/corpora/midx/4f3aa59bae0619c9a06b631d9cb7767591810ab0 differ diff --git a/fuzzers/corpora/midx/501840d963cedd2945018de59e0202444d7ebf4b b/fuzzers/corpora/midx/501840d963cedd2945018de59e0202444d7ebf4b new file mode 100644 index 000000000..cd26169c2 Binary files /dev/null and b/fuzzers/corpora/midx/501840d963cedd2945018de59e0202444d7ebf4b differ diff --git a/fuzzers/corpora/midx/50479958c030d1addceb1ca8c27f24447e555e65 b/fuzzers/corpora/midx/50479958c030d1addceb1ca8c27f24447e555e65 new file mode 100644 index 000000000..22159a49e Binary files /dev/null and b/fuzzers/corpora/midx/50479958c030d1addceb1ca8c27f24447e555e65 differ diff --git a/fuzzers/corpora/midx/508ba8ef164a809f739834a39d690e700101a7a1 b/fuzzers/corpora/midx/508ba8ef164a809f739834a39d690e700101a7a1 new file mode 100644 index 000000000..7cf01e116 Binary files /dev/null and b/fuzzers/corpora/midx/508ba8ef164a809f739834a39d690e700101a7a1 differ diff --git a/fuzzers/corpora/midx/521d345313812e54bc6c944485e19dbb39a87768 b/fuzzers/corpora/midx/521d345313812e54bc6c944485e19dbb39a87768 new file mode 100644 index 000000000..6e9550f74 Binary files /dev/null and b/fuzzers/corpora/midx/521d345313812e54bc6c944485e19dbb39a87768 differ diff --git a/fuzzers/corpora/midx/5369d74ac157f85b597c1b28bbd6768105e9327b b/fuzzers/corpora/midx/5369d74ac157f85b597c1b28bbd6768105e9327b new file mode 100644 index 000000000..bda1f8c5d Binary files /dev/null and b/fuzzers/corpora/midx/5369d74ac157f85b597c1b28bbd6768105e9327b differ diff --git a/fuzzers/corpora/midx/53997b0146ff49bfe464be203b130a67ea93fd26 b/fuzzers/corpora/midx/53997b0146ff49bfe464be203b130a67ea93fd26 new file mode 100644 index 000000000..12ea4cd28 Binary files /dev/null and b/fuzzers/corpora/midx/53997b0146ff49bfe464be203b130a67ea93fd26 differ diff --git a/fuzzers/corpora/midx/560ea8bd7d11b00e0d21631b6d9ec7e63f0a5286 b/fuzzers/corpora/midx/560ea8bd7d11b00e0d21631b6d9ec7e63f0a5286 new file mode 100644 index 000000000..0c984e107 Binary files /dev/null and b/fuzzers/corpora/midx/560ea8bd7d11b00e0d21631b6d9ec7e63f0a5286 differ diff --git a/fuzzers/corpora/midx/5682ebc6878e247ce9bc636d34ada6ad338fcaf0 b/fuzzers/corpora/midx/5682ebc6878e247ce9bc636d34ada6ad338fcaf0 new file mode 100644 index 000000000..1b881402f Binary files /dev/null and b/fuzzers/corpora/midx/5682ebc6878e247ce9bc636d34ada6ad338fcaf0 differ diff --git a/fuzzers/corpora/midx/5762abb5234edd913754b69e1ab03274c711ee68 b/fuzzers/corpora/midx/5762abb5234edd913754b69e1ab03274c711ee68 new file mode 100644 index 000000000..668572272 Binary files /dev/null and b/fuzzers/corpora/midx/5762abb5234edd913754b69e1ab03274c711ee68 differ diff --git a/fuzzers/corpora/midx/579406f055070559bda3c6120107feb3e637c481 b/fuzzers/corpora/midx/579406f055070559bda3c6120107feb3e637c481 new file mode 100644 index 000000000..be7a59b5c --- /dev/null +++ b/fuzzers/corpora/midx/579406f055070559bda3c6120107feb3e637c481 @@ -0,0 +1,2 @@ +˙&ă +˙˙)Ĺ \ No newline at end of file diff --git a/fuzzers/corpora/midx/5837d16af4a9c1f2616467cc4aa9ec8836e05c58 b/fuzzers/corpora/midx/5837d16af4a9c1f2616467cc4aa9ec8836e05c58 new file mode 100644 index 000000000..69bf0eb68 Binary files /dev/null and b/fuzzers/corpora/midx/5837d16af4a9c1f2616467cc4aa9ec8836e05c58 differ diff --git a/fuzzers/corpora/midx/58901e865fe20b9fa136cca4b253d3ae73c2b78e b/fuzzers/corpora/midx/58901e865fe20b9fa136cca4b253d3ae73c2b78e new file mode 100644 index 000000000..c3605201e Binary files /dev/null and b/fuzzers/corpora/midx/58901e865fe20b9fa136cca4b253d3ae73c2b78e differ diff --git a/fuzzers/corpora/midx/58a87098a14572e46b53c87340083f999d8fcfc2 b/fuzzers/corpora/midx/58a87098a14572e46b53c87340083f999d8fcfc2 new file mode 100644 index 000000000..f3711cd08 Binary files /dev/null and b/fuzzers/corpora/midx/58a87098a14572e46b53c87340083f999d8fcfc2 differ diff --git a/fuzzers/corpora/midx/59ae139a21448e0eb7371ddc6ef57f0c9dfe9c85 b/fuzzers/corpora/midx/59ae139a21448e0eb7371ddc6ef57f0c9dfe9c85 new file mode 100644 index 000000000..953072ca1 Binary files /dev/null and b/fuzzers/corpora/midx/59ae139a21448e0eb7371ddc6ef57f0c9dfe9c85 differ diff --git a/fuzzers/corpora/midx/5a7e81419f895168c555ac9b4e75a1ad4f04b34a b/fuzzers/corpora/midx/5a7e81419f895168c555ac9b4e75a1ad4f04b34a new file mode 100644 index 000000000..c6b2c583f Binary files /dev/null and b/fuzzers/corpora/midx/5a7e81419f895168c555ac9b4e75a1ad4f04b34a differ diff --git a/fuzzers/corpora/midx/5b848c1f56a150d64020e9b0bb398a286dca4096 b/fuzzers/corpora/midx/5b848c1f56a150d64020e9b0bb398a286dca4096 new file mode 100644 index 000000000..17e91c12e Binary files /dev/null and b/fuzzers/corpora/midx/5b848c1f56a150d64020e9b0bb398a286dca4096 differ diff --git a/fuzzers/corpora/midx/5bd311bd846336149b2815666052fdb7e8bf2ea6 b/fuzzers/corpora/midx/5bd311bd846336149b2815666052fdb7e8bf2ea6 new file mode 100644 index 000000000..ccfa796ec Binary files /dev/null and b/fuzzers/corpora/midx/5bd311bd846336149b2815666052fdb7e8bf2ea6 differ diff --git a/fuzzers/corpora/midx/5ce77eb98473a2e01d04909939edf7aabef5762c b/fuzzers/corpora/midx/5ce77eb98473a2e01d04909939edf7aabef5762c new file mode 100644 index 000000000..b8ed8eea9 Binary files /dev/null and b/fuzzers/corpora/midx/5ce77eb98473a2e01d04909939edf7aabef5762c differ diff --git a/fuzzers/corpora/midx/5e5cd5819811507ac69bd8abad27433ccd6b7521 b/fuzzers/corpora/midx/5e5cd5819811507ac69bd8abad27433ccd6b7521 new file mode 100644 index 000000000..9069e16c1 Binary files /dev/null and b/fuzzers/corpora/midx/5e5cd5819811507ac69bd8abad27433ccd6b7521 differ diff --git a/fuzzers/corpora/midx/5ea114ae3dbb140364000c416152b0f32ce3de23 b/fuzzers/corpora/midx/5ea114ae3dbb140364000c416152b0f32ce3de23 new file mode 100644 index 000000000..2c0394488 Binary files /dev/null and b/fuzzers/corpora/midx/5ea114ae3dbb140364000c416152b0f32ce3de23 differ diff --git a/fuzzers/corpora/midx/5f181bb0a79603c84534a9b8e37ecdeb1d2aeeb5 b/fuzzers/corpora/midx/5f181bb0a79603c84534a9b8e37ecdeb1d2aeeb5 new file mode 100644 index 000000000..c1a826f37 --- /dev/null +++ b/fuzzers/corpora/midx/5f181bb0a79603c84534a9b8e37ecdeb1d2aeeb5 @@ -0,0 +1 @@ +ăÂë®<™“ V¨Ý`oÓ¤Ük @rÜshuffleéDHE-PSK-AR˙˙˙˙˙˙˙'MIDŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰßŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŕŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŮŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŮŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰ[ŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰŰ \ No newline at end of file diff --git a/fuzzers/corpora/midx/5f428ce1169e28353cedb8be3e2f6edd0ef354e4 b/fuzzers/corpora/midx/5f428ce1169e28353cedb8be3e2f6edd0ef354e4 new file mode 100644 index 000000000..e2b08527f Binary files /dev/null and b/fuzzers/corpora/midx/5f428ce1169e28353cedb8be3e2f6edd0ef354e4 differ diff --git a/fuzzers/corpora/midx/5f9bc7729dc331e3c4d8e52df0688abad6d4aee8 b/fuzzers/corpora/midx/5f9bc7729dc331e3c4d8e52df0688abad6d4aee8 new file mode 100644 index 000000000..31b96f9a9 Binary files /dev/null and b/fuzzers/corpora/midx/5f9bc7729dc331e3c4d8e52df0688abad6d4aee8 differ diff --git a/fuzzers/corpora/midx/619527e1d650cd1c26e9bc61e424c9fdc04b17b9 b/fuzzers/corpora/midx/619527e1d650cd1c26e9bc61e424c9fdc04b17b9 new file mode 100644 index 000000000..87c36d778 Binary files /dev/null and b/fuzzers/corpora/midx/619527e1d650cd1c26e9bc61e424c9fdc04b17b9 differ diff --git a/fuzzers/corpora/midx/625d3676de25188865e05db2a3933c38508406fc b/fuzzers/corpora/midx/625d3676de25188865e05db2a3933c38508406fc new file mode 100644 index 000000000..95c2db2f0 Binary files /dev/null and b/fuzzers/corpora/midx/625d3676de25188865e05db2a3933c38508406fc differ diff --git a/fuzzers/corpora/midx/6368569cfde7fbe369a0ee4695fa4d5a7d7887a6 b/fuzzers/corpora/midx/6368569cfde7fbe369a0ee4695fa4d5a7d7887a6 new file mode 100644 index 000000000..47ffb54a7 Binary files /dev/null and b/fuzzers/corpora/midx/6368569cfde7fbe369a0ee4695fa4d5a7d7887a6 differ diff --git a/fuzzers/corpora/midx/6388fe4d630064ea1ea33aa85381d9c82e328e95 b/fuzzers/corpora/midx/6388fe4d630064ea1ea33aa85381d9c82e328e95 new file mode 100644 index 000000000..85cf1e1d9 Binary files /dev/null and b/fuzzers/corpora/midx/6388fe4d630064ea1ea33aa85381d9c82e328e95 differ diff --git a/fuzzers/corpora/midx/64cff4e110f0bcb3ea833c1afda6e27a57dac0bc b/fuzzers/corpora/midx/64cff4e110f0bcb3ea833c1afda6e27a57dac0bc new file mode 100644 index 000000000..29ac450b3 Binary files /dev/null and b/fuzzers/corpora/midx/64cff4e110f0bcb3ea833c1afda6e27a57dac0bc differ diff --git a/fuzzers/corpora/midx/66449b87ce47b681c6326f337bebf03366a0ee99 b/fuzzers/corpora/midx/66449b87ce47b681c6326f337bebf03366a0ee99 new file mode 100644 index 000000000..a2b3b25d4 Binary files /dev/null and b/fuzzers/corpora/midx/66449b87ce47b681c6326f337bebf03366a0ee99 differ diff --git a/fuzzers/corpora/midx/66ae3584497a1823a955c33e5bc53f7434c13e49 b/fuzzers/corpora/midx/66ae3584497a1823a955c33e5bc53f7434c13e49 new file mode 100644 index 000000000..0d5dcff5e Binary files /dev/null and b/fuzzers/corpora/midx/66ae3584497a1823a955c33e5bc53f7434c13e49 differ diff --git a/fuzzers/corpora/midx/66e238a6ad70fb30c82171ff1b73ea71b4379355 b/fuzzers/corpora/midx/66e238a6ad70fb30c82171ff1b73ea71b4379355 new file mode 100644 index 000000000..6f28e8dfd Binary files /dev/null and b/fuzzers/corpora/midx/66e238a6ad70fb30c82171ff1b73ea71b4379355 differ diff --git a/fuzzers/corpora/midx/66f345dc060ac5a1fe8bcf0828102d072deb1111 b/fuzzers/corpora/midx/66f345dc060ac5a1fe8bcf0828102d072deb1111 new file mode 100644 index 000000000..6d3181f63 Binary files /dev/null and b/fuzzers/corpora/midx/66f345dc060ac5a1fe8bcf0828102d072deb1111 differ diff --git a/fuzzers/corpora/midx/66f839146ef46deed25fd2cd169a4f1a2a3533fa b/fuzzers/corpora/midx/66f839146ef46deed25fd2cd169a4f1a2a3533fa new file mode 100644 index 000000000..5a6223d74 Binary files /dev/null and b/fuzzers/corpora/midx/66f839146ef46deed25fd2cd169a4f1a2a3533fa differ diff --git a/fuzzers/corpora/midx/671720ee2b7ba45920b41b8016eb5206b88168ee b/fuzzers/corpora/midx/671720ee2b7ba45920b41b8016eb5206b88168ee new file mode 100644 index 000000000..564ff2b1b Binary files /dev/null and b/fuzzers/corpora/midx/671720ee2b7ba45920b41b8016eb5206b88168ee differ diff --git a/fuzzers/corpora/midx/679c7140ad60ed32aeb7ee464499dd52b0fc212f b/fuzzers/corpora/midx/679c7140ad60ed32aeb7ee464499dd52b0fc212f new file mode 100644 index 000000000..189132305 Binary files /dev/null and b/fuzzers/corpora/midx/679c7140ad60ed32aeb7ee464499dd52b0fc212f differ diff --git a/fuzzers/corpora/midx/67c5e6ce7bb47cefe54d749374f3288a2c915936 b/fuzzers/corpora/midx/67c5e6ce7bb47cefe54d749374f3288a2c915936 new file mode 100644 index 000000000..7e3303af9 Binary files /dev/null and b/fuzzers/corpora/midx/67c5e6ce7bb47cefe54d749374f3288a2c915936 differ diff --git a/fuzzers/corpora/midx/69592399b45f2f83e0cc823c5f0e3865ac3fa611 b/fuzzers/corpora/midx/69592399b45f2f83e0cc823c5f0e3865ac3fa611 new file mode 100644 index 000000000..272619cb6 Binary files /dev/null and b/fuzzers/corpora/midx/69592399b45f2f83e0cc823c5f0e3865ac3fa611 differ diff --git a/fuzzers/corpora/midx/6abf97508f0ed808b7fe0d9bb2439981153badd2 b/fuzzers/corpora/midx/6abf97508f0ed808b7fe0d9bb2439981153badd2 new file mode 100644 index 000000000..800363386 Binary files /dev/null and b/fuzzers/corpora/midx/6abf97508f0ed808b7fe0d9bb2439981153badd2 differ diff --git a/fuzzers/corpora/midx/6b2dfb51b35b78680cb02ff54e06f0c983c04866 b/fuzzers/corpora/midx/6b2dfb51b35b78680cb02ff54e06f0c983c04866 new file mode 100644 index 000000000..2909a341a Binary files /dev/null and b/fuzzers/corpora/midx/6b2dfb51b35b78680cb02ff54e06f0c983c04866 differ diff --git a/fuzzers/corpora/midx/6bbf6ab605fedd41ed6c7581ec9f87c75403e9c3 b/fuzzers/corpora/midx/6bbf6ab605fedd41ed6c7581ec9f87c75403e9c3 new file mode 100644 index 000000000..d41ae611d Binary files /dev/null and b/fuzzers/corpora/midx/6bbf6ab605fedd41ed6c7581ec9f87c75403e9c3 differ diff --git a/fuzzers/corpora/midx/6c0656104902e1323f3a19c46df7cffecae94f1c b/fuzzers/corpora/midx/6c0656104902e1323f3a19c46df7cffecae94f1c new file mode 100644 index 000000000..a47781bdf Binary files /dev/null and b/fuzzers/corpora/midx/6c0656104902e1323f3a19c46df7cffecae94f1c differ diff --git a/fuzzers/corpora/midx/6c0ce8006b3ebd8202e61fe5f4cc2285248bd1ba b/fuzzers/corpora/midx/6c0ce8006b3ebd8202e61fe5f4cc2285248bd1ba new file mode 100644 index 000000000..ca2e6fb53 Binary files /dev/null and b/fuzzers/corpora/midx/6c0ce8006b3ebd8202e61fe5f4cc2285248bd1ba differ diff --git a/fuzzers/corpora/midx/6cc635e6dd4e430ed4fb68a9f5add38aa02ae14f b/fuzzers/corpora/midx/6cc635e6dd4e430ed4fb68a9f5add38aa02ae14f new file mode 100644 index 000000000..8f04f864c Binary files /dev/null and b/fuzzers/corpora/midx/6cc635e6dd4e430ed4fb68a9f5add38aa02ae14f differ diff --git a/fuzzers/corpora/midx/6d1b281d7bdd9887e53505fd5d040731db18ba48 b/fuzzers/corpora/midx/6d1b281d7bdd9887e53505fd5d040731db18ba48 new file mode 100644 index 000000000..93f359a47 Binary files /dev/null and b/fuzzers/corpora/midx/6d1b281d7bdd9887e53505fd5d040731db18ba48 differ diff --git a/fuzzers/corpora/midx/6d5c35f9d87253b2fbe383bfde3775a9f737da12 b/fuzzers/corpora/midx/6d5c35f9d87253b2fbe383bfde3775a9f737da12 new file mode 100644 index 000000000..fe238cdfd --- /dev/null +++ b/fuzzers/corpora/midx/6d5c35f9d87253b2fbe383bfde3775a9f737da12 @@ -0,0 +1 @@ +ă˙˙˙˙˙˙˙ďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďď˙˙˙˙˙˙Óďďďďďďďďďďďďďďďďďďďď÷ďďďďďďďďďďď˙ \ No newline at end of file diff --git a/fuzzers/corpora/midx/6d95355018cadedd97bed65c45a44a7ff6f065f7 b/fuzzers/corpora/midx/6d95355018cadedd97bed65c45a44a7ff6f065f7 new file mode 100644 index 000000000..1c1a35486 Binary files /dev/null and b/fuzzers/corpora/midx/6d95355018cadedd97bed65c45a44a7ff6f065f7 differ diff --git a/fuzzers/corpora/midx/6dd70e887ab94db3327d9aaa0335914a1f4986b7 b/fuzzers/corpora/midx/6dd70e887ab94db3327d9aaa0335914a1f4986b7 new file mode 100644 index 000000000..c1edd0b5d Binary files /dev/null and b/fuzzers/corpora/midx/6dd70e887ab94db3327d9aaa0335914a1f4986b7 differ diff --git a/fuzzers/corpora/midx/6ed51a953a8b6671de417406e340d8d0a211aa12 b/fuzzers/corpora/midx/6ed51a953a8b6671de417406e340d8d0a211aa12 new file mode 100644 index 000000000..d21f30c03 Binary files /dev/null and b/fuzzers/corpora/midx/6ed51a953a8b6671de417406e340d8d0a211aa12 differ diff --git a/fuzzers/corpora/midx/6f911f19652a4457c93ef92b594bc1dc2ca900f8 b/fuzzers/corpora/midx/6f911f19652a4457c93ef92b594bc1dc2ca900f8 new file mode 100644 index 000000000..8c537dc8d Binary files /dev/null and b/fuzzers/corpora/midx/6f911f19652a4457c93ef92b594bc1dc2ca900f8 differ diff --git a/fuzzers/corpora/midx/6fa76cbaeb3cf0417c7a372132167bcd737db66b b/fuzzers/corpora/midx/6fa76cbaeb3cf0417c7a372132167bcd737db66b new file mode 100644 index 000000000..a506334e0 Binary files /dev/null and b/fuzzers/corpora/midx/6fa76cbaeb3cf0417c7a372132167bcd737db66b differ diff --git a/fuzzers/corpora/midx/71f66d3f7da318d69681a22ebbceb1a2bb290658 b/fuzzers/corpora/midx/71f66d3f7da318d69681a22ebbceb1a2bb290658 new file mode 100644 index 000000000..317820a99 Binary files /dev/null and b/fuzzers/corpora/midx/71f66d3f7da318d69681a22ebbceb1a2bb290658 differ diff --git a/fuzzers/corpora/midx/7227a2dc335af13e7225536c49969f46a800750a b/fuzzers/corpora/midx/7227a2dc335af13e7225536c49969f46a800750a new file mode 100644 index 000000000..d7b9d6f34 --- /dev/null +++ b/fuzzers/corpora/midx/7227a2dc335af13e7225536c49969f46a800750a @@ -0,0 +1 @@ +ăj \ No newline at end of file diff --git a/fuzzers/corpora/midx/72fce27bbccf582f2023f5e168853251e576592a b/fuzzers/corpora/midx/72fce27bbccf582f2023f5e168853251e576592a new file mode 100644 index 000000000..646d858bf Binary files /dev/null and b/fuzzers/corpora/midx/72fce27bbccf582f2023f5e168853251e576592a differ diff --git a/fuzzers/corpora/midx/738e5543ae005a6de85dfcd960eb8e3e6faa8947 b/fuzzers/corpora/midx/738e5543ae005a6de85dfcd960eb8e3e6faa8947 new file mode 100644 index 000000000..33dd640b4 Binary files /dev/null and b/fuzzers/corpora/midx/738e5543ae005a6de85dfcd960eb8e3e6faa8947 differ diff --git a/fuzzers/corpora/midx/739d9c8868445202305d0a4e5766df1c68932688 b/fuzzers/corpora/midx/739d9c8868445202305d0a4e5766df1c68932688 new file mode 100644 index 000000000..58450d924 Binary files /dev/null and b/fuzzers/corpora/midx/739d9c8868445202305d0a4e5766df1c68932688 differ diff --git a/fuzzers/corpora/midx/7438b07314917c84d348e7d9629e3712190c7da7 b/fuzzers/corpora/midx/7438b07314917c84d348e7d9629e3712190c7da7 new file mode 100644 index 000000000..197006e44 Binary files /dev/null and b/fuzzers/corpora/midx/7438b07314917c84d348e7d9629e3712190c7da7 differ diff --git a/fuzzers/corpora/midx/7490f00d660f5d8dedfa606cca241bd07be86a4f b/fuzzers/corpora/midx/7490f00d660f5d8dedfa606cca241bd07be86a4f new file mode 100644 index 000000000..9f056b2b5 Binary files /dev/null and b/fuzzers/corpora/midx/7490f00d660f5d8dedfa606cca241bd07be86a4f differ diff --git a/fuzzers/corpora/midx/75c64e8b61af41b28516c2c0fe902362d55a24f3 b/fuzzers/corpora/midx/75c64e8b61af41b28516c2c0fe902362d55a24f3 new file mode 100644 index 000000000..7832dbce6 Binary files /dev/null and b/fuzzers/corpora/midx/75c64e8b61af41b28516c2c0fe902362d55a24f3 differ diff --git a/fuzzers/corpora/midx/75e94b59a41e7f086b6f7ab3bca801251744ae3d b/fuzzers/corpora/midx/75e94b59a41e7f086b6f7ab3bca801251744ae3d new file mode 100644 index 000000000..573a589e9 Binary files /dev/null and b/fuzzers/corpora/midx/75e94b59a41e7f086b6f7ab3bca801251744ae3d differ diff --git a/fuzzers/corpora/midx/7612ceb3a989f97a7bb19f57c7f9c61366953642 b/fuzzers/corpora/midx/7612ceb3a989f97a7bb19f57c7f9c61366953642 new file mode 100644 index 000000000..1dddb9d6d Binary files /dev/null and b/fuzzers/corpora/midx/7612ceb3a989f97a7bb19f57c7f9c61366953642 differ diff --git a/fuzzers/corpora/midx/76ac2328e1c979bca648b4082b8bfe6f2e2e73ea b/fuzzers/corpora/midx/76ac2328e1c979bca648b4082b8bfe6f2e2e73ea new file mode 100644 index 000000000..fa3ab13d8 Binary files /dev/null and b/fuzzers/corpora/midx/76ac2328e1c979bca648b4082b8bfe6f2e2e73ea differ diff --git a/fuzzers/corpora/midx/76f296039ba4d666c9147ad234d43b55050808e3 b/fuzzers/corpora/midx/76f296039ba4d666c9147ad234d43b55050808e3 new file mode 100644 index 000000000..114e764aa Binary files /dev/null and b/fuzzers/corpora/midx/76f296039ba4d666c9147ad234d43b55050808e3 differ diff --git a/fuzzers/corpora/midx/777f248eea53e3dd2b726e1e0de5eeda43b6d323 b/fuzzers/corpora/midx/777f248eea53e3dd2b726e1e0de5eeda43b6d323 new file mode 100644 index 000000000..120ffd6ed --- /dev/null +++ b/fuzzers/corpora/midx/777f248eea53e3dd2b726e1e0de5eeda43b6d323 @@ -0,0 +1 @@ +› \ No newline at end of file diff --git a/fuzzers/corpora/midx/792fcd0075bd8031a98a68ce04d6a9f23feef7b4 b/fuzzers/corpora/midx/792fcd0075bd8031a98a68ce04d6a9f23feef7b4 new file mode 100644 index 000000000..ca5572e9c Binary files /dev/null and b/fuzzers/corpora/midx/792fcd0075bd8031a98a68ce04d6a9f23feef7b4 differ diff --git a/fuzzers/corpora/midx/7a936c3e69013b2c71dcb72f0eccd99c93367533 b/fuzzers/corpora/midx/7a936c3e69013b2c71dcb72f0eccd99c93367533 new file mode 100644 index 000000000..8c3d72944 Binary files /dev/null and b/fuzzers/corpora/midx/7a936c3e69013b2c71dcb72f0eccd99c93367533 differ diff --git a/fuzzers/corpora/midx/7b30d0cd07108f2e45ce1a3fab3f971b25dcf5cd b/fuzzers/corpora/midx/7b30d0cd07108f2e45ce1a3fab3f971b25dcf5cd new file mode 100644 index 000000000..08ddd3465 Binary files /dev/null and b/fuzzers/corpora/midx/7b30d0cd07108f2e45ce1a3fab3f971b25dcf5cd differ diff --git a/fuzzers/corpora/midx/7b87f367b5fa3bf29bae19031814e5d0120a15ba b/fuzzers/corpora/midx/7b87f367b5fa3bf29bae19031814e5d0120a15ba new file mode 100644 index 000000000..146d3ee7f Binary files /dev/null and b/fuzzers/corpora/midx/7b87f367b5fa3bf29bae19031814e5d0120a15ba differ diff --git a/fuzzers/corpora/midx/7c12e4bca60858eae13c47a66e54cd9e96a50909 b/fuzzers/corpora/midx/7c12e4bca60858eae13c47a66e54cd9e96a50909 new file mode 100644 index 000000000..a3cb4abe1 Binary files /dev/null and b/fuzzers/corpora/midx/7c12e4bca60858eae13c47a66e54cd9e96a50909 differ diff --git a/fuzzers/corpora/midx/7c59f95e649b3be6344f4f835afd0d9a894c1144 b/fuzzers/corpora/midx/7c59f95e649b3be6344f4f835afd0d9a894c1144 new file mode 100644 index 000000000..4a9c07ce0 Binary files /dev/null and b/fuzzers/corpora/midx/7c59f95e649b3be6344f4f835afd0d9a894c1144 differ diff --git a/fuzzers/corpora/midx/7dcb6494c3614a8690dc496309f90e0f23634c37 b/fuzzers/corpora/midx/7dcb6494c3614a8690dc496309f90e0f23634c37 new file mode 100644 index 000000000..ef09d98dc Binary files /dev/null and b/fuzzers/corpora/midx/7dcb6494c3614a8690dc496309f90e0f23634c37 differ diff --git a/fuzzers/corpora/midx/7e64b86827ea98f0a4eb54736c460a59b0c30420 b/fuzzers/corpora/midx/7e64b86827ea98f0a4eb54736c460a59b0c30420 new file mode 100644 index 000000000..6062c8d5e Binary files /dev/null and b/fuzzers/corpora/midx/7e64b86827ea98f0a4eb54736c460a59b0c30420 differ diff --git a/fuzzers/corpora/midx/8125d9eaa09b3d2283fea73223866cb36877c4a4 b/fuzzers/corpora/midx/8125d9eaa09b3d2283fea73223866cb36877c4a4 new file mode 100644 index 000000000..d91f4ebd1 Binary files /dev/null and b/fuzzers/corpora/midx/8125d9eaa09b3d2283fea73223866cb36877c4a4 differ diff --git a/fuzzers/corpora/midx/81c7fc514fa9a07b5b87b94cf9c00df2b1325a74 b/fuzzers/corpora/midx/81c7fc514fa9a07b5b87b94cf9c00df2b1325a74 new file mode 100644 index 000000000..2c19a2acf Binary files /dev/null and b/fuzzers/corpora/midx/81c7fc514fa9a07b5b87b94cf9c00df2b1325a74 differ diff --git a/fuzzers/corpora/midx/81f9df0493052d980ca13918637bc6ce565615b3 b/fuzzers/corpora/midx/81f9df0493052d980ca13918637bc6ce565615b3 new file mode 100644 index 000000000..1030a4bca Binary files /dev/null and b/fuzzers/corpora/midx/81f9df0493052d980ca13918637bc6ce565615b3 differ diff --git a/fuzzers/corpora/midx/82556b9345134dd689cb9d0d08d3dc8459454181 b/fuzzers/corpora/midx/82556b9345134dd689cb9d0d08d3dc8459454181 new file mode 100644 index 000000000..e8a113f06 Binary files /dev/null and b/fuzzers/corpora/midx/82556b9345134dd689cb9d0d08d3dc8459454181 differ diff --git a/fuzzers/corpora/midx/82d35a7a6ffb333b02d0d597e88ffdd481237a8b b/fuzzers/corpora/midx/82d35a7a6ffb333b02d0d597e88ffdd481237a8b new file mode 100644 index 000000000..1f2de8ae6 Binary files /dev/null and b/fuzzers/corpora/midx/82d35a7a6ffb333b02d0d597e88ffdd481237a8b differ diff --git a/fuzzers/corpora/midx/82e931da372a2c69c0f10274342173c2be091f1c b/fuzzers/corpora/midx/82e931da372a2c69c0f10274342173c2be091f1c new file mode 100644 index 000000000..34a1c15ff Binary files /dev/null and b/fuzzers/corpora/midx/82e931da372a2c69c0f10274342173c2be091f1c differ diff --git a/fuzzers/corpora/midx/83e2b53f22afe8f7ee21d30fae2619ad0d6a71e3 b/fuzzers/corpora/midx/83e2b53f22afe8f7ee21d30fae2619ad0d6a71e3 new file mode 100644 index 000000000..8815c9beb Binary files /dev/null and b/fuzzers/corpora/midx/83e2b53f22afe8f7ee21d30fae2619ad0d6a71e3 differ diff --git a/fuzzers/corpora/midx/83f4d70189dbc0d3aaf5025977c53d4d34fc5893 b/fuzzers/corpora/midx/83f4d70189dbc0d3aaf5025977c53d4d34fc5893 new file mode 100644 index 000000000..78b1f7c95 Binary files /dev/null and b/fuzzers/corpora/midx/83f4d70189dbc0d3aaf5025977c53d4d34fc5893 differ diff --git a/fuzzers/corpora/midx/85e17cceba7850be893afdc04c8233bea1ef6e72 b/fuzzers/corpora/midx/85e17cceba7850be893afdc04c8233bea1ef6e72 new file mode 100644 index 000000000..0e157c96c Binary files /dev/null and b/fuzzers/corpora/midx/85e17cceba7850be893afdc04c8233bea1ef6e72 differ diff --git a/fuzzers/corpora/midx/874d4abdcd7db751eb930928231669afe90589f5 b/fuzzers/corpora/midx/874d4abdcd7db751eb930928231669afe90589f5 new file mode 100644 index 000000000..238ca42c3 Binary files /dev/null and b/fuzzers/corpora/midx/874d4abdcd7db751eb930928231669afe90589f5 differ diff --git a/fuzzers/corpora/midx/87894ec663568153d7837f49b80f6d2e99818bd7 b/fuzzers/corpora/midx/87894ec663568153d7837f49b80f6d2e99818bd7 new file mode 100644 index 000000000..d2775fdab Binary files /dev/null and b/fuzzers/corpora/midx/87894ec663568153d7837f49b80f6d2e99818bd7 differ diff --git a/fuzzers/corpora/midx/88052b76108b4ede342f3dd87bb6835b2f71ea83 b/fuzzers/corpora/midx/88052b76108b4ede342f3dd87bb6835b2f71ea83 new file mode 100644 index 000000000..c0a6a3209 Binary files /dev/null and b/fuzzers/corpora/midx/88052b76108b4ede342f3dd87bb6835b2f71ea83 differ diff --git a/fuzzers/corpora/midx/884c54256c0ec2cf1c5fa08a0b3d9c2fea021300 b/fuzzers/corpora/midx/884c54256c0ec2cf1c5fa08a0b3d9c2fea021300 new file mode 100644 index 000000000..e0980eed5 Binary files /dev/null and b/fuzzers/corpora/midx/884c54256c0ec2cf1c5fa08a0b3d9c2fea021300 differ diff --git a/fuzzers/corpora/midx/8858f36373db5fd6b805a768af55c21019c664b2 b/fuzzers/corpora/midx/8858f36373db5fd6b805a768af55c21019c664b2 new file mode 100644 index 000000000..50c738d68 Binary files /dev/null and b/fuzzers/corpora/midx/8858f36373db5fd6b805a768af55c21019c664b2 differ diff --git a/fuzzers/corpora/midx/88fe8b6767c1bd32308208b22e0b00697e5eddf7 b/fuzzers/corpora/midx/88fe8b6767c1bd32308208b22e0b00697e5eddf7 new file mode 100644 index 000000000..da39bf149 Binary files /dev/null and b/fuzzers/corpora/midx/88fe8b6767c1bd32308208b22e0b00697e5eddf7 differ diff --git a/fuzzers/corpora/midx/898cac1610f2f2fb67eb092cd053f0006c3070e3 b/fuzzers/corpora/midx/898cac1610f2f2fb67eb092cd053f0006c3070e3 new file mode 100644 index 000000000..babd31d25 Binary files /dev/null and b/fuzzers/corpora/midx/898cac1610f2f2fb67eb092cd053f0006c3070e3 differ diff --git a/fuzzers/corpora/midx/89d0f5573ae1b524e7e9bdb1fb54ea4ce99e3ef0 b/fuzzers/corpora/midx/89d0f5573ae1b524e7e9bdb1fb54ea4ce99e3ef0 new file mode 100644 index 000000000..43858e291 Binary files /dev/null and b/fuzzers/corpora/midx/89d0f5573ae1b524e7e9bdb1fb54ea4ce99e3ef0 differ diff --git a/fuzzers/corpora/midx/8a55300e400efd56be5e12258ebf575c4f3b55ed b/fuzzers/corpora/midx/8a55300e400efd56be5e12258ebf575c4f3b55ed new file mode 100644 index 000000000..bf76c1a0d Binary files /dev/null and b/fuzzers/corpora/midx/8a55300e400efd56be5e12258ebf575c4f3b55ed differ diff --git a/fuzzers/corpora/midx/8bf7b464aaa2c2b536aa1d76a1297c19155f5603 b/fuzzers/corpora/midx/8bf7b464aaa2c2b536aa1d76a1297c19155f5603 new file mode 100644 index 000000000..6b10f9584 --- /dev/null +++ b/fuzzers/corpora/midx/8bf7b464aaa2c2b536aa1d76a1297c19155f5603 @@ -0,0 +1 @@ +Ă \ No newline at end of file diff --git a/fuzzers/corpora/midx/8c05e8ef26302a79c89670ad3aa4e8d0bc921923 b/fuzzers/corpora/midx/8c05e8ef26302a79c89670ad3aa4e8d0bc921923 new file mode 100644 index 000000000..9f142f008 Binary files /dev/null and b/fuzzers/corpora/midx/8c05e8ef26302a79c89670ad3aa4e8d0bc921923 differ diff --git a/fuzzers/corpora/midx/8c15f5a268ded9663197d66e8d7d4098e0ae9bf5 b/fuzzers/corpora/midx/8c15f5a268ded9663197d66e8d7d4098e0ae9bf5 new file mode 100644 index 000000000..9b1b882c9 Binary files /dev/null and b/fuzzers/corpora/midx/8c15f5a268ded9663197d66e8d7d4098e0ae9bf5 differ diff --git a/fuzzers/corpora/midx/8ca9e85a9e628f0016ea4e6413945b3830730c24 b/fuzzers/corpora/midx/8ca9e85a9e628f0016ea4e6413945b3830730c24 new file mode 100644 index 000000000..e64a7c9dd Binary files /dev/null and b/fuzzers/corpora/midx/8ca9e85a9e628f0016ea4e6413945b3830730c24 differ diff --git a/fuzzers/corpora/midx/8e74126a239927900a8f655c813a4b230191a5ba b/fuzzers/corpora/midx/8e74126a239927900a8f655c813a4b230191a5ba new file mode 100644 index 000000000..32005e34a Binary files /dev/null and b/fuzzers/corpora/midx/8e74126a239927900a8f655c813a4b230191a5ba differ diff --git a/fuzzers/corpora/midx/8ee63e791c004427dd033b468b2ed7446ee6e2e0 b/fuzzers/corpora/midx/8ee63e791c004427dd033b468b2ed7446ee6e2e0 new file mode 100644 index 000000000..a9d264ac2 Binary files /dev/null and b/fuzzers/corpora/midx/8ee63e791c004427dd033b468b2ed7446ee6e2e0 differ diff --git a/fuzzers/corpora/midx/9028113aa78b649e13ff259027a4e450d469e5da b/fuzzers/corpora/midx/9028113aa78b649e13ff259027a4e450d469e5da new file mode 100644 index 000000000..12c09a392 Binary files /dev/null and b/fuzzers/corpora/midx/9028113aa78b649e13ff259027a4e450d469e5da differ diff --git a/fuzzers/corpora/midx/90db2115b8262ebecbefbe8f0a07c451e39bca07 b/fuzzers/corpora/midx/90db2115b8262ebecbefbe8f0a07c451e39bca07 new file mode 100644 index 000000000..38fc26c2c Binary files /dev/null and b/fuzzers/corpora/midx/90db2115b8262ebecbefbe8f0a07c451e39bca07 differ diff --git a/fuzzers/corpora/midx/923f28a4d1917e20ee0736b90695c2123c0c987c b/fuzzers/corpora/midx/923f28a4d1917e20ee0736b90695c2123c0c987c new file mode 100644 index 000000000..8961e95f2 Binary files /dev/null and b/fuzzers/corpora/midx/923f28a4d1917e20ee0736b90695c2123c0c987c differ diff --git a/fuzzers/corpora/midx/92a5c74e0506d65d1a12686496452870367b169a b/fuzzers/corpora/midx/92a5c74e0506d65d1a12686496452870367b169a new file mode 100644 index 000000000..4e08402b6 Binary files /dev/null and b/fuzzers/corpora/midx/92a5c74e0506d65d1a12686496452870367b169a differ diff --git a/fuzzers/corpora/midx/92dcf94eb2f92b4e1a232eab3b3f808f4236f118 b/fuzzers/corpora/midx/92dcf94eb2f92b4e1a232eab3b3f808f4236f118 new file mode 100644 index 000000000..0999c8a25 Binary files /dev/null and b/fuzzers/corpora/midx/92dcf94eb2f92b4e1a232eab3b3f808f4236f118 differ diff --git a/fuzzers/corpora/midx/9414502aedbef5e307897683625418dd4ac575ac b/fuzzers/corpora/midx/9414502aedbef5e307897683625418dd4ac575ac new file mode 100644 index 000000000..98260fb4c Binary files /dev/null and b/fuzzers/corpora/midx/9414502aedbef5e307897683625418dd4ac575ac differ diff --git a/fuzzers/corpora/midx/9422e25bec5fec9f84603a85673b54b1a5e77a40 b/fuzzers/corpora/midx/9422e25bec5fec9f84603a85673b54b1a5e77a40 new file mode 100644 index 000000000..e0d9ca7f0 Binary files /dev/null and b/fuzzers/corpora/midx/9422e25bec5fec9f84603a85673b54b1a5e77a40 differ diff --git a/fuzzers/corpora/midx/943754e865888063e0684aec838222522390d43e b/fuzzers/corpora/midx/943754e865888063e0684aec838222522390d43e new file mode 100644 index 000000000..2a6ba4eb5 Binary files /dev/null and b/fuzzers/corpora/midx/943754e865888063e0684aec838222522390d43e differ diff --git a/fuzzers/corpora/midx/943e067806ae069afbc029ea7a612410e5395687 b/fuzzers/corpora/midx/943e067806ae069afbc029ea7a612410e5395687 new file mode 100644 index 000000000..d51ab5fbf Binary files /dev/null and b/fuzzers/corpora/midx/943e067806ae069afbc029ea7a612410e5395687 differ diff --git a/fuzzers/corpora/midx/9547646cc1a5d260df099b00ea7ee2b95567aee1 b/fuzzers/corpora/midx/9547646cc1a5d260df099b00ea7ee2b95567aee1 new file mode 100644 index 000000000..92426bcf9 Binary files /dev/null and b/fuzzers/corpora/midx/9547646cc1a5d260df099b00ea7ee2b95567aee1 differ diff --git a/fuzzers/corpora/midx/968f7027ec9fbf75a519069ea5189e85a81448b2 b/fuzzers/corpora/midx/968f7027ec9fbf75a519069ea5189e85a81448b2 new file mode 100644 index 000000000..56dfbcdd3 Binary files /dev/null and b/fuzzers/corpora/midx/968f7027ec9fbf75a519069ea5189e85a81448b2 differ diff --git a/fuzzers/corpora/midx/9691046a2f8b31319a6fdfde0506c9a72aed839a b/fuzzers/corpora/midx/9691046a2f8b31319a6fdfde0506c9a72aed839a new file mode 100644 index 000000000..e3cfcb079 Binary files /dev/null and b/fuzzers/corpora/midx/9691046a2f8b31319a6fdfde0506c9a72aed839a differ diff --git a/fuzzers/corpora/midx/96a8cd5c33986cc26cc00eb2de627149f5259e33 b/fuzzers/corpora/midx/96a8cd5c33986cc26cc00eb2de627149f5259e33 new file mode 100644 index 000000000..85fb8fa3c Binary files /dev/null and b/fuzzers/corpora/midx/96a8cd5c33986cc26cc00eb2de627149f5259e33 differ diff --git a/fuzzers/corpora/midx/972466bbc33d2d7d7c21be21c7594b51e78675c5 b/fuzzers/corpora/midx/972466bbc33d2d7d7c21be21c7594b51e78675c5 new file mode 100644 index 000000000..b8fd7b35c Binary files /dev/null and b/fuzzers/corpora/midx/972466bbc33d2d7d7c21be21c7594b51e78675c5 differ diff --git a/fuzzers/corpora/midx/980f21a3609762154030f7cf0fe98a892d20f220 b/fuzzers/corpora/midx/980f21a3609762154030f7cf0fe98a892d20f220 new file mode 100644 index 000000000..d89f9cd77 Binary files /dev/null and b/fuzzers/corpora/midx/980f21a3609762154030f7cf0fe98a892d20f220 differ diff --git a/fuzzers/corpora/midx/9865f12189ef977418d8410fceebb6830c74d820 b/fuzzers/corpora/midx/9865f12189ef977418d8410fceebb6830c74d820 new file mode 100644 index 000000000..c4d3f67dc Binary files /dev/null and b/fuzzers/corpora/midx/9865f12189ef977418d8410fceebb6830c74d820 differ diff --git a/fuzzers/corpora/midx/98a1096d609545083878d5126743bbc5985786a9 b/fuzzers/corpora/midx/98a1096d609545083878d5126743bbc5985786a9 new file mode 100644 index 000000000..6cf168ee1 Binary files /dev/null and b/fuzzers/corpora/midx/98a1096d609545083878d5126743bbc5985786a9 differ diff --git a/fuzzers/corpora/midx/98c3b6bbf5dc19bc4aad894087277a36d7c79669 b/fuzzers/corpora/midx/98c3b6bbf5dc19bc4aad894087277a36d7c79669 new file mode 100644 index 000000000..7a11bb57f Binary files /dev/null and b/fuzzers/corpora/midx/98c3b6bbf5dc19bc4aad894087277a36d7c79669 differ diff --git a/fuzzers/corpora/midx/98f9cd44400b592f809596004125267acf848435 b/fuzzers/corpora/midx/98f9cd44400b592f809596004125267acf848435 new file mode 100644 index 000000000..d4e6332b9 Binary files /dev/null and b/fuzzers/corpora/midx/98f9cd44400b592f809596004125267acf848435 differ diff --git a/fuzzers/corpora/midx/9a97260f04ecfe0918499ede95cf4bcb3dbc2b51 b/fuzzers/corpora/midx/9a97260f04ecfe0918499ede95cf4bcb3dbc2b51 new file mode 100644 index 000000000..ba3011ba7 Binary files /dev/null and b/fuzzers/corpora/midx/9a97260f04ecfe0918499ede95cf4bcb3dbc2b51 differ diff --git a/fuzzers/corpora/midx/9ba0dba2ca4405d04113086309882dac6182e6b8 b/fuzzers/corpora/midx/9ba0dba2ca4405d04113086309882dac6182e6b8 new file mode 100644 index 000000000..4513cd9f6 Binary files /dev/null and b/fuzzers/corpora/midx/9ba0dba2ca4405d04113086309882dac6182e6b8 differ diff --git a/fuzzers/corpora/midx/9c329ee4b02f2d26ee1a399c873b0452aedca3c0 b/fuzzers/corpora/midx/9c329ee4b02f2d26ee1a399c873b0452aedca3c0 new file mode 100644 index 000000000..ac164f4ad Binary files /dev/null and b/fuzzers/corpora/midx/9c329ee4b02f2d26ee1a399c873b0452aedca3c0 differ diff --git a/fuzzers/corpora/midx/9e8e638837e202d83ff606a22dd0e310150fa260 b/fuzzers/corpora/midx/9e8e638837e202d83ff606a22dd0e310150fa260 new file mode 100644 index 000000000..93f205f64 Binary files /dev/null and b/fuzzers/corpora/midx/9e8e638837e202d83ff606a22dd0e310150fa260 differ diff --git a/fuzzers/corpora/midx/9ee03d17e070df72547e423a412da0b6a60ad565 b/fuzzers/corpora/midx/9ee03d17e070df72547e423a412da0b6a60ad565 new file mode 100644 index 000000000..874ce8f02 Binary files /dev/null and b/fuzzers/corpora/midx/9ee03d17e070df72547e423a412da0b6a60ad565 differ diff --git a/fuzzers/corpora/midx/9fad6bd2b07d65e607039bb2bcda0816410cf983 b/fuzzers/corpora/midx/9fad6bd2b07d65e607039bb2bcda0816410cf983 new file mode 100644 index 000000000..160c9ab57 Binary files /dev/null and b/fuzzers/corpora/midx/9fad6bd2b07d65e607039bb2bcda0816410cf983 differ diff --git a/fuzzers/corpora/midx/9fcbd21f4dd194a623d832422384a1519742f0bb b/fuzzers/corpora/midx/9fcbd21f4dd194a623d832422384a1519742f0bb new file mode 100644 index 000000000..cce3746eb Binary files /dev/null and b/fuzzers/corpora/midx/9fcbd21f4dd194a623d832422384a1519742f0bb differ diff --git a/fuzzers/corpora/midx/a019fb7f17aa36a9743c530e1f11d5613b8b1158 b/fuzzers/corpora/midx/a019fb7f17aa36a9743c530e1f11d5613b8b1158 new file mode 100644 index 000000000..e6a45fad9 Binary files /dev/null and b/fuzzers/corpora/midx/a019fb7f17aa36a9743c530e1f11d5613b8b1158 differ diff --git a/fuzzers/corpora/midx/a0b8c6ef20198377b19f59e41f08f4cf2107f460 b/fuzzers/corpora/midx/a0b8c6ef20198377b19f59e41f08f4cf2107f460 new file mode 100644 index 000000000..f10d52cea Binary files /dev/null and b/fuzzers/corpora/midx/a0b8c6ef20198377b19f59e41f08f4cf2107f460 differ diff --git a/fuzzers/corpora/midx/a14079a3e8cbc2112da4fa747ef20cdfd580e068 b/fuzzers/corpora/midx/a14079a3e8cbc2112da4fa747ef20cdfd580e068 new file mode 100644 index 000000000..1d17566b8 Binary files /dev/null and b/fuzzers/corpora/midx/a14079a3e8cbc2112da4fa747ef20cdfd580e068 differ diff --git a/fuzzers/corpora/midx/a14d61ba0c609665d37e6c6da929cb53c5b70545 b/fuzzers/corpora/midx/a14d61ba0c609665d37e6c6da929cb53c5b70545 new file mode 100644 index 000000000..d70d19ef9 Binary files /dev/null and b/fuzzers/corpora/midx/a14d61ba0c609665d37e6c6da929cb53c5b70545 differ diff --git a/fuzzers/corpora/midx/a15cf2a13e408cb76af0091a0c286af7ffce58e1 b/fuzzers/corpora/midx/a15cf2a13e408cb76af0091a0c286af7ffce58e1 new file mode 100644 index 000000000..23b70ad6f Binary files /dev/null and b/fuzzers/corpora/midx/a15cf2a13e408cb76af0091a0c286af7ffce58e1 differ diff --git a/fuzzers/corpora/midx/a1ddedbdd05eac99b8b31322635771cd9c999f8a b/fuzzers/corpora/midx/a1ddedbdd05eac99b8b31322635771cd9c999f8a new file mode 100644 index 000000000..066e405c2 Binary files /dev/null and b/fuzzers/corpora/midx/a1ddedbdd05eac99b8b31322635771cd9c999f8a differ diff --git a/fuzzers/corpora/midx/a235661c3f8b0174a1658e9c435a69577c49256a b/fuzzers/corpora/midx/a235661c3f8b0174a1658e9c435a69577c49256a new file mode 100644 index 000000000..ca719f251 Binary files /dev/null and b/fuzzers/corpora/midx/a235661c3f8b0174a1658e9c435a69577c49256a differ diff --git a/fuzzers/corpora/midx/a261397a4db5ac196c72d73ba6999e9fd4fc5c1f b/fuzzers/corpora/midx/a261397a4db5ac196c72d73ba6999e9fd4fc5c1f new file mode 100644 index 000000000..ae0d0428a Binary files /dev/null and b/fuzzers/corpora/midx/a261397a4db5ac196c72d73ba6999e9fd4fc5c1f differ diff --git a/fuzzers/corpora/midx/a3a803fd6a56d31269717983bbdf2fceebb626c3 b/fuzzers/corpora/midx/a3a803fd6a56d31269717983bbdf2fceebb626c3 new file mode 100644 index 000000000..f813f2576 Binary files /dev/null and b/fuzzers/corpora/midx/a3a803fd6a56d31269717983bbdf2fceebb626c3 differ diff --git a/fuzzers/corpora/midx/a3d5b0b21d977e8f94d401250de1bbd4fa1d0ee0 b/fuzzers/corpora/midx/a3d5b0b21d977e8f94d401250de1bbd4fa1d0ee0 new file mode 100644 index 000000000..151c74bf9 Binary files /dev/null and b/fuzzers/corpora/midx/a3d5b0b21d977e8f94d401250de1bbd4fa1d0ee0 differ diff --git a/fuzzers/corpora/midx/a42f2900ca519bd15b8d6f507449d1a07de2ef75 b/fuzzers/corpora/midx/a42f2900ca519bd15b8d6f507449d1a07de2ef75 new file mode 100644 index 000000000..efd2d8793 Binary files /dev/null and b/fuzzers/corpora/midx/a42f2900ca519bd15b8d6f507449d1a07de2ef75 differ diff --git a/fuzzers/corpora/midx/a4884775b414eaf9643224564f3be405519cf99a b/fuzzers/corpora/midx/a4884775b414eaf9643224564f3be405519cf99a new file mode 100644 index 000000000..7e6260b4c Binary files /dev/null and b/fuzzers/corpora/midx/a4884775b414eaf9643224564f3be405519cf99a differ diff --git a/fuzzers/corpora/midx/a48da63e9a5709c24cb66f598a7a964cbc7ccfc7 b/fuzzers/corpora/midx/a48da63e9a5709c24cb66f598a7a964cbc7ccfc7 new file mode 100644 index 000000000..2e553bf4e Binary files /dev/null and b/fuzzers/corpora/midx/a48da63e9a5709c24cb66f598a7a964cbc7ccfc7 differ diff --git a/fuzzers/corpora/midx/a5789fd83dff18079ea7ba41c999f57bee4db41b b/fuzzers/corpora/midx/a5789fd83dff18079ea7ba41c999f57bee4db41b new file mode 100644 index 000000000..5d0a92655 Binary files /dev/null and b/fuzzers/corpora/midx/a5789fd83dff18079ea7ba41c999f57bee4db41b differ diff --git a/fuzzers/corpora/midx/a5bb1c60191742df4a91afb622e9b22a2f0b7765 b/fuzzers/corpora/midx/a5bb1c60191742df4a91afb622e9b22a2f0b7765 new file mode 100644 index 000000000..967cd2599 Binary files /dev/null and b/fuzzers/corpora/midx/a5bb1c60191742df4a91afb622e9b22a2f0b7765 differ diff --git a/fuzzers/corpora/midx/a5fdfade1cef5e7e494dd6e3791bca5a663d7012 b/fuzzers/corpora/midx/a5fdfade1cef5e7e494dd6e3791bca5a663d7012 new file mode 100644 index 000000000..0739dd639 Binary files /dev/null and b/fuzzers/corpora/midx/a5fdfade1cef5e7e494dd6e3791bca5a663d7012 differ diff --git a/fuzzers/corpora/midx/a6c66f79f5aaf2c1a26ff16754fe1a8c22627e0c b/fuzzers/corpora/midx/a6c66f79f5aaf2c1a26ff16754fe1a8c22627e0c new file mode 100644 index 000000000..8d2257752 Binary files /dev/null and b/fuzzers/corpora/midx/a6c66f79f5aaf2c1a26ff16754fe1a8c22627e0c differ diff --git a/fuzzers/corpora/midx/a7478a05a1fc04a9e035be5593bfb6a281ec460f b/fuzzers/corpora/midx/a7478a05a1fc04a9e035be5593bfb6a281ec460f new file mode 100644 index 000000000..f25cd8e2c Binary files /dev/null and b/fuzzers/corpora/midx/a7478a05a1fc04a9e035be5593bfb6a281ec460f differ diff --git a/fuzzers/corpora/midx/a75193dd600661d2b417d4e29b23faa7d721c214 b/fuzzers/corpora/midx/a75193dd600661d2b417d4e29b23faa7d721c214 new file mode 100644 index 000000000..765d7f1d5 Binary files /dev/null and b/fuzzers/corpora/midx/a75193dd600661d2b417d4e29b23faa7d721c214 differ diff --git a/fuzzers/corpora/midx/a7ccae74c641ffcdda0042e6c04438d5b32c4cf3 b/fuzzers/corpora/midx/a7ccae74c641ffcdda0042e6c04438d5b32c4cf3 new file mode 100644 index 000000000..c180cfacd Binary files /dev/null and b/fuzzers/corpora/midx/a7ccae74c641ffcdda0042e6c04438d5b32c4cf3 differ diff --git a/fuzzers/corpora/midx/a94aa5881abdea5374775b8155812121673f89c3 b/fuzzers/corpora/midx/a94aa5881abdea5374775b8155812121673f89c3 new file mode 100644 index 000000000..3e2266b74 Binary files /dev/null and b/fuzzers/corpora/midx/a94aa5881abdea5374775b8155812121673f89c3 differ diff --git a/fuzzers/corpora/midx/a98d794f0f24be7a36917826121fc14a24120893 b/fuzzers/corpora/midx/a98d794f0f24be7a36917826121fc14a24120893 new file mode 100644 index 000000000..2529c4e04 --- /dev/null +++ b/fuzzers/corpora/midx/a98d794f0f24be7a36917826121fc14a24120893 @@ -0,0 +1 @@ +Ńă \ No newline at end of file diff --git a/fuzzers/corpora/midx/a993077e321bc4e1831bb5a8ac7511d90d32ae27 b/fuzzers/corpora/midx/a993077e321bc4e1831bb5a8ac7511d90d32ae27 new file mode 100644 index 000000000..c0d4c9b0a Binary files /dev/null and b/fuzzers/corpora/midx/a993077e321bc4e1831bb5a8ac7511d90d32ae27 differ diff --git a/fuzzers/corpora/midx/aa3bc67656945e43f9342d3aaaef247584d96cfa b/fuzzers/corpora/midx/aa3bc67656945e43f9342d3aaaef247584d96cfa new file mode 100644 index 000000000..a6e20c9db Binary files /dev/null and b/fuzzers/corpora/midx/aa3bc67656945e43f9342d3aaaef247584d96cfa differ diff --git a/fuzzers/corpora/midx/ab111c4d72e3d6796e3d7391e9f35b4e6fefc04a b/fuzzers/corpora/midx/ab111c4d72e3d6796e3d7391e9f35b4e6fefc04a new file mode 100644 index 000000000..4b65b4d2a Binary files /dev/null and b/fuzzers/corpora/midx/ab111c4d72e3d6796e3d7391e9f35b4e6fefc04a differ diff --git a/fuzzers/corpora/midx/ab248c42f77952d5d17d6f5203adaa5925c05c64 b/fuzzers/corpora/midx/ab248c42f77952d5d17d6f5203adaa5925c05c64 new file mode 100644 index 000000000..87bc32739 Binary files /dev/null and b/fuzzers/corpora/midx/ab248c42f77952d5d17d6f5203adaa5925c05c64 differ diff --git a/fuzzers/corpora/midx/ab8451fadf805e5087837d9f6d91ef7eb6fa5edb b/fuzzers/corpora/midx/ab8451fadf805e5087837d9f6d91ef7eb6fa5edb new file mode 100644 index 000000000..ad08d1cd8 Binary files /dev/null and b/fuzzers/corpora/midx/ab8451fadf805e5087837d9f6d91ef7eb6fa5edb differ diff --git a/fuzzers/corpora/midx/abbee3b37aff879b1cef47390001b89b0f6ebc0a b/fuzzers/corpora/midx/abbee3b37aff879b1cef47390001b89b0f6ebc0a new file mode 100644 index 000000000..0cfebbdff Binary files /dev/null and b/fuzzers/corpora/midx/abbee3b37aff879b1cef47390001b89b0f6ebc0a differ diff --git a/fuzzers/corpora/midx/ac15b23f03af8be6dbbb3bbb8d3877a1f9e074a3 b/fuzzers/corpora/midx/ac15b23f03af8be6dbbb3bbb8d3877a1f9e074a3 new file mode 100644 index 000000000..15ed8032d Binary files /dev/null and b/fuzzers/corpora/midx/ac15b23f03af8be6dbbb3bbb8d3877a1f9e074a3 differ diff --git a/fuzzers/corpora/midx/ac47bda12269c06d773f5f3c6517f78513a54a08 b/fuzzers/corpora/midx/ac47bda12269c06d773f5f3c6517f78513a54a08 new file mode 100644 index 000000000..7ba9b5691 Binary files /dev/null and b/fuzzers/corpora/midx/ac47bda12269c06d773f5f3c6517f78513a54a08 differ diff --git a/fuzzers/corpora/midx/ad1f4fb57f481a00a9bb231517a3155ef0d0877f b/fuzzers/corpora/midx/ad1f4fb57f481a00a9bb231517a3155ef0d0877f new file mode 100644 index 000000000..7ae9220e3 Binary files /dev/null and b/fuzzers/corpora/midx/ad1f4fb57f481a00a9bb231517a3155ef0d0877f differ diff --git a/fuzzers/corpora/midx/ad25e7ffabedd94833d2529886af4d459529ec9d b/fuzzers/corpora/midx/ad25e7ffabedd94833d2529886af4d459529ec9d new file mode 100644 index 000000000..a1de60487 Binary files /dev/null and b/fuzzers/corpora/midx/ad25e7ffabedd94833d2529886af4d459529ec9d differ diff --git a/fuzzers/corpora/midx/ad796ebb423f58187806c4a7ee7b787394353ce6 b/fuzzers/corpora/midx/ad796ebb423f58187806c4a7ee7b787394353ce6 new file mode 100644 index 000000000..17e5905e7 Binary files /dev/null and b/fuzzers/corpora/midx/ad796ebb423f58187806c4a7ee7b787394353ce6 differ diff --git a/fuzzers/corpora/midx/adc83b19e793491b1c6ea0fd8b46cd9f32e592fc b/fuzzers/corpora/midx/adc83b19e793491b1c6ea0fd8b46cd9f32e592fc new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/fuzzers/corpora/midx/adc83b19e793491b1c6ea0fd8b46cd9f32e592fc @@ -0,0 +1 @@ + diff --git a/fuzzers/corpora/midx/ae14b80f26f5cee2d85d5154c2cef1eefafa8cc9 b/fuzzers/corpora/midx/ae14b80f26f5cee2d85d5154c2cef1eefafa8cc9 new file mode 100644 index 000000000..d0309c3e1 Binary files /dev/null and b/fuzzers/corpora/midx/ae14b80f26f5cee2d85d5154c2cef1eefafa8cc9 differ diff --git a/fuzzers/corpora/midx/ae3ba892de543801b3c1dfbce370eb2c80a6fb27 b/fuzzers/corpora/midx/ae3ba892de543801b3c1dfbce370eb2c80a6fb27 new file mode 100644 index 000000000..7f0f42dde Binary files /dev/null and b/fuzzers/corpora/midx/ae3ba892de543801b3c1dfbce370eb2c80a6fb27 differ diff --git a/fuzzers/corpora/midx/aecc0c7f08810803da234e26e7c6fa7a9f1c0593 b/fuzzers/corpora/midx/aecc0c7f08810803da234e26e7c6fa7a9f1c0593 new file mode 100644 index 000000000..8edc20975 Binary files /dev/null and b/fuzzers/corpora/midx/aecc0c7f08810803da234e26e7c6fa7a9f1c0593 differ diff --git a/fuzzers/corpora/midx/aed2e85d5d39d25e738a34f30a722680bde30368 b/fuzzers/corpora/midx/aed2e85d5d39d25e738a34f30a722680bde30368 new file mode 100644 index 000000000..006970c68 Binary files /dev/null and b/fuzzers/corpora/midx/aed2e85d5d39d25e738a34f30a722680bde30368 differ diff --git a/fuzzers/corpora/midx/b00a75de1987c6f549bf73a63e8f23a2de6641b3 b/fuzzers/corpora/midx/b00a75de1987c6f549bf73a63e8f23a2de6641b3 new file mode 100644 index 000000000..6b7abb024 Binary files /dev/null and b/fuzzers/corpora/midx/b00a75de1987c6f549bf73a63e8f23a2de6641b3 differ diff --git a/fuzzers/corpora/midx/b02e9f951ce9f10a8eb80f1fc61cd3d2832dd7f4 b/fuzzers/corpora/midx/b02e9f951ce9f10a8eb80f1fc61cd3d2832dd7f4 new file mode 100644 index 000000000..1bc7029e6 Binary files /dev/null and b/fuzzers/corpora/midx/b02e9f951ce9f10a8eb80f1fc61cd3d2832dd7f4 differ diff --git a/fuzzers/corpora/midx/b04aff8ab2e133d45bf44565bd4bf9e33b795a97 b/fuzzers/corpora/midx/b04aff8ab2e133d45bf44565bd4bf9e33b795a97 new file mode 100644 index 000000000..fbba22081 Binary files /dev/null and b/fuzzers/corpora/midx/b04aff8ab2e133d45bf44565bd4bf9e33b795a97 differ diff --git a/fuzzers/corpora/midx/b12097ed83db761f7bb79411a59e2474de9b1199 b/fuzzers/corpora/midx/b12097ed83db761f7bb79411a59e2474de9b1199 new file mode 100644 index 000000000..75c785561 Binary files /dev/null and b/fuzzers/corpora/midx/b12097ed83db761f7bb79411a59e2474de9b1199 differ diff --git a/fuzzers/corpora/midx/b1beb2f462b4cb30a09d534b9f49f2e08d76363c b/fuzzers/corpora/midx/b1beb2f462b4cb30a09d534b9f49f2e08d76363c new file mode 100644 index 000000000..1f4bc7b24 --- /dev/null +++ b/fuzzers/corpora/midx/b1beb2f462b4cb30a09d534b9f49f2e08d76363c @@ -0,0 +1 @@ +ăđc˝D \ No newline at end of file diff --git a/fuzzers/corpora/midx/b201733b6165f4544578bd6aad3f55aeafd9a194 b/fuzzers/corpora/midx/b201733b6165f4544578bd6aad3f55aeafd9a194 new file mode 100644 index 000000000..51e078769 Binary files /dev/null and b/fuzzers/corpora/midx/b201733b6165f4544578bd6aad3f55aeafd9a194 differ diff --git a/fuzzers/corpora/midx/b2699f25c21ffe453dcce20e31b3093e0f9b2abf b/fuzzers/corpora/midx/b2699f25c21ffe453dcce20e31b3093e0f9b2abf new file mode 100644 index 000000000..19e656b32 --- /dev/null +++ b/fuzzers/corpora/midx/b2699f25c21ffe453dcce20e31b3093e0f9b2abf @@ -0,0 +1 @@ +Ĺç \ No newline at end of file diff --git a/fuzzers/corpora/midx/b34a5760a1036f909e0243cd857fcef65e40d752 b/fuzzers/corpora/midx/b34a5760a1036f909e0243cd857fcef65e40d752 new file mode 100644 index 000000000..1a9d7cefc Binary files /dev/null and b/fuzzers/corpora/midx/b34a5760a1036f909e0243cd857fcef65e40d752 differ diff --git a/fuzzers/corpora/midx/b3fdacd639073cc1954bcb1f31046d094e2d2296 b/fuzzers/corpora/midx/b3fdacd639073cc1954bcb1f31046d094e2d2296 new file mode 100644 index 000000000..f393c6843 Binary files /dev/null and b/fuzzers/corpora/midx/b3fdacd639073cc1954bcb1f31046d094e2d2296 differ diff --git a/fuzzers/corpora/midx/b40a6dbe32c8e6a9b777331e7fd97f0d94ceca1c b/fuzzers/corpora/midx/b40a6dbe32c8e6a9b777331e7fd97f0d94ceca1c new file mode 100644 index 000000000..c8ea5fc1a Binary files /dev/null and b/fuzzers/corpora/midx/b40a6dbe32c8e6a9b777331e7fd97f0d94ceca1c differ diff --git a/fuzzers/corpora/midx/b52ff2010f22ae6758cde5d529fd19de2a7d5fc5 b/fuzzers/corpora/midx/b52ff2010f22ae6758cde5d529fd19de2a7d5fc5 new file mode 100644 index 000000000..ffe413839 Binary files /dev/null and b/fuzzers/corpora/midx/b52ff2010f22ae6758cde5d529fd19de2a7d5fc5 differ diff --git a/fuzzers/corpora/midx/b53a7a2afd9dfc55c328b4e06a36882c53126e95 b/fuzzers/corpora/midx/b53a7a2afd9dfc55c328b4e06a36882c53126e95 new file mode 100644 index 000000000..1624d98d7 Binary files /dev/null and b/fuzzers/corpora/midx/b53a7a2afd9dfc55c328b4e06a36882c53126e95 differ diff --git a/fuzzers/corpora/midx/b548ae8a77a62b7f375b8b48e7184ceed59bc8f8 b/fuzzers/corpora/midx/b548ae8a77a62b7f375b8b48e7184ceed59bc8f8 new file mode 100644 index 000000000..290535642 Binary files /dev/null and b/fuzzers/corpora/midx/b548ae8a77a62b7f375b8b48e7184ceed59bc8f8 differ diff --git a/fuzzers/corpora/midx/b66eaf0b689495cc7c194ab1fca7d36ae9da9758 b/fuzzers/corpora/midx/b66eaf0b689495cc7c194ab1fca7d36ae9da9758 new file mode 100644 index 000000000..c02a2407b Binary files /dev/null and b/fuzzers/corpora/midx/b66eaf0b689495cc7c194ab1fca7d36ae9da9758 differ diff --git a/fuzzers/corpora/midx/b680bf23da22b8b7e77d847169fe9b6968d79e8b b/fuzzers/corpora/midx/b680bf23da22b8b7e77d847169fe9b6968d79e8b new file mode 100644 index 000000000..e75d39a56 --- /dev/null +++ b/fuzzers/corpora/midx/b680bf23da22b8b7e77d847169fe9b6968d79e8b @@ -0,0 +1 @@ +ăo٬˙˙ \ No newline at end of file diff --git a/fuzzers/corpora/midx/b70d6e7d230fb1393b8f665adcd5658cad7059fe b/fuzzers/corpora/midx/b70d6e7d230fb1393b8f665adcd5658cad7059fe new file mode 100644 index 000000000..54a848653 Binary files /dev/null and b/fuzzers/corpora/midx/b70d6e7d230fb1393b8f665adcd5658cad7059fe differ diff --git a/fuzzers/corpora/midx/b87a59f78adb3ef18b0176a8e7fe7e90c2ab4ef7 b/fuzzers/corpora/midx/b87a59f78adb3ef18b0176a8e7fe7e90c2ab4ef7 new file mode 100644 index 000000000..0b9db199d Binary files /dev/null and b/fuzzers/corpora/midx/b87a59f78adb3ef18b0176a8e7fe7e90c2ab4ef7 differ diff --git a/fuzzers/corpora/midx/b88c5233090e859e923acbdfa9b168f95d7fc14b b/fuzzers/corpora/midx/b88c5233090e859e923acbdfa9b168f95d7fc14b new file mode 100644 index 000000000..a3841a89e Binary files /dev/null and b/fuzzers/corpora/midx/b88c5233090e859e923acbdfa9b168f95d7fc14b differ diff --git a/fuzzers/corpora/midx/ba1923ea69eec8fe765e8d1222eccb928ca6c3c2 b/fuzzers/corpora/midx/ba1923ea69eec8fe765e8d1222eccb928ca6c3c2 new file mode 100644 index 000000000..e5534a264 Binary files /dev/null and b/fuzzers/corpora/midx/ba1923ea69eec8fe765e8d1222eccb928ca6c3c2 differ diff --git a/fuzzers/corpora/midx/ba4d695c1eb02c702bd99a3db27838c7ba617d79 b/fuzzers/corpora/midx/ba4d695c1eb02c702bd99a3db27838c7ba617d79 new file mode 100644 index 000000000..2a60fe951 Binary files /dev/null and b/fuzzers/corpora/midx/ba4d695c1eb02c702bd99a3db27838c7ba617d79 differ diff --git a/fuzzers/corpora/midx/ba7e4f999dc22d223c7f75db36646bfa05848572 b/fuzzers/corpora/midx/ba7e4f999dc22d223c7f75db36646bfa05848572 new file mode 100644 index 000000000..b94268612 Binary files /dev/null and b/fuzzers/corpora/midx/ba7e4f999dc22d223c7f75db36646bfa05848572 differ diff --git a/fuzzers/corpora/midx/bc5f0cd338d1d17a230378390aa810bc7b103cda b/fuzzers/corpora/midx/bc5f0cd338d1d17a230378390aa810bc7b103cda new file mode 100644 index 000000000..9b147c438 Binary files /dev/null and b/fuzzers/corpora/midx/bc5f0cd338d1d17a230378390aa810bc7b103cda differ diff --git a/fuzzers/corpora/midx/bcbb4cf10018a177dd9a6c642d887e0de3d8e522 b/fuzzers/corpora/midx/bcbb4cf10018a177dd9a6c642d887e0de3d8e522 new file mode 100644 index 000000000..400d7bb42 Binary files /dev/null and b/fuzzers/corpora/midx/bcbb4cf10018a177dd9a6c642d887e0de3d8e522 differ diff --git a/fuzzers/corpora/midx/bcfeb114df6d5c6e0c85cbe1081631bc321ff65b b/fuzzers/corpora/midx/bcfeb114df6d5c6e0c85cbe1081631bc321ff65b new file mode 100644 index 000000000..200a997a0 Binary files /dev/null and b/fuzzers/corpora/midx/bcfeb114df6d5c6e0c85cbe1081631bc321ff65b differ diff --git a/fuzzers/corpora/midx/bd582237a9293e2a53d8222722a69e7d215822bf b/fuzzers/corpora/midx/bd582237a9293e2a53d8222722a69e7d215822bf new file mode 100644 index 000000000..9b34fbc94 Binary files /dev/null and b/fuzzers/corpora/midx/bd582237a9293e2a53d8222722a69e7d215822bf differ diff --git a/fuzzers/corpora/midx/bdc83a415da40f74825379203538a2e4d27cffa7 b/fuzzers/corpora/midx/bdc83a415da40f74825379203538a2e4d27cffa7 new file mode 100644 index 000000000..af4b9e3c2 Binary files /dev/null and b/fuzzers/corpora/midx/bdc83a415da40f74825379203538a2e4d27cffa7 differ diff --git a/fuzzers/corpora/midx/be160536594c87dc07554a71c7d24cd1d718aecc b/fuzzers/corpora/midx/be160536594c87dc07554a71c7d24cd1d718aecc new file mode 100644 index 000000000..220794194 Binary files /dev/null and b/fuzzers/corpora/midx/be160536594c87dc07554a71c7d24cd1d718aecc differ diff --git a/fuzzers/corpora/midx/be8f3c744a23f67fb316a39609ca11ddac025b58 b/fuzzers/corpora/midx/be8f3c744a23f67fb316a39609ca11ddac025b58 new file mode 100644 index 000000000..e90303655 Binary files /dev/null and b/fuzzers/corpora/midx/be8f3c744a23f67fb316a39609ca11ddac025b58 differ diff --git a/fuzzers/corpora/midx/bf873b027b48f3fd7b727473c832486d99ddb196 b/fuzzers/corpora/midx/bf873b027b48f3fd7b727473c832486d99ddb196 new file mode 100644 index 000000000..f96da4c2b Binary files /dev/null and b/fuzzers/corpora/midx/bf873b027b48f3fd7b727473c832486d99ddb196 differ diff --git a/fuzzers/corpora/midx/bf8e20ef6b79131ef9bab8c9c1bb7dbecbead6a5 b/fuzzers/corpora/midx/bf8e20ef6b79131ef9bab8c9c1bb7dbecbead6a5 new file mode 100644 index 000000000..199ed39f0 Binary files /dev/null and b/fuzzers/corpora/midx/bf8e20ef6b79131ef9bab8c9c1bb7dbecbead6a5 differ diff --git a/fuzzers/corpora/midx/bf90507b8f7c7eebb89edeaabf6a432d86e7df4a b/fuzzers/corpora/midx/bf90507b8f7c7eebb89edeaabf6a432d86e7df4a new file mode 100644 index 000000000..428e5678a Binary files /dev/null and b/fuzzers/corpora/midx/bf90507b8f7c7eebb89edeaabf6a432d86e7df4a differ diff --git a/fuzzers/corpora/midx/bfa7a5ce666899fb3e2a7216dbf59886da672658 b/fuzzers/corpora/midx/bfa7a5ce666899fb3e2a7216dbf59886da672658 new file mode 100644 index 000000000..45cf661dd Binary files /dev/null and b/fuzzers/corpora/midx/bfa7a5ce666899fb3e2a7216dbf59886da672658 differ diff --git a/fuzzers/corpora/midx/bfeaa454d8db33efabba88f146bee6c803369ba0 b/fuzzers/corpora/midx/bfeaa454d8db33efabba88f146bee6c803369ba0 new file mode 100644 index 000000000..82b09f3c3 Binary files /dev/null and b/fuzzers/corpora/midx/bfeaa454d8db33efabba88f146bee6c803369ba0 differ diff --git a/fuzzers/corpora/midx/c0388910e8d88dcd2e65848ba2cef465caa6b258 b/fuzzers/corpora/midx/c0388910e8d88dcd2e65848ba2cef465caa6b258 new file mode 100644 index 000000000..01e4b8994 Binary files /dev/null and b/fuzzers/corpora/midx/c0388910e8d88dcd2e65848ba2cef465caa6b258 differ diff --git a/fuzzers/corpora/midx/c0db293f75bb44668bcbb79286ebed87df141a85 b/fuzzers/corpora/midx/c0db293f75bb44668bcbb79286ebed87df141a85 new file mode 100644 index 000000000..bb56c1416 Binary files /dev/null and b/fuzzers/corpora/midx/c0db293f75bb44668bcbb79286ebed87df141a85 differ diff --git a/fuzzers/corpora/midx/c1234da1441255244aba15ecad2a4fa7fd47115e b/fuzzers/corpora/midx/c1234da1441255244aba15ecad2a4fa7fd47115e new file mode 100644 index 000000000..e79db44bf Binary files /dev/null and b/fuzzers/corpora/midx/c1234da1441255244aba15ecad2a4fa7fd47115e differ diff --git a/fuzzers/corpora/midx/c2206ac3c289a759ee0e9d0d31cc336f0802f7bc b/fuzzers/corpora/midx/c2206ac3c289a759ee0e9d0d31cc336f0802f7bc new file mode 100644 index 000000000..66a47b970 --- /dev/null +++ b/fuzzers/corpora/midx/c2206ac3c289a759ee0e9d0d31cc336f0802f7bc @@ -0,0 +1 @@ +ăďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďď;ďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďď \ No newline at end of file diff --git a/fuzzers/corpora/midx/c22340ab36e5cff088a58272f63cf69e54a1a9f4 b/fuzzers/corpora/midx/c22340ab36e5cff088a58272f63cf69e54a1a9f4 new file mode 100644 index 000000000..5f2f36ceb Binary files /dev/null and b/fuzzers/corpora/midx/c22340ab36e5cff088a58272f63cf69e54a1a9f4 differ diff --git a/fuzzers/corpora/midx/c242c9336c4c22b316e0e56d616b2d45b3318ca4 b/fuzzers/corpora/midx/c242c9336c4c22b316e0e56d616b2d45b3318ca4 new file mode 100644 index 000000000..b4824b458 Binary files /dev/null and b/fuzzers/corpora/midx/c242c9336c4c22b316e0e56d616b2d45b3318ca4 differ diff --git a/fuzzers/corpora/midx/c25a51d8dfaf58d5b609729bb156a80e3b0d892f b/fuzzers/corpora/midx/c25a51d8dfaf58d5b609729bb156a80e3b0d892f new file mode 100644 index 000000000..1209373c9 Binary files /dev/null and b/fuzzers/corpora/midx/c25a51d8dfaf58d5b609729bb156a80e3b0d892f differ diff --git a/fuzzers/corpora/midx/c3419450240d06982b0d828911b188a903355216 b/fuzzers/corpora/midx/c3419450240d06982b0d828911b188a903355216 new file mode 100644 index 000000000..b0ac7f488 Binary files /dev/null and b/fuzzers/corpora/midx/c3419450240d06982b0d828911b188a903355216 differ diff --git a/fuzzers/corpora/midx/c36ea7651f76ae817d8d60cae580e47638741372 b/fuzzers/corpora/midx/c36ea7651f76ae817d8d60cae580e47638741372 new file mode 100644 index 000000000..92ef97229 Binary files /dev/null and b/fuzzers/corpora/midx/c36ea7651f76ae817d8d60cae580e47638741372 differ diff --git a/fuzzers/corpora/midx/c42300c021bfd35702f564e917839503922cbe9a b/fuzzers/corpora/midx/c42300c021bfd35702f564e917839503922cbe9a new file mode 100644 index 000000000..553b6ee2a Binary files /dev/null and b/fuzzers/corpora/midx/c42300c021bfd35702f564e917839503922cbe9a differ diff --git a/fuzzers/corpora/midx/c45d82ddade99ef857b563e435f2efe89e58b0be b/fuzzers/corpora/midx/c45d82ddade99ef857b563e435f2efe89e58b0be new file mode 100644 index 000000000..a45b45e7c Binary files /dev/null and b/fuzzers/corpora/midx/c45d82ddade99ef857b563e435f2efe89e58b0be differ diff --git a/fuzzers/corpora/midx/c4d1e9187de1e13353b3beb3c1ab16dd62cda571 b/fuzzers/corpora/midx/c4d1e9187de1e13353b3beb3c1ab16dd62cda571 new file mode 100644 index 000000000..12fdcbdc5 Binary files /dev/null and b/fuzzers/corpora/midx/c4d1e9187de1e13353b3beb3c1ab16dd62cda571 differ diff --git a/fuzzers/corpora/midx/c4e98278a25011c54734494d4534a97489cf4c24 b/fuzzers/corpora/midx/c4e98278a25011c54734494d4534a97489cf4c24 new file mode 100644 index 000000000..4cef0a128 Binary files /dev/null and b/fuzzers/corpora/midx/c4e98278a25011c54734494d4534a97489cf4c24 differ diff --git a/fuzzers/corpora/midx/c4f996ab08f56ce2e9fec7a0428ded510dd6a04a b/fuzzers/corpora/midx/c4f996ab08f56ce2e9fec7a0428ded510dd6a04a new file mode 100644 index 000000000..78d9033c1 Binary files /dev/null and b/fuzzers/corpora/midx/c4f996ab08f56ce2e9fec7a0428ded510dd6a04a differ diff --git a/fuzzers/corpora/midx/c544850a7325e7226583895204f99de730525803 b/fuzzers/corpora/midx/c544850a7325e7226583895204f99de730525803 new file mode 100644 index 000000000..cd87f9b9f Binary files /dev/null and b/fuzzers/corpora/midx/c544850a7325e7226583895204f99de730525803 differ diff --git a/fuzzers/corpora/midx/c56629528d5bebdb94f85522caf0f36bbcb19106 b/fuzzers/corpora/midx/c56629528d5bebdb94f85522caf0f36bbcb19106 new file mode 100644 index 000000000..6416cd684 Binary files /dev/null and b/fuzzers/corpora/midx/c56629528d5bebdb94f85522caf0f36bbcb19106 differ diff --git a/fuzzers/corpora/midx/c5c75b58883ccf41b20b140740e2ce763c6086cd b/fuzzers/corpora/midx/c5c75b58883ccf41b20b140740e2ce763c6086cd new file mode 100644 index 000000000..9f9a51a5d Binary files /dev/null and b/fuzzers/corpora/midx/c5c75b58883ccf41b20b140740e2ce763c6086cd differ diff --git a/fuzzers/corpora/midx/c62da85dca0d4dfb1d7af5d0520eb74993a1e3b0 b/fuzzers/corpora/midx/c62da85dca0d4dfb1d7af5d0520eb74993a1e3b0 new file mode 100644 index 000000000..8f9050c48 Binary files /dev/null and b/fuzzers/corpora/midx/c62da85dca0d4dfb1d7af5d0520eb74993a1e3b0 differ diff --git a/fuzzers/corpora/midx/c6379aaaecd282b8ed6d0b4291d0d9fdc763160a b/fuzzers/corpora/midx/c6379aaaecd282b8ed6d0b4291d0d9fdc763160a new file mode 100644 index 000000000..2478f3579 Binary files /dev/null and b/fuzzers/corpora/midx/c6379aaaecd282b8ed6d0b4291d0d9fdc763160a differ diff --git a/fuzzers/corpora/midx/c6431921184e3edf4fd3e47384c69654cdac0189 b/fuzzers/corpora/midx/c6431921184e3edf4fd3e47384c69654cdac0189 new file mode 100644 index 000000000..2acd685af Binary files /dev/null and b/fuzzers/corpora/midx/c6431921184e3edf4fd3e47384c69654cdac0189 differ diff --git a/fuzzers/corpora/midx/c6f2ca17c6d313a35676cbacd094eb40fd74b23e b/fuzzers/corpora/midx/c6f2ca17c6d313a35676cbacd094eb40fd74b23e new file mode 100644 index 000000000..d1c63b98a Binary files /dev/null and b/fuzzers/corpora/midx/c6f2ca17c6d313a35676cbacd094eb40fd74b23e differ diff --git a/fuzzers/corpora/midx/c83e04d58e04fccac37b9dd313eab72011fe8ea1 b/fuzzers/corpora/midx/c83e04d58e04fccac37b9dd313eab72011fe8ea1 new file mode 100644 index 000000000..d11f86a44 Binary files /dev/null and b/fuzzers/corpora/midx/c83e04d58e04fccac37b9dd313eab72011fe8ea1 differ diff --git a/fuzzers/corpora/midx/c88dc350b98a5c5ae0503683318c1f30443906a8 b/fuzzers/corpora/midx/c88dc350b98a5c5ae0503683318c1f30443906a8 new file mode 100644 index 000000000..528a69e7b --- /dev/null +++ b/fuzzers/corpora/midx/c88dc350b98a5c5ae0503683318c1f30443906a8 @@ -0,0 +1 @@ +ăp \ No newline at end of file diff --git a/fuzzers/corpora/midx/c89ee2e9e30a474b5f9532ec61d7aad78377baa0 b/fuzzers/corpora/midx/c89ee2e9e30a474b5f9532ec61d7aad78377baa0 new file mode 100644 index 000000000..6280ce2ae Binary files /dev/null and b/fuzzers/corpora/midx/c89ee2e9e30a474b5f9532ec61d7aad78377baa0 differ diff --git a/fuzzers/corpora/midx/c921be4abeb44d1ff07f76f632a16e86526bc4be b/fuzzers/corpora/midx/c921be4abeb44d1ff07f76f632a16e86526bc4be new file mode 100644 index 000000000..6f53b9df4 Binary files /dev/null and b/fuzzers/corpora/midx/c921be4abeb44d1ff07f76f632a16e86526bc4be differ diff --git a/fuzzers/corpora/midx/c98bdc0431aaece1e8a721aff0ea511cfb8062a6 b/fuzzers/corpora/midx/c98bdc0431aaece1e8a721aff0ea511cfb8062a6 new file mode 100644 index 000000000..cc0580ca3 Binary files /dev/null and b/fuzzers/corpora/midx/c98bdc0431aaece1e8a721aff0ea511cfb8062a6 differ diff --git a/fuzzers/corpora/midx/c9c456fd3e35a942ef4ab756e04e725cf1f71167 b/fuzzers/corpora/midx/c9c456fd3e35a942ef4ab756e04e725cf1f71167 new file mode 100644 index 000000000..6a7c367dd Binary files /dev/null and b/fuzzers/corpora/midx/c9c456fd3e35a942ef4ab756e04e725cf1f71167 differ diff --git a/fuzzers/corpora/midx/cd1f1a31b79af77e1e764102942ba7a79dcd24cf b/fuzzers/corpora/midx/cd1f1a31b79af77e1e764102942ba7a79dcd24cf new file mode 100644 index 000000000..883c745b1 Binary files /dev/null and b/fuzzers/corpora/midx/cd1f1a31b79af77e1e764102942ba7a79dcd24cf differ diff --git a/fuzzers/corpora/midx/cd57e5904254c2278e9ecf28ed7414d7aed8eef1 b/fuzzers/corpora/midx/cd57e5904254c2278e9ecf28ed7414d7aed8eef1 new file mode 100644 index 000000000..709c1a458 Binary files /dev/null and b/fuzzers/corpora/midx/cd57e5904254c2278e9ecf28ed7414d7aed8eef1 differ diff --git a/fuzzers/corpora/midx/cd665cdc2bd6a26eb68c9af6d1728a7d4f6eb309 b/fuzzers/corpora/midx/cd665cdc2bd6a26eb68c9af6d1728a7d4f6eb309 new file mode 100644 index 000000000..094e31ba1 Binary files /dev/null and b/fuzzers/corpora/midx/cd665cdc2bd6a26eb68c9af6d1728a7d4f6eb309 differ diff --git a/fuzzers/corpora/midx/ce72111c4314b22c4c7824bc8ea340ebd6d3fa84 b/fuzzers/corpora/midx/ce72111c4314b22c4c7824bc8ea340ebd6d3fa84 new file mode 100644 index 000000000..9bf41358a Binary files /dev/null and b/fuzzers/corpora/midx/ce72111c4314b22c4c7824bc8ea340ebd6d3fa84 differ diff --git a/fuzzers/corpora/midx/ceacc7ace2f4be962b0db2eeeea3fe6a00ca9dd6 b/fuzzers/corpora/midx/ceacc7ace2f4be962b0db2eeeea3fe6a00ca9dd6 new file mode 100644 index 000000000..6ddf30de7 Binary files /dev/null and b/fuzzers/corpora/midx/ceacc7ace2f4be962b0db2eeeea3fe6a00ca9dd6 differ diff --git a/fuzzers/corpora/midx/cf40769d8b4fcbac1b10ced2e0c3c1294f23fcdd b/fuzzers/corpora/midx/cf40769d8b4fcbac1b10ced2e0c3c1294f23fcdd new file mode 100644 index 000000000..18327c918 Binary files /dev/null and b/fuzzers/corpora/midx/cf40769d8b4fcbac1b10ced2e0c3c1294f23fcdd differ diff --git a/fuzzers/corpora/midx/d120111a77a3e3d1d504a04bbfc5f53effa14eb0 b/fuzzers/corpora/midx/d120111a77a3e3d1d504a04bbfc5f53effa14eb0 new file mode 100644 index 000000000..84043fe32 Binary files /dev/null and b/fuzzers/corpora/midx/d120111a77a3e3d1d504a04bbfc5f53effa14eb0 differ diff --git a/fuzzers/corpora/midx/d1ce81240a32aec2de1b0d779aa29a62c36f291f b/fuzzers/corpora/midx/d1ce81240a32aec2de1b0d779aa29a62c36f291f new file mode 100644 index 000000000..f49192cdc Binary files /dev/null and b/fuzzers/corpora/midx/d1ce81240a32aec2de1b0d779aa29a62c36f291f differ diff --git a/fuzzers/corpora/midx/d21869b290cd2b448e7b8103dced97e62fefffcc b/fuzzers/corpora/midx/d21869b290cd2b448e7b8103dced97e62fefffcc new file mode 100644 index 000000000..1b98c7fe9 Binary files /dev/null and b/fuzzers/corpora/midx/d21869b290cd2b448e7b8103dced97e62fefffcc differ diff --git a/fuzzers/corpora/midx/d2bffcd01e87ce9860007b244ff1e79ecd3d4d0f b/fuzzers/corpora/midx/d2bffcd01e87ce9860007b244ff1e79ecd3d4d0f new file mode 100644 index 000000000..a7ef0a4f5 Binary files /dev/null and b/fuzzers/corpora/midx/d2bffcd01e87ce9860007b244ff1e79ecd3d4d0f differ diff --git a/fuzzers/corpora/midx/d2d668b6e28fca83da5146021879c2b006406fa4 b/fuzzers/corpora/midx/d2d668b6e28fca83da5146021879c2b006406fa4 new file mode 100644 index 000000000..b4692596c Binary files /dev/null and b/fuzzers/corpora/midx/d2d668b6e28fca83da5146021879c2b006406fa4 differ diff --git a/fuzzers/corpora/midx/d37abe0d299b8ad1e90f5b7af302c24f411a7ed1 b/fuzzers/corpora/midx/d37abe0d299b8ad1e90f5b7af302c24f411a7ed1 new file mode 100644 index 000000000..81365c3b3 Binary files /dev/null and b/fuzzers/corpora/midx/d37abe0d299b8ad1e90f5b7af302c24f411a7ed1 differ diff --git a/fuzzers/corpora/midx/d3d689a12ab3808313d5ba0044e8c67ecb4337e4 b/fuzzers/corpora/midx/d3d689a12ab3808313d5ba0044e8c67ecb4337e4 new file mode 100644 index 000000000..4afea5eac Binary files /dev/null and b/fuzzers/corpora/midx/d3d689a12ab3808313d5ba0044e8c67ecb4337e4 differ diff --git a/fuzzers/corpora/midx/d48eb559213edf05aa2850a14194885ae2086ba4 b/fuzzers/corpora/midx/d48eb559213edf05aa2850a14194885ae2086ba4 new file mode 100644 index 000000000..0b91a6fa3 Binary files /dev/null and b/fuzzers/corpora/midx/d48eb559213edf05aa2850a14194885ae2086ba4 differ diff --git a/fuzzers/corpora/midx/d490f365693e49ebdeaf658b3f549311a399c6a8 b/fuzzers/corpora/midx/d490f365693e49ebdeaf658b3f549311a399c6a8 new file mode 100644 index 000000000..7ed6c9128 Binary files /dev/null and b/fuzzers/corpora/midx/d490f365693e49ebdeaf658b3f549311a399c6a8 differ diff --git a/fuzzers/corpora/midx/d54821b652a8611c486bedd8645081d3a4b1c8d1 b/fuzzers/corpora/midx/d54821b652a8611c486bedd8645081d3a4b1c8d1 new file mode 100644 index 000000000..eda0c25d7 Binary files /dev/null and b/fuzzers/corpora/midx/d54821b652a8611c486bedd8645081d3a4b1c8d1 differ diff --git a/fuzzers/corpora/midx/d5586a91f9a879e8a67ec7b09a48038909918ad9 b/fuzzers/corpora/midx/d5586a91f9a879e8a67ec7b09a48038909918ad9 new file mode 100644 index 000000000..0abb2188a Binary files /dev/null and b/fuzzers/corpora/midx/d5586a91f9a879e8a67ec7b09a48038909918ad9 differ diff --git a/fuzzers/corpora/midx/d696362920a2fad8e280293e8d1c92b18c87e4ae b/fuzzers/corpora/midx/d696362920a2fad8e280293e8d1c92b18c87e4ae new file mode 100644 index 000000000..b72ac49a9 Binary files /dev/null and b/fuzzers/corpora/midx/d696362920a2fad8e280293e8d1c92b18c87e4ae differ diff --git a/fuzzers/corpora/midx/d6b546a2b1bc1c8f80028e4be10c45a06014b32d b/fuzzers/corpora/midx/d6b546a2b1bc1c8f80028e4be10c45a06014b32d new file mode 100644 index 000000000..75ee6a9f2 Binary files /dev/null and b/fuzzers/corpora/midx/d6b546a2b1bc1c8f80028e4be10c45a06014b32d differ diff --git a/fuzzers/corpora/midx/d7f04cbca92b2122e0f437ed4dd8fd1782d40f7f b/fuzzers/corpora/midx/d7f04cbca92b2122e0f437ed4dd8fd1782d40f7f new file mode 100644 index 000000000..3b0ada6d8 Binary files /dev/null and b/fuzzers/corpora/midx/d7f04cbca92b2122e0f437ed4dd8fd1782d40f7f differ diff --git a/fuzzers/corpora/midx/d81944a0c1ed56d11129533d9a3d0d038113d53d b/fuzzers/corpora/midx/d81944a0c1ed56d11129533d9a3d0d038113d53d new file mode 100644 index 000000000..fa170d1e5 Binary files /dev/null and b/fuzzers/corpora/midx/d81944a0c1ed56d11129533d9a3d0d038113d53d differ diff --git a/fuzzers/corpora/midx/d8524e83ea63c9b365c2e93af75a8100a08b1b69 b/fuzzers/corpora/midx/d8524e83ea63c9b365c2e93af75a8100a08b1b69 new file mode 100644 index 000000000..68f680b7d Binary files /dev/null and b/fuzzers/corpora/midx/d8524e83ea63c9b365c2e93af75a8100a08b1b69 differ diff --git a/fuzzers/corpora/midx/d8d9a2d06763cf6feb433cef92a80ef14baab31a b/fuzzers/corpora/midx/d8d9a2d06763cf6feb433cef92a80ef14baab31a new file mode 100644 index 000000000..2f47818c5 Binary files /dev/null and b/fuzzers/corpora/midx/d8d9a2d06763cf6feb433cef92a80ef14baab31a differ diff --git a/fuzzers/corpora/midx/d917fbd641cc40786246387456a636899d56b5a6 b/fuzzers/corpora/midx/d917fbd641cc40786246387456a636899d56b5a6 new file mode 100644 index 000000000..e2d69484c Binary files /dev/null and b/fuzzers/corpora/midx/d917fbd641cc40786246387456a636899d56b5a6 differ diff --git a/fuzzers/corpora/midx/d99f9ec8b504029457185ac03ea8ba21c2611737 b/fuzzers/corpora/midx/d99f9ec8b504029457185ac03ea8ba21c2611737 new file mode 100644 index 000000000..c3e992a9b Binary files /dev/null and b/fuzzers/corpora/midx/d99f9ec8b504029457185ac03ea8ba21c2611737 differ diff --git a/fuzzers/corpora/midx/d9c9c90c1bbc55beb81875838e9067c473d0fa92 b/fuzzers/corpora/midx/d9c9c90c1bbc55beb81875838e9067c473d0fa92 new file mode 100644 index 000000000..b14945649 Binary files /dev/null and b/fuzzers/corpora/midx/d9c9c90c1bbc55beb81875838e9067c473d0fa92 differ diff --git a/fuzzers/corpora/midx/d9e908317a6ef08a7528924672836a550d34cb5f b/fuzzers/corpora/midx/d9e908317a6ef08a7528924672836a550d34cb5f new file mode 100644 index 000000000..1c5b0c801 Binary files /dev/null and b/fuzzers/corpora/midx/d9e908317a6ef08a7528924672836a550d34cb5f differ diff --git a/fuzzers/corpora/midx/d9ef71deb57fa6f40e027be2c84fa37d288e1cc5 b/fuzzers/corpora/midx/d9ef71deb57fa6f40e027be2c84fa37d288e1cc5 new file mode 100644 index 000000000..87ef310c2 Binary files /dev/null and b/fuzzers/corpora/midx/d9ef71deb57fa6f40e027be2c84fa37d288e1cc5 differ diff --git a/fuzzers/corpora/midx/da8841b9d04382d62d4aeb3fde4dc78466f31543 b/fuzzers/corpora/midx/da8841b9d04382d62d4aeb3fde4dc78466f31543 new file mode 100644 index 000000000..10eae46bf Binary files /dev/null and b/fuzzers/corpora/midx/da8841b9d04382d62d4aeb3fde4dc78466f31543 differ diff --git a/fuzzers/corpora/midx/db3fbb74c9c9c4185f91eca85f14c3d2c3d9f487 b/fuzzers/corpora/midx/db3fbb74c9c9c4185f91eca85f14c3d2c3d9f487 new file mode 100644 index 000000000..a6344ce7a Binary files /dev/null and b/fuzzers/corpora/midx/db3fbb74c9c9c4185f91eca85f14c3d2c3d9f487 differ diff --git a/fuzzers/corpora/midx/db7a31de22258d4dc17d44a27d9340946e9c9ee9 b/fuzzers/corpora/midx/db7a31de22258d4dc17d44a27d9340946e9c9ee9 new file mode 100644 index 000000000..32c8a8e8a Binary files /dev/null and b/fuzzers/corpora/midx/db7a31de22258d4dc17d44a27d9340946e9c9ee9 differ diff --git a/fuzzers/corpora/midx/dbbe57fc653930b4ff43f168565ba84ef25f60c2 b/fuzzers/corpora/midx/dbbe57fc653930b4ff43f168565ba84ef25f60c2 new file mode 100644 index 000000000..9219ff3f5 Binary files /dev/null and b/fuzzers/corpora/midx/dbbe57fc653930b4ff43f168565ba84ef25f60c2 differ diff --git a/fuzzers/corpora/midx/dbe74c0d9e7b62c1fd87d5e3ea73ee04f0337154 b/fuzzers/corpora/midx/dbe74c0d9e7b62c1fd87d5e3ea73ee04f0337154 new file mode 100644 index 000000000..4ebae470a Binary files /dev/null and b/fuzzers/corpora/midx/dbe74c0d9e7b62c1fd87d5e3ea73ee04f0337154 differ diff --git a/fuzzers/corpora/midx/dbebf36a6b91568ac059142c3ca3211226da12a8 b/fuzzers/corpora/midx/dbebf36a6b91568ac059142c3ca3211226da12a8 new file mode 100644 index 000000000..d180a9bf2 Binary files /dev/null and b/fuzzers/corpora/midx/dbebf36a6b91568ac059142c3ca3211226da12a8 differ diff --git a/fuzzers/corpora/midx/ddacbb379242b31a00d62fdff5777dffc1e899c2 b/fuzzers/corpora/midx/ddacbb379242b31a00d62fdff5777dffc1e899c2 new file mode 100644 index 000000000..999ece9f7 Binary files /dev/null and b/fuzzers/corpora/midx/ddacbb379242b31a00d62fdff5777dffc1e899c2 differ diff --git a/fuzzers/corpora/midx/decd2cd9cef352610ac9e5cc461df1829543f9f0 b/fuzzers/corpora/midx/decd2cd9cef352610ac9e5cc461df1829543f9f0 new file mode 100644 index 000000000..28af13b4a --- /dev/null +++ b/fuzzers/corpora/midx/decd2cd9cef352610ac9e5cc461df1829543f9f0 @@ -0,0 +1,3 @@ +ă +yă +y \ No newline at end of file diff --git a/fuzzers/corpora/midx/deeae69363db06972798b296a0c5c99e02cb2b4c b/fuzzers/corpora/midx/deeae69363db06972798b296a0c5c99e02cb2b4c new file mode 100644 index 000000000..63cffc896 Binary files /dev/null and b/fuzzers/corpora/midx/deeae69363db06972798b296a0c5c99e02cb2b4c differ diff --git a/fuzzers/corpora/midx/e03e105323e6e7b2af90ad876b5c547af90d8f6b b/fuzzers/corpora/midx/e03e105323e6e7b2af90ad876b5c547af90d8f6b new file mode 100644 index 000000000..020fa1752 Binary files /dev/null and b/fuzzers/corpora/midx/e03e105323e6e7b2af90ad876b5c547af90d8f6b differ diff --git a/fuzzers/corpora/midx/e3133215848c9cde428338c9d51424c8a81b96f5 b/fuzzers/corpora/midx/e3133215848c9cde428338c9d51424c8a81b96f5 new file mode 100644 index 000000000..460d60898 Binary files /dev/null and b/fuzzers/corpora/midx/e3133215848c9cde428338c9d51424c8a81b96f5 differ diff --git a/fuzzers/corpora/midx/e32a25f0347b0e95d4bea16c27a1f374847683bd b/fuzzers/corpora/midx/e32a25f0347b0e95d4bea16c27a1f374847683bd new file mode 100644 index 000000000..3329d6155 Binary files /dev/null and b/fuzzers/corpora/midx/e32a25f0347b0e95d4bea16c27a1f374847683bd differ diff --git a/fuzzers/corpora/midx/e45ce97522194abcdd7ff9beb931e20b86c97a79 b/fuzzers/corpora/midx/e45ce97522194abcdd7ff9beb931e20b86c97a79 new file mode 100644 index 000000000..137a820e0 Binary files /dev/null and b/fuzzers/corpora/midx/e45ce97522194abcdd7ff9beb931e20b86c97a79 differ diff --git a/fuzzers/corpora/midx/e484023d50fc1036e46a437053b965c527700d42 b/fuzzers/corpora/midx/e484023d50fc1036e46a437053b965c527700d42 new file mode 100644 index 000000000..996f1e633 Binary files /dev/null and b/fuzzers/corpora/midx/e484023d50fc1036e46a437053b965c527700d42 differ diff --git a/fuzzers/corpora/midx/e4e60e77fe3a050940d0afcc7dbab7ef06b04ba3 b/fuzzers/corpora/midx/e4e60e77fe3a050940d0afcc7dbab7ef06b04ba3 new file mode 100644 index 000000000..31520a8cd Binary files /dev/null and b/fuzzers/corpora/midx/e4e60e77fe3a050940d0afcc7dbab7ef06b04ba3 differ diff --git a/fuzzers/corpora/midx/e51629784092d9cf811ea1bd894297f062ed7ec4 b/fuzzers/corpora/midx/e51629784092d9cf811ea1bd894297f062ed7ec4 new file mode 100644 index 000000000..1f4127cd6 Binary files /dev/null and b/fuzzers/corpora/midx/e51629784092d9cf811ea1bd894297f062ed7ec4 differ diff --git a/fuzzers/corpora/midx/e5a7e837029178b3fb6a26d77ea4574ffeaa219d b/fuzzers/corpora/midx/e5a7e837029178b3fb6a26d77ea4574ffeaa219d new file mode 100644 index 000000000..7607ce3ad Binary files /dev/null and b/fuzzers/corpora/midx/e5a7e837029178b3fb6a26d77ea4574ffeaa219d differ diff --git a/fuzzers/corpora/midx/e5c616e9efdd9c80181f9210d0e3a81c08fe9b4d b/fuzzers/corpora/midx/e5c616e9efdd9c80181f9210d0e3a81c08fe9b4d new file mode 100644 index 000000000..476b4fd75 Binary files /dev/null and b/fuzzers/corpora/midx/e5c616e9efdd9c80181f9210d0e3a81c08fe9b4d differ diff --git a/fuzzers/corpora/midx/e5e6e84e2c7770537c744bcfdbe8303afe39ef92 b/fuzzers/corpora/midx/e5e6e84e2c7770537c744bcfdbe8303afe39ef92 new file mode 100644 index 000000000..79045de27 Binary files /dev/null and b/fuzzers/corpora/midx/e5e6e84e2c7770537c744bcfdbe8303afe39ef92 differ diff --git a/fuzzers/corpora/midx/e5fb20928feec1ee3114597317edc0e06c413749 b/fuzzers/corpora/midx/e5fb20928feec1ee3114597317edc0e06c413749 new file mode 100644 index 000000000..d6758cfb1 Binary files /dev/null and b/fuzzers/corpora/midx/e5fb20928feec1ee3114597317edc0e06c413749 differ diff --git a/fuzzers/corpora/midx/e789319791fe704e5a8ffd7cb570c8d2722ac35f b/fuzzers/corpora/midx/e789319791fe704e5a8ffd7cb570c8d2722ac35f new file mode 100644 index 000000000..19fdbe717 Binary files /dev/null and b/fuzzers/corpora/midx/e789319791fe704e5a8ffd7cb570c8d2722ac35f differ diff --git a/fuzzers/corpora/midx/e9fdb9f08f225b4231f01dda9c7b61e7b78bf7d3 b/fuzzers/corpora/midx/e9fdb9f08f225b4231f01dda9c7b61e7b78bf7d3 new file mode 100644 index 000000000..576a1f88e Binary files /dev/null and b/fuzzers/corpora/midx/e9fdb9f08f225b4231f01dda9c7b61e7b78bf7d3 differ diff --git a/fuzzers/corpora/midx/ea6780324dca9a06db28598dfb590436d846d99f b/fuzzers/corpora/midx/ea6780324dca9a06db28598dfb590436d846d99f new file mode 100644 index 000000000..d8b617ccb Binary files /dev/null and b/fuzzers/corpora/midx/ea6780324dca9a06db28598dfb590436d846d99f differ diff --git a/fuzzers/corpora/midx/ea6afcc92b8a6c9e14cc053d351909ad5b0a3fdf b/fuzzers/corpora/midx/ea6afcc92b8a6c9e14cc053d351909ad5b0a3fdf new file mode 100644 index 000000000..8393e3675 Binary files /dev/null and b/fuzzers/corpora/midx/ea6afcc92b8a6c9e14cc053d351909ad5b0a3fdf differ diff --git a/fuzzers/corpora/midx/ea8c569029c0cacc4ae75e95b2f4e84abb6867f4 b/fuzzers/corpora/midx/ea8c569029c0cacc4ae75e95b2f4e84abb6867f4 new file mode 100644 index 000000000..2a86dc532 Binary files /dev/null and b/fuzzers/corpora/midx/ea8c569029c0cacc4ae75e95b2f4e84abb6867f4 differ diff --git a/fuzzers/corpora/midx/eb3e80c3ea9cfe9e08b2eef117aaa522a51a619c b/fuzzers/corpora/midx/eb3e80c3ea9cfe9e08b2eef117aaa522a51a619c new file mode 100644 index 000000000..d1fb9997b Binary files /dev/null and b/fuzzers/corpora/midx/eb3e80c3ea9cfe9e08b2eef117aaa522a51a619c differ diff --git a/fuzzers/corpora/midx/ec55b30741fe8fffeec584176c8d20f6a679cfa1 b/fuzzers/corpora/midx/ec55b30741fe8fffeec584176c8d20f6a679cfa1 new file mode 100644 index 000000000..69efa4a31 Binary files /dev/null and b/fuzzers/corpora/midx/ec55b30741fe8fffeec584176c8d20f6a679cfa1 differ diff --git a/fuzzers/corpora/midx/ed0724a6c3804a3ab20a980b5ca48671689a602f b/fuzzers/corpora/midx/ed0724a6c3804a3ab20a980b5ca48671689a602f new file mode 100644 index 000000000..85ec5a60c Binary files /dev/null and b/fuzzers/corpora/midx/ed0724a6c3804a3ab20a980b5ca48671689a602f differ diff --git a/fuzzers/corpora/midx/edeb545d1cf852dc9582fa764010fe844a5e3515 b/fuzzers/corpora/midx/edeb545d1cf852dc9582fa764010fe844a5e3515 new file mode 100644 index 000000000..3187fc701 Binary files /dev/null and b/fuzzers/corpora/midx/edeb545d1cf852dc9582fa764010fe844a5e3515 differ diff --git a/fuzzers/corpora/midx/ee70b920de91f1be6b4448070ee2d1bd9e08286d b/fuzzers/corpora/midx/ee70b920de91f1be6b4448070ee2d1bd9e08286d new file mode 100644 index 000000000..6d1f0a2ed Binary files /dev/null and b/fuzzers/corpora/midx/ee70b920de91f1be6b4448070ee2d1bd9e08286d differ diff --git a/fuzzers/corpora/midx/ef004af4e947d25b4d1d1dd16502260d4c7a99cd b/fuzzers/corpora/midx/ef004af4e947d25b4d1d1dd16502260d4c7a99cd new file mode 100644 index 000000000..ac39a8eed Binary files /dev/null and b/fuzzers/corpora/midx/ef004af4e947d25b4d1d1dd16502260d4c7a99cd differ diff --git a/fuzzers/corpora/midx/f009d226503b73aed0f1fd952ef8725433d158be b/fuzzers/corpora/midx/f009d226503b73aed0f1fd952ef8725433d158be new file mode 100644 index 000000000..55470add6 Binary files /dev/null and b/fuzzers/corpora/midx/f009d226503b73aed0f1fd952ef8725433d158be differ diff --git a/fuzzers/corpora/midx/f0a821dffe21afd357932febaf6e8ee331f53197 b/fuzzers/corpora/midx/f0a821dffe21afd357932febaf6e8ee331f53197 new file mode 100644 index 000000000..c4464b19c Binary files /dev/null and b/fuzzers/corpora/midx/f0a821dffe21afd357932febaf6e8ee331f53197 differ diff --git a/fuzzers/corpora/midx/f101a2fe93dfaaed1c596022b4e509cf3a591c8a b/fuzzers/corpora/midx/f101a2fe93dfaaed1c596022b4e509cf3a591c8a new file mode 100644 index 000000000..5576bd013 Binary files /dev/null and b/fuzzers/corpora/midx/f101a2fe93dfaaed1c596022b4e509cf3a591c8a differ diff --git a/fuzzers/corpora/midx/f1101f71657385174f8cb920026a761404b4395d b/fuzzers/corpora/midx/f1101f71657385174f8cb920026a761404b4395d new file mode 100644 index 000000000..59bd02e18 Binary files /dev/null and b/fuzzers/corpora/midx/f1101f71657385174f8cb920026a761404b4395d differ diff --git a/fuzzers/corpora/midx/f138c84e42d3cc61a219c4be9db791750f0541c8 b/fuzzers/corpora/midx/f138c84e42d3cc61a219c4be9db791750f0541c8 new file mode 100644 index 000000000..ab2d713fa --- /dev/null +++ b/fuzzers/corpora/midx/f138c84e42d3cc61a219c4be9db791750f0541c8 @@ -0,0 +1 @@ +ă]]˙˙˙˙˙s5e \ No newline at end of file diff --git a/fuzzers/corpora/midx/f1da273522bfff4a4971b4ffc31e365f60fdbbfe b/fuzzers/corpora/midx/f1da273522bfff4a4971b4ffc31e365f60fdbbfe new file mode 100644 index 000000000..7417bb73b Binary files /dev/null and b/fuzzers/corpora/midx/f1da273522bfff4a4971b4ffc31e365f60fdbbfe differ diff --git a/fuzzers/corpora/midx/f2fe69d30ec47e78a9e92f1423698a52270672b2 b/fuzzers/corpora/midx/f2fe69d30ec47e78a9e92f1423698a52270672b2 new file mode 100644 index 000000000..6eb21da0e Binary files /dev/null and b/fuzzers/corpora/midx/f2fe69d30ec47e78a9e92f1423698a52270672b2 differ diff --git a/fuzzers/corpora/midx/f368bb6f633587a7bb271de7e20695f178c89686 b/fuzzers/corpora/midx/f368bb6f633587a7bb271de7e20695f178c89686 new file mode 100644 index 000000000..0c0cac9cd Binary files /dev/null and b/fuzzers/corpora/midx/f368bb6f633587a7bb271de7e20695f178c89686 differ diff --git a/fuzzers/corpora/midx/f38ced5a16edaceb5f527ebc35e7870f42586c90 b/fuzzers/corpora/midx/f38ced5a16edaceb5f527ebc35e7870f42586c90 new file mode 100644 index 000000000..adc467ac6 Binary files /dev/null and b/fuzzers/corpora/midx/f38ced5a16edaceb5f527ebc35e7870f42586c90 differ diff --git a/fuzzers/corpora/midx/f404371362ae68ffb2837ce1766346ebb645d173 b/fuzzers/corpora/midx/f404371362ae68ffb2837ce1766346ebb645d173 new file mode 100644 index 000000000..a0b47bc8f Binary files /dev/null and b/fuzzers/corpora/midx/f404371362ae68ffb2837ce1766346ebb645d173 differ diff --git a/fuzzers/corpora/midx/f473b5e1cf51502345f5c1840ec3948d308dd314 b/fuzzers/corpora/midx/f473b5e1cf51502345f5c1840ec3948d308dd314 new file mode 100644 index 000000000..301811de6 Binary files /dev/null and b/fuzzers/corpora/midx/f473b5e1cf51502345f5c1840ec3948d308dd314 differ diff --git a/fuzzers/corpora/midx/f4ad43d6f913c3be6243dfc439e4b6f5b2e814b9 b/fuzzers/corpora/midx/f4ad43d6f913c3be6243dfc439e4b6f5b2e814b9 new file mode 100644 index 000000000..9e3bc983c Binary files /dev/null and b/fuzzers/corpora/midx/f4ad43d6f913c3be6243dfc439e4b6f5b2e814b9 differ diff --git a/fuzzers/corpora/midx/f4cde4083a974d755a38bf5ea3820f78b576754a b/fuzzers/corpora/midx/f4cde4083a974d755a38bf5ea3820f78b576754a new file mode 100644 index 000000000..0699a327c Binary files /dev/null and b/fuzzers/corpora/midx/f4cde4083a974d755a38bf5ea3820f78b576754a differ diff --git a/fuzzers/corpora/midx/f5888d0dcacda196d73772aabc18fe2ad6e1dfa2 b/fuzzers/corpora/midx/f5888d0dcacda196d73772aabc18fe2ad6e1dfa2 new file mode 100644 index 000000000..488911f2f Binary files /dev/null and b/fuzzers/corpora/midx/f5888d0dcacda196d73772aabc18fe2ad6e1dfa2 differ diff --git a/fuzzers/corpora/midx/f5c3577a62d401f071d5edaa77c54ae98d6a0318 b/fuzzers/corpora/midx/f5c3577a62d401f071d5edaa77c54ae98d6a0318 new file mode 100644 index 000000000..bfec0079b --- /dev/null +++ b/fuzzers/corpora/midx/f5c3577a62d401f071d5edaa77c54ae98d6a0318 @@ -0,0 +1 @@ +Ďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďďď \ No newline at end of file diff --git a/fuzzers/corpora/midx/f5dee0d9da0d6950069ac36b1880090a20f50f3e b/fuzzers/corpora/midx/f5dee0d9da0d6950069ac36b1880090a20f50f3e new file mode 100644 index 000000000..9330af78a Binary files /dev/null and b/fuzzers/corpora/midx/f5dee0d9da0d6950069ac36b1880090a20f50f3e differ diff --git a/fuzzers/corpora/midx/f605fff495fef2719585c706c05c350812402a35 b/fuzzers/corpora/midx/f605fff495fef2719585c706c05c350812402a35 new file mode 100644 index 000000000..7cae730c1 Binary files /dev/null and b/fuzzers/corpora/midx/f605fff495fef2719585c706c05c350812402a35 differ diff --git a/fuzzers/corpora/midx/f6fdaf4e77e29c780b9e0b91637777575bebfab4 b/fuzzers/corpora/midx/f6fdaf4e77e29c780b9e0b91637777575bebfab4 new file mode 100644 index 000000000..0b2545e7a Binary files /dev/null and b/fuzzers/corpora/midx/f6fdaf4e77e29c780b9e0b91637777575bebfab4 differ diff --git a/fuzzers/corpora/midx/f72700bd65fa86c588607ec50d60a9c684c86f43 b/fuzzers/corpora/midx/f72700bd65fa86c588607ec50d60a9c684c86f43 new file mode 100644 index 000000000..3dfa423ce Binary files /dev/null and b/fuzzers/corpora/midx/f72700bd65fa86c588607ec50d60a9c684c86f43 differ diff --git a/fuzzers/corpora/midx/f777db12ef18f002febd5af13e2b948c95d964c3 b/fuzzers/corpora/midx/f777db12ef18f002febd5af13e2b948c95d964c3 new file mode 100644 index 000000000..1869c3da1 Binary files /dev/null and b/fuzzers/corpora/midx/f777db12ef18f002febd5af13e2b948c95d964c3 differ diff --git a/fuzzers/corpora/midx/f777e9274d508e7ac1069e2a04bedc042942491c b/fuzzers/corpora/midx/f777e9274d508e7ac1069e2a04bedc042942491c new file mode 100644 index 000000000..cb62442ca Binary files /dev/null and b/fuzzers/corpora/midx/f777e9274d508e7ac1069e2a04bedc042942491c differ diff --git a/fuzzers/corpora/midx/f81306f8ceaec3d06d5d34afa9769d15f0d209eb b/fuzzers/corpora/midx/f81306f8ceaec3d06d5d34afa9769d15f0d209eb new file mode 100644 index 000000000..4a36e1fac Binary files /dev/null and b/fuzzers/corpora/midx/f81306f8ceaec3d06d5d34afa9769d15f0d209eb differ diff --git a/fuzzers/corpora/midx/f84c2b36689f22809d9bda00febab557c381ffa4 b/fuzzers/corpora/midx/f84c2b36689f22809d9bda00febab557c381ffa4 new file mode 100644 index 000000000..de7f301bd Binary files /dev/null and b/fuzzers/corpora/midx/f84c2b36689f22809d9bda00febab557c381ffa4 differ diff --git a/fuzzers/corpora/midx/f98168fa74c26b17ad0c3002f2263beb0af7c0ce b/fuzzers/corpora/midx/f98168fa74c26b17ad0c3002f2263beb0af7c0ce new file mode 100644 index 000000000..c1c20439e Binary files /dev/null and b/fuzzers/corpora/midx/f98168fa74c26b17ad0c3002f2263beb0af7c0ce differ diff --git a/fuzzers/corpora/midx/fa6759d6a2807bbad83ba21761772c0119122c35 b/fuzzers/corpora/midx/fa6759d6a2807bbad83ba21761772c0119122c35 new file mode 100644 index 000000000..79b7fe107 Binary files /dev/null and b/fuzzers/corpora/midx/fa6759d6a2807bbad83ba21761772c0119122c35 differ diff --git a/fuzzers/corpora/midx/fa8b927b25a67fa3d60b12c53ac365366cc2b52d b/fuzzers/corpora/midx/fa8b927b25a67fa3d60b12c53ac365366cc2b52d new file mode 100644 index 000000000..22522c2c5 Binary files /dev/null and b/fuzzers/corpora/midx/fa8b927b25a67fa3d60b12c53ac365366cc2b52d differ diff --git a/fuzzers/corpora/midx/fc5e4b78e59daebed1118389b57a386981f2430e b/fuzzers/corpora/midx/fc5e4b78e59daebed1118389b57a386981f2430e new file mode 100644 index 000000000..5c6a22d0c Binary files /dev/null and b/fuzzers/corpora/midx/fc5e4b78e59daebed1118389b57a386981f2430e differ diff --git a/fuzzers/corpora/midx/fdaf408880429153cfcf5d978727cd7b84c3d60e b/fuzzers/corpora/midx/fdaf408880429153cfcf5d978727cd7b84c3d60e new file mode 100644 index 000000000..76f7c5276 Binary files /dev/null and b/fuzzers/corpora/midx/fdaf408880429153cfcf5d978727cd7b84c3d60e differ diff --git a/fuzzers/corpora/midx/fe50e7564a28683b24c57f8bcdcb3fbfa61f5c6a b/fuzzers/corpora/midx/fe50e7564a28683b24c57f8bcdcb3fbfa61f5c6a new file mode 100644 index 000000000..f20372060 Binary files /dev/null and b/fuzzers/corpora/midx/fe50e7564a28683b24c57f8bcdcb3fbfa61f5c6a differ diff --git a/fuzzers/corpora/midx/fe64b998872d3ad87df2019173ddc52686841d7d b/fuzzers/corpora/midx/fe64b998872d3ad87df2019173ddc52686841d7d new file mode 100644 index 000000000..1b4e28ef7 Binary files /dev/null and b/fuzzers/corpora/midx/fe64b998872d3ad87df2019173ddc52686841d7d differ diff --git a/fuzzers/corpora/midx/fec56c7cc86871aaa9c7a947c4084307cac2778d b/fuzzers/corpora/midx/fec56c7cc86871aaa9c7a947c4084307cac2778d new file mode 100644 index 000000000..c57cd188a Binary files /dev/null and b/fuzzers/corpora/midx/fec56c7cc86871aaa9c7a947c4084307cac2778d differ diff --git a/fuzzers/corpora/midx/ff164dfc56dd28709488130dc6dfc17406bf9e9d b/fuzzers/corpora/midx/ff164dfc56dd28709488130dc6dfc17406bf9e9d new file mode 100644 index 000000000..ceda10e93 Binary files /dev/null and b/fuzzers/corpora/midx/ff164dfc56dd28709488130dc6dfc17406bf9e9d differ diff --git a/fuzzers/corpora/midx/ff7035b3c055718728a6025b3cdf55c34c4c744b b/fuzzers/corpora/midx/ff7035b3c055718728a6025b3cdf55c34c4c744b new file mode 100644 index 000000000..8c963ab05 Binary files /dev/null and b/fuzzers/corpora/midx/ff7035b3c055718728a6025b3cdf55c34c4c744b differ diff --git a/fuzzers/midx_fuzzer.c b/fuzzers/midx_fuzzer.c new file mode 100644 index 000000000..e67873faa --- /dev/null +++ b/fuzzers/midx_fuzzer.c @@ -0,0 +1,76 @@ +/* + * libgit2 multi-pack-index fuzzer 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 + +#include "git2.h" + +#include "buffer.h" +#include "common.h" +#include "futils.h" +#include "hash.h" +#include "midx.h" + +int LLVMFuzzerInitialize(int *argc, char ***argv) +{ + GIT_UNUSED(argc); + GIT_UNUSED(argv); + + if (git_libgit2_init() < 0) { + fprintf(stderr, "Failed to initialize libgit2\n"); + abort(); + } + return 0; +} + +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + git_midx_file idx = {{0}}; + git_midx_entry e; + git_buf midx_buf = GIT_BUF_INIT; + git_oid oid = {{0}}; + bool append_hash = false; + + if (size < 4) + return 0; + + /* + * If the first byte in the stream has the high bit set, append the + * SHA1 hash so that the packfile is somewhat valid. + */ + append_hash = *data & 0x80; + /* Keep a 4-byte alignment to avoid unaligned accesses. */ + data += 4; + size -= 4; + + if (append_hash) { + if (git_buf_init(&midx_buf, size + sizeof(oid)) < 0) + goto cleanup; + if (git_hash_buf(&oid, data, size) < 0) { + fprintf(stderr, "Failed to compute the SHA1 hash\n"); + abort(); + } + memcpy(midx_buf.ptr, data, size); + memcpy(midx_buf.ptr + size, &oid, sizeof(oid)); + } else { + git_buf_attach_notowned(&midx_buf, (char *)data, size); + } + + if (git_midx_parse(&idx, (const unsigned char *)git_buf_cstr(&midx_buf), git_buf_len(&midx_buf)) < 0) + goto cleanup; + + /* Search for any oid, just to exercise that codepath. */ + if (git_midx_entry_find(&e, &idx, &oid, GIT_OID_HEXSZ) < 0) + goto cleanup; + +cleanup: + git_midx_close(&idx); + git_buf_dispose(&midx_buf); + return 0; +} diff --git a/include/git2/annotated_commit.h b/include/git2/annotated_commit.h index fa795bfc4..3b7103f20 100644 --- a/include/git2/annotated_commit.h +++ b/include/git2/annotated_commit.h @@ -78,7 +78,7 @@ GIT_EXTERN(int) git_annotated_commit_lookup( const git_oid *id); /** - * Creates a `git_annotated_comit` from a revision string. + * Creates a `git_annotated_commit` from a revision string. * * See `man gitrevisions`, or * http://git-scm.com/docs/git-rev-parse.html#_specifying_revisions for diff --git a/include/git2/blame.h b/include/git2/blame.h index 73f6cf979..f42c81552 100644 --- a/include/git2/blame.h +++ b/include/git2/blame.h @@ -47,6 +47,8 @@ typedef enum { * to canonical real names and email addresses. The mailmap will be read * from the working directory, or HEAD in a bare repository. */ GIT_BLAME_USE_MAILMAP = (1<<5), + /** Ignore whitespace differences */ + GIT_BLAME_IGNORE_WHITESPACE = (1<<6), } git_blame_flag_t; /** diff --git a/include/git2/common.h b/include/git2/common.h index d6696061d..8dd30d506 100644 --- a/include/git2/common.h +++ b/include/git2/common.h @@ -205,7 +205,9 @@ typedef enum { GIT_OPT_GET_PACK_MAX_OBJECTS, GIT_OPT_SET_PACK_MAX_OBJECTS, GIT_OPT_DISABLE_PACK_KEEP_FILE_CHECKS, - GIT_OPT_ENABLE_HTTP_EXPECT_CONTINUE + GIT_OPT_ENABLE_HTTP_EXPECT_CONTINUE, + GIT_OPT_GET_MWINDOW_FILE_LIMIT, + GIT_OPT_SET_MWINDOW_FILE_LIMIT } git_libgit2_opt_t; /** @@ -227,8 +229,18 @@ typedef enum { * * * opts(GIT_OPT_SET_MWINDOW_MAPPED_LIMIT, size_t): * - * >Set the maximum amount of memory that can be mapped at any time - * by the library + * > Set the maximum amount of memory that can be mapped at any time + * > by the library + * + * * opts(GIT_OPT_GET_MWINDOW_FILE_LIMIT, size_t *): + * + * > Get the maximum number of files that will be mapped at any time by the + * > library + * + * * opts(GIT_OPT_SET_MWINDOW_FILE_LIMIT, size_t): + * + * > Set the maximum number of files that can be mapped at any time + * > by the library. The default (0) is unlimited. * * * opts(GIT_OPT_GET_SEARCH_PATH, int level, git_buf *buf) * diff --git a/include/git2/deprecated.h b/include/git2/deprecated.h index e5e56edae..3f285018d 100644 --- a/include/git2/deprecated.h +++ b/include/git2/deprecated.h @@ -102,7 +102,11 @@ GIT_EXTERN(int) git_blob_create_fromstream_commit( GIT_EXTERN(int) git_blob_create_frombuffer( git_oid *id, git_repository *repo, const void *buffer, size_t len); -/** Deprecated in favor of @see git_blob_filter */ +/** Deprecated in favor of `git_blob_filter`. + * + * @deprecated Use git_blob_filter + * @see git_blob_filter + */ GIT_EXTERN(int) git_blob_filtered_content( git_buf *out, git_blob *blob, @@ -233,7 +237,7 @@ GIT_EXTERN(void) giterr_clear(void); GIT_EXTERN(void) giterr_set_str(int error_class, const char *string); /** - * Indicates that an out-of-memory situation occured. This is an alias + * Indicates that an out-of-memory situation occurred. This is an alias * of `git_error_set_oom` and is preserved for backward compatibility. * * This function is deprecated, but there is no plan to remove this @@ -524,6 +528,42 @@ typedef int GIT_CALLBACK(git_headlist_cb)(git_remote_head *rhead, void *payload) /**@}*/ +/** @name Deprecated String Array Functions + * + * These types are retained for backward compatibility. The newer + * versions of these values should be preferred in all new code. + * + * There is no plan to remove these backward compatibility values at + * this time. + */ +/**@{*/ + +/** + * Copy a string array object from source to target. + * + * This function is deprecated, but there is no plan to remove this + * function at this time. + * + * @param tgt target + * @param src source + * @return 0 on success, < 0 on allocation failure + */ +GIT_EXTERN(int) git_strarray_copy(git_strarray *tgt, const git_strarray *src); + +/** + * Free the memory referred to by the git_strarray. This is an alias of + * `git_strarray_dispose` and is preserved for backward compatibility. + * + * This function is deprecated, but there is no plan to remove this + * function at this time. + * + * @deprecated Use git_strarray_dispose + * @see git_strarray_dispose + */ +GIT_EXTERN(void) git_strarray_free(git_strarray *array); + +/**@}*/ + /** @name Deprecated Options Initialization Functions * * These functions are retained for backward compatibility. The newer diff --git a/include/git2/errors.h b/include/git2/errors.h index 5c85c4d6c..8887b3299 100644 --- a/include/git2/errors.h +++ b/include/git2/errors.h @@ -107,7 +107,8 @@ typedef enum { GIT_ERROR_PATCH, GIT_ERROR_WORKTREE, GIT_ERROR_SHA1, - GIT_ERROR_HTTP + GIT_ERROR_HTTP, + GIT_ERROR_INTERNAL } git_error_t; /** diff --git a/include/git2/index.h b/include/git2/index.h index 8723aa636..314135109 100644 --- a/include/git2/index.h +++ b/include/git2/index.h @@ -555,8 +555,7 @@ GIT_EXTERN(int) git_index_add_bypath(git_index *index, const char *path); * * If a previous index entry exists that has the same path as the * given 'entry', it will be replaced. Otherwise, the 'entry' will be - * added. The `id` and the `file_size` of the 'entry' are updated with the - * real value of the blob. + * added. * * This forces the file to be added to the index, not looking * at gitignore rules. Those rules can be evaluated through diff --git a/include/git2/pack.h b/include/git2/pack.h index 922a3cd9d..3b9beb665 100644 --- a/include/git2/pack.h +++ b/include/git2/pack.h @@ -155,7 +155,7 @@ GIT_EXTERN(int) git_packbuilder_write_buf(git_buf *buf, git_packbuilder *pb); * Write the new pack and corresponding index file to path. * * @param pb The packbuilder - * @param path to the directory where the packfile and index should be stored + * @param path Path to the directory where the packfile and index should be stored, or NULL for default location * @param mode permissions to use creating a packfile or 0 for defaults * @param progress_cb function to call with progress information from the indexer (optional) * @param progress_cb_payload payload for the progress callback (optional) diff --git a/include/git2/strarray.h b/include/git2/strarray.h index 86fa25f3f..0f657e6c5 100644 --- a/include/git2/strarray.h +++ b/include/git2/strarray.h @@ -25,20 +25,16 @@ typedef struct git_strarray { } git_strarray; /** - * Close a string array object - * - * This method should be called on `git_strarray` objects where the strings - * array is allocated and contains allocated strings, such as what you - * would get from `git_strarray_copy()`. Not doing so, will result in a - * memory leak. + * Free the strings contained in a string array. This method should + * be called on `git_strarray` objects that were provided by the + * library. Not doing so, will result in a memory leak. * * This does not free the `git_strarray` itself, since the library will - * never allocate that object directly itself (it is more commonly embedded - * inside another struct or created on the stack). + * never allocate that object directly itself. * - * @param array git_strarray from which to free string data + * @param array The git_strarray that contains strings to free */ -GIT_EXTERN(void) git_strarray_free(git_strarray *array); +GIT_EXTERN(void) git_strarray_dispose(git_strarray *array); /** * Copy a string array object from source to target. diff --git a/include/git2/version.h b/include/git2/version.h index 2d8708622..c1020bbea 100644 --- a/include/git2/version.h +++ b/include/git2/version.h @@ -7,12 +7,12 @@ #ifndef INCLUDE_git_version_h__ #define INCLUDE_git_version_h__ -#define LIBGIT2_VERSION "1.0.1" +#define LIBGIT2_VERSION "1.1.0" #define LIBGIT2_VER_MAJOR 1 -#define LIBGIT2_VER_MINOR 0 -#define LIBGIT2_VER_REVISION 1 +#define LIBGIT2_VER_MINOR 1 +#define LIBGIT2_VER_REVISION 0 #define LIBGIT2_VER_PATCH 0 -#define LIBGIT2_SOVERSION "1.0" +#define LIBGIT2_SOVERSION "1.1" #endif diff --git a/package.json b/package.json index 79cddbee7..5e74f3bd5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "libgit2", - "version": "1.0.1", + "version": "1.1.0", "repo": "https://github.com/libgit2/libgit2", "description": " A cross-platform, linkable library implementation of Git that you can use in your application.", "install": "mkdir build && cd build && cmake .. && cmake --build ." diff --git a/script/release.py b/script/release.py index 3d8e9b806..1a240deca 100755 --- a/script/release.py +++ b/script/release.py @@ -40,6 +40,15 @@ def verify_version(version): 'SOVERSION': [ '"{}.{}"'.format(version.major, version.minor), None ], } + # Parse CMakeLists + with open('CMakeLists.txt') as f: + for line in f.readlines(): + if line.startswith('project(libgit2 VERSION "{}"'.format(version)): + break + else: + raise Error("cmake: invalid project definition") + + # Parse version.h with open('include/git2/version.h') as f: lines = f.readlines() @@ -166,7 +175,7 @@ def main(): parser.add_argument('--tree', default='HEAD', help='tree to create release for (default: HEAD)') parser.add_argument('--dryrun', action='store_true', help='generate release, but do not post it') parser.add_argument('--repository', default='libgit2/libgit2', help='GitHub repository to create repository in') - parser.add_argument('--user', help='user to authenitcate as') + parser.add_argument('--user', help='user to authenticate as') parser.add_argument('--password', help='password to authenticate with') parser.add_argument('version', type=Version, help='version of the new release') args = parser.parse_args() diff --git a/script/sanitizers.supp b/script/sanitizers.supp new file mode 100644 index 000000000..4e0e9be83 --- /dev/null +++ b/script/sanitizers.supp @@ -0,0 +1,4 @@ +[undefined] +# This library allows unaligned access on Intel-like processors. Prevent UBSan +# from complaining about that. +fun:sha1_compression_states diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dff1d94e8..d01cc6458 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,3 +1,6 @@ +add_library(git2internal OBJECT) +set_target_properties(git2internal PROPERTIES C_STANDARD 90) + IF(DEBUG_POOL) SET(GIT_DEBUG_POOL 1) ENDIF() @@ -21,6 +24,8 @@ SET(LIBGIT2_INCLUDES SET(LIBGIT2_SYSTEM_INCLUDES "") SET(LIBGIT2_LIBS "") +enable_warnings(missing-declarations) + # Enable tracing IF(ENABLE_TRACE) SET(GIT_TRACE 1) @@ -36,19 +41,19 @@ CHECK_PROTOTYPE_DEFINITION(qsort_r "void qsort_r(void *base, size_t nmemb, size_t size, void *thunk, int (*compar)(void *, const void *, const void *))" "" "stdlib.h" HAVE_QSORT_R_BSD) IF (HAVE_QSORT_R_BSD) - ADD_DEFINITIONS(-DHAVE_QSORT_R_BSD) + target_compile_definitions(git2internal PRIVATE HAVE_QSORT_R_BSD) ENDIF() CHECK_PROTOTYPE_DEFINITION(qsort_r "void qsort_r(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *, void *), void *arg)" "" "stdlib.h" HAVE_QSORT_R_GNU) IF (HAVE_QSORT_R_GNU) - ADD_DEFINITIONS(-DHAVE_QSORT_R_GNU) + target_compile_definitions(git2internal PRIVATE HAVE_QSORT_R_GNU) ENDIF() CHECK_FUNCTION_EXISTS(qsort_s HAVE_QSORT_S) IF (HAVE_QSORT_S) - ADD_DEFINITIONS(-DHAVE_QSORT_S) + target_compile_definitions(git2internal PRIVATE HAVE_QSORT_S) ENDIF () # Find required dependencies @@ -76,12 +81,15 @@ ENDIF() ADD_FEATURE_INFO(threadsafe THREADSAFE "threadsafe support") -IF (WIN32 AND EMBED_SSH_PATH) - FILE(GLOB SRC_SSH "${EMBED_SSH_PATH}/src/*.c") - LIST(APPEND LIBGIT2_SYSTEM_INCLUDES "${EMBED_SSH_PATH}/include") - FILE(WRITE "${EMBED_SSH_PATH}/src/libssh2_config.h" "#define HAVE_WINCNG\n#define LIBSSH2_WINCNG\n#include \"../win32/libssh2_config.h\"") - SET(GIT_SSH 1) -ENDIF() +if(WIN32 AND EMBED_SSH_PATH) + file(GLOB SRC_SSH "${EMBED_SSH_PATH}/src/*.c") + list(SORT SRC_SSH) + target_sources(git2internal PRIVATE ${SRC_SSH}) + + list(APPEND LIBGIT2_SYSTEM_INCLUDES "${EMBED_SSH_PATH}/include") + file(WRITE "${EMBED_SSH_PATH}/src/libssh2_config.h" "#define HAVE_WINCNG\n#define LIBSSH2_WINCNG\n#include \"../win32/libssh2_config.h\"") + set(GIT_SSH 1) +endif() IF (WIN32 AND WINHTTP) SET(GIT_WINHTTP 1) @@ -101,8 +109,9 @@ IF (WIN32 AND WINHTTP) LIST(APPEND LIBGIT2_PC_LIBS "-lrpcrt4" "-lcrypt32" "-lole32") ENDIF() -Include(SelectHTTPSBackend) -Include(SelectHashes) +include(SelectHTTPSBackend) +include(SelectHashes) +target_sources(git2internal PRIVATE ${SRC_SHA1}) # Specify regular expression implementation FIND_PACKAGE(PCRE) @@ -264,36 +273,43 @@ ELSEIF (HAVE_STRUCT_STAT_ST_MTIME_NSEC) SET(GIT_USE_STAT_MTIME_NSEC 1) ENDIF() -ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=64) +target_compile_definitions(git2internal PRIVATE _FILE_OFFSET_BITS=64) # Collect sourcefiles -FILE(GLOB SRC_H +file(GLOB SRC_H "${libgit2_SOURCE_DIR}/include/git2.h" "${libgit2_SOURCE_DIR}/include/git2/*.h" "${libgit2_SOURCE_DIR}/include/git2/sys/*.h") +list(SORT SRC_H) +target_sources(git2internal PRIVATE ${SRC_H}) # On Windows use specific platform sources -IF (WIN32 AND NOT CYGWIN) - IF(MSVC) - SET(WIN_RC "win32/git2.rc") - ENDIF() +if(WIN32 AND NOT CYGWIN) + SET(WIN_RC "win32/git2.rc") - FILE(GLOB SRC_OS win32/*.c win32/*.h) -ELSEIF (AMIGA) - ADD_DEFINITIONS(-DNO_ADDRINFO -DNO_READDIR_R -DNO_MMAP) -ELSE() - FILE(GLOB SRC_OS unix/*.c unix/*.h) -ENDIF() + file(GLOB SRC_OS win32/*.c win32/*.h) + list(SORT SRC_OS) + target_sources(git2internal PRIVATE ${SRC_OS}) +elseif(AMIGA) + target_compile_definitions(git2internal PRIVATE NO_ADDRINFO NO_READDIR_R NO_MMAP) +else() + file(GLOB SRC_OS unix/*.c unix/*.h) + list(SORT SRC_OS) + target_sources(git2internal PRIVATE ${SRC_OS}) +endif() IF (USE_LEAK_CHECKER STREQUAL "valgrind") - ADD_DEFINITIONS(-DVALGRIND) + target_compile_definitions(git2internal PRIVATE VALGRIND) ENDIF() -FILE(GLOB SRC_GIT2 *.c *.h +file(GLOB SRC_GIT2 *.c *.h allocators/*.c allocators/*.h streams/*.c streams/*.h transports/*.c transports/*.h xdiff/*.c xdiff/*.h) +list(SORT SRC_GIT2) +target_sources(git2internal PRIVATE ${SRC_GIT2}) + IF(APPLE) # The old Secure Transport API has been deprecated in macOS 10.15. SET_SOURCE_FILES_PROPERTIES(streams/stransport.c PROPERTIES COMPILE_FLAGS -Wno-deprecated) @@ -319,10 +335,6 @@ ENDIF() CONFIGURE_FILE(features.h.in git2/sys/features.h) -SET(LIBGIT2_SOURCES ${SRC_H} ${SRC_GIT2} ${SRC_OS} ${SRC_SSH} ${SRC_SHA1}) - -ADD_LIBRARY(git2internal OBJECT ${LIBGIT2_SOURCES}) -SET_TARGET_PROPERTIES(git2internal PROPERTIES C_STANDARD 90) IDE_SPLIT_SOURCES(git2internal) LIST(APPEND LIBGIT2_OBJECTS $) @@ -358,19 +370,19 @@ ENDIF() IDE_SPLIT_SOURCES(git2) -IF (SONAME) - SET_TARGET_PROPERTIES(git2 PROPERTIES VERSION ${LIBGIT2_VERSION_STRING}) - SET_TARGET_PROPERTIES(git2 PROPERTIES SOVERSION ${LIBGIT2_SOVERSION}) - IF (LIBGIT2_FILENAME) - ADD_DEFINITIONS(-DLIBGIT2_FILENAME=\"${LIBGIT2_FILENAME}\") - SET_TARGET_PROPERTIES(git2 PROPERTIES OUTPUT_NAME ${LIBGIT2_FILENAME}) - ELSEIF (DEFINED LIBGIT2_PREFIX) - SET_TARGET_PROPERTIES(git2 PROPERTIES PREFIX "${LIBGIT2_PREFIX}") - ENDIF() -ENDIF() +if(SONAME) + set_target_properties(git2 PROPERTIES VERSION ${libgit2_VERSION}) + set_target_properties(git2 PROPERTIES SOVERSION "${libgit2_VERSION_MAJOR}.${libgit2_VERSION_MINOR}") + if(LIBGIT2_FILENAME) + target_compile_definitions(git2internal PRIVATE LIBGIT2_FILENAME=\"${LIBGIT2_FILENAME}\") + set_target_properties(git2 PROPERTIES OUTPUT_NAME ${LIBGIT2_FILENAME}) + elseif(DEFINED LIBGIT2_PREFIX) + set_target_properties(git2 PROPERTIES PREFIX "${LIBGIT2_PREFIX}") + endif() +endif() PKG_BUILD_CONFIG(NAME libgit2 - VERSION ${LIBGIT2_VERSION_STRING} + VERSION ${libgit2_VERSION} DESCRIPTION "The git library, take 2" LIBS_SELF git2 PRIVATE_LIBS ${LIBGIT2_PC_LIBS} diff --git a/src/apply.c b/src/apply.c index fc60e1418..b0be2d8e6 100644 --- a/src/apply.c +++ b/src/apply.c @@ -63,7 +63,11 @@ static int patch_image_init_fromstr( memset(out, 0x0, sizeof(patch_image)); - git_pool_init(&out->pool, sizeof(git_diff_line)); + if (git_pool_init(&out->pool, sizeof(git_diff_line)) < 0) + return -1; + + if (!in_len) + return 0; for (start = in; start < in + in_len; start = end) { end = memchr(start, '\n', in_len - (start - in)); diff --git a/src/assert_safe.h b/src/assert_safe.h new file mode 100644 index 000000000..8c261100f --- /dev/null +++ b/src/assert_safe.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_assert_safe_h__ +#define INCLUDE_assert_safe_h__ + +/* + * In a debug build, we'll assert(3) for aide in debugging. In release + * builds, we will provide macros that will set an error message that + * indicate a failure and return. Note that memory leaks can occur in + * a release-mode assertion failure -- it is impractical to provide + * safe clean up routines in these very extreme failures, but care + * should be taken to not leak very large objects. + */ + +#if (defined(_DEBUG) || defined(GIT_ASSERT_HARD)) && GIT_ASSERT_HARD != 0 +# include + +# define GIT_ASSERT(expr) assert(expr) +# define GIT_ASSERT_ARG(expr) assert(expr) + +# define GIT_ASSERT_WITH_RETVAL(expr, fail) assert(expr) +# define GIT_ASSERT_ARG_WITH_RETVAL(expr, fail) assert(expr) +#else + +/** Internal consistency check to stop the function. */ +# define GIT_ASSERT(expr) GIT_ASSERT_WITH_RETVAL(expr, -1) + +/** + * Assert that a consumer-provided argument is valid, setting an + * actionable error message and returning -1 if it is not. + */ +# define GIT_ASSERT_ARG(expr) GIT_ASSERT_ARG_WITH_RETVAL(expr, -1) + +/** Internal consistency check to return the `fail` param on failure. */ +# define GIT_ASSERT_WITH_RETVAL(expr, fail) \ + GIT_ASSERT__WITH_RETVAL(expr, GIT_ERROR_INTERNAL, "unrecoverable internal error", fail) + +/** + * Assert that a consumer-provided argument is valid, setting an + * actionable error message and returning the `fail` param if not. + */ +# define GIT_ASSERT_ARG_WITH_RETVAL(expr, fail) \ + GIT_ASSERT__WITH_RETVAL(expr, GIT_ERROR_INVALID, "invalid argument", fail) + +# define GIT_ASSERT__WITH_RETVAL(expr, code, msg, fail) do { \ + if (!(expr)) { \ + git_error_set(code, "%s: '%s'", msg, #expr); \ + return fail; \ + } \ + } while(0) + +#endif /* GIT_ASSERT_HARD */ + +#endif diff --git a/src/attr_file.c b/src/attr_file.c index 82da5268f..3f69b5ffc 100644 --- a/src/attr_file.c +++ b/src/attr_file.c @@ -41,16 +41,21 @@ int git_attr_file__new( if (git_mutex_init(&attrs->lock) < 0) { git_error_set(GIT_ERROR_OS, "failed to initialize lock"); - git__free(attrs); - return -1; + goto on_error; } - git_pool_init(&attrs->pool, 1); + if (git_pool_init(&attrs->pool, 1) < 0) + goto on_error; + GIT_REFCOUNT_INC(attrs); attrs->entry = entry; attrs->source = source; *out = attrs; return 0; + +on_error: + git__free(attrs); + return -1; } int git_attr_file__clear_rules(git_attr_file *file, bool need_lock) diff --git a/src/attrcache.c b/src/attrcache.c index f02dd9d1d..47fb675e0 100644 --- a/src/attrcache.c +++ b/src/attrcache.c @@ -391,11 +391,10 @@ int git_attr_cache__init(git_repository *repo) * hashtable for attribute macros, and string pool */ if ((ret = git_strmap_new(&cache->files)) < 0 || - (ret = git_strmap_new(&cache->macros)) < 0) + (ret = git_strmap_new(&cache->macros)) < 0 || + (ret = git_pool_init(&cache->pool, 1)) < 0) goto cancel; - git_pool_init(&cache->pool, 1); - cache = git__compare_and_swap(&repo->attrcache, NULL, cache); if (cache) goto cancel; /* raced with another thread, free this but no error */ diff --git a/src/blame.c b/src/blame.c index 23c21027a..1046dab55 100644 --- a/src/blame.c +++ b/src/blame.c @@ -538,7 +538,9 @@ int git_blame_options_init(git_blame_options *opts, unsigned int version) return 0; } +#ifndef GIT_DEPRECATE_HARD int git_blame_init_options(git_blame_options *opts, unsigned int version) { return git_blame_options_init(opts, version); } +#endif diff --git a/src/blame_git.c b/src/blame_git.c index a9157c4ed..073137a68 100644 --- a/src/blame_git.c +++ b/src/blame_git.c @@ -365,11 +365,14 @@ static void trim_common_tail(mmfile_t *a, mmfile_t *b, long ctx) b->size -= trimmed - recovered; } -static int diff_hunks(mmfile_t file_a, mmfile_t file_b, void *cb_data) +static int diff_hunks(mmfile_t file_a, mmfile_t file_b, void *cb_data, git_blame_options *options) { - xpparam_t xpp = {0}; xdemitconf_t xecfg = {0}; xdemitcb_t ecb = {0}; + xpparam_t xpp = {0}; + + if (options->flags & GIT_BLAME_IGNORE_WHITESPACE) + xpp.flags |= XDF_IGNORE_WHITESPACE; xecfg.hunk_func = my_emit; ecb.priv = cb_data; @@ -409,7 +412,7 @@ static int pass_blame_to_parent( fill_origin_blob(parent, &file_p); fill_origin_blob(target, &file_o); - if (diff_hunks(file_p, file_o, &d) < 0) + if (diff_hunks(file_p, file_o, &d, &blame->options) < 0) return -1; /* The reset (i.e. anything after tlno) are the same as the parent */ diff --git a/src/blob.c b/src/blob.c index 5e734e2c1..da4e6ffa5 100644 --- a/src/blob.c +++ b/src/blob.c @@ -445,6 +445,7 @@ int git_blob_filter( /* Deprecated functions */ +#ifndef GIT_DEPRECATE_HARD int git_blob_create_frombuffer( git_oid *id, git_repository *repo, const void *buffer, size_t len) { @@ -491,3 +492,4 @@ int git_blob_filtered_content( return git_blob_filter(out, blob, path, &opts); } +#endif diff --git a/src/branch.c b/src/branch.c index 8926c8956..715f6cf99 100644 --- a/src/branch.c +++ b/src/branch.c @@ -134,39 +134,37 @@ int git_branch_create_from_annotated( repository, branch_name, commit->commit, commit->description, force); } -static int branch_equals(git_repository *repo, const char *path, void *payload) +static int branch_is_checked_out(git_repository *worktree, void *payload) { git_reference *branch = (git_reference *) payload; git_reference *head = NULL; - int equal = 0; + int error; - if (git_reference__read_head(&head, repo, path) < 0 || - git_reference_type(head) != GIT_REFERENCE_SYMBOLIC) - goto done; + if (git_repository_is_bare(worktree)) + return 0; - equal = !git__strcmp(head->target.symbolic, branch->name); + if ((error = git_reference_lookup(&head, worktree, GIT_HEAD_FILE)) < 0) { + if (error == GIT_ENOTFOUND) + error = 0; + goto out; + } -done: + if (git_reference_type(head) != GIT_REFERENCE_SYMBOLIC) + goto out; + + error = !git__strcmp(head->target.symbolic, branch->name); + +out: git_reference_free(head); - return equal; + return error; } int git_branch_is_checked_out(const git_reference *branch) { - git_repository *repo; - int flags = 0; - - assert(branch); - if (!git_reference_is_branch(branch)) return 0; - - repo = git_reference_owner(branch); - - if (git_repository_is_bare(repo)) - flags |= GIT_REPOSITORY_FOREACH_HEAD_SKIP_REPO; - - return git_repository_foreach_head(repo, branch_equals, flags, (void *) branch) == 1; + return git_repository_foreach_worktree(git_reference_owner(branch), + branch_is_checked_out, (void *)branch) == 1; } int git_branch_delete(git_reference *branch) @@ -548,7 +546,7 @@ cleanup: if (error < 0) git_buf_dispose(buf); - git_strarray_free(&remote_list); + git_strarray_dispose(&remote_list); return error; } diff --git a/src/buffer.c b/src/buffer.c index 328fdfe7f..c203650c7 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -133,10 +133,12 @@ void git_buf_dispose(git_buf *buf) git_buf_init(buf, 0); } +#ifndef GIT_DEPRECATE_HARD void git_buf_free(git_buf *buf) { git_buf_dispose(buf); } +#endif void git_buf_sanitize(git_buf *buf) { @@ -363,7 +365,7 @@ int git_buf_encode_base85(git_buf *buf, const char *data, size_t len) for (i = 24; i >= 0; i -= 8) { uint8_t ch = *data++; - acc |= ch << i; + acc |= (uint32_t)ch << i; if (--len == 0) break; @@ -757,7 +759,8 @@ int git_buf_join( ssize_t offset_a = -1; /* not safe to have str_b point internally to the buffer */ - assert(str_b < buf->ptr || str_b >= buf->ptr + buf->size); + if (buf->size) + assert(str_b < buf->ptr || str_b >= buf->ptr + buf->size); /* figure out if we need to insert a separator */ if (separator && strlen_a) { @@ -767,7 +770,7 @@ int git_buf_join( } /* str_a could be part of the buffer */ - if (str_a >= buf->ptr && str_a < buf->ptr + buf->size) + if (buf->size && str_a >= buf->ptr && str_a < buf->ptr + buf->size) offset_a = str_a - buf->ptr; GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, strlen_a, strlen_b); diff --git a/src/cache.c b/src/cache.c index af42b3959..a76da50d7 100644 --- a/src/cache.c +++ b/src/cache.c @@ -41,27 +41,6 @@ int git_cache_set_max_object_size(git_object_t type, size_t size) return 0; } -void git_cache_dump_stats(git_cache *cache) -{ - git_cached_obj *object; - - if (git_cache_size(cache) == 0) - return; - - printf("Cache %p: %"PRIuZ" items cached, %"PRIdZ" bytes\n", - cache, git_cache_size(cache), cache->used_memory); - - git_oidmap_foreach_value(cache->map, object, { - char oid_str[9]; - printf(" %s%c %s (%"PRIuZ")\n", - git_object_type2string(object->type), - object->flags == GIT_CACHE_STORE_PARSED ? '*' : ' ', - git_oid_tostr(oid_str, sizeof(oid_str), &object->oid), - object->size - ); - }); -} - int git_cache_init(git_cache *cache) { memset(cache, 0, sizeof(*cache)); @@ -189,7 +168,7 @@ static void *cache_store(git_cache *cache, git_cached_obj *entry) return entry; /* soften the load on the cache */ - if (git_cache__current_storage.val > git_cache__max_storage) + if (git_atomic_ssize_get(&git_cache__current_storage) > git_cache__max_storage) cache_evict_entries(cache); /* not found */ diff --git a/src/checkout.c b/src/checkout.c index 5cfa7280b..94a2cb9fa 100644 --- a/src/checkout.c +++ b/src/checkout.c @@ -44,7 +44,6 @@ enum { CHECKOUT_ACTION__REMOVE_CONFLICT = 16, CHECKOUT_ACTION__UPDATE_CONFLICT = 32, CHECKOUT_ACTION__MAX = 32, - CHECKOUT_ACTION__DEFER_REMOVE = 64, CHECKOUT_ACTION__REMOVE_AND_UPDATE = (CHECKOUT_ACTION__UPDATE_BLOB | CHECKOUT_ACTION__REMOVE), }; @@ -196,7 +195,7 @@ static bool checkout_is_workdir_modified( } if (git_submodule_status(&sm_status, data->repo, wditem->path, GIT_SUBMODULE_IGNORE_UNSPECIFIED) < 0 || - GIT_SUBMODULE_STATUS_IS_WD_DIRTY(sm_status)) + GIT_SUBMODULE_STATUS_IS_WD_DIRTY(sm_status)) rval = true; else if ((sm_oid = git_submodule_wd_id(sm)) == NULL) rval = false; @@ -217,9 +216,10 @@ static bool checkout_is_workdir_modified( ie = git_index_get_bypath(data->index, wditem->path, 0); if (ie != NULL && - git_index_time_eq(&wditem->mtime, &ie->mtime) && - wditem->file_size == ie->file_size && - !is_filemode_changed(wditem->mode, ie->mode, data->respect_filemode)) { + !git_index_entry_newer_than_index(ie, data->index) && + git_index_time_eq(&wditem->mtime, &ie->mtime) && + wditem->file_size == ie->file_size && + !is_filemode_changed(wditem->mode, ie->mode, data->respect_filemode)) { /* The workdir is modified iff the index entry is modified */ return !is_workdir_base_or_new(&ie->id, baseitem, newitem) || @@ -273,9 +273,8 @@ static int checkout_action_common( /* if the file is on disk and doesn't match our mode, force update */ if (wd && - GIT_PERMS_IS_EXEC(wd->mode) != - GIT_PERMS_IS_EXEC(delta->new_file.mode)) - *action |= CHECKOUT_ACTION__REMOVE; + GIT_PERMS_IS_EXEC(wd->mode) != GIT_PERMS_IS_EXEC(delta->new_file.mode)) + *action |= CHECKOUT_ACTION__REMOVE; notify = GIT_CHECKOUT_NOTIFY_UPDATED; } @@ -371,8 +370,13 @@ static int checkout_action_wd_only( if (!git_pathspec__match( pathspec, wd->path, (data->strategy & GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH) != 0, - git_iterator_ignore_case(workdir), NULL, NULL)) - return git_iterator_advance(wditem, workdir); + git_iterator_ignore_case(workdir), NULL, NULL)) { + + if (wd->mode == GIT_FILEMODE_TREE) + return git_iterator_advance_into(wditem, workdir); + else + return git_iterator_advance(wditem, workdir); + } /* check if item is tracked in the index but not in the checkout diff */ if (data->index != NULL) { @@ -794,13 +798,13 @@ static int checkout_conflictdata_cmp(const void *a, const void *b) int diff; if ((diff = checkout_idxentry_cmp(ca->ancestor, cb->ancestor)) == 0 && - (diff = checkout_idxentry_cmp(ca->ours, cb->theirs)) == 0) + (diff = checkout_idxentry_cmp(ca->ours, cb->theirs)) == 0) diff = checkout_idxentry_cmp(ca->theirs, cb->theirs); return diff; } -int checkout_conflictdata_empty( +static int checkout_conflictdata_empty( const git_vector *conflicts, size_t idx, void *payload) { checkout_conflictdata *conflict; @@ -1173,7 +1177,7 @@ static int checkout_conflicts_mark_directoryfile( /* Find d/f conflicts */ git_vector_foreach(&data->update_conflicts, i, conflict) { if ((conflict->ours && conflict->theirs) || - (!conflict->ours && !conflict->theirs)) + (!conflict->ours && !conflict->theirs)) continue; path = conflict->ours ? @@ -1222,8 +1226,8 @@ static int checkout_get_update_conflicts( return 0; if ((error = checkout_conflicts_load(data, workdir, pathspec)) < 0 || - (error = checkout_conflicts_coalesce_renames(data)) < 0 || - (error = checkout_conflicts_mark_directoryfile(data)) < 0) + (error = checkout_conflicts_coalesce_renames(data)) < 0 || + (error = checkout_conflicts_mark_directoryfile(data)) < 0) goto done; done: @@ -1304,14 +1308,15 @@ static int checkout_get_actions( size_t i, *counts = NULL; uint32_t *actions = NULL; - git_pool_init(&pathpool, 1); + if (git_pool_init(&pathpool, 1) < 0) + return -1; if (data->opts.paths.count > 0 && - git_pathspec__vinit(&pathspec, &data->opts.paths, &pathpool) < 0) + git_pathspec__vinit(&pathspec, &data->opts.paths, &pathpool) < 0) return -1; if ((error = git_iterator_current(&wditem, workdir)) < 0 && - error != GIT_ITEROVER) + error != GIT_ITEROVER) goto fail; deltas = &data->diff->deltas; @@ -1350,8 +1355,7 @@ static int checkout_get_actions( counts[CHECKOUT_ACTION__REMOVE] += data->removes.length; if (counts[CHECKOUT_ACTION__CONFLICT] > 0 && - (data->strategy & GIT_CHECKOUT_ALLOW_CONFLICTS) == 0) - { + (data->strategy & GIT_CHECKOUT_ALLOW_CONFLICTS) == 0) { git_error_set(GIT_ERROR_CHECKOUT, "%"PRIuZ" %s checkout", counts[CHECKOUT_ACTION__CONFLICT], counts[CHECKOUT_ACTION__CONFLICT] == 1 ? @@ -1362,7 +1366,7 @@ static int checkout_get_actions( if ((error = checkout_get_remove_conflicts(data, workdir, &pathspec)) < 0 || - (error = checkout_get_update_conflicts(data, workdir, &pathspec)) < 0) + (error = checkout_get_update_conflicts(data, workdir, &pathspec)) < 0) goto fail; counts[CHECKOUT_ACTION__REMOVE_CONFLICT] = git_vector_length(&data->remove_conflicts); @@ -1853,26 +1857,6 @@ static int checkout_remove_the_old( return 0; } -static int checkout_deferred_remove(git_repository *repo, const char *path) -{ -#if 0 - int error = git_futils_rmdir_r( - path, data->opts.target_directory, GIT_RMDIR_EMPTY_PARENTS); - - if (error == GIT_ENOTFOUND) { - error = 0; - git_error_clear(); - } - - return error; -#else - GIT_UNUSED(repo); - GIT_UNUSED(path); - assert(false); - return 0; -#endif -} - static int checkout_create_the_new( unsigned int *actions, checkout_data *data) @@ -1882,15 +1866,6 @@ static int checkout_create_the_new( size_t i; git_vector_foreach(&data->diff->deltas, i, delta) { - if (actions[i] & CHECKOUT_ACTION__DEFER_REMOVE) { - /* this had a blocker directory that should only be removed iff - * all of the contents of the directory were safely removed - */ - if ((error = checkout_deferred_remove( - data->repo, delta->old_file.path)) < 0) - return error; - } - if (actions[i] & CHECKOUT_ACTION__UPDATE_BLOB && !S_ISLNK(delta->new_file.mode)) { if ((error = checkout_blob(data, &delta->new_file)) < 0) return error; @@ -1915,20 +1890,10 @@ static int checkout_create_submodules( unsigned int *actions, checkout_data *data) { - int error = 0; git_diff_delta *delta; size_t i; git_vector_foreach(&data->diff->deltas, i, delta) { - if (actions[i] & CHECKOUT_ACTION__DEFER_REMOVE) { - /* this has a blocker directory that should only be removed iff - * all of the contents of the directory were safely removed - */ - if ((error = checkout_deferred_remove( - data->repo, delta->old_file.path)) < 0) - return error; - } - if (actions[i] & CHECKOUT_ACTION__UPDATE_SUBMODULE) { int error = checkout_submodule(data, &delta->new_file); if (error < 0) @@ -2520,9 +2485,8 @@ static int checkout_data_init( git_config_entry_free(conflict_style); } - git_pool_init(&data->pool, 1); - - if ((error = git_vector_init(&data->removes, 0, git__strcmp_cb)) < 0 || + if ((error = git_pool_init(&data->pool, 1)) < 0 || + (error = git_vector_init(&data->removes, 0, git__strcmp_cb)) < 0 || (error = git_vector_init(&data->remove_conflicts, 0, NULL)) < 0 || (error = git_vector_init(&data->update_conflicts, 0, NULL)) < 0 || (error = git_buf_puts(&data->target_path, data->opts.target_directory)) < 0 || @@ -2544,6 +2508,17 @@ cleanup: #define CHECKOUT_INDEX_DONT_WRITE_MASK \ (GIT_CHECKOUT_DONT_UPDATE_INDEX | GIT_CHECKOUT_DONT_WRITE_INDEX) +GIT_INLINE(void) setup_pathspecs( + git_iterator_options *iter_opts, + const git_checkout_options *checkout_opts) +{ + if (checkout_opts && + (checkout_opts->checkout_strategy & GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH)) { + iter_opts->pathlist.count = checkout_opts->paths.count; + iter_opts->pathlist.strings = checkout_opts->paths.strings; + } +} + int git_checkout_iterator( git_iterator *target, git_index *index, @@ -2586,6 +2561,8 @@ int git_checkout_iterator( workdir_opts.start = data.pfx; workdir_opts.end = data.pfx; + setup_pathspecs(&workdir_opts, opts); + if ((error = git_iterator_reset_range(target, data.pfx, data.pfx)) < 0 || (error = git_iterator_for_workdir_ext( &workdir, data.repo, data.opts.target_directory, index, NULL, @@ -2596,10 +2573,8 @@ int git_checkout_iterator( GIT_ITERATOR_IGNORE_CASE : GIT_ITERATOR_DONT_IGNORE_CASE; baseline_opts.start = data.pfx; baseline_opts.end = data.pfx; - if (opts && (opts->checkout_strategy & GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH)) { - baseline_opts.pathlist.count = opts->paths.count; - baseline_opts.pathlist.strings = opts->paths.strings; - } + + setup_pathspecs(&baseline_opts, opts); if (data.opts.baseline_index) { if ((error = git_iterator_for_index( @@ -2689,6 +2664,7 @@ int git_checkout_index( git_index *index, const git_checkout_options *opts) { + git_iterator_options iter_opts = GIT_ITERATOR_OPTIONS_INIT; int error, owned = 0; git_iterator *index_i; @@ -2716,7 +2692,9 @@ int git_checkout_index( return error; GIT_REFCOUNT_INC(index); - if (!(error = git_iterator_for_index(&index_i, repo, index, NULL))) + setup_pathspecs(&iter_opts, opts); + + if (!(error = git_iterator_for_index(&index_i, repo, index, &iter_opts))) error = git_checkout_iterator(index_i, index, opts); if (owned) @@ -2773,10 +2751,7 @@ int git_checkout_tree( if ((error = git_repository_index(&index, repo)) < 0) return error; - if (opts && (opts->checkout_strategy & GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH)) { - iter_opts.pathlist.count = opts->paths.count; - iter_opts.pathlist.strings = opts->paths.strings; - } + setup_pathspecs(&iter_opts, opts); if (!(error = git_iterator_for_tree(&tree_i, tree, &iter_opts))) error = git_checkout_iterator(tree_i, index, opts); @@ -2803,7 +2778,9 @@ int git_checkout_options_init(git_checkout_options *opts, unsigned int version) return 0; } +#ifndef GIT_DEPRECATE_HARD int git_checkout_init_options(git_checkout_options *opts, unsigned int version) { return git_checkout_options_init(opts, version); } +#endif diff --git a/src/cherrypick.c b/src/cherrypick.c index 640d11a7b..103897aae 100644 --- a/src/cherrypick.c +++ b/src/cherrypick.c @@ -229,8 +229,10 @@ int git_cherrypick_options_init( return 0; } +#ifndef GIT_DEPRECATE_HARD int git_cherrypick_init_options( git_cherrypick_options *opts, unsigned int version) { return git_cherrypick_options_init(opts, version); } +#endif diff --git a/src/clone.c b/src/clone.c index 3d749c32f..a93ec475f 100644 --- a/src/clone.c +++ b/src/clone.c @@ -137,6 +137,80 @@ static int update_head_to_new_branch( return error; } +static int update_head_to_default(git_repository *repo) +{ + git_buf initialbranch = GIT_BUF_INIT; + const char *branch_name; + int error = 0; + + if ((error = git_repository_initialbranch(&initialbranch, repo)) < 0) + goto done; + + if (git__prefixcmp(initialbranch.ptr, GIT_REFS_HEADS_DIR) != 0) { + git_error_set(GIT_ERROR_INVALID, "invalid initial branch '%s'", initialbranch.ptr); + error = -1; + goto done; + } + + branch_name = initialbranch.ptr + strlen(GIT_REFS_HEADS_DIR); + + error = setup_tracking_config(repo, branch_name, GIT_REMOTE_ORIGIN, + initialbranch.ptr); + +done: + git_buf_dispose(&initialbranch); + return error; +} + +static int update_remote_head( + git_repository *repo, + git_remote *remote, + git_buf *target, + const char *reflog_message) +{ + git_refspec *refspec; + git_reference *remote_head = NULL; + git_buf remote_head_name = GIT_BUF_INIT; + git_buf remote_branch_name = GIT_BUF_INIT; + int error; + + /* Determine the remote tracking ref name from the local branch */ + refspec = git_remote__matching_refspec(remote, git_buf_cstr(target)); + + if (refspec == NULL) { + git_error_set(GIT_ERROR_NET, "the remote's default branch does not fit the refspec configuration"); + error = GIT_EINVALIDSPEC; + goto cleanup; + } + + if ((error = git_refspec_transform( + &remote_branch_name, + refspec, + git_buf_cstr(target))) < 0) + goto cleanup; + + if ((error = git_buf_printf(&remote_head_name, + "%s%s/%s", + GIT_REFS_REMOTES_DIR, + git_remote_name(remote), + GIT_HEAD_FILE)) < 0) + goto cleanup; + + error = git_reference_symbolic_create( + &remote_head, + repo, + git_buf_cstr(&remote_head_name), + git_buf_cstr(&remote_branch_name), + true, + reflog_message); + +cleanup: + git_reference_free(remote_head); + git_buf_dispose(&remote_branch_name); + git_buf_dispose(&remote_head_name); + return error; +} + static int update_head_to_remote( git_repository *repo, git_remote *remote, @@ -144,10 +218,8 @@ static int update_head_to_remote( { int error = 0; size_t refs_len; - git_refspec *refspec; const git_remote_head *remote_head, **refs; const git_oid *remote_head_id; - git_buf remote_master_name = GIT_BUF_INIT; git_buf branch = GIT_BUF_INIT; if ((error = git_remote_ls(&refs, &refs_len, remote)) < 0) @@ -155,8 +227,7 @@ static int update_head_to_remote( /* We cloned an empty repository or one with an unborn HEAD */ if (refs_len == 0 || strcmp(refs[0]->name, GIT_HEAD_FILE)) - return setup_tracking_config( - repo, "master", GIT_REMOTE_ORIGIN, GIT_REFS_HEADS_MASTER_FILE); + return update_head_to_default(repo); /* We know we have HEAD, let's see where it points */ remote_head = refs[0]; @@ -171,19 +242,7 @@ static int update_head_to_remote( goto cleanup; } - refspec = git_remote__matching_refspec(remote, git_buf_cstr(&branch)); - - if (refspec == NULL) { - git_error_set(GIT_ERROR_NET, "the remote's default branch does not fit the refspec configuration"); - error = GIT_EINVALIDSPEC; - goto cleanup; - } - - /* Determine the remote tracking reference name from the local master */ - if ((error = git_refspec_transform( - &remote_master_name, - refspec, - git_buf_cstr(&branch))) < 0) + if ((error = update_remote_head(repo, remote, &branch, reflog_message)) < 0) goto cleanup; error = update_head_to_new_branch( @@ -193,7 +252,6 @@ static int update_head_to_remote( reflog_message); cleanup: - git_buf_dispose(&remote_master_name); git_buf_dispose(&branch); return error; @@ -479,10 +537,12 @@ int git_clone_options_init(git_clone_options *opts, unsigned int version) return 0; } +#ifndef GIT_DEPRECATE_HARD int git_clone_init_options(git_clone_options *opts, unsigned int version) { return git_clone_options_init(opts, version); } +#endif static bool can_link(const char *src, const char *dst, int link) { diff --git a/src/common.h b/src/common.h index a4152caf2..2b1a4a456 100644 --- a/src/common.h +++ b/src/common.h @@ -80,6 +80,7 @@ #include "errors.h" #include "thread-utils.h" #include "integer.h" +#include "assert_safe.h" /* * Include the declarations for deprecated functions; this ensures diff --git a/src/config.c b/src/config.c index 8338da010..42f46e6cf 100644 --- a/src/config.c +++ b/src/config.c @@ -1000,7 +1000,7 @@ static int multivar_iter_next(git_config_entry **entry, git_config_iterator *_it return error; } -void multivar_iter_free(git_config_iterator *_iter) +static void multivar_iter_free(git_config_iterator *_iter) { multivar_iter *iter = (multivar_iter *) _iter; @@ -1227,9 +1227,6 @@ int git_config_lookup_map_value( { size_t i; - if (!value) - goto fail_parse; - for (i = 0; i < map_n; ++i) { const git_configmap *m = maps + i; @@ -1238,7 +1235,7 @@ int git_config_lookup_map_value( case GIT_CONFIGMAP_TRUE: { int bool_val; - if (git__parse_bool(&bool_val, value) == 0 && + if (git_config_parse_bool(&bool_val, value) == 0 && bool_val == (int)m->type) { *out = m->map_value; return 0; @@ -1252,7 +1249,7 @@ int git_config_lookup_map_value( break; case GIT_CONFIGMAP_STRING: - if (strcasecmp(value, m->str_match) == 0) { + if (value && strcasecmp(value, m->str_match) == 0) { *out = m->map_value; return 0; } @@ -1260,7 +1257,6 @@ int git_config_lookup_map_value( } } -fail_parse: git_error_set(GIT_ERROR_CONFIG, "failed to map '%s'", value); return -1; } diff --git a/src/config_entries.c b/src/config_entries.c index 3ddd3369a..66aae096d 100644 --- a/src/config_entries.c +++ b/src/config_entries.c @@ -11,9 +11,13 @@ typedef struct config_entry_list { struct config_entry_list *next; struct config_entry_list *last; git_config_entry *entry; - bool first; } config_entry_list; +typedef struct { + git_config_entry *entry; + bool multivar; +} config_entry_map_head; + typedef struct config_entries_iterator { git_config_iterator parent; git_config_entries *entries; @@ -102,14 +106,16 @@ void git_config_entries_incref(git_config_entries *entries) static void config_entries_free(git_config_entries *entries) { config_entry_list *list = NULL, *next; + config_entry_map_head *head; + git_strmap_foreach_value(entries->map, head, + git__free((char *) head->entry->name); git__free(head) + ); git_strmap_free(entries->map); list = entries->list; while (list != NULL) { next = list->next; - if (list->first) - git__free((char *) list->entry->name); git__free((char *) list->entry->value); git__free(list->entry); git__free(list); @@ -127,40 +133,42 @@ void git_config_entries_free(git_config_entries *entries) int git_config_entries_append(git_config_entries *entries, git_config_entry *entry) { - config_entry_list *existing, *head; + config_entry_list *list_head; + config_entry_map_head *map_head; - head = git__calloc(1, sizeof(config_entry_list)); - GIT_ERROR_CHECK_ALLOC(head); - head->entry = entry; - - /* - * This is a micro-optimization for configuration files - * with a lot of same keys. As for multivars the entry's - * key will be the same for all entries, we can just free - * all except the first entry's name and just re-use it. - */ - if ((existing = git_strmap_get(entries->map, entry->name)) != NULL) { + if ((map_head = git_strmap_get(entries->map, entry->name)) != NULL) { + map_head->multivar = true; + /* + * This is a micro-optimization for configuration files + * with a lot of same keys. As for multivars the entry's + * key will be the same for all entries, we can just free + * all except the first entry's name and just re-use it. + */ git__free((char *) entry->name); - entry->name = existing->entry->name; + entry->name = map_head->entry->name; } else { - head->first = 1; + map_head = git__calloc(1, sizeof(*map_head)); + if ((git_strmap_set(entries->map, entry->name, map_head)) < 0) + return -1; } + map_head->entry = entry; + + list_head = git__calloc(1, sizeof(config_entry_list)); + GIT_ERROR_CHECK_ALLOC(list_head); + list_head->entry = entry; if (entries->list) - entries->list->last->next = head; + entries->list->last->next = list_head; else - entries->list = head; - entries->list->last = head; - - if (git_strmap_set(entries->map, entry->name, head) < 0) - return -1; + entries->list = list_head; + entries->list->last = list_head; return 0; } int git_config_entries_get(git_config_entry **out, git_config_entries *entries, const char *key) { - config_entry_list *entry; + config_entry_map_head *entry; if ((entry = git_strmap_get(entries->map, key)) == NULL) return GIT_ENOTFOUND; *out = entry->entry; @@ -169,12 +177,12 @@ int git_config_entries_get(git_config_entry **out, git_config_entries *entries, int git_config_entries_get_unique(git_config_entry **out, git_config_entries *entries, const char *key) { - config_entry_list *entry; + config_entry_map_head *entry; if ((entry = git_strmap_get(entries->map, key)) == NULL) return GIT_ENOTFOUND; - if (!entry->first) { + if (entry->multivar) { git_error_set(GIT_ERROR_CONFIG, "entry is not unique due to being a multivar"); return -1; } diff --git a/src/config_parse.c b/src/config_parse.c index 48ad1164f..ed2c87f6b 100644 --- a/src/config_parse.c +++ b/src/config_parse.c @@ -451,7 +451,7 @@ static int parse_variable(git_config_parser *reader, char **var_name, char **var git_buf_attach(&multi_value, value, 0); value = NULL; - if (parse_multiline_variable(reader, &multi_value, quote_count) < 0 || + if (parse_multiline_variable(reader, &multi_value, quote_count % 2) < 0 || git_buf_oom(&multi_value)) { error = -1; git_buf_dispose(&multi_value); diff --git a/src/config_snapshot.c b/src/config_snapshot.c index 62b9068fb..e295d2f7f 100644 --- a/src/config_snapshot.c +++ b/src/config_snapshot.c @@ -5,8 +5,9 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#include "config.h" +#include "config_backend.h" +#include "config.h" #include "config_entries.h" typedef struct { diff --git a/src/describe.c b/src/describe.c index 42e5848c2..8beffdeba 100644 --- a/src/describe.c +++ b/src/describe.c @@ -685,7 +685,7 @@ int git_describe_commit( get_name, &data)) < 0) goto cleanup; - if (git_oidmap_size(data.names) == 0 && !opts->show_commit_oid_as_fallback) { + if (git_oidmap_size(data.names) == 0 && !normalized.show_commit_oid_as_fallback) { git_error_set(GIT_ERROR_DESCRIBE, "cannot describe - " "no reference found, cannot describe anything."); error = -1; @@ -876,10 +876,12 @@ int git_describe_options_init(git_describe_options *opts, unsigned int version) return 0; } +#ifndef GIT_DEPRECATE_HARD int git_describe_init_options(git_describe_options *opts, unsigned int version) { return git_describe_options_init(opts, version); } +#endif int git_describe_format_options_init(git_describe_format_options *opts, unsigned int version) { @@ -888,7 +890,9 @@ int git_describe_format_options_init(git_describe_format_options *opts, unsigned return 0; } +#ifndef GIT_DEPRECATE_HARD int git_describe_init_format_options(git_describe_format_options *opts, unsigned int version) { return git_describe_format_options_init(opts, version); } +#endif diff --git a/src/diff.c b/src/diff.c index 47f49d949..3e52e3f18 100644 --- a/src/diff.c +++ b/src/diff.c @@ -32,11 +32,6 @@ GIT_INLINE(const char *) diff_delta__path(const git_diff_delta *delta) return str; } -const char *git_diff_delta__path(const git_diff_delta *delta) -{ - return diff_delta__path(delta); -} - int git_diff_delta__cmp(const void *a, const void *b) { const git_diff_delta *da = a, *db = b; @@ -155,7 +150,7 @@ int git_diff_foreach( return error; } -int git_diff_format_email__append_header_tobuf( +static int diff_format_email_append_header_tobuf( git_buf *out, const git_oid *id, const git_signature *author, @@ -212,7 +207,7 @@ int git_diff_format_email__append_header_tobuf( return error; } -int git_diff_format_email__append_patches_tobuf( +static int diff_format_email_append_patches_tobuf( git_buf *out, git_diff *diff) { @@ -292,7 +287,7 @@ int git_diff_format_email( strncpy(summary, opts->summary, offset); } - error = git_diff_format_email__append_header_tobuf(out, + error = diff_format_email_append_header_tobuf(out, opts->id, opts->author, summary == NULL ? opts->summary : summary, opts->body, opts->patch_no, opts->total_patches, ignore_marker); @@ -305,7 +300,7 @@ int git_diff_format_email( (error = git_diff_get_stats(&stats, diff)) < 0 || (error = git_diff_stats_to_buf(out, stats, format_flags, 0)) < 0 || (error = git_buf_putc(out, '\n')) < 0 || - (error = git_diff_format_email__append_patches_tobuf(out, diff)) < 0) + (error = diff_format_email_append_patches_tobuf(out, diff)) < 0) goto on_error; error = git_buf_puts(out, "--\nlibgit2 " LIBGIT2_VERSION "\n\n"); @@ -357,10 +352,12 @@ int git_diff_options_init(git_diff_options *opts, unsigned int version) return 0; } +#ifndef GIT_DEPRECATE_HARD int git_diff_init_options(git_diff_options *opts, unsigned int version) { return git_diff_options_init(opts, version); } +#endif int git_diff_find_options_init( git_diff_find_options *opts, unsigned int version) @@ -370,11 +367,13 @@ int git_diff_find_options_init( return 0; } +#ifndef GIT_DEPRECATE_HARD int git_diff_find_init_options( git_diff_find_options *opts, unsigned int version) { return git_diff_find_options_init(opts, version); } +#endif int git_diff_format_email_options_init( git_diff_format_email_options *opts, unsigned int version) @@ -385,11 +384,13 @@ int git_diff_format_email_options_init( return 0; } +#ifndef GIT_DEPRECATE_HARD int git_diff_format_email_init_options( git_diff_format_email_options *opts, unsigned int version) { return git_diff_format_email_options_init(opts, version); } +#endif static int flush_hunk(git_oid *result, git_hash_ctx *ctx) { @@ -426,7 +427,7 @@ static void strip_spaces(git_buf *buf) git_buf_truncate(buf, len); } -int git_diff_patchid_print_callback__to_buf( +static int diff_patchid_print_callback_to_buf( const git_diff_delta *delta, const git_diff_hunk *hunk, const git_diff_line *line, @@ -485,7 +486,7 @@ int git_diff_patchid(git_oid *out, git_diff *diff, git_diff_patchid_options *opt if ((error = git_diff_print(diff, GIT_DIFF_FORMAT_PATCH_ID, - git_diff_patchid_print_callback__to_buf, + diff_patchid_print_callback_to_buf, &args)) < 0) goto out; diff --git a/src/diff_file.c b/src/diff_file.c index 621bff556..015e0706b 100644 --- a/src/diff_file.c +++ b/src/diff_file.c @@ -160,8 +160,10 @@ int git_diff_file_content__init_from_src( fc->flags |= GIT_DIFF_FLAG__FREE_BLOB; } else { + int error; + if ((error = git_odb_hash(&fc->file->id, src->buf, src->buflen, GIT_OBJECT_BLOB)) < 0) + return error; fc->file->size = src->buflen; - git_odb_hash(&fc->file->id, src->buf, src->buflen, GIT_OBJECT_BLOB); fc->file->id_abbrev = GIT_OID_HEXSZ; fc->map.len = src->buflen; diff --git a/src/diff_generate.c b/src/diff_generate.c index b69ef3032..e7bfd6223 100644 --- a/src/diff_generate.c +++ b/src/diff_generate.c @@ -301,14 +301,14 @@ GIT_INLINE(const char *) diff_delta__i2w_path(const git_diff_delta *delta) delta->old_file.path : delta->new_file.path; } -int git_diff_delta__i2w_cmp(const void *a, const void *b) +static int diff_delta_i2w_cmp(const void *a, const void *b) { const git_diff_delta *da = a, *db = b; int val = strcmp(diff_delta__i2w_path(da), diff_delta__i2w_path(db)); return val ? val : ((int)da->status - (int)db->status); } -int git_diff_delta__i2w_casecmp(const void *a, const void *b) +static int diff_delta_i2w_casecmp(const void *a, const void *b) { const git_diff_delta *da = a, *db = b; int val = strcasecmp(diff_delta__i2w_path(da), diff_delta__i2w_path(db)); @@ -361,7 +361,7 @@ static const char *diff_mnemonic_prefix( return pfx; } -void git_diff__set_ignore_case(git_diff *diff, bool ignore_case) +static void diff_set_ignore_case(git_diff *diff, bool ignore_case) { if (!ignore_case) { diff->opts.flags &= ~GIT_DIFF_IGNORE_CASE; @@ -423,16 +423,15 @@ static git_diff_generated *diff_generated_alloc( git_attr_session__init(&diff->base.attrsession, repo); memcpy(&diff->base.opts, &dflt, sizeof(git_diff_options)); - git_pool_init(&diff->base.pool, 1); - - if (git_vector_init(&diff->base.deltas, 0, git_diff_delta__cmp) < 0) { + if (git_pool_init(&diff->base.pool, 1) < 0 || + git_vector_init(&diff->base.deltas, 0, git_diff_delta__cmp) < 0) { git_diff_free(&diff->base); return NULL; } /* Use case-insensitive compare if either iterator has * the ignore_case bit set */ - git_diff__set_ignore_case( + diff_set_ignore_case( &diff->base, git_iterator_ignore_case(old_iter) || git_iterator_ignore_case(new_iter)); @@ -1376,7 +1375,7 @@ int git_diff_tree_to_index( /* if index is in case-insensitive order, re-sort deltas to match */ if (index_ignore_case) - git_diff__set_ignore_case(diff, true); + diff_set_ignore_case(diff, true); *out = diff; diff = NULL; @@ -1527,7 +1526,7 @@ int git_diff_index_to_index( /* if index is in case-insensitive order, re-sort deltas to match */ if (old_index->ignore_case || new_index->ignore_case) - git_diff__set_ignore_case(diff, true); + diff_set_ignore_case(diff, true); *out = diff; diff = NULL; @@ -1584,10 +1583,10 @@ int git_diff__paired_foreach( if (i2w_icase && !icase_mismatch) { strcomp = git__strcasecmp; - git_vector_set_cmp(&idx2wd->deltas, git_diff_delta__i2w_casecmp); + git_vector_set_cmp(&idx2wd->deltas, diff_delta_i2w_casecmp); git_vector_sort(&idx2wd->deltas); } else if (idx2wd != NULL) { - git_vector_set_cmp(&idx2wd->deltas, git_diff_delta__i2w_cmp); + git_vector_set_cmp(&idx2wd->deltas, diff_delta_i2w_cmp); git_vector_sort(&idx2wd->deltas); } diff --git a/src/diff_parse.c b/src/diff_parse.c index 098e56f9a..75e41a544 100644 --- a/src/diff_parse.c +++ b/src/diff_parse.c @@ -52,9 +52,8 @@ static git_diff_parsed *diff_parsed_alloc(void) diff->base.opts.flags &= ~GIT_DIFF_IGNORE_CASE; - git_pool_init(&diff->base.pool, 1); - - if (git_vector_init(&diff->patches, 0, NULL) < 0 || + if (git_pool_init(&diff->base.pool, 1) < 0 || + git_vector_init(&diff->patches, 0, NULL) < 0 || git_vector_init(&diff->base.deltas, 0, git_diff_delta__cmp) < 0) { git_diff_free(&diff->base); return NULL; diff --git a/src/diff_print.c b/src/diff_print.c index 369e5c1e6..9ce04d70e 100644 --- a/src/diff_print.c +++ b/src/diff_print.c @@ -337,7 +337,7 @@ static int diff_delta_format_with_paths( return git_buf_printf(out, template, oldpath, newpath); } -int diff_delta_format_similarity_header( +static int diff_delta_format_similarity_header( git_buf *out, const git_diff_delta *delta) { @@ -351,17 +351,16 @@ int diff_delta_format_similarity_header( goto done; } + GIT_ASSERT(delta->status == GIT_DELTA_RENAMED || delta->status == GIT_DELTA_COPIED); if (delta->status == GIT_DELTA_RENAMED) type = "rename"; - else if (delta->status == GIT_DELTA_COPIED) - type = "copy"; else - abort(); + type = "copy"; if ((error = git_buf_puts(&old_path, delta->old_file.path)) < 0 || - (error = git_buf_puts(&new_path, delta->new_file.path)) < 0 || - (error = git_buf_quote(&old_path)) < 0 || - (error = git_buf_quote(&new_path)) < 0) + (error = git_buf_puts(&new_path, delta->new_file.path)) < 0 || + (error = git_buf_quote(&old_path)) < 0 || + (error = git_buf_quote(&new_path)) < 0) goto done; git_buf_printf(out, @@ -428,8 +427,11 @@ int git_diff_delta__format_file_header( git_buf_printf(out, "diff --git %s %s\n", old_path.ptr, new_path.ptr); + if (unchanged && delta->old_file.mode != delta->new_file.mode) + diff_print_modes(out, delta); + if (delta->status == GIT_DELTA_RENAMED || - (delta->status == GIT_DELTA_COPIED && unchanged)) { + (delta->status == GIT_DELTA_COPIED && unchanged)) { if ((error = diff_delta_format_similarity_header(out, delta)) < 0) goto done; } @@ -444,9 +446,6 @@ int git_diff_delta__format_file_header( "--- %s\n+++ %s\n", old_path.ptr, new_path.ptr); } - if (unchanged && delta->old_file.mode != delta->new_file.mode) - diff_print_modes(out, delta); - if (git_buf_oom(out)) error = -1; @@ -492,6 +491,9 @@ static int format_binary( } git_buf_putc(pi->buf, '\n'); + if (git_buf_oom(pi->buf)) + return -1; + return 0; } @@ -502,21 +504,17 @@ static int diff_print_patch_file_binary_noshow( git_buf old_path = GIT_BUF_INIT, new_path = GIT_BUF_INIT; int error; - if ((error = diff_delta_format_path( - &old_path, old_pfx, delta->old_file.path)) < 0 || - (error = diff_delta_format_path( - &new_path, new_pfx, delta->new_file.path)) < 0) + if ((error = diff_delta_format_path(&old_path, old_pfx, delta->old_file.path)) < 0 || + (error = diff_delta_format_path(&new_path, new_pfx, delta->new_file.path)) < 0 || + (error = diff_delta_format_with_paths(pi->buf, delta, "Binary files %s and %s differ\n", + old_path.ptr, new_path.ptr)) < 0) goto done; pi->line.num_lines = 1; - error = diff_delta_format_with_paths( - pi->buf, delta, "Binary files %s and %s differ\n", - old_path.ptr, new_path.ptr); done: git_buf_dispose(&old_path); git_buf_dispose(&new_path); - return error; } @@ -540,10 +538,9 @@ static int diff_print_patch_file_binary( pi->line.num_lines++; if ((error = format_binary(pi, binary->new_file.type, binary->new_file.data, - binary->new_file.datalen, binary->new_file.inflatedlen)) < 0 || - (error = format_binary(pi, binary->old_file.type, binary->old_file.data, - binary->old_file.datalen, binary->old_file.inflatedlen)) < 0) { - + binary->new_file.datalen, binary->new_file.inflatedlen)) < 0 || + (error = format_binary(pi, binary->old_file.type, binary->old_file.data, + binary->old_file.datalen, binary->old_file.inflatedlen)) < 0) { if (error == GIT_EBUFS) { git_error_clear(); git_buf_truncate(pi->buf, pre_binary_size); @@ -580,16 +577,15 @@ static int diff_print_patch_file( GIT_UNUSED(progress); if (S_ISDIR(delta->new_file.mode) || - delta->status == GIT_DELTA_UNMODIFIED || - delta->status == GIT_DELTA_IGNORED || - delta->status == GIT_DELTA_UNREADABLE || - (delta->status == GIT_DELTA_UNTRACKED && + delta->status == GIT_DELTA_UNMODIFIED || + delta->status == GIT_DELTA_IGNORED || + delta->status == GIT_DELTA_UNREADABLE || + (delta->status == GIT_DELTA_UNTRACKED && (pi->flags & GIT_DIFF_SHOW_UNTRACKED_CONTENT) == 0)) return 0; - if ((error = git_diff_delta__format_file_header( - pi->buf, delta, oldpfx, newpfx, - id_strlen, print_index)) < 0) + if ((error = git_diff_delta__format_file_header(pi->buf, delta, oldpfx, newpfx, + id_strlen, print_index)) < 0) return error; pi->line.origin = GIT_DIFF_LINE_FILE_HDR; @@ -699,17 +695,16 @@ int git_diff_print( return -1; } - if (!(error = diff_print_info_init_fromdiff( - &pi, &buf, diff, format, print_cb, payload))) { - error = git_diff_foreach( - diff, print_file, print_binary, print_hunk, print_line, &pi); + if ((error = diff_print_info_init_fromdiff(&pi, &buf, diff, format, print_cb, payload)) < 0) + goto out; - if (error) /* make sure error message is set */ - git_error_set_after_callback_function(error, "git_diff_print"); + if ((error = git_diff_foreach(diff, print_file, print_binary, print_hunk, print_line, &pi)) != 0) { + git_error_set_after_callback_function(error, "git_diff_print"); + goto out; } +out: git_buf_dispose(&buf); - return error; } @@ -728,8 +723,8 @@ int git_diff_print_callback__to_buf( } if (line->origin == GIT_DIFF_LINE_ADDITION || - line->origin == GIT_DIFF_LINE_DELETION || - line->origin == GIT_DIFF_LINE_CONTEXT) + line->origin == GIT_DIFF_LINE_DELETION || + line->origin == GIT_DIFF_LINE_CONTEXT) git_buf_putc(output, line->origin); return git_buf_put(output, line->content, line->content_len); @@ -742,14 +737,27 @@ int git_diff_print_callback__to_file_handle( void *payload) { FILE *fp = payload ? payload : stdout; + int error; - GIT_UNUSED(delta); GIT_UNUSED(hunk); + GIT_UNUSED(delta); + GIT_UNUSED(hunk); if (line->origin == GIT_DIFF_LINE_CONTEXT || - line->origin == GIT_DIFF_LINE_ADDITION || - line->origin == GIT_DIFF_LINE_DELETION) - fputc(line->origin, fp); - fwrite(line->content, 1, line->content_len, fp); + line->origin == GIT_DIFF_LINE_ADDITION || + line->origin == GIT_DIFF_LINE_DELETION) { + while ((error = fputc(line->origin, fp)) == EINTR) + continue; + if (error) { + git_error_set(GIT_ERROR_OS, "could not write status"); + return -1; + } + } + + if (fwrite(line->content, line->content_len, 1, fp) != 1) { + git_error_set(GIT_ERROR_OS, "could not write line"); + return -1; + } + return 0; } @@ -758,8 +766,7 @@ int git_diff_to_buf(git_buf *out, git_diff *diff, git_diff_format_t format) { assert(out && diff); git_buf_sanitize(out); - return git_diff_print( - diff, format, git_diff_print_callback__to_buf, out); + return git_diff_print(diff, format, git_diff_print_callback__to_buf, out); } /* print a git_patch to an output callback */ @@ -768,28 +775,24 @@ int git_patch_print( git_diff_line_cb print_cb, void *payload) { - int error; git_buf temp = GIT_BUF_INIT; diff_print_info pi; + int error; assert(patch && print_cb); - if (!(error = diff_print_info_init_frompatch( - &pi, &temp, patch, - GIT_DIFF_FORMAT_PATCH, print_cb, payload))) - { - error = git_patch__invoke_callbacks( - patch, - diff_print_patch_file, diff_print_patch_binary, - diff_print_patch_hunk, diff_print_patch_line, - &pi); + if ((error = diff_print_info_init_frompatch(&pi, &temp, patch, + GIT_DIFF_FORMAT_PATCH, print_cb, payload)) < 0) + goto out; - if (error) /* make sure error message is set */ - git_error_set_after_callback_function(error, "git_patch_print"); + if ((error = git_patch__invoke_callbacks(patch, diff_print_patch_file, diff_print_patch_binary, + diff_print_patch_hunk, diff_print_patch_line, &pi)) < 0) { + git_error_set_after_callback_function(error, "git_patch_print"); + goto out; } +out: git_buf_dispose(&temp); - return error; } diff --git a/src/diff_stats.c b/src/diff_stats.c index 19c9da05f..f5fda7925 100644 --- a/src/diff_stats.c +++ b/src/diff_stats.c @@ -46,14 +46,14 @@ static int digits_for_value(size_t val) return count; } -int git_diff_file_stats__full_to_buf( +static int diff_file_stats_full_to_buf( git_buf *out, const git_diff_delta *delta, const diff_file_stats *filestat, const git_diff_stats *stats, size_t width) { - const char *old_path = NULL, *new_path = NULL; + const char *old_path = NULL, *new_path = NULL, *adddel_path = NULL; size_t padding; git_object_size_t old_size, new_size; @@ -62,7 +62,7 @@ int git_diff_file_stats__full_to_buf( old_size = delta->old_file.size; new_size = delta->new_file.size; - if (strcmp(old_path, new_path) != 0) { + if (old_path && new_path && strcmp(old_path, new_path) != 0) { size_t common_dirlen; int error; @@ -82,10 +82,11 @@ int git_diff_file_stats__full_to_buf( if (error < 0) goto on_error; } else { - if (git_buf_printf(out, " %s", old_path) < 0) + adddel_path = new_path ? new_path : old_path; + if (git_buf_printf(out, " %s", adddel_path) < 0) goto on_error; - padding = stats->max_name - strlen(old_path); + padding = stats->max_name - strlen(adddel_path); if (stats->renames > 0) padding += strlen(DIFF_RENAME_FILE_SEPARATOR); @@ -134,7 +135,7 @@ on_error: return (git_buf_oom(out) ? -1 : 0); } -int git_diff_file_stats__number_to_buf( +static int diff_file_stats_number_to_buf( git_buf *out, const git_diff_delta *delta, const diff_file_stats *filestats) @@ -151,7 +152,7 @@ int git_diff_file_stats__number_to_buf( return error; } -int git_diff_file_stats__summary_to_buf( +static int diff_file_stats_summary_to_buf( git_buf *out, const git_diff_delta *delta) { @@ -211,7 +212,7 @@ int git_diff_get_stats( /* TODO ugh */ namelen = strlen(delta->new_file.path); - if (strcmp(delta->old_file.path, delta->new_file.path) != 0) { + if (delta->old_file.path && strcmp(delta->old_file.path, delta->new_file.path) != 0) { namelen += strlen(delta->old_file.path); stats->renames++; } @@ -288,7 +289,7 @@ int git_diff_stats_to_buf( if ((delta = git_diff_get_delta(stats->diff, i)) == NULL) continue; - error = git_diff_file_stats__number_to_buf( + error = diff_file_stats_number_to_buf( out, delta, &stats->filestats[i]); if (error < 0) return error; @@ -309,7 +310,7 @@ int git_diff_stats_to_buf( if ((delta = git_diff_get_delta(stats->diff, i)) == NULL) continue; - error = git_diff_file_stats__full_to_buf( + error = diff_file_stats_full_to_buf( out, delta, &stats->filestats[i], stats, width); if (error < 0) return error; @@ -342,7 +343,7 @@ int git_diff_stats_to_buf( if ((delta = git_diff_get_delta(stats->diff, i)) == NULL) continue; - error = git_diff_file_stats__summary_to_buf(out, delta); + error = diff_file_stats_summary_to_buf(out, delta); if (error < 0) return error; } diff --git a/src/diff_tform.c b/src/diff_tform.c index 437144ae2..7de88bd0d 100644 --- a/src/diff_tform.c +++ b/src/diff_tform.c @@ -136,11 +136,10 @@ int git_diff__merge( return -1; } - if (git_vector_init(&onto_new, onto->deltas.length, git_diff_delta__cmp) < 0) + if (git_vector_init(&onto_new, onto->deltas.length, git_diff_delta__cmp) < 0 || + git_pool_init(&onto_pool, 1) < 0) return -1; - git_pool_init(&onto_pool, 1); - for (i = 0, j = 0; i < onto->deltas.length || j < from->deltas.length; ) { git_diff_delta *o = GIT_VECTOR_GET(&onto->deltas, i); const git_diff_delta *f = GIT_VECTOR_GET(&from->deltas, j); diff --git a/src/errors.c b/src/errors.c index b34aa3abb..8570226b4 100644 --- a/src/errors.c +++ b/src/errors.c @@ -210,6 +210,7 @@ void git_error_system_set(int code) /* Deprecated error values and functions */ +#ifndef GIT_DEPRECATE_HARD const git_error *giterr_last(void) { return git_error_last(); @@ -229,3 +230,4 @@ void giterr_set_oom(void) { git_error_set_oom(); } +#endif diff --git a/src/fetch.c b/src/fetch.c index f2f313192..f4a4c9f81 100644 --- a/src/fetch.c +++ b/src/fetch.c @@ -155,7 +155,9 @@ int git_fetch_options_init(git_fetch_options *opts, unsigned int version) return 0; } +#ifndef GIT_DEPRECATE_HARD int git_fetch_init_options(git_fetch_options *opts, unsigned int version) { return git_fetch_options_init(opts, version); } +#endif diff --git a/src/filter.c b/src/filter.c index bb9d66ad6..09b57dc80 100644 --- a/src/filter.c +++ b/src/filter.c @@ -941,7 +941,7 @@ out: return error; } -void stream_list_free(git_vector *streams) +static void filter_streams_free(git_vector *streams) { git_writestream *stream; size_t i; @@ -990,7 +990,7 @@ done: if (fd >= 0) p_close(fd); - stream_list_free(&filter_streams); + filter_streams_free(&filter_streams); git_buf_dispose(&abspath); return error; } @@ -1018,7 +1018,7 @@ out: if (initialized) error |= stream_start->close(stream_start); - stream_list_free(&filter_streams); + filter_streams_free(&filter_streams); return error; } diff --git a/src/futils.c b/src/futils.c index a7c360a1c..8c0f008b3 100644 --- a/src/futils.c +++ b/src/futils.c @@ -834,12 +834,12 @@ int git_futils_rmdir_r( return error; } -int git_futils_fake_symlink(const char *old, const char *new) +int git_futils_fake_symlink(const char *target, const char *path) { int retcode = GIT_ERROR; - int fd = git_futils_creat_withpath(new, 0755, 0644); + int fd = git_futils_creat_withpath(path, 0755, 0644); if (fd >= 0) { - retcode = p_write(fd, old, strlen(old)); + retcode = p_write(fd, target, strlen(target)); p_close(fd); } return retcode; diff --git a/src/futils.h b/src/futils.h index 3d5664679..4668d7b63 100644 --- a/src/futils.h +++ b/src/futils.h @@ -316,11 +316,11 @@ extern void git_futils_mmap_free(git_map *map); /** * Create a "fake" symlink (text file containing the target path). * - * @param new symlink file to be created - * @param old original symlink target + * @param target original symlink target + * @param path symlink file to be created * @return 0 on success, -1 on error */ -extern int git_futils_fake_symlink(const char *new, const char *old); +extern int git_futils_fake_symlink(const char *target, const char *path); /** * A file stamp represents a snapshot of information about a file that can diff --git a/src/global.c b/src/global.c index 5af35aa62..9fe8cd5d3 100644 --- a/src/global.c +++ b/src/global.c @@ -12,6 +12,7 @@ #include "sysdir.h" #include "filter.h" #include "merge_driver.h" +#include "pool.h" #include "streams/registry.h" #include "streams/mbedtls.h" #include "streams/openssl.h" @@ -38,7 +39,8 @@ static git_global_init_fn git__init_callbacks[] = { git_stream_registry_global_init, git_openssl_stream_global_init, git_mbedtls_stream_global_init, - git_mwindow_global_init + git_mwindow_global_init, + git_pool_global_init }; static git_global_shutdown_fn git__shutdown_callbacks[ARRAY_SIZE(git__init_callbacks)]; diff --git a/src/idxmap.c b/src/idxmap.c index 4dcf963b3..bc23608f2 100644 --- a/src/idxmap.c +++ b/src/idxmap.c @@ -138,28 +138,6 @@ void *git_idxmap_icase_get(git_idxmap_icase *map, const git_index_entry *key) return kh_val(map, idx); } -void git_idxmap_insert(git_idxmap *map, const git_index_entry *key, void *value, int *rval) -{ - khiter_t idx = kh_put(idx, map, key, rval); - - if ((*rval) >= 0) { - if ((*rval) == 0) - kh_key(map, idx) = key; - kh_val(map, idx) = value; - } -} - -void git_idxmap_icase_insert(git_idxmap_icase *map, const git_index_entry *key, void *value, int *rval) -{ - khiter_t idx = kh_put(idxicase, map, key, rval); - - if ((*rval) >= 0) { - if ((*rval) == 0) - kh_key(map, idx) = key; - kh_val(map, idx) = value; - } -} - int git_idxmap_delete(git_idxmap *map, const git_index_entry *key) { khiter_t idx = kh_get(idx, map, key); diff --git a/src/index.c b/src/index.c index 36a8bdb7b..d5afc9bb6 100644 --- a/src/index.c +++ b/src/index.c @@ -411,7 +411,8 @@ int git_index_open(git_index **index_out, const char *index_path) index = git__calloc(1, sizeof(git_index)); GIT_ERROR_CHECK_ALLOC(index); - git_pool_init(&index->tree_pool, 1); + if (git_pool_init(&index->tree_pool, 1) < 0) + goto fail; if (index_path != NULL) { index->index_file_path = git__strdup(index_path); @@ -2780,17 +2781,19 @@ static int write_disk_entry(git_filebuf *file, git_index_entry *entry, const cha ondisk.flags = htons(entry->flags); if (entry->flags & GIT_INDEX_ENTRY_EXTENDED) { + const size_t path_offset = offsetof(struct entry_long, path); struct entry_long ondisk_ext; memcpy(&ondisk_ext, &ondisk, sizeof(struct entry_short)); ondisk_ext.flags_extended = htons(entry->flags_extended & GIT_INDEX_ENTRY_EXTENDED_FLAGS); - memcpy(mem, &ondisk_ext, offsetof(struct entry_long, path)); - path = ((struct entry_long*)mem)->path; - disk_size -= offsetof(struct entry_long, path); + memcpy(mem, &ondisk_ext, path_offset); + path = (char *)mem + path_offset; + disk_size -= path_offset; } else { - memcpy(mem, &ondisk, offsetof(struct entry_short, path)); - path = ((struct entry_short*)mem)->path; - disk_size -= offsetof(struct entry_short, path); + const size_t path_offset = offsetof(struct entry_short, path); + memcpy(mem, &ondisk, path_offset); + path = (char *)mem + path_offset; + disk_size -= path_offset; } if (last) { @@ -3716,9 +3719,11 @@ void git_indexwriter_cleanup(git_indexwriter *writer) /* Deprecated functions */ +#ifndef GIT_DEPRECATE_HARD int git_index_add_frombuffer( git_index *index, const git_index_entry *source_entry, const void *buffer, size_t len) { return git_index_add_from_buffer(index, source_entry, buffer, len); } +#endif diff --git a/src/indexer.c b/src/indexer.c index 68fdd85c5..8c74f0e72 100644 --- a/src/indexer.c +++ b/src/indexer.c @@ -123,10 +123,12 @@ int git_indexer_options_init(git_indexer_options *opts, unsigned int version) return 0; } +#ifndef GIT_DEPRECATE_HARD int git_indexer_init_options(git_indexer_options *opts, unsigned int version) { return git_indexer_options_init(opts, version); } +#endif int git_indexer_new( git_indexer **out, @@ -265,10 +267,11 @@ static int advance_delta_offset(git_indexer *idx, git_object_t type) if (type == GIT_OBJECT_REF_DELTA) { idx->off += GIT_OID_RAWSZ; } else { - off64_t base_off = get_delta_base(idx->pack, &w, &idx->off, type, idx->entry_start); + off64_t base_off; + int error = get_delta_base(&base_off, idx->pack, &w, &idx->off, type, idx->entry_start); git_mwindow_close(&w); - if (base_off < 0) - return (int)base_off; + if (error < 0) + return error; } return 0; @@ -424,7 +427,10 @@ static int store_object(git_indexer *idx) pentry = git__calloc(1, sizeof(struct git_pack_entry)); GIT_ERROR_CHECK_ALLOC(pentry); - git_hash_final(&oid, &idx->hash_ctx); + if (git_hash_final(&oid, &idx->hash_ctx)) { + git__free(pentry); + goto on_error; + } entry_size = idx->off - entry_start; if (entry_start > UINT31_MAX) { entry->offset = UINT32_MAX; diff --git a/src/iterator.c b/src/iterator.c index e26e2c0c7..a393187c0 100644 --- a/src/iterator.c +++ b/src/iterator.c @@ -897,9 +897,8 @@ static int tree_iterator_init(tree_iterator *iter) { int error; - git_pool_init(&iter->entry_pool, sizeof(tree_iterator_entry)); - - if ((error = tree_iterator_frame_init(iter, iter->root, NULL)) < 0) + if ((error = git_pool_init(&iter->entry_pool, sizeof(tree_iterator_entry))) < 0 || + (error = tree_iterator_frame_init(iter, iter->root, NULL)) < 0) return error; iter->base.flags &= ~GIT_ITERATOR_FIRST_ACCESS; @@ -1376,7 +1375,8 @@ static int filesystem_iterator_frame_push( filesystem_iterator_entry_cmp)) < 0) goto done; - git_pool_init(&new_frame->entry_pool, 1); + if ((error = git_pool_init(&new_frame->entry_pool, 1)) < 0) + goto done; /* check if this directory is ignored */ filesystem_iterator_frame_push_ignores(iter, frame_entry, new_frame); diff --git a/src/merge.c b/src/merge.c index afe69e564..2f6bf6fe7 100644 --- a/src/merge.c +++ b/src/merge.c @@ -80,7 +80,7 @@ static int cache_invalid_marker; /* Merge base computation */ -int merge_bases_many(git_commit_list **out, git_revwalk **walk_out, git_repository *repo, size_t length, const git_oid input_array[]) +static int merge_bases_many(git_commit_list **out, git_revwalk **walk_out, git_repository *repo, size_t length, const git_oid input_array[]) { git_revwalk *walk = NULL; git_vector list; @@ -1810,12 +1810,12 @@ git_merge_diff_list *git_merge_diff_list__alloc(git_repository *repo) diff_list->repo = repo; - git_pool_init(&diff_list->pool, 1); - if (git_vector_init(&diff_list->staged, 0, NULL) < 0 || - git_vector_init(&diff_list->conflicts, 0, NULL) < 0 || - git_vector_init(&diff_list->resolved, 0, NULL) < 0) { - git_merge_diff_list__free(diff_list); + if (git_pool_init(&diff_list->pool, 1) < 0 || + git_vector_init(&diff_list->staged, 0, NULL) < 0 || + git_vector_init(&diff_list->conflicts, 0, NULL) < 0 || + git_vector_init(&diff_list->resolved, 0, NULL) < 0) { + git_merge_diff_list__free(diff_list); return NULL; } @@ -2845,7 +2845,7 @@ on_error: return error; } -const char *merge_their_label(const char *branchname) +static const char *merge_their_label(const char *branchname) { const char *slash; @@ -3351,10 +3351,12 @@ int git_merge_options_init(git_merge_options *opts, unsigned int version) return 0; } +#ifndef GIT_DEPRECATE_HARD int git_merge_init_options(git_merge_options *opts, unsigned int version) { return git_merge_options_init(opts, version); } +#endif int git_merge_file_input_init(git_merge_file_input *input, unsigned int version) { @@ -3363,10 +3365,12 @@ int git_merge_file_input_init(git_merge_file_input *input, unsigned int version) return 0; } +#ifndef GIT_DEPRECATE_HARD int git_merge_file_init_input(git_merge_file_input *input, unsigned int version) { return git_merge_file_input_init(input, version); } +#endif int git_merge_file_options_init( git_merge_file_options *opts, unsigned int version) @@ -3376,8 +3380,10 @@ int git_merge_file_options_init( return 0; } +#ifndef GIT_DEPRECATE_HARD int git_merge_file_init_options( git_merge_file_options *opts, unsigned int version) { return git_merge_file_options_init(opts, version); } +#endif diff --git a/src/merge_file.c b/src/merge_file.c index 23daa84c4..755340fa9 100644 --- a/src/merge_file.c +++ b/src/merge_file.c @@ -28,7 +28,7 @@ #define GIT_MERGE_FILE_SIDE_EXISTS(X) ((X)->mode != 0) -int git_merge_file__input_from_index( +static int merge_file_input_from_index( git_merge_file_input *input_out, git_odb_object **odb_object_out, git_odb *odb, @@ -276,17 +276,15 @@ int git_merge_file_from_index( goto done; if (ancestor) { - if ((error = git_merge_file__input_from_index( + if ((error = merge_file_input_from_index( &ancestor_input, &odb_object[0], odb, ancestor)) < 0) goto done; ancestor_ptr = &ancestor_input; } - if ((error = git_merge_file__input_from_index( - &our_input, &odb_object[1], odb, ours)) < 0 || - (error = git_merge_file__input_from_index( - &their_input, &odb_object[2], odb, theirs)) < 0) + if ((error = merge_file_input_from_index(&our_input, &odb_object[1], odb, ours)) < 0 || + (error = merge_file_input_from_index(&their_input, &odb_object[2], odb, theirs)) < 0) goto done; error = merge_file__from_inputs(out, diff --git a/src/midx.c b/src/midx.c new file mode 100644 index 000000000..21cfff497 --- /dev/null +++ b/src/midx.c @@ -0,0 +1,418 @@ +/* + * 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 "midx.h" + +#include "buffer.h" +#include "futils.h" +#include "hash.h" +#include "odb.h" +#include "pack.h" + +#define GIT_MIDX_FILE_MODE 0444 + +#define MIDX_SIGNATURE 0x4d494458 /* "MIDX" */ +#define MIDX_VERSION 1 +#define MIDX_OBJECT_ID_VERSION 1 +struct git_midx_header { + uint32_t signature; + uint8_t version; + uint8_t object_id_version; + uint8_t chunks; + uint8_t base_midx_files; + uint32_t packfiles; +}; + +#define MIDX_PACKFILE_NAMES_ID 0x504e414d /* "PNAM" */ +#define MIDX_OID_FANOUT_ID 0x4f494446 /* "OIDF" */ +#define MIDX_OID_LOOKUP_ID 0x4f49444c /* "OIDL" */ +#define MIDX_OBJECT_OFFSETS_ID 0x4f4f4646 /* "OOFF" */ +#define MIDX_OBJECT_LARGE_OFFSETS_ID 0x4c4f4646 /* "LOFF" */ + +struct git_midx_chunk { + off64_t offset; + size_t length; +}; + +static int midx_error(const char *message) +{ + git_error_set(GIT_ERROR_ODB, "invalid multi-pack-index file - %s", message); + return -1; +} + +static int midx_parse_packfile_names( + git_midx_file *idx, + const unsigned char *data, + uint32_t packfiles, + struct git_midx_chunk *chunk) +{ + int error; + uint32_t i; + char *packfile_name = (char *)(data + chunk->offset); + size_t chunk_size = chunk->length, len; + if (chunk->offset == 0) + return midx_error("missing Packfile Names chunk"); + if (chunk->length == 0) + return midx_error("empty Packfile Names chunk"); + if ((error = git_vector_init(&idx->packfile_names, packfiles, git__strcmp_cb)) < 0) + return error; + for (i = 0; i < packfiles; ++i) { + len = p_strnlen(packfile_name, chunk_size); + if (len == 0) + return midx_error("empty packfile name"); + if (len + 1 > chunk_size) + return midx_error("unterminated packfile name"); + git_vector_insert(&idx->packfile_names, packfile_name); + if (i && strcmp(git_vector_get(&idx->packfile_names, i - 1), packfile_name) >= 0) + return midx_error("packfile names are not sorted"); + if (strlen(packfile_name) <= strlen(".idx") || git__suffixcmp(packfile_name, ".idx") != 0) + return midx_error("non-.idx packfile name"); + if (strchr(packfile_name, '/') != NULL || strchr(packfile_name, '\\') != NULL) + return midx_error("non-local packfile"); + packfile_name += len + 1; + chunk_size -= len + 1; + } + return 0; +} + +static int midx_parse_oid_fanout( + git_midx_file *idx, + const unsigned char *data, + struct git_midx_chunk *chunk_oid_fanout) +{ + uint32_t i, nr; + if (chunk_oid_fanout->offset == 0) + return midx_error("missing OID Fanout chunk"); + if (chunk_oid_fanout->length == 0) + return midx_error("empty OID Fanout chunk"); + if (chunk_oid_fanout->length != 256 * 4) + return midx_error("OID Fanout chunk has wrong length"); + + idx->oid_fanout = (const uint32_t *)(data + chunk_oid_fanout->offset); + nr = 0; + for (i = 0; i < 256; ++i) { + uint32_t n = ntohl(idx->oid_fanout[i]); + if (n < nr) + return midx_error("index is non-monotonic"); + nr = n; + } + idx->num_objects = nr; + return 0; +} + +static int midx_parse_oid_lookup( + git_midx_file *idx, + const unsigned char *data, + struct git_midx_chunk *chunk_oid_lookup) +{ + uint32_t i; + git_oid *oid, *prev_oid, zero_oid = {{0}}; + + if (chunk_oid_lookup->offset == 0) + return midx_error("missing OID Lookup chunk"); + if (chunk_oid_lookup->length == 0) + return midx_error("empty OID Lookup chunk"); + if (chunk_oid_lookup->length != idx->num_objects * 20) + return midx_error("OID Lookup chunk has wrong length"); + + idx->oid_lookup = oid = (git_oid *)(data + chunk_oid_lookup->offset); + prev_oid = &zero_oid; + for (i = 0; i < idx->num_objects; ++i, ++oid) { + if (git_oid_cmp(prev_oid, oid) >= 0) + return midx_error("OID Lookup index is non-monotonic"); + prev_oid = oid; + } + + return 0; +} + +static int midx_parse_object_offsets( + git_midx_file *idx, + const unsigned char *data, + struct git_midx_chunk *chunk_object_offsets) +{ + if (chunk_object_offsets->offset == 0) + return midx_error("missing Object Offsets chunk"); + if (chunk_object_offsets->length == 0) + return midx_error("empty Object Offsets chunk"); + if (chunk_object_offsets->length != idx->num_objects * 8) + return midx_error("Object Offsets chunk has wrong length"); + + idx->object_offsets = data + chunk_object_offsets->offset; + + return 0; +} + +static int midx_parse_object_large_offsets( + git_midx_file *idx, + const unsigned char *data, + struct git_midx_chunk *chunk_object_large_offsets) +{ + if (chunk_object_large_offsets->length == 0) + return 0; + if (chunk_object_large_offsets->length % 8 != 0) + return midx_error("malformed Object Large Offsets chunk"); + + idx->object_large_offsets = data + chunk_object_large_offsets->offset; + idx->num_object_large_offsets = chunk_object_large_offsets->length / 8; + + return 0; +} + +int git_midx_parse( + git_midx_file *idx, + const unsigned char *data, + size_t size) +{ + struct git_midx_header *hdr; + const unsigned char *chunk_hdr; + struct git_midx_chunk *last_chunk; + uint32_t i; + off64_t last_chunk_offset, chunk_offset, trailer_offset; + git_oid idx_checksum = {{0}}; + int error; + struct git_midx_chunk chunk_packfile_names = {0}, + chunk_oid_fanout = {0}, + chunk_oid_lookup = {0}, + chunk_object_offsets = {0}, + chunk_object_large_offsets = {0}; + + assert(idx); + + if (size < sizeof(struct git_midx_header) + 20) + return midx_error("multi-pack index is too short"); + + hdr = ((struct git_midx_header *)data); + + if (hdr->signature != htonl(MIDX_SIGNATURE) || + hdr->version != MIDX_VERSION || + hdr->object_id_version != MIDX_OBJECT_ID_VERSION) { + return midx_error("unsupported multi-pack index version"); + } + if (hdr->chunks == 0) + return midx_error("no chunks in multi-pack index"); + + /* + * The very first chunk's offset should be after the header, all the chunk + * headers, and a special zero chunk. + */ + last_chunk_offset = + sizeof(struct git_midx_header) + + (1 + hdr->chunks) * 12; + trailer_offset = size - 20; + if (trailer_offset < last_chunk_offset) + return midx_error("wrong index size"); + git_oid_cpy(&idx->checksum, (git_oid *)(data + trailer_offset)); + + if (git_hash_buf(&idx_checksum, data, (size_t)trailer_offset) < 0) + return midx_error("could not calculate signature"); + if (!git_oid_equal(&idx_checksum, &idx->checksum)) + return midx_error("index signature mismatch"); + + chunk_hdr = data + sizeof(struct git_midx_header); + last_chunk = NULL; + for (i = 0; i < hdr->chunks; ++i, chunk_hdr += 12) { + chunk_offset = ((off64_t)ntohl(*((uint32_t *)(chunk_hdr + 4)))) << 32 | + ((off64_t)ntohl(*((uint32_t *)(chunk_hdr + 8)))); + if (chunk_offset < last_chunk_offset) + return midx_error("chunks are non-monotonic"); + if (chunk_offset >= trailer_offset) + return midx_error("chunks extend beyond the trailer"); + if (last_chunk != NULL) + last_chunk->length = (size_t)(chunk_offset - last_chunk_offset); + last_chunk_offset = chunk_offset; + + switch (ntohl(*((uint32_t *)(chunk_hdr + 0)))) { + case MIDX_PACKFILE_NAMES_ID: + chunk_packfile_names.offset = last_chunk_offset; + last_chunk = &chunk_packfile_names; + break; + + case MIDX_OID_FANOUT_ID: + chunk_oid_fanout.offset = last_chunk_offset; + last_chunk = &chunk_oid_fanout; + break; + + case MIDX_OID_LOOKUP_ID: + chunk_oid_lookup.offset = last_chunk_offset; + last_chunk = &chunk_oid_lookup; + break; + + case MIDX_OBJECT_OFFSETS_ID: + chunk_object_offsets.offset = last_chunk_offset; + last_chunk = &chunk_object_offsets; + break; + + case MIDX_OBJECT_LARGE_OFFSETS_ID: + chunk_object_large_offsets.offset = last_chunk_offset; + last_chunk = &chunk_object_large_offsets; + break; + + default: + return midx_error("unrecognized chunk ID"); + } + } + last_chunk->length = (size_t)(trailer_offset - last_chunk_offset); + + error = midx_parse_packfile_names( + idx, data, ntohl(hdr->packfiles), &chunk_packfile_names); + if (error < 0) + return error; + error = midx_parse_oid_fanout(idx, data, &chunk_oid_fanout); + if (error < 0) + return error; + error = midx_parse_oid_lookup(idx, data, &chunk_oid_lookup); + if (error < 0) + return error; + error = midx_parse_object_offsets(idx, data, &chunk_object_offsets); + if (error < 0) + return error; + error = midx_parse_object_large_offsets(idx, data, &chunk_object_large_offsets); + if (error < 0) + return error; + + return 0; +} + +int git_midx_open( + git_midx_file **idx_out, + const char *path) +{ + git_midx_file *idx; + git_file fd = -1; + size_t idx_size; + struct stat st; + int error; + + /* TODO: properly open the file without access time using O_NOATIME */ + fd = git_futils_open_ro(path); + if (fd < 0) + return fd; + + if (p_fstat(fd, &st) < 0) { + p_close(fd); + git_error_set(GIT_ERROR_ODB, "multi-pack-index file not found - '%s'", path); + return -1; + } + + if (!S_ISREG(st.st_mode) || !git__is_sizet(st.st_size)) { + p_close(fd); + git_error_set(GIT_ERROR_ODB, "invalid pack index '%s'", path); + return -1; + } + idx_size = (size_t)st.st_size; + + idx = git__calloc(1, sizeof(git_midx_file)); + GIT_ERROR_CHECK_ALLOC(idx); + + error = git_futils_mmap_ro(&idx->index_map, fd, 0, idx_size); + p_close(fd); + if (error < 0) { + git_midx_free(idx); + return error; + } + + if ((error = git_midx_parse(idx, idx->index_map.data, idx_size)) < 0) { + git_midx_free(idx); + return error; + } + + *idx_out = idx; + return 0; +} + +int git_midx_entry_find( + git_midx_entry *e, + git_midx_file *idx, + const git_oid *short_oid, + size_t len) +{ + int pos, found = 0; + size_t pack_index; + uint32_t hi, lo; + const git_oid *current = NULL; + const unsigned char *object_offset; + off64_t offset; + + assert(idx); + + hi = ntohl(idx->oid_fanout[(int)short_oid->id[0]]); + lo = ((short_oid->id[0] == 0x0) ? 0 : ntohl(idx->oid_fanout[(int)short_oid->id[0] - 1])); + + pos = git_pack__lookup_sha1(idx->oid_lookup, 20, lo, hi, short_oid->id); + + if (pos >= 0) { + /* An object matching exactly the oid was found */ + found = 1; + current = idx->oid_lookup + pos; + } else { + /* No object was found */ + /* pos refers to the object with the "closest" oid to short_oid */ + pos = -1 - pos; + if (pos < (int)idx->num_objects) { + current = idx->oid_lookup + pos; + + if (!git_oid_ncmp(short_oid, current, len)) + found = 1; + } + } + + if (found && len != GIT_OID_HEXSZ && pos + 1 < (int)idx->num_objects) { + /* Check for ambiguousity */ + const git_oid *next = current + 1; + + if (!git_oid_ncmp(short_oid, next, len)) { + found = 2; + } + } + + if (!found) + return git_odb__error_notfound("failed to find offset for multi-pack index entry", short_oid, len); + if (found > 1) + return git_odb__error_ambiguous("found multiple offsets for multi-pack index entry"); + + object_offset = idx->object_offsets + pos * 8; + offset = ntohl(*((uint32_t *)(object_offset + 4))); + if (offset & 0x80000000) { + uint32_t object_large_offsets_pos = offset & 0x7fffffff; + const unsigned char *object_large_offsets_index = idx->object_large_offsets; + + /* Make sure we're not being sent out of bounds */ + if (object_large_offsets_pos >= idx->num_object_large_offsets) + return git_odb__error_notfound("invalid index into the object large offsets table", short_oid, len); + + object_large_offsets_index += 8 * object_large_offsets_pos; + + offset = (((uint64_t)ntohl(*((uint32_t *)(object_large_offsets_index + 0)))) << 32) | + ntohl(*((uint32_t *)(object_large_offsets_index + 4))); + } + pack_index = ntohl(*((uint32_t *)(object_offset + 0))); + if (pack_index >= git_vector_length(&idx->packfile_names)) + return midx_error("invalid index into the packfile names table"); + e->pack_index = pack_index; + e->offset = offset; + git_oid_cpy(&e->sha1, current); + return 0; +} + +void git_midx_close(git_midx_file *idx) +{ + assert(idx); + + if (idx->index_map.data) + git_futils_mmap_free(&idx->index_map); + git_vector_free(&idx->packfile_names); +} + +void git_midx_free(git_midx_file *idx) +{ + if (!idx) + return; + + git_midx_close(idx); + git__free(idx); +} diff --git a/src/midx.h b/src/midx.h new file mode 100644 index 000000000..e6a64cd81 --- /dev/null +++ b/src/midx.h @@ -0,0 +1,83 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#ifndef INCLUDE_midx_h__ +#define INCLUDE_midx_h__ + +#include "common.h" + +#include + +#include "map.h" +#include "mwindow.h" + +/* + * A multi-pack-index file. + * + * This file contains a merged index for multiple independent .pack files. This + * can help speed up locating objects without requiring a garbage collection + * cycle to create a single .pack file. + * + * Support for this feature was added in git 2.21, and requires the + * `core.multiPackIndex` config option to be set. + */ +typedef struct git_midx_file { + git_map index_map; + + /* The table of Packfile Names. */ + git_vector packfile_names; + + /* The OID Fanout table. */ + const uint32_t *oid_fanout; + /* The total number of objects in the index. */ + uint32_t num_objects; + + /* The OID Lookup table. */ + git_oid *oid_lookup; + + /* The Object Offsets table. Each entry has two 4-byte fields with the pack index and the offset. */ + const unsigned char *object_offsets; + + /* The Object Large Offsets table. */ + const unsigned char *object_large_offsets; + /* The number of entries in the Object Large Offsets table. Each entry has an 8-byte with an offset */ + size_t num_object_large_offsets; + + /* The trailer of the file. Contains the SHA1-checksum of the whole file. */ + git_oid checksum; +} git_midx_file; + +/* + * An entry in the multi-pack-index file. Similar in purpose to git_pack_entry. + */ +typedef struct git_midx_entry { + /* The index within idx->packfile_names where the packfile name can be found. */ + size_t pack_index; + /* The offset within the .pack file where the requested object is found. */ + off64_t offset; + /* The SHA-1 hash of the requested object. */ + git_oid sha1; +} git_midx_entry; + +int git_midx_open( + git_midx_file **idx_out, + const char *path); +int git_midx_entry_find( + git_midx_entry *e, + git_midx_file *idx, + const git_oid *short_oid, + size_t len); +void git_midx_close(git_midx_file *idx); +void git_midx_free(git_midx_file *idx); + +/* This is exposed for use in the fuzzers. */ +int git_midx_parse( + git_midx_file *idx, + const unsigned char *data, + size_t size); + +#endif diff --git a/src/mwindow.c b/src/mwindow.c index 262786a5f..ac26452f4 100644 --- a/src/mwindow.c +++ b/src/mwindow.c @@ -22,11 +22,15 @@ #define DEFAULT_MAPPED_LIMIT \ ((1024 * 1024) * (sizeof(void*) >= 8 ? 8192ULL : 256UL)) +/* default is unlimited */ +#define DEFAULT_FILE_LIMIT 0 + size_t git_mwindow__window_size = DEFAULT_WINDOW_SIZE; size_t git_mwindow__mapped_limit = DEFAULT_MAPPED_LIMIT; +size_t git_mwindow__file_limit = DEFAULT_FILE_LIMIT; /* Whenever you want to read or modify this, grab git__mwindow_mutex */ -static git_mwindow_ctl mem_ctl; +git_mwindow_ctl git_mwindow__mem_ctl; /* Global list of mwindow files, to open packs once across repos */ git_strmap *git__pack_cache = NULL; @@ -132,7 +136,7 @@ void git_mwindow_free_all(git_mwindow_file *mwf) */ void git_mwindow_free_all_locked(git_mwindow_file *mwf) { - git_mwindow_ctl *ctl = &mem_ctl; + git_mwindow_ctl *ctl = &git_mwindow__mem_ctl; size_t i; /* @@ -174,82 +178,146 @@ int git_mwindow_contains(git_mwindow *win, off64_t offset) && offset <= (off64_t)(win_off + win->window_map.len); } -/* - * Find the least-recently-used window in a file - */ -static void git_mwindow_scan_lru( - git_mwindow_file *mwf, - git_mwindow **lru_w, - git_mwindow **lru_l) -{ - git_mwindow *w, *w_l; +#define GIT_MWINDOW__LRU -1 +#define GIT_MWINDOW__MRU 1 - for (w_l = NULL, w = mwf->windows; w; w = w->next) { - if (!w->inuse_cnt) { - /* - * If the current one is more recent than the last one, - * store it in the output parameter. If lru_w is NULL, - * it's the first loop, so store it as well. - */ - if (!*lru_w || w->last_used < (*lru_w)->last_used) { - *lru_w = w; - *lru_l = w_l; - } +/* + * Find the least- or most-recently-used window in a file that is not currently + * being used. The 'only_unused' flag controls whether the caller requires the + * file to only have unused windows. If '*out_window' is non-null, it is used as + * a starting point for the comparison. + * + * Returns whether such a window was found in the file. + */ +static bool git_mwindow_scan_recently_used( + git_mwindow_file *mwf, + git_mwindow **out_window, + git_mwindow **out_last, + bool only_unused, + int comparison_sign) +{ + git_mwindow *w, *w_last; + git_mwindow *lru_window = NULL, *lru_last = NULL; + bool found = false; + + assert(mwf); + assert(out_window); + + lru_window = *out_window; + if (out_last) + lru_last = *out_last; + + for (w_last = NULL, w = mwf->windows; w; w_last = w, w = w->next) { + if (w->inuse_cnt) { + if (only_unused) + return false; + /* This window is currently being used. Skip it. */ + continue; + } + + /* + * If the current one is more (or less) recent than the last one, + * store it in the output parameter. If lru_window is NULL, + * it's the first loop, so store it as well. + */ + if (!lru_window || + (comparison_sign == GIT_MWINDOW__LRU && lru_window->last_used > w->last_used) || + (comparison_sign == GIT_MWINDOW__MRU && lru_window->last_used < w->last_used)) { + lru_window = w; + lru_last = w_last; + found = true; } - w_l = w; } + + if (!found) + return false; + + *out_window = lru_window; + if (out_last) + *out_last = lru_last; + return true; } /* - * Close the least recently used window. You should check to see if - * the file descriptors need closing from time to time. Called under - * lock from new_window. + * Close the least recently used window (that is currently not being used) out + * of all the files. Called under lock from new_window. */ -static int git_mwindow_close_lru(git_mwindow_file *mwf) +static int git_mwindow_close_lru_window(void) { - git_mwindow_ctl *ctl = &mem_ctl; + git_mwindow_ctl *ctl = &git_mwindow__mem_ctl; + git_mwindow_file *cur; size_t i; - git_mwindow *lru_w = NULL, *lru_l = NULL, **list = &mwf->windows; + git_mwindow *lru_window = NULL, *lru_last = NULL, **list = NULL; - /* FIXME: Does this give us any advantage? */ - if(mwf->windows) - git_mwindow_scan_lru(mwf, &lru_w, &lru_l); - - for (i = 0; i < ctl->windowfiles.length; ++i) { - git_mwindow *last = lru_w; - git_mwindow_file *cur = git_vector_get(&ctl->windowfiles, i); - git_mwindow_scan_lru(cur, &lru_w, &lru_l); - if (lru_w != last) + git_vector_foreach(&ctl->windowfiles, i, cur) { + if (git_mwindow_scan_recently_used( + cur, &lru_window, &lru_last, false, GIT_MWINDOW__LRU)) { list = &cur->windows; + } } - if (!lru_w) { + if (!lru_window) { git_error_set(GIT_ERROR_OS, "failed to close memory window; couldn't find LRU"); return -1; } - ctl->mapped -= lru_w->window_map.len; - git_futils_mmap_free(&lru_w->window_map); + ctl->mapped -= lru_window->window_map.len; + git_futils_mmap_free(&lru_window->window_map); - if (lru_l) - lru_l->next = lru_w->next; + if (lru_last) + lru_last->next = lru_window->next; else - *list = lru_w->next; + *list = lru_window->next; - git__free(lru_w); + git__free(lru_window); ctl->open_windows--; return 0; } +/* + * Close the file that does not have any open windows AND whose + * most-recently-used window is the least-recently used one across all + * currently open files. + * + * Called under lock from new_window. + */ +static int git_mwindow_close_lru_file(void) +{ + git_mwindow_ctl *ctl = &git_mwindow__mem_ctl; + git_mwindow_file *lru_file = NULL, *current_file = NULL; + git_mwindow *lru_window = NULL; + size_t i; + + git_vector_foreach(&ctl->windowfiles, i, current_file) { + git_mwindow *mru_window = NULL; + if (!git_mwindow_scan_recently_used( + current_file, &mru_window, NULL, true, GIT_MWINDOW__MRU)) { + continue; + } + if (!lru_window || lru_window->last_used > mru_window->last_used) + lru_file = current_file; + } + + if (!lru_file) { + git_error_set(GIT_ERROR_OS, "failed to close memory window file; couldn't find LRU"); + return -1; + } + + git_mwindow_free_all_locked(lru_file); + p_close(lru_file->fd); + lru_file->fd = -1; + + return 0; +} + /* This gets called under lock from git_mwindow_open */ static git_mwindow *new_window( - git_mwindow_file *mwf, git_file fd, off64_t size, off64_t offset) { - git_mwindow_ctl *ctl = &mem_ctl; + git_mwindow_ctl *ctl = &git_mwindow__mem_ctl; size_t walign = git_mwindow__window_size / 2; off64_t len; git_mwindow *w; @@ -269,7 +337,7 @@ static git_mwindow *new_window( ctl->mapped += (size_t)len; while (git_mwindow__mapped_limit < ctl->mapped && - git_mwindow_close_lru(mwf) == 0) /* nop */; + git_mwindow_close_lru_window() == 0) /* nop */; /* * We treat `mapped_limit` as a soft limit. If we can't find a @@ -283,7 +351,7 @@ static git_mwindow *new_window( * we're below our soft limits, so free up what we can and try again. */ - while (git_mwindow_close_lru(mwf) == 0) + while (git_mwindow_close_lru_window() == 0) /* nop */; if (git_futils_mmap_ro(&w->window_map, fd, w->offset, (size_t)len) < 0) { @@ -315,7 +383,7 @@ unsigned char *git_mwindow_open( size_t extra, unsigned int *left) { - git_mwindow_ctl *ctl = &mem_ctl; + git_mwindow_ctl *ctl = &git_mwindow__mem_ctl; git_mwindow *w = *cursor; if (git_mutex_lock(&git__mwindow_mutex)) { @@ -339,7 +407,7 @@ unsigned char *git_mwindow_open( * one. */ if (!w) { - w = new_window(mwf, mwf->fd, mwf->size, offset); + w = new_window(mwf->fd, mwf->size, offset); if (w == NULL) { git_mutex_unlock(&git__mwindow_mutex); return NULL; @@ -367,7 +435,7 @@ unsigned char *git_mwindow_open( int git_mwindow_file_register(git_mwindow_file *mwf) { - git_mwindow_ctl *ctl = &mem_ctl; + git_mwindow_ctl *ctl = &git_mwindow__mem_ctl; int ret; if (git_mutex_lock(&git__mwindow_mutex)) { @@ -381,6 +449,11 @@ int git_mwindow_file_register(git_mwindow_file *mwf) return -1; } + if (git_mwindow__file_limit) { + while (git_mwindow__file_limit <= ctl->windowfiles.length && + git_mwindow_close_lru_file() == 0) /* nop */; + } + ret = git_vector_insert(&ctl->windowfiles, mwf); git_mutex_unlock(&git__mwindow_mutex); @@ -389,7 +462,7 @@ int git_mwindow_file_register(git_mwindow_file *mwf) void git_mwindow_file_deregister(git_mwindow_file *mwf) { - git_mwindow_ctl *ctl = &mem_ctl; + git_mwindow_ctl *ctl = &git_mwindow__mem_ctl; git_mwindow_file *cur; size_t i; diff --git a/src/net.c b/src/net.c index d42fce52d..dbde626b5 100644 --- a/src/net.c +++ b/src/net.c @@ -336,7 +336,12 @@ bool git_net_url_valid(git_net_url *url) int git_net_url_is_default_port(git_net_url *url) { - return (strcmp(url->port, default_port_for_scheme(url->scheme)) == 0); + const char *default_port; + + if ((default_port = default_port_for_scheme(url->scheme)) != NULL) + return (strcmp(url->port, default_port) == 0); + else + return false; } void git_net_url_swap(git_net_url *a, git_net_url *b) diff --git a/src/object.c b/src/object.c index 1b47ab1a6..749b0caf2 100644 --- a/src/object.c +++ b/src/object.c @@ -86,7 +86,8 @@ int git_object__from_raw( GIT_ERROR_CHECK_ALLOC(object); object->cached.flags = GIT_CACHE_STORE_PARSED; object->cached.type = type; - git_odb_hash(&object->cached.oid, data, size, type); + if ((error = git_odb_hash(&object->cached.oid, data, size, type)) < 0) + return error; /* Parse raw object data */ def = &git_objects_table[type]; diff --git a/src/odb.c b/src/odb.c index 68d9a9a3f..129a63255 100644 --- a/src/odb.c +++ b/src/odb.c @@ -44,8 +44,8 @@ typedef struct static git_cache *odb_cache(git_odb *odb) { - if (odb->rc.owner != NULL) { - git_repository *owner = odb->rc.owner; + git_repository *owner = GIT_REFCOUNT_OWNER(odb); + if (owner != NULL) { return &owner->objects; } @@ -664,7 +664,7 @@ int git_odb_open(git_odb **out, const char *objects_dir) int git_odb__set_caps(git_odb *odb, int caps) { if (caps == GIT_ODB_CAP_FROM_OWNER) { - git_repository *repo = odb->rc.owner; + git_repository *repo = GIT_REFCOUNT_OWNER(odb); int val; if (!repo) { @@ -1283,12 +1283,13 @@ int git_odb_write( git_oid *oid, git_odb *db, const void *data, size_t len, git_object_t type) { size_t i; - int error = GIT_ERROR; + int error; git_odb_stream *stream; assert(oid && db); - git_odb_hash(oid, data, len, type); + if ((error = git_odb_hash(oid, data, len, type)) < 0) + return error; if (git_oid_is_zero(oid)) return error_null_oid(GIT_EINVALID, "cannot write object"); @@ -1296,7 +1297,7 @@ int git_odb_write( if (git_odb__freshen(db, oid)) return 0; - for (i = 0; i < db->backends.length && error < 0; ++i) { + for (i = 0, error = GIT_ERROR; i < db->backends.length && error < 0; ++i) { backend_internal *internal = git_vector_get(&db->backends, i); git_odb_backend *b = internal->backend; @@ -1510,10 +1511,12 @@ void *git_odb_backend_data_alloc(git_odb_backend *backend, size_t len) return git__malloc(len); } +#ifndef GIT_DEPRECATE_HARD void *git_odb_backend_malloc(git_odb_backend *backend, size_t len) { return git_odb_backend_data_alloc(backend, len); } +#endif void git_odb_backend_data_free(git_odb_backend *backend, void *data) { diff --git a/src/odb_loose.c b/src/odb_loose.c index 4a54b3fc0..68287795a 100644 --- a/src/odb_loose.c +++ b/src/odb_loose.c @@ -304,7 +304,7 @@ static int read_loose_standard(git_rawobj *out, git_buf *obj) * (including the initial sequence in the head buffer). */ if (GIT_ADD_SIZET_OVERFLOW(&alloc_size, hdr.size, 1) || - (body = git__malloc(alloc_size)) == NULL) { + (body = git__calloc(1, alloc_size)) == NULL) { error = -1; goto done; } @@ -386,8 +386,8 @@ static int read_header_loose_standard( git_rawobj *out, const unsigned char *data, size_t len) { git_zstream zs = GIT_ZSTREAM_INIT; - obj_hdr hdr; - unsigned char inflated[MAX_HEADER_LEN]; + obj_hdr hdr = {0}; + unsigned char inflated[MAX_HEADER_LEN] = {0}; size_t header_len, inflated_len = sizeof(inflated); int error; diff --git a/src/odb_mempack.c b/src/odb_mempack.c index 69c423bec..6d20b39ba 100644 --- a/src/odb_mempack.c +++ b/src/odb_mempack.c @@ -110,6 +110,8 @@ int git_mempack_dump(git_buf *pack, git_repository *repo, git_odb_backend *_back if (git_packbuilder_new(&packbuilder, repo) < 0) return -1; + git_packbuilder_set_threads(packbuilder, 0); + for (i = 0; i < db->commits.size; ++i) { struct memobject *commit = db->commits.ptr[i]; diff --git a/src/oid.c b/src/oid.c index 641956652..7831aca89 100644 --- a/src/oid.c +++ b/src/oid.c @@ -253,10 +253,12 @@ int git_oid_is_zero(const git_oid *oid_a) return 1; } +#ifndef GIT_DEPRECATE_HARD int git_oid_iszero(const git_oid *oid_a) { return git_oid_is_zero(oid_a); } +#endif typedef short node_index; diff --git a/src/pack-objects.c b/src/pack-objects.c index 49b4e4772..cf10e6cb5 100644 --- a/src/pack-objects.c +++ b/src/pack-objects.c @@ -141,14 +141,11 @@ int git_packbuilder_new(git_packbuilder **out, git_repository *repo) pb = git__calloc(1, sizeof(*pb)); GIT_ERROR_CHECK_ALLOC(pb); - if (git_oidmap_new(&pb->object_ix) < 0) + if (git_oidmap_new(&pb->object_ix) < 0 || + git_oidmap_new(&pb->walk_objects) < 0 || + git_pool_init(&pb->object_pool, sizeof(struct walk_object)) < 0) goto on_error; - if (git_oidmap_new(&pb->walk_objects) < 0) - goto on_error; - - git_pool_init(&pb->object_pool, sizeof(struct walk_object)); - pb->repo = repo; pb->nr_threads = 1; /* do not spawn any thread by default */ @@ -1384,20 +1381,29 @@ int git_packbuilder_write( git_indexer_progress_cb progress_cb, void *progress_cb_payload) { + int error = -1; + git_buf object_path = GIT_BUF_INIT; git_indexer_options opts = GIT_INDEXER_OPTIONS_INIT; - git_indexer *indexer; + git_indexer *indexer = NULL; git_indexer_progress stats; struct pack_write_context ctx; int t; PREPARE_PACK; + if (path == NULL) { + if ((error = git_repository_item_path(&object_path, pb->repo, GIT_REPOSITORY_ITEM_OBJECTS)) < 0) + goto cleanup; + if ((error = git_buf_joinpath(&object_path, git_buf_cstr(&object_path), "pack")) < 0) + goto cleanup; + path = git_buf_cstr(&object_path); + } + opts.progress_cb = progress_cb; opts.progress_cb_payload = progress_cb_payload; - if (git_indexer_new( - &indexer, path, mode, pb->odb, &opts) < 0) - return -1; + if ((error = git_indexer_new(&indexer, path, mode, pb->odb, &opts)) < 0) + goto cleanup; if (!git_repository__configmap_lookup(&t, pb->repo, GIT_CONFIGMAP_FSYNCOBJECTFILES) && t) git_indexer__set_fsync(indexer, 1); @@ -1405,16 +1411,18 @@ int git_packbuilder_write( ctx.indexer = indexer; ctx.stats = &stats; - if (git_packbuilder_foreach(pb, write_cb, &ctx) < 0 || - git_indexer_commit(indexer, &stats) < 0) { - git_indexer_free(indexer); - return -1; - } + if ((error = git_packbuilder_foreach(pb, write_cb, &ctx)) < 0) + goto cleanup; + + if ((error = git_indexer_commit(indexer, &stats)) < 0) + goto cleanup; git_oid_cpy(&pb->pack_oid, git_indexer_hash(indexer)); +cleanup: git_indexer_free(indexer); - return 0; + git_buf_dispose(&object_path); + return error; } #undef PREPARE_PACK @@ -1634,7 +1642,7 @@ static int mark_edges_uninteresting(git_packbuilder *pb, git_commit_list *commit return 0; } -int insert_tree(git_packbuilder *pb, git_tree *tree) +static int pack_objects_insert_tree(git_packbuilder *pb, git_tree *tree) { size_t i; int error; @@ -1661,7 +1669,7 @@ int insert_tree(git_packbuilder *pb, git_tree *tree) if ((error = git_tree_lookup(&subtree, pb->repo, entry_id)) < 0) return error; - error = insert_tree(pb, subtree); + error = pack_objects_insert_tree(pb, subtree); git_tree_free(subtree); if (error < 0) @@ -1687,7 +1695,7 @@ int insert_tree(git_packbuilder *pb, git_tree *tree) return error; } -int insert_commit(git_packbuilder *pb, struct walk_object *obj) +static int pack_objects_insert_commit(git_packbuilder *pb, struct walk_object *obj) { int error; git_commit *commit = NULL; @@ -1704,7 +1712,7 @@ int insert_commit(git_packbuilder *pb, struct walk_object *obj) if ((error = git_tree_lookup(&tree, pb->repo, git_commit_tree_id(commit))) < 0) goto cleanup; - if ((error = insert_tree(pb, tree)) < 0) + if ((error = pack_objects_insert_tree(pb, tree)) < 0) goto cleanup; cleanup: @@ -1739,7 +1747,7 @@ int git_packbuilder_insert_walk(git_packbuilder *pb, git_revwalk *walk) if (obj->seen || obj->uninteresting) continue; - if ((error = insert_commit(pb, obj)) < 0) + if ((error = pack_objects_insert_commit(pb, obj)) < 0) return error; } diff --git a/src/pack.c b/src/pack.c index fcf64f57d..1b5cf670f 100644 --- a/src/pack.c +++ b/src/pack.c @@ -488,8 +488,12 @@ int git_packfile_resolve_header( size_t base_size; git_packfile_stream stream; - base_offset = get_delta_base(p, &w_curs, &curpos, type, offset); + error = get_delta_base(&base_offset, p, &w_curs, &curpos, type, offset); git_mwindow_close(&w_curs); + + if (error < 0) + return error; + if ((error = git_packfile_stream_open(&stream, p, curpos)) < 0) return error; error = git_delta_read_header_fromstream(&base_size, size_p, &stream); @@ -508,8 +512,12 @@ int git_packfile_resolve_header( return error; if (type != GIT_OBJECT_OFS_DELTA && type != GIT_OBJECT_REF_DELTA) break; - base_offset = get_delta_base(p, &w_curs, &curpos, type, base_offset); + + error = get_delta_base(&base_offset, p, &w_curs, &curpos, type, base_offset); git_mwindow_close(&w_curs); + + if (error < 0) + return error; } *type_p = type; @@ -583,17 +591,11 @@ static int pack_dependency_chain(git_dependency_chain *chain_out, if (type != GIT_OBJECT_OFS_DELTA && type != GIT_OBJECT_REF_DELTA) break; - base_offset = get_delta_base(p, &w_curs, &curpos, type, obj_offset); + error = get_delta_base(&base_offset, p, &w_curs, &curpos, type, obj_offset); git_mwindow_close(&w_curs); - if (base_offset == 0) { - error = packfile_error("delta offset is zero"); + if (error < 0) goto on_error; - } - if (base_offset < 0) { /* must actually be an error code */ - error = (int)base_offset; - goto on_error; - } /* we need to pass the pos *after* the delta-base bit */ elem->offset = curpos; @@ -842,7 +844,10 @@ static int packfile_unpack_compressed( unsigned int window_len; unsigned char *in; - in = pack_window_open(p, mwindow, *position, &window_len); + if ((in = pack_window_open(p, mwindow, *position, &window_len)) == NULL) { + error = -1; + goto out; + } if ((error = git_zstream_set_input(&zstream, in, window_len)) < 0 || (error = git_zstream_get_output_chunk(data + total, &bytes, &zstream)) < 0) { @@ -852,9 +857,12 @@ static int packfile_unpack_compressed( git_mwindow_close(mwindow); + if (!bytes) + break; + *position += window_len - zstream.in_len; total += bytes; - } while (total < size); + } while (!git_zstream_eos(&zstream)); if (total != size || !git_zstream_eos(&zstream)) { git_error_set(GIT_ERROR_ZLIB, "error inflating zlib stream"); @@ -878,18 +886,21 @@ out: * curpos is where the data starts, delta_obj_offset is the where the * header starts */ -off64_t get_delta_base( - struct git_pack_file *p, - git_mwindow **w_curs, - off64_t *curpos, - git_object_t type, - off64_t delta_obj_offset) +int get_delta_base( + off64_t *delta_base_out, + struct git_pack_file *p, + git_mwindow **w_curs, + off64_t *curpos, + git_object_t type, + off64_t delta_obj_offset) { unsigned int left = 0; unsigned char *base_info; off64_t base_offset; git_oid unused; + assert(delta_base_out); + base_info = pack_window_open(p, w_curs, *curpos, &left); /* Assumption: the only reason this would fail is because the file is too small */ if (base_info == NULL) @@ -909,12 +920,12 @@ off64_t get_delta_base( return GIT_EBUFS; unsigned_base_offset += 1; if (!unsigned_base_offset || MSB(unsigned_base_offset, 7)) - return 0; /* overflow */ + return packfile_error("overflow"); c = base_info[used++]; unsigned_base_offset = (unsigned_base_offset << 7) + (c & 127); } if (unsigned_base_offset == 0 || (size_t)delta_obj_offset <= unsigned_base_offset) - return 0; /* out of bound */ + return packfile_error("out of bounds"); base_offset = delta_obj_offset - unsigned_base_offset; *curpos += used; } else if (type == GIT_OBJECT_REF_DELTA) { @@ -925,8 +936,12 @@ off64_t get_delta_base( git_oid_fromraw(&oid, base_info); if ((entry = git_oidmap_get(p->idx_cache, &oid)) != NULL) { + if (entry->offset == 0) + return packfile_error("delta offset is zero"); + *curpos += 20; - return entry->offset; + *delta_base_out = entry->offset; + return 0; } else { /* If we're building an index, don't try to find the pack * entry; we just haven't seen it yet. We'll make @@ -941,9 +956,13 @@ off64_t get_delta_base( return packfile_error("base entry delta is not in the same pack"); *curpos += 20; } else - return 0; + return packfile_error("unknown object type"); - return base_offset; + if (base_offset == 0) + return packfile_error("delta offset is zero"); + + *delta_base_out = base_offset; + return 0; } /*********************************************************** @@ -1238,14 +1257,14 @@ int git_pack_foreach_entry( return error; } -static int sha1_position(const void *table, size_t stride, unsigned lo, - unsigned hi, const unsigned char *key) +int git_pack__lookup_sha1(const void *oid_lookup_table, size_t stride, unsigned lo, + unsigned hi, const unsigned char *oid_prefix) { - const unsigned char *base = table; + const unsigned char *base = oid_lookup_table; while (lo < hi) { unsigned mi = (lo + hi) / 2; - int cmp = git_oid__hashcmp(base + mi * stride, key); + int cmp = git_oid__hashcmp(base + mi * stride, oid_prefix); if (!cmp) return mi; @@ -1307,7 +1326,7 @@ static int pack_entry_find_offset( short_oid->id[0], short_oid->id[1], short_oid->id[2], lo, hi, p->num_objects); #endif - pos = sha1_position(index, stride, lo, hi, short_oid->id); + pos = git_pack__lookup_sha1(index, stride, lo, hi, short_oid->id); if (pos >= 0) { /* An object matching exactly the oid was found */ diff --git a/src/pack.h b/src/pack.h index a6a32ff20..cebfcd1bd 100644 --- a/src/pack.h +++ b/src/pack.h @@ -106,6 +106,19 @@ struct git_pack_file { char pack_name[GIT_FLEX_ARRAY]; /* more */ }; +/** + * Return the position where an OID (or a prefix) would be inserted within the + * OID Lookup Table of an .idx file. This performs binary search between the lo + * and hi indices. + * + * The stride parameter is provided because .idx files version 1 store the OIDs + * interleaved with the 4-byte file offsets of the objects within the .pack + * file (stride = 24), whereas files with version 2 store them in a contiguous + * flat array (stride = 20). + */ +int git_pack__lookup_sha1(const void *oid_lookup_table, size_t stride, unsigned lo, + unsigned hi, const unsigned char *oid_prefix); + struct git_pack_entry { off64_t offset; git_oid sha1; @@ -143,8 +156,12 @@ int git_packfile_stream_open(git_packfile_stream *obj, struct git_pack_file *p, ssize_t git_packfile_stream_read(git_packfile_stream *obj, void *buffer, size_t len); void git_packfile_stream_dispose(git_packfile_stream *obj); -off64_t get_delta_base(struct git_pack_file *p, git_mwindow **w_curs, - off64_t *curpos, git_object_t type, +int get_delta_base( + off64_t *delta_base_out, + struct git_pack_file *p, + git_mwindow **w_curs, + off64_t *curpos, + git_object_t type, off64_t delta_obj_offset); void git_packfile_close(struct git_pack_file *p, bool unlink_packfile); diff --git a/src/patch_generate.c b/src/patch_generate.c index 18256d076..6dd61c18f 100644 --- a/src/patch_generate.c +++ b/src/patch_generate.c @@ -209,9 +209,7 @@ static int patch_generated_load(git_patch_generated *patch, git_patch_generated_ if ((error = git_diff_file_content__load( &patch->ofile, &patch->base.diff_opts)) < 0 || - should_skip_binary(patch, patch->ofile.file)) - goto cleanup; - if ((error = git_diff_file_content__load( + (error = git_diff_file_content__load( &patch->nfile, &patch->base.diff_opts)) < 0 || should_skip_binary(patch, patch->nfile.file)) goto cleanup; diff --git a/src/patch_parse.c b/src/patch_parse.c index 9d089ad83..2bf94c2cb 100644 --- a/src/patch_parse.c +++ b/src/patch_parse.c @@ -198,7 +198,7 @@ static int parse_header_git_index( return -1; if (git_parse_peek(&c, &ctx->parse_ctx, 0) == 0 && c == ' ') { - uint16_t mode; + uint16_t mode = 0; git_parse_advance_chars(&ctx->parse_ctx, 1); @@ -407,10 +407,12 @@ static const parse_header_transition transitions[] = { { "--- " , STATE_DIFF, STATE_PATH, parse_header_git_oldpath }, { "--- " , STATE_INDEX, STATE_PATH, parse_header_git_oldpath }, + { "--- " , STATE_FILEMODE, STATE_PATH, parse_header_git_oldpath }, { "+++ " , STATE_PATH, STATE_END, parse_header_git_newpath }, { "GIT binary patch" , STATE_INDEX, STATE_END, NULL }, { "Binary files " , STATE_INDEX, STATE_END, NULL }, + { "similarity index " , STATE_END, STATE_SIMILARITY, parse_header_similarity }, { "similarity index " , STATE_DIFF, STATE_SIMILARITY, parse_header_similarity }, { "dissimilarity index ", STATE_DIFF, STATE_SIMILARITY, parse_header_dissimilarity }, { "rename from " , STATE_SIMILARITY, STATE_RENAME, parse_header_renamefrom }, @@ -940,7 +942,7 @@ static int parse_patch_body( return parse_patch_hunks(patch, ctx); } -int check_header_names( +static int check_header_names( const char *one, const char *two, const char *old_or_new, diff --git a/src/path.c b/src/path.c index 625b95c0d..f271c532c 100644 --- a/src/path.c +++ b/src/path.c @@ -322,7 +322,7 @@ int git_path_root(const char *path) return -1; /* Not a real error - signals that path is not rooted */ } -void git_path_trim_slashes(git_buf *path) +static void path_trim_slashes(git_buf *path) { int ceiling = git_path_root(path->ptr) + 1; assert(ceiling >= 0); @@ -1219,7 +1219,7 @@ int git_path_diriter_init( if (git_buf_puts(&diriter->path_utf8, path) < 0) return -1; - git_path_trim_slashes(&diriter->path_utf8); + path_trim_slashes(&diriter->path_utf8); if (diriter->path_utf8.size == 0) { git_error_set(GIT_ERROR_FILESYSTEM, "could not open directory '%s'", path); @@ -1368,7 +1368,7 @@ int git_path_diriter_init( if (git_buf_puts(&diriter->path, path) < 0) return -1; - git_path_trim_slashes(&diriter->path); + path_trim_slashes(&diriter->path); if (diriter->path.size == 0) { git_error_set(GIT_ERROR_FILESYSTEM, "could not open directory '%s'", path); @@ -2045,7 +2045,7 @@ int git_path_validate_system_file_ownership(const char *path) git_error_set(GIT_ERROR_INVALID, "programdata configuration file owner is not valid"); ret = GIT_ERROR; } - free(info); + git__free(info); cleanup: if (descriptor) diff --git a/src/pathspec.c b/src/pathspec.c index 19ea9eb19..83f776c91 100644 --- a/src/pathspec.c +++ b/src/pathspec.c @@ -238,9 +238,9 @@ int git_pathspec__init(git_pathspec *ps, const git_strarray *paths) memset(ps, 0, sizeof(*ps)); ps->prefix = git_pathspec_prefix(paths); - git_pool_init(&ps->pool, 1); - if ((error = git_pathspec__vinit(&ps->pathspec, paths, &ps->pool)) < 0) + if ((error = git_pool_init(&ps->pool, 1)) < 0 || + (error = git_pathspec__vinit(&ps->pathspec, paths, &ps->pool)) < 0) git_pathspec__clear(ps); return error; @@ -316,7 +316,8 @@ static git_pathspec_match_list *pathspec_match_alloc( if (!m) return NULL; - git_pool_init(&m->pool, 1); + if (git_pool_init(&m->pool, 1) < 0) + return NULL; /* need to keep reference to pathspec and increment refcount because * failures array stores pointers to the pattern strings of the diff --git a/src/pool.c b/src/pool.c index b3bc8d489..0c423dd3a 100644 --- a/src/pool.c +++ b/src/pool.c @@ -21,30 +21,29 @@ struct git_pool_page { static void *pool_alloc_page(git_pool *pool, size_t size); -size_t git_pool__system_page_size(void) +#ifndef GIT_DEBUG_POOL + +static size_t system_page_size = 0; + +int git_pool_global_init(void) { - static size_t size = 0; - - if (!size) { - size_t page_size; - if (git__page_size(&page_size) < 0) - page_size = 4096; - /* allow space for malloc overhead */ - size = (page_size - (2 * sizeof(void *)) - sizeof(git_pool_page)); - } - - return size; + if (git__page_size(&system_page_size) < 0) + system_page_size = 4096; + /* allow space for malloc overhead */ + system_page_size -= (2 * sizeof(void *)) + sizeof(git_pool_page); + return 0; } -#ifndef GIT_DEBUG_POOL -void git_pool_init(git_pool *pool, size_t item_size) +int git_pool_init(git_pool *pool, size_t item_size) { assert(pool); assert(item_size >= 1); memset(pool, 0, sizeof(git_pool)); pool->item_size = item_size; - pool->page_size = git_pool__system_page_size(); + pool->page_size = system_page_size; + + return 0; } void git_pool_clear(git_pool *pool) @@ -112,6 +111,11 @@ bool git_pool__ptr_in_pool(git_pool *pool, void *ptr) #else +int git_pool_global_init(void) +{ + return 0; +} + static int git_pool__ptr_cmp(const void * a, const void * b) { if(a > b) { @@ -125,7 +129,7 @@ static int git_pool__ptr_cmp(const void * a, const void * b) } } -void git_pool_init(git_pool *pool, size_t item_size) +int git_pool_init(git_pool *pool, size_t item_size) { assert(pool); assert(item_size >= 1); @@ -134,6 +138,8 @@ void git_pool_init(git_pool *pool, size_t item_size) pool->item_size = item_size; pool->page_size = git_pool__system_page_size(); git_vector_init(&pool->allocations, 100, git_pool__ptr_cmp); + + return 0; } void git_pool_clear(git_pool *pool) diff --git a/src/pool.h b/src/pool.h index 23f68990f..cecb84665 100644 --- a/src/pool.h +++ b/src/pool.h @@ -81,7 +81,7 @@ typedef struct { * Of course, you can use this in other ways, but those are the * two most common patterns. */ -extern void git_pool_init(git_pool *pool, size_t item_size); +extern int git_pool_init(git_pool *pool, size_t item_size); /** * Free all items in pool @@ -135,4 +135,12 @@ extern uint32_t git_pool__open_pages(git_pool *pool); #endif extern bool git_pool__ptr_in_pool(git_pool *pool, void *ptr); +/** + * This function is being called by our global setup routines to + * initialize the system pool size. + * + * @return 0 on success, <0 on failure + */ +extern int git_pool_global_init(void); + #endif diff --git a/src/proxy.c b/src/proxy.c index 367c4b1f7..78a4c5535 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -16,10 +16,12 @@ int git_proxy_options_init(git_proxy_options *opts, unsigned int version) return 0; } +#ifndef GIT_DEPRECATE_HARD int git_proxy_init_options(git_proxy_options *opts, unsigned int version) { return git_proxy_options_init(opts, version); } +#endif int git_proxy_options_dup(git_proxy_options *tgt, const git_proxy_options *src) { diff --git a/src/push.c b/src/push.c index 34867c2e4..b724188f9 100644 --- a/src/push.c +++ b/src/push.c @@ -555,7 +555,9 @@ int git_push_options_init(git_push_options *opts, unsigned int version) return 0; } +#ifndef GIT_DEPRECATE_HARD int git_push_init_options(git_push_options *opts, unsigned int version) { return git_push_options_init(opts, version); } +#endif diff --git a/src/rebase.c b/src/rebase.c index 0a38807a7..7c6561195 100644 --- a/src/rebase.c +++ b/src/rebase.c @@ -501,10 +501,12 @@ int git_rebase_options_init(git_rebase_options *opts, unsigned int version) return 0; } +#ifndef GIT_DEPRECATE_HARD int git_rebase_init_options(git_rebase_options *opts, unsigned int version) { return git_rebase_options_init(opts, version); } +#endif static int rebase_ensure_not_in_progress(git_repository *repo) { diff --git a/src/refdb.c b/src/refdb.c index fbbf5193c..fb86d5ccb 100644 --- a/src/refdb.c +++ b/src/refdb.c @@ -17,6 +17,9 @@ #include "reflog.h" #include "posix.h" +#define DEFAULT_NESTING_LEVEL 5 +#define MAX_NESTING_LEVEL 10 + int git_refdb_new(git_refdb **out, git_repository *repo) { git_refdb *db; @@ -134,6 +137,59 @@ int git_refdb_lookup(git_reference **out, git_refdb *db, const char *ref_name) return 0; } +int git_refdb_resolve( + git_reference **out, + git_refdb *db, + const char *ref_name, + int max_nesting) +{ + git_reference *ref = NULL; + int error = 0, nesting; + + *out = NULL; + + if (max_nesting > MAX_NESTING_LEVEL) + max_nesting = MAX_NESTING_LEVEL; + else if (max_nesting < 0) + max_nesting = DEFAULT_NESTING_LEVEL; + + if ((error = git_refdb_lookup(&ref, db, ref_name)) < 0) + goto out; + + for (nesting = 0; nesting < max_nesting; nesting++) { + git_reference *resolved; + + if (ref->type == GIT_REFERENCE_DIRECT) + break; + + if ((error = git_refdb_lookup(&resolved, db, git_reference_symbolic_target(ref))) < 0) { + /* If we found a symbolic reference with a nonexistent target, return it. */ + if (error == GIT_ENOTFOUND) { + error = 0; + *out = ref; + ref = NULL; + } + goto out; + } + + git_reference_free(ref); + ref = resolved; + } + + if (ref->type != GIT_REFERENCE_DIRECT && max_nesting != 0) { + git_error_set(GIT_ERROR_REFERENCE, + "cannot resolve reference (>%u levels deep)", max_nesting); + error = -1; + goto out; + } + + *out = ref; + ref = NULL; +out: + git_reference_free(ref); + return error; +} + int git_refdb_iterator(git_reference_iterator **out, git_refdb *db, const char *glob) { int error; @@ -231,6 +287,85 @@ int git_refdb_reflog_read(git_reflog **out, git_refdb *db, const char *name) return 0; } +int git_refdb_should_write_reflog(int *out, git_refdb *db, const git_reference *ref) +{ + int error, logall; + + error = git_repository__configmap_lookup(&logall, db->repo, GIT_CONFIGMAP_LOGALLREFUPDATES); + if (error < 0) + return error; + + /* Defaults to the opposite of the repo being bare */ + if (logall == GIT_LOGALLREFUPDATES_UNSET) + logall = !git_repository_is_bare(db->repo); + + *out = 0; + switch (logall) { + case GIT_LOGALLREFUPDATES_FALSE: + *out = 0; + break; + + case GIT_LOGALLREFUPDATES_TRUE: + /* Only write if it already has a log, + * or if it's under heads/, remotes/ or notes/ + */ + *out = git_refdb_has_log(db, ref->name) || + !git__prefixcmp(ref->name, GIT_REFS_HEADS_DIR) || + !git__strcmp(ref->name, GIT_HEAD_FILE) || + !git__prefixcmp(ref->name, GIT_REFS_REMOTES_DIR) || + !git__prefixcmp(ref->name, GIT_REFS_NOTES_DIR); + break; + + case GIT_LOGALLREFUPDATES_ALWAYS: + *out = 1; + break; + } + + return 0; +} + +int git_refdb_should_write_head_reflog(int *out, git_refdb *db, const git_reference *ref) +{ + git_reference *head = NULL, *resolved = NULL; + const char *name; + int error; + + *out = 0; + + if (ref->type == GIT_REFERENCE_SYMBOLIC) { + error = 0; + goto out; + } + + if ((error = git_refdb_lookup(&head, db, GIT_HEAD_FILE)) < 0) + goto out; + + if (git_reference_type(head) == GIT_REFERENCE_DIRECT) + goto out; + + /* Go down the symref chain until we find the branch */ + if ((error = git_refdb_resolve(&resolved, db, git_reference_symbolic_target(head), -1)) < 0) { + if (error != GIT_ENOTFOUND) + goto out; + error = 0; + name = git_reference_symbolic_target(head); + } else if (git_reference_type(resolved) == GIT_REFERENCE_SYMBOLIC) { + name = git_reference_symbolic_target(resolved); + } else { + name = git_reference_name(resolved); + } + + if (strcmp(name, ref->name)) + goto out; + + *out = 1; + +out: + git_reference_free(resolved); + git_reference_free(head); + return error; +} + int git_refdb_has_log(git_refdb *db, const char *refname) { assert(db && refname); diff --git a/src/refdb.h b/src/refdb.h index 2d4ec753a..84e19b1c3 100644 --- a/src/refdb.h +++ b/src/refdb.h @@ -30,6 +30,31 @@ int git_refdb_lookup( git_refdb *refdb, const char *ref_name); +/** + * Resolve the reference by following symbolic references. + * + * Given a reference name, this function will follow any symbolic references up + * to `max_nesting` deep and return the resolved direct reference. If any of + * the intermediate symbolic references points to a non-existing reference, + * then that symbolic reference is returned instead with an error code of `0`. + * If the given reference is a direct reference already, it is returned + * directly. + * + * If `max_nesting` is `0`, the reference will not be resolved. If it's + * negative, it will be set to the default resolve depth which is `5`. + * + * @param out Pointer to store the result in. + * @param db The refdb to use for resolving the reference. + * @param ref_name The reference name to lookup and resolve. + * @param max_nesting The maximum nesting depth. + * @return `0` on success, a negative error code otherwise. + */ +int git_refdb_resolve( + git_reference **out, + git_refdb *db, + const char *ref_name, + int max_nesting); + int git_refdb_rename( git_reference **out, git_refdb *db, @@ -50,6 +75,50 @@ int git_refdb_delete(git_refdb *refdb, const char *ref_name, const git_oid *old_ int git_refdb_reflog_read(git_reflog **out, git_refdb *db, const char *name); int git_refdb_reflog_write(git_reflog *reflog); +/** + * Determine whether a reflog entry should be created for the given reference. + * + * Whether or not writing to a reference should create a reflog entry is + * dependent on a number of things. Most importantly, there's the + * "core.logAllRefUpdates" setting that controls in which situations a + * reference should get a corresponding reflog entry. The following values for + * it are understood: + * + * - "false": Do not log reference updates. + * + * - "true": Log normal reference updates. This will write entries for + * references in "refs/heads", "refs/remotes", "refs/notes" and + * "HEAD" or if the reference already has a log entry. + * + * - "always": Always create a reflog entry. + * + * If unset, the value will default to "true" for non-bare repositories and + * "false" for bare ones. + * + * @param out pointer to which the result will be written, `1` means a reflog + * entry should be written, `0` means none should be written. + * @param db The refdb to decide this for. + * @param ref The reference one wants to check. + * @return `0` on success, a negative error code otherwise. + */ +int git_refdb_should_write_reflog(int *out, git_refdb *db, const git_reference *ref); + +/** + * Determine whether a reflog entry should be created for HEAD if creating one + * for the given reference + * + * In case the given reference is being pointed to by HEAD, then creating a + * reflog entry for this reference also requires us to create a corresponding + * reflog entry for HEAD. This function can be used to determine that scenario. + * + * @param out pointer to which the result will be written, `1` means a reflog + * entry should be written, `0` means none should be written. + * @param db The refdb to decide this for. + * @param ref The reference one wants to check. + * @return `0` on success, a negative error code otherwise. + */ +int git_refdb_should_write_head_reflog(int *out, git_refdb *db, const git_reference *ref); + int git_refdb_has_log(git_refdb *db, const char *refname); int git_refdb_ensure_log(git_refdb *refdb, const char *refname); diff --git a/src/refdb_fs.c b/src/refdb_fs.c index 1e53b3af5..7e0481909 100644 --- a/src/refdb_fs.c +++ b/src/refdb_fs.c @@ -5,8 +5,6 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#include "refdb_fs.h" - #include "refs.h" #include "hash.h" #include "repository.h" @@ -685,7 +683,8 @@ static int refdb_fs_backend__iterator( iter = git__calloc(1, sizeof(refdb_fs_iter)); GIT_ERROR_CHECK_ALLOC(iter); - git_pool_init(&iter->pool, 1); + if ((error = git_pool_init(&iter->pool, 1)) < 0) + goto out; if ((error = git_vector_init(&iter->loose, 8, NULL)) < 0) goto out; @@ -1129,44 +1128,6 @@ cleanup: } static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, const git_oid *old, const git_oid *new, const git_signature *author, const char *message); -static int has_reflog(git_repository *repo, const char *name); - -static int should_write_reflog(int *write, git_repository *repo, const char *name) -{ - int error, logall; - - error = git_repository__configmap_lookup(&logall, repo, GIT_CONFIGMAP_LOGALLREFUPDATES); - if (error < 0) - return error; - - /* Defaults to the opposite of the repo being bare */ - if (logall == GIT_LOGALLREFUPDATES_UNSET) - logall = !git_repository_is_bare(repo); - - *write = 0; - switch (logall) { - case GIT_LOGALLREFUPDATES_FALSE: - *write = 0; - break; - - case GIT_LOGALLREFUPDATES_TRUE: - /* Only write if it already has a log, - * or if it's under heads/, remotes/ or notes/ - */ - *write = has_reflog(repo, name) || - !git__prefixcmp(name, GIT_REFS_HEADS_DIR) || - !git__strcmp(name, GIT_HEAD_FILE) || - !git__prefixcmp(name, GIT_REFS_REMOTES_DIR) || - !git__prefixcmp(name, GIT_REFS_NOTES_DIR); - break; - - case GIT_LOGALLREFUPDATES_ALWAYS: - *write = 1; - break; - } - - return 0; -} static int cmp_old_ref(int *cmp, git_refdb_backend *backend, const char *name, const git_oid *old_id, const char *old_target) @@ -1220,54 +1181,28 @@ out: */ static int maybe_append_head(refdb_fs_backend *backend, const git_reference *ref, const git_signature *who, const char *message) { - int error; + git_reference *head = NULL; + git_refdb *refdb = NULL; + int error, write_reflog; git_oid old_id; - git_reference *tmp = NULL, *head = NULL, *peeled = NULL; - const char *name; - if (ref->type == GIT_REFERENCE_SYMBOLIC) - return 0; + if ((error = git_repository_refdb(&refdb, backend->repo)) < 0 || + (error = git_refdb_should_write_head_reflog(&write_reflog, refdb, ref)) < 0) + goto out; + if (!write_reflog) + goto out; /* if we can't resolve, we use {0}*40 as old id */ if (git_reference_name_to_id(&old_id, backend->repo, ref->name) < 0) memset(&old_id, 0, sizeof(old_id)); - if ((error = git_reference_lookup(&head, backend->repo, GIT_HEAD_FILE)) < 0) - return error; + if ((error = git_reference_lookup(&head, backend->repo, GIT_HEAD_FILE)) < 0 || + (error = reflog_append(backend, head, &old_id, git_reference_target(ref), who, message)) < 0) + goto out; - if (git_reference_type(head) == GIT_REFERENCE_DIRECT) - goto cleanup; - - if ((error = git_reference_lookup(&tmp, backend->repo, GIT_HEAD_FILE)) < 0) - goto cleanup; - - /* Go down the symref chain until we find the branch */ - while (git_reference_type(tmp) == GIT_REFERENCE_SYMBOLIC) { - error = git_reference_lookup(&peeled, backend->repo, git_reference_symbolic_target(tmp)); - if (error < 0) - break; - - git_reference_free(tmp); - tmp = peeled; - } - - if (error == GIT_ENOTFOUND) { - error = 0; - name = git_reference_symbolic_target(tmp); - } else if (error < 0) { - goto cleanup; - } else { - name = git_reference_name(tmp); - } - - if (strcmp(name, ref->name)) - goto cleanup; - - error = reflog_append(backend, head, &old_id, git_reference_target(ref), who, message); - -cleanup: - git_reference_free(tmp); +out: git_reference_free(head); + git_refdb_free(refdb); return error; } @@ -1336,7 +1271,10 @@ static int refdb_fs_backend__write_tail( } if (update_reflog) { - if ((error = should_write_reflog(&should_write, backend->repo, ref->name)) < 0) + git_refdb *refdb; + + if ((error = git_repository_refdb__weakptr(&refdb, backend->repo)) < 0 || + (error = git_refdb_should_write_reflog(&should_write, refdb, ref)) < 0) goto on_error; if (should_write) { diff --git a/src/refdb_fs.h b/src/refdb_fs.h deleted file mode 100644 index 0c84814df..000000000 --- a/src/refdb_fs.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (C) the libgit2 contributors. All rights reserved. - * - * This file is part of libgit2, distributed under the GNU GPL v2 with - * a Linking Exception. For full terms see the included COPYING file. - */ -#ifndef INCLUDE_refdb_fs_h__ -#define INCLUDE_refdb_fs_h__ - -#include "common.h" - -#include "strmap.h" - -typedef struct { - git_strmap *packfile; - time_t packfile_time; -} git_refcache; - -#endif diff --git a/src/reflog.c b/src/reflog.c index 24dada047..34537aa1f 100644 --- a/src/reflog.c +++ b/src/reflog.c @@ -12,12 +12,8 @@ #include "signature.h" #include "refdb.h" -#include - -git_reflog_entry *git_reflog_entry__alloc(void) -{ - return git__calloc(1, sizeof(git_reflog_entry)); -} +#include "git2/sys/refdb_backend.h" +#include "git2/sys/reflog.h" void git_reflog_entry__free(git_reflog_entry *entry) { diff --git a/src/refs.c b/src/refs.c index 633d83abd..51635a9e4 100644 --- a/src/refs.c +++ b/src/refs.c @@ -27,9 +27,6 @@ bool git_reference__enable_symbolic_ref_target_validation = true; -#define DEFAULT_NESTING_LEVEL 5 -#define MAX_NESTING_LEVEL 10 - enum { GIT_PACKREF_HAS_PEEL = 1, GIT_PACKREF_WAS_LOOSE = 2 @@ -214,89 +211,32 @@ int git_reference_lookup_resolved( const char *name, int max_nesting) { - git_refname_t scan_name; - git_reference_t scan_type; - int error = 0, nesting; - git_reference *ref = NULL; + git_refname_t normalized; git_refdb *refdb; + int error = 0; assert(ref_out && repo && name); - *ref_out = NULL; - - if (max_nesting > MAX_NESTING_LEVEL) - max_nesting = MAX_NESTING_LEVEL; - else if (max_nesting < 0) - max_nesting = DEFAULT_NESTING_LEVEL; - - scan_type = GIT_REFERENCE_SYMBOLIC; - - if ((error = reference_normalize_for_repo(scan_name, repo, name, true)) < 0) + if ((error = reference_normalize_for_repo(normalized, repo, name, true)) < 0 || + (error = git_repository_refdb__weakptr(&refdb, repo)) < 0 || + (error = git_refdb_resolve(ref_out, refdb, normalized, max_nesting)) < 0) return error; - if ((error = git_repository_refdb__weakptr(&refdb, repo)) < 0) - return error; - - for (nesting = max_nesting; - nesting >= 0 && scan_type == GIT_REFERENCE_SYMBOLIC; - nesting--) - { - if (nesting != max_nesting) { - strncpy(scan_name, ref->target.symbolic, sizeof(scan_name)); - git_reference_free(ref); - } - - if ((error = git_refdb_lookup(&ref, refdb, scan_name)) < 0) - return error; - - scan_type = ref->type; + /* + * The resolved reference may be a symbolic reference in case its + * target doesn't exist. If the user asked us to resolve (e.g. + * `max_nesting != 0`), then we need to return an error in case we got + * a symbolic reference back. + */ + if (max_nesting && git_reference_type(*ref_out) == GIT_REFERENCE_SYMBOLIC) { + git_reference_free(*ref_out); + *ref_out = NULL; + return GIT_ENOTFOUND; } - if (scan_type != GIT_REFERENCE_DIRECT && max_nesting != 0) { - git_error_set(GIT_ERROR_REFERENCE, - "cannot resolve reference (>%u levels deep)", max_nesting); - git_reference_free(ref); - return -1; - } - - *ref_out = ref; return 0; } -int git_reference__read_head( - git_reference **out, - git_repository *repo, - const char *path) -{ - git_buf reference = GIT_BUF_INIT; - char *name = NULL; - int error; - - if ((error = git_futils_readbuffer(&reference, path)) < 0) - goto out; - git_buf_rtrim(&reference); - - if (git__strncmp(reference.ptr, GIT_SYMREF, strlen(GIT_SYMREF)) == 0) { - git_buf_consume(&reference, reference.ptr + strlen(GIT_SYMREF)); - - name = git_path_basename(path); - - if ((*out = git_reference__alloc_symbolic(name, reference.ptr)) == NULL) { - error = -1; - goto out; - } - } else { - if ((error = git_reference_lookup(out, repo, reference.ptr)) < 0) - goto out; - } - -out: - git__free(name); - git_buf_dispose(&reference); - - return error; -} - int git_reference_dwim(git_reference **out, git_repository *repo, const char *refname) { int error = 0, i; @@ -480,7 +420,7 @@ static int reference__create( return 0; } -int configured_ident(git_signature **out, const git_repository *repo) +static int refs_configured_ident(git_signature **out, const git_repository *repo) { if (repo->ident_name && repo->ident_email) return git_signature_now(out, repo->ident_name, repo->ident_email); @@ -494,7 +434,7 @@ int git_reference__log_signature(git_signature **out, git_repository *repo) int error; git_signature *who; - if(((error = configured_ident(&who, repo)) < 0) && + if(((error = refs_configured_ident(&who, repo)) < 0) && ((error = git_signature_default(&who, repo)) < 0) && ((error = git_signature_now(&who, "unknown", "unknown")) < 0)) return error; @@ -631,84 +571,33 @@ int git_reference_symbolic_set_target( typedef struct { const char *old_name; git_refname_t new_name; -} rename_cb_data; +} refs_update_head_payload; -static int update_wt_heads(git_repository *repo, const char *path, void *payload) +static int refs_update_head(git_repository *worktree, void *_payload) { - rename_cb_data *data = (rename_cb_data *) payload; - git_reference *head = NULL; - char *gitdir = NULL; + refs_update_head_payload *payload = (refs_update_head_payload *)_payload; + git_reference *head = NULL, *updated = NULL; int error; - if ((error = git_reference__read_head(&head, repo, path)) < 0) { - git_error_set(GIT_ERROR_REFERENCE, "could not read HEAD when renaming references"); + if ((error = git_reference_lookup(&head, worktree, GIT_HEAD_FILE)) < 0) goto out; - } - - if ((gitdir = git_path_dirname(path)) == NULL) { - error = -1; - goto out; - } if (git_reference_type(head) != GIT_REFERENCE_SYMBOLIC || - git__strcmp(head->target.symbolic, data->old_name) != 0) { - error = 0; + git__strcmp(git_reference_symbolic_target(head), payload->old_name) != 0) goto out; - } - /* Update HEAD it was pointing to the reference being renamed */ - if ((error = git_repository_create_head(gitdir, data->new_name)) < 0) { + /* Update HEAD if it was pointing to the reference being renamed */ + if ((error = git_reference_symbolic_set_target(&updated, head, payload->new_name, NULL)) < 0) { git_error_set(GIT_ERROR_REFERENCE, "failed to update HEAD after renaming reference"); goto out; } out: + git_reference_free(updated); git_reference_free(head); - git__free(gitdir); - return error; } -static int reference__rename(git_reference **out, git_reference *ref, const char *new_name, int force, - const git_signature *signature, const char *message) -{ - git_repository *repo; - git_refname_t normalized; - bool should_head_be_updated = false; - int error = 0; - - assert(ref && new_name && signature); - - repo = git_reference_owner(ref); - - if ((error = reference_normalize_for_repo( - normalized, repo, new_name, true)) < 0) - return error; - - /* Check if we have to update HEAD. */ - if ((error = git_branch_is_head(ref)) < 0) - return error; - - should_head_be_updated = (error > 0); - - if ((error = git_refdb_rename(out, ref->db, ref->name, normalized, force, signature, message)) < 0) - return error; - - /* Update HEAD if it was pointing to the reference being renamed */ - if (should_head_be_updated) { - error = git_repository_set_head(ref->db->repo, normalized); - } else { - rename_cb_data payload; - payload.old_name = ref->name; - memcpy(&payload.new_name, &normalized, sizeof(normalized)); - - error = git_repository_foreach_head(repo, update_wt_heads, 0, &payload); - } - - return error; -} - - int git_reference_rename( git_reference **out, git_reference *ref, @@ -716,17 +605,28 @@ int git_reference_rename( int force, const char *log_message) { - git_signature *who; + refs_update_head_payload payload; + git_signature *signature = NULL; + git_repository *repo; int error; assert(out && ref); - if ((error = git_reference__log_signature(&who, ref->db->repo)) < 0) - return error; + repo = git_reference_owner(ref); - error = reference__rename(out, ref, new_name, force, who, log_message); - git_signature_free(who); + if ((error = git_reference__log_signature(&signature, repo)) < 0 || + (error = reference_normalize_for_repo(payload.new_name, repo, new_name, true)) < 0 || + (error = git_refdb_rename(out, ref->db, ref->name, payload.new_name, force, signature, log_message)) < 0) + goto out; + payload.old_name = ref->name; + + /* We may have to update any HEAD that was pointing to the renamed reference. */ + if ((error = git_repository_foreach_worktree(repo, refs_update_head, &payload)) < 0) + goto out; + +out: + git_signature_free(signature); return error; } @@ -1154,40 +1054,6 @@ int git_reference_cmp( return git_oid__cmp(&ref1->target.oid, &ref2->target.oid); } -/** - * Get the end of a chain of references. If the final one is not - * found, we return the reference just before that. - */ -static int get_terminal(git_reference **out, git_repository *repo, const char *ref_name, int nesting) -{ - git_reference *ref; - int error = 0; - - if (nesting > MAX_NESTING_LEVEL) { - git_error_set(GIT_ERROR_REFERENCE, "reference chain too deep (%d)", nesting); - return GIT_ENOTFOUND; - } - - /* set to NULL to let the caller know that they're at the end of the chain */ - if ((error = git_reference_lookup(&ref, repo, ref_name)) < 0) { - *out = NULL; - return error; - } - - if (git_reference_type(ref) == GIT_REFERENCE_DIRECT) { - *out = ref; - error = 0; - } else { - error = get_terminal(out, repo, git_reference_symbolic_target(ref), nesting + 1); - if (error == GIT_ENOTFOUND && !*out) - *out = ref; - else - git_reference_free(ref); - } - - return error; -} - /* * Starting with the reference given by `ref_name`, follows symbolic * references until a direct reference is found and updated the OID @@ -1202,31 +1068,37 @@ int git_reference__update_terminal( { git_reference *ref = NULL, *ref2 = NULL; git_signature *who = NULL; + git_refdb *refdb = NULL; const git_signature *to_use; int error = 0; if (!sig && (error = git_reference__log_signature(&who, repo)) < 0) - return error; + goto out; to_use = sig ? sig : who; - error = get_terminal(&ref, repo, ref_name, 0); - /* found a dangling symref */ - if (error == GIT_ENOTFOUND && ref) { - assert(git_reference_type(ref) == GIT_REFERENCE_SYMBOLIC); - git_error_clear(); + if ((error = git_repository_refdb__weakptr(&refdb, repo)) < 0) + goto out; + + if ((error = git_refdb_resolve(&ref, refdb, ref_name, -1)) < 0) { + if (error == GIT_ENOTFOUND) { + git_error_clear(); + error = reference__create(&ref2, repo, ref_name, oid, NULL, 0, to_use, + log_message, NULL, NULL); + } + goto out; + } + + /* In case the resolved reference is symbolic, then it's a dangling symref. */ + if (git_reference_type(ref) == GIT_REFERENCE_SYMBOLIC) { error = reference__create(&ref2, repo, ref->target.symbolic, oid, NULL, 0, to_use, log_message, NULL, NULL); - } else if (error == GIT_ENOTFOUND) { - git_error_clear(); - error = reference__create(&ref2, repo, ref_name, oid, NULL, 0, to_use, - log_message, NULL, NULL); - } else if (error == 0) { - assert(git_reference_type(ref) == GIT_REFERENCE_DIRECT); + } else { error = reference__create(&ref2, repo, ref->name, oid, NULL, 1, to_use, log_message, &ref->target.oid, NULL); } +out: git_reference_free(ref2); git_reference_free(ref); git_signature_free(who); diff --git a/src/refs.h b/src/refs.h index adc345a12..e0ee03b0e 100644 --- a/src/refs.h +++ b/src/refs.h @@ -45,7 +45,6 @@ extern bool git_reference__enable_symbolic_ref_target_validation; #define GIT_REBASE_APPLY_DIR "rebase-apply/" #define GIT_REBASE_APPLY_REBASING_FILE GIT_REBASE_APPLY_DIR "rebasing" #define GIT_REBASE_APPLY_APPLYING_FILE GIT_REBASE_APPLY_DIR "applying" -#define GIT_REFS_HEADS_MASTER_FILE GIT_REFS_HEADS_DIR "master" #define GIT_SEQUENCER_DIR "sequencer/" #define GIT_SEQUENCER_HEAD_FILE GIT_SEQUENCER_DIR "head" @@ -90,6 +89,7 @@ int git_reference__is_valid_name(const char *refname, unsigned int flags); int git_reference__is_branch(const char *ref_name); int git_reference__is_remote(const char *ref_name); int git_reference__is_tag(const char *ref_name); +int git_reference__is_note(const char *ref_name); const char *git_reference__shorthand(const char *name); /** @@ -115,24 +115,6 @@ int git_reference_lookup_resolved( const char *name, int max_deref); -/** - * Read reference from a file. - * - * This function will read in the file at `path`. If it is a - * symref, it will return a new unresolved symbolic reference - * with the given name pointing to the reference pointed to by - * the file. If it is not a symbolic reference, it will return - * the resolved reference. - * - * Note that because the refdb is not involved for symbolic references, they - * won't be owned, hence you should either not make the returned reference - * 'externally visible', or perform the lookup before returning it to the user. - */ -int git_reference__read_head( - git_reference **out, - git_repository *repo, - const char *path); - int git_reference__log_signature(git_signature **out, git_repository *repo); /** Update a reference after a commit. */ diff --git a/src/regexp.c b/src/regexp.c index 5fe49f37e..c1b9ef4cd 100644 --- a/src/regexp.c +++ b/src/regexp.c @@ -12,7 +12,7 @@ int git_regexp_compile(git_regexp *r, const char *pattern, int flags) { int erroffset, cflags = 0; - const char *error; + const char *error = NULL; if (flags & GIT_REGEXP_ICASE) cflags |= PCRE_CASELESS; @@ -41,7 +41,7 @@ int git_regexp_match(const git_regexp *r, const char *string) int git_regexp_search(const git_regexp *r, const char *string, size_t nmatches, git_regmatch *matches) { - int static_ovec[9], *ovec; + int static_ovec[9] = {0}, *ovec; int error; size_t i; diff --git a/src/remote.c b/src/remote.c index 740dd9434..51e99dc94 100644 --- a/src/remote.c +++ b/src/remote.c @@ -195,10 +195,12 @@ int git_remote_create_options_init(git_remote_create_options *opts, unsigned int return 0; } +#ifndef GIT_DEPRECATE_HARD int git_remote_create_init_options(git_remote_create_options *opts, unsigned int version) { return git_remote_create_options_init(opts, version); } +#endif int git_remote_create_with_opts(git_remote **out, const char *url, const git_remote_create_options *opts) { @@ -686,7 +688,7 @@ int git_remote__urlfordirection(git_buf *url_out, struct git_remote *remote, int return resolve_url(url_out, url, direction, callbacks); } -int set_transport_callbacks(git_transport *t, const git_remote_callbacks *cbs) +static int remote_transport_set_callbacks(git_transport *t, const git_remote_callbacks *cbs) { if (!t->set_callbacks || !cbs) return 0; @@ -744,7 +746,7 @@ int git_remote__connect(git_remote *remote, git_direction direction, const git_r if ((error = set_transport_custom_headers(t, conn->custom_headers)) != 0) goto on_error; - if ((error = set_transport_callbacks(t, callbacks)) < 0 || + if ((error = remote_transport_set_callbacks(t, callbacks)) < 0 || (error = t->connect(t, url.ptr, credentials, payload, conn->proxy, direction, flags)) != 0) goto on_error; @@ -1237,7 +1239,7 @@ static int prune_candidates(git_vector *candidates, git_remote *remote) } out: - git_strarray_free(&arr); + git_strarray_dispose(&arr); return error; } @@ -2373,29 +2375,36 @@ int git_remote_default_branch(git_buf *out, git_remote *remote) const git_remote_head *guess = NULL; const git_oid *head_id; size_t heads_len, i; + git_buf local_default = GIT_BUF_INIT; int error; assert(out); if ((error = git_remote_ls(&heads, &heads_len, remote)) < 0) - return error; + goto done; - if (heads_len == 0) - return GIT_ENOTFOUND; - - if (strcmp(heads[0]->name, GIT_HEAD_FILE)) - return GIT_ENOTFOUND; + if (heads_len == 0 || strcmp(heads[0]->name, GIT_HEAD_FILE)) { + error = GIT_ENOTFOUND; + goto done; + } git_buf_sanitize(out); + /* the first one must be HEAD so if that has the symref info, we're done */ - if (heads[0]->symref_target) - return git_buf_puts(out, heads[0]->symref_target); + if (heads[0]->symref_target) { + error = git_buf_puts(out, heads[0]->symref_target); + goto done; + } /* * If there's no symref information, we have to look over them - * and guess. We return the first match unless the master - * branch is a candidate. Then we return the master branch. + * and guess. We return the first match unless the default + * branch is a candidate. Then we return the default branch. */ + + if ((error = git_repository_initialbranch(&local_default, remote->repo)) < 0) + goto done; + head_id = &heads[0]->oid; for (i = 1; i < heads_len; i++) { @@ -2410,16 +2419,22 @@ int git_remote_default_branch(git_buf *out, git_remote *remote) continue; } - if (!git__strcmp(GIT_REFS_HEADS_MASTER_FILE, heads[i]->name)) { + if (!git__strcmp(local_default.ptr, heads[i]->name)) { guess = heads[i]; break; } } - if (!guess) - return GIT_ENOTFOUND; + if (!guess) { + error = GIT_ENOTFOUND; + goto done; + } - return git_buf_puts(out, guess->name); + error = git_buf_puts(out, guess->name); + +done: + git_buf_dispose(&local_default); + return error; } int git_remote_upload(git_remote *remote, const git_strarray *refspecs, const git_push_options *opts) diff --git a/src/repository.c b/src/repository.c index fe0d696c6..513dbd61f 100644 --- a/src/repository.c +++ b/src/repository.c @@ -62,16 +62,18 @@ static const struct { { GIT_REPOSITORY_ITEM_COMMONDIR, GIT_REPOSITORY_ITEM_GITDIR, "worktrees", true } }; -static int check_repositoryformatversion(git_config *config); +static int check_repositoryformatversion(int *version, git_config *config); +static int check_extensions(git_config *config, int version); #define GIT_COMMONDIR_FILE "commondir" #define GIT_GITDIR_FILE "gitdir" #define GIT_FILE_CONTENT_PREFIX "gitdir:" -#define GIT_BRANCH_MASTER "master" +#define GIT_BRANCH_DEFAULT "master" #define GIT_REPO_VERSION 0 +#define GIT_REPO_MAX_VERSION 1 git_buf git_repository__reserved_names_win32[] = { { DOT_GIT, 0, CONST_STRLEN(DOT_GIT) }, @@ -813,6 +815,7 @@ int git_repository_open_ext( gitlink = GIT_BUF_INIT, commondir = GIT_BUF_INIT; git_repository *repo = NULL; git_config *config = NULL; + int version = 0; if (flags & GIT_REPOSITORY_OPEN_FROM_ENV) return _git_repository_open_ext_from_env(repo_ptr, start_path); @@ -854,7 +857,10 @@ int git_repository_open_ext( if (error < 0 && error != GIT_ENOTFOUND) goto cleanup; - if (config && (error = check_repositoryformatversion(config)) < 0) + if (config && (error = check_repositoryformatversion(&version, config)) < 0) + goto cleanup; + + if ((error = check_extensions(config, version)) < 0) goto cleanup; if ((flags & GIT_REPOSITORY_OPEN_BARE) != 0) @@ -1350,11 +1356,11 @@ bool git_repository__reserved_names( } #endif -static int check_repositoryformatversion(git_config *config) +static int check_repositoryformatversion(int *version, git_config *config) { - int version, error; + int error; - error = git_config_get_int32(&version, config, "core.repositoryformatversion"); + error = git_config_get_int32(version, config, "core.repositoryformatversion"); /* git ignores this if the config variable isn't there */ if (error == GIT_ENOTFOUND) return 0; @@ -1362,16 +1368,35 @@ static int check_repositoryformatversion(git_config *config) if (error < 0) return -1; - if (GIT_REPO_VERSION < version) { + if (GIT_REPO_MAX_VERSION < *version) { git_error_set(GIT_ERROR_REPOSITORY, - "unsupported repository version %d. Only versions up to %d are supported.", - version, GIT_REPO_VERSION); + "unsupported repository version %d; only versions up to %d are supported", + *version, GIT_REPO_MAX_VERSION); return -1; } return 0; } +static int check_valid_extension(const git_config_entry *entry, void *payload) +{ + GIT_UNUSED(payload); + + if (!strcmp(entry->name, "extensions.noop")) + return 0; + + git_error_set(GIT_ERROR_REPOSITORY, "unsupported extension name %s", entry->name); + return -1; +} + +static int check_extensions(git_config *config, int version) +{ + if (version < 1) + return 0; + + return git_config_foreach_match(config, "^extensions\\.", check_valid_extension, NULL); +} + int git_repository_create_head(const char *git_dir, const char *ref_name) { git_buf ref_path = GIT_BUF_INIT; @@ -1383,9 +1408,6 @@ int git_repository_create_head(const char *git_dir, const char *ref_name) (error = git_filebuf_open(&ref, ref_path.ptr, 0, GIT_REFS_FILE_MODE)) < 0) goto out; - if (!ref_name) - ref_name = GIT_BRANCH_MASTER; - if (git__prefixcmp(ref_name, GIT_REFS_DIR) == 0) fmt = "ref: %s\n"; else @@ -1583,11 +1605,15 @@ static int repo_init_config( git_config *config = NULL; bool is_bare = ((flags & GIT_REPOSITORY_INIT_BARE) != 0); bool is_reinit = ((flags & GIT_REPOSITORY_INIT__IS_REINIT) != 0); + int version = 0; if ((error = repo_local_config(&config, &cfg_path, NULL, repo_dir)) < 0) goto cleanup; - if (is_reinit && (error = check_repositoryformatversion(config)) < 0) + if (is_reinit && (error = check_repositoryformatversion(&version, config)) < 0) + goto cleanup; + + if ((error = check_extensions(config, version)) < 0) goto cleanup; #define SET_REPO_CONFIG(TYPE, NAME, VAL) do { \ @@ -2032,6 +2058,43 @@ static int repo_init_directories( return error; } +static int repo_init_head(const char *repo_dir, const char *given) +{ + git_config *cfg = NULL; + git_buf head_path = GIT_BUF_INIT, cfg_branch = GIT_BUF_INIT; + const char *initial_head = NULL; + int error; + + if ((error = git_buf_joinpath(&head_path, repo_dir, GIT_HEAD_FILE)) < 0) + goto out; + + /* + * A template may have set a HEAD; use that unless it's been + * overridden by the caller's given initial head setting. + */ + if (git_path_exists(head_path.ptr) && !given) + goto out; + + if (given) { + initial_head = given; + } else if ((error = git_config_open_default(&cfg)) >= 0 && + (error = git_config_get_string_buf(&cfg_branch, cfg, "init.defaultbranch")) >= 0) { + initial_head = cfg_branch.ptr; + } + + if (!initial_head) + initial_head = GIT_BRANCH_DEFAULT; + + error = git_repository_create_head(repo_dir, initial_head); + +out: + git_config_free(cfg); + git_buf_dispose(&head_path); + git_buf_dispose(&cfg_branch); + + return error; +} + static int repo_init_create_origin(git_repository *repo, const char *url) { int error; @@ -2062,7 +2125,7 @@ int git_repository_init_ext( git_repository_init_options *opts) { git_buf repo_path = GIT_BUF_INIT, wd_path = GIT_BUF_INIT, - common_path = GIT_BUF_INIT, head_path = GIT_BUF_INIT; + common_path = GIT_BUF_INIT; const char *wd; bool is_valid; int error; @@ -2096,16 +2159,7 @@ int git_repository_init_ext( } else { if ((error = repo_init_structure(repo_path.ptr, wd, opts)) < 0 || (error = repo_init_config(repo_path.ptr, wd, opts->flags, opts->mode)) < 0 || - (error = git_buf_joinpath(&head_path, repo_path.ptr, GIT_HEAD_FILE)) < 0) - goto out; - - /* - * Only set the new HEAD if the file does not exist already via - * a template or if the caller has explicitly supplied an - * initial HEAD value. - */ - if ((!git_path_exists(head_path.ptr) || opts->initial_head) && - (error = git_repository_create_head(repo_path.ptr, opts->initial_head)) < 0) + (error = repo_init_head(repo_path.ptr, opts->initial_head)) < 0) goto out; } @@ -2117,7 +2171,6 @@ int git_repository_init_ext( goto out; out: - git_buf_dispose(&head_path); git_buf_dispose(&common_path); git_buf_dispose(&repo_path); git_buf_dispose(&wd_path); @@ -2148,12 +2201,6 @@ int git_repository_head_detached(git_repository *repo) return exists; } -static int get_worktree_file_path(git_buf *out, git_repository *repo, const char *worktree, const char *file) -{ - git_buf_clear(out); - return git_buf_printf(out, "%s/worktrees/%s/%s", repo->commondir, worktree, file); -} - int git_repository_head_detached_for_worktree(git_repository *repo, const char *name) { git_reference *ref = NULL; @@ -2194,7 +2241,8 @@ int git_repository_head(git_reference **head_out, git_repository *repo) int git_repository_head_for_worktree(git_reference **out, git_repository *repo, const char *name) { - git_buf path = GIT_BUF_INIT; + git_repository *worktree_repo = NULL; + git_worktree *worktree = NULL; git_reference *head = NULL; int error; @@ -2202,65 +2250,68 @@ int git_repository_head_for_worktree(git_reference **out, git_repository *repo, *out = NULL; - if ((error = get_worktree_file_path(&path, repo, name, GIT_HEAD_FILE)) < 0 || - (error = git_reference__read_head(&head, repo, path.ptr)) < 0) + if ((error = git_worktree_lookup(&worktree, repo, name)) < 0 || + (error = git_repository_open_from_worktree(&worktree_repo, worktree)) < 0 || + (error = git_reference_lookup(&head, worktree_repo, GIT_HEAD_FILE)) < 0) goto out; if (git_reference_type(head) != GIT_REFERENCE_DIRECT) { - git_reference *resolved; - - error = git_reference_lookup_resolved(&resolved, repo, git_reference_symbolic_target(head), -1); - git_reference_free(head); - head = resolved; + if ((error = git_reference_lookup_resolved(out, worktree_repo, git_reference_symbolic_target(head), -1)) < 0) + goto out; + } else { + *out = head; + head = NULL; } - *out = head; - out: - if (error) - git_reference_free(head); - - git_buf_dispose(&path); - + git_reference_free(head); + git_worktree_free(worktree); + git_repository_free(worktree_repo); return error; } -int git_repository_foreach_head(git_repository *repo, - git_repository_foreach_head_cb cb, - int flags, void *payload) +int git_repository_foreach_worktree(git_repository *repo, + git_repository_foreach_worktree_cb cb, + void *payload) { - git_strarray worktrees = GIT_VECTOR_INIT; - git_buf path = GIT_BUF_INIT; - int error = 0; + git_strarray worktrees = {0}; + git_repository *worktree_repo = NULL; + git_worktree *worktree = NULL; + int error; size_t i; + if ((error = git_repository_open(&worktree_repo, repo->commondir)) < 0 || + (error = cb(worktree_repo, payload) != 0)) + goto out; - if (!(flags & GIT_REPOSITORY_FOREACH_HEAD_SKIP_REPO)) { - /* Gather HEAD of main repository */ - if ((error = git_buf_joinpath(&path, repo->commondir, GIT_HEAD_FILE)) < 0 || - (error = cb(repo, path.ptr, payload) != 0)) - goto out; - } + git_repository_free(worktree_repo); + worktree_repo = NULL; - if (!(flags & GIT_REPOSITORY_FOREACH_HEAD_SKIP_WORKTREES)) { - if ((error = git_worktree_list(&worktrees, repo)) < 0) { - error = 0; - goto out; - } + if ((error = git_worktree_list(&worktrees, repo)) < 0) + goto out; - /* Gather HEADs of all worktrees */ - for (i = 0; i < worktrees.count; i++) { - if (get_worktree_file_path(&path, repo, worktrees.strings[i], GIT_HEAD_FILE) < 0) - continue; + for (i = 0; i < worktrees.count; i++) { + git_repository_free(worktree_repo); + worktree_repo = NULL; + git_worktree_free(worktree); + worktree = NULL; - if ((error = cb(repo, path.ptr, payload)) != 0) + if ((error = git_worktree_lookup(&worktree, repo, worktrees.strings[i]) < 0) || + (error = git_repository_open_from_worktree(&worktree_repo, worktree)) < 0) { + if (error != GIT_ENOTFOUND) goto out; + error = 0; + continue; } + + if ((error = cb(worktree_repo, payload)) != 0) + goto out; } out: - git_buf_dispose(&path); - git_strarray_free(&worktrees); + git_strarray_dispose(&worktrees); + git_repository_free(worktree_repo); + git_worktree_free(worktree); return error; } @@ -2303,23 +2354,59 @@ static int repo_contains_no_reference(git_repository *repo) return error; } +int git_repository_initialbranch(git_buf *out, git_repository *repo) +{ + git_config *config; + git_config_entry *entry = NULL; + const char *branch; + int error; + + if ((error = git_repository_config__weakptr(&config, repo)) < 0) + return error; + + if ((error = git_config_get_entry(&entry, config, "init.defaultbranch")) == 0) { + branch = entry->value; + } + else if (error == GIT_ENOTFOUND) { + branch = GIT_BRANCH_DEFAULT; + } + else { + goto done; + } + + if ((error = git_buf_puts(out, GIT_REFS_HEADS_DIR)) < 0 || + (error = git_buf_puts(out, branch)) < 0) + goto done; + + if (!git_reference_is_valid_name(out->ptr)) { + git_error_set(GIT_ERROR_INVALID, "the value of init.defaultBranch is not a valid reference name"); + error = -1; + } + +done: + git_config_entry_free(entry); + return error; +} + int git_repository_is_empty(git_repository *repo) { git_reference *head = NULL; - int is_empty = 0; + git_buf initialbranch = GIT_BUF_INIT; + int result = 0; - if (git_reference_lookup(&head, repo, GIT_HEAD_FILE) < 0) - return -1; + if ((result = git_reference_lookup(&head, repo, GIT_HEAD_FILE)) < 0 || + (result = git_repository_initialbranch(&initialbranch, repo)) < 0) + goto done; - if (git_reference_type(head) == GIT_REFERENCE_SYMBOLIC) - is_empty = - (strcmp(git_reference_symbolic_target(head), - GIT_REFS_HEADS_DIR "master") == 0) && - repo_contains_no_reference(repo); + result = (git_reference_type(head) == GIT_REFERENCE_SYMBOLIC && + strcmp(git_reference_symbolic_target(head), initialbranch.ptr) == 0 && + repo_contains_no_reference(repo)); +done: git_reference_free(head); + git_buf_dispose(&initialbranch); - return is_empty; + return result; } static const char *resolved_parent_path(const git_repository *repo, git_repository_item_t item, git_repository_item_t fallback) @@ -2899,11 +2986,13 @@ int git_repository_init_options_init( return 0; } +#ifndef GIT_DEPRECATE_HARD int git_repository_init_init_options( git_repository_init_options *opts, unsigned int version) { return git_repository_init_options_init(opts, version); } +#endif int git_repository_ident(const char **name, const char **email, const git_repository *repo) { diff --git a/src/repository.h b/src/repository.h index bafdb5896..de009ba5e 100644 --- a/src/repository.h +++ b/src/repository.h @@ -166,34 +166,11 @@ GIT_INLINE(git_attr_cache *) git_repository_attr_cache(git_repository *repo) int git_repository_head_tree(git_tree **tree, git_repository *repo); int git_repository_create_head(const char *git_dir, const char *ref_name); -/* - * Called for each HEAD. - * - * Can return either 0, causing the iteration over HEADs to - * continue, or a non-0 value causing the iteration to abort. The - * return value is passed back to the caller of - * `git_repository_foreach_head` - */ -typedef int (*git_repository_foreach_head_cb)(git_repository *repo, const char *path, void *payload); +typedef int (*git_repository_foreach_worktree_cb)(git_repository *, void *); -enum { - /* Skip enumeration of the main repository HEAD */ - GIT_REPOSITORY_FOREACH_HEAD_SKIP_REPO = (1u << 0), - /* Skip enumeration of worktree HEADs */ - GIT_REPOSITORY_FOREACH_HEAD_SKIP_WORKTREES = (1u << 1), -}; - -/* - * Iterate over repository and all worktree HEADs. - * - * This function will be called for the repository HEAD and for - * all HEADS of linked worktrees. For each HEAD, the callback is - * executed with the given payload. The return value equals the - * return value of the last executed callback function. - */ -int git_repository_foreach_head(git_repository *repo, - git_repository_foreach_head_cb cb, - int flags, void *payload); +int git_repository_foreach_worktree(git_repository *repo, + git_repository_foreach_worktree_cb cb, + void *payload); /* * Weak pointers to repository internals. @@ -255,4 +232,10 @@ extern size_t git_repository__reserved_names_posix_len; bool git_repository__reserved_names( git_buf **out, size_t *outlen, git_repository *repo, bool include_ntfs); +/* + * The default branch for the repository; the `init.defaultBranch` + * configuration option, if set, or `master` if it is not. + */ +int git_repository_initialbranch(git_buf *out, git_repository *repo); + #endif diff --git a/src/revert.c b/src/revert.c index b41a2a131..b84bc7d79 100644 --- a/src/revert.c +++ b/src/revert.c @@ -231,7 +231,9 @@ int git_revert_options_init(git_revert_options *opts, unsigned int version) return 0; } +#ifndef GIT_DEPRECATE_HARD int git_revert_init_options(git_revert_options *opts, unsigned int version) { return git_revert_options_init(opts, version); } +#endif diff --git a/src/revparse.c b/src/revparse.c index c627de67c..1cc8b97f5 100644 --- a/src/revparse.c +++ b/src/revparse.c @@ -537,7 +537,8 @@ static int extract_curly_braces_content(git_buf *buf, const char *spec, size_t * if (spec[*pos] == '\0') return GIT_EINVALIDSPEC; - git_buf_putc(buf, spec[(*pos)++]); + if (git_buf_putc(buf, spec[(*pos)++]) < 0) + return -1; } (*pos)++; @@ -585,7 +586,7 @@ static int extract_how_many(int *n, const char *spec, size_t *pos) *pos = end_ptr - spec; } - } while (spec[(*pos)] == kind && kind == '~'); + } while (spec[(*pos)] == kind && kind == '~'); *n = accumulated; @@ -659,7 +660,7 @@ static int ensure_left_hand_identifier_is_not_known_yet(git_object *object, git_ return GIT_EINVALIDSPEC; } -int revparse__ext( +static int revparse( git_object **object_out, git_reference **reference_out, size_t *identifier_len_out, @@ -835,7 +836,7 @@ int git_revparse_ext( git_object *obj = NULL; git_reference *ref = NULL; - if ((error = revparse__ext(&obj, &ref, &identifier_len, repo, spec)) < 0) + if ((error = revparse(&obj, &ref, &identifier_len, repo, spec)) < 0) goto cleanup; *object_out = obj; diff --git a/src/revwalk.c b/src/revwalk.c index abbd65ac2..1efb938bd 100644 --- a/src/revwalk.c +++ b/src/revwalk.c @@ -659,13 +659,11 @@ int git_revwalk_new(git_revwalk **revwalk_out, git_repository *repo) git_revwalk *walk = git__calloc(1, sizeof(git_revwalk)); GIT_ERROR_CHECK_ALLOC(walk); - if (git_oidmap_new(&walk->commits) < 0) + if (git_oidmap_new(&walk->commits) < 0 || + git_pqueue_init(&walk->iterator_time, 0, 8, git_commit_list_time_cmp) < 0 || + git_pool_init(&walk->commit_pool, COMMIT_ALLOC) < 0) return -1; - if (git_pqueue_init(&walk->iterator_time, 0, 8, git_commit_list_time_cmp) < 0) - return -1; - - git_pool_init(&walk->commit_pool, COMMIT_ALLOC); walk->get_next = &revwalk_next_unsorted; walk->enqueue = &revwalk_enqueue_unsorted; diff --git a/src/settings.c b/src/settings.c index f9f6b8497..69ebcb7ab 100644 --- a/src/settings.c +++ b/src/settings.c @@ -59,6 +59,7 @@ int git_libgit2_features(void) /* Declarations for tuneable settings */ extern size_t git_mwindow__window_size; extern size_t git_mwindow__mapped_limit; +extern size_t git_mwindow__file_limit; extern size_t git_indexer__max_objects; extern bool git_disable_pack_keep_file_checks; @@ -124,6 +125,14 @@ int git_libgit2_opts(int key, ...) *(va_arg(ap, size_t *)) = git_mwindow__mapped_limit; break; + case GIT_OPT_SET_MWINDOW_FILE_LIMIT: + git_mwindow__file_limit = va_arg(ap, size_t); + break; + + case GIT_OPT_GET_MWINDOW_FILE_LIMIT: + *(va_arg(ap, size_t *)) = git_mwindow__file_limit; + break; + case GIT_OPT_GET_SEARCH_PATH: if ((error = config_level_to_sysdir(va_arg(ap, int))) >= 0) { git_buf *out = va_arg(ap, git_buf *); diff --git a/src/sortedcache.c b/src/sortedcache.c index 8f7ea23e2..ee6363f6d 100644 --- a/src/sortedcache.c +++ b/src/sortedcache.c @@ -25,9 +25,8 @@ int git_sortedcache_new( sc = git__calloc(1, alloclen); GIT_ERROR_CHECK_ALLOC(sc); - git_pool_init(&sc->pool, 1); - - if (git_vector_init(&sc->items, 4, item_cmp) < 0 || + if (git_pool_init(&sc->pool, 1) < 0 || + git_vector_init(&sc->items, 4, item_cmp) < 0 || git_strmap_new(&sc->map) < 0) goto fail; diff --git a/src/stash.c b/src/stash.c index 790f56fdd..0d5dc4351 100644 --- a/src/stash.c +++ b/src/stash.c @@ -776,10 +776,12 @@ int git_stash_apply_options_init(git_stash_apply_options *opts, unsigned int ver return 0; } +#ifndef GIT_DEPRECATE_HARD int git_stash_apply_init_options(git_stash_apply_options *opts, unsigned int version) { return git_stash_apply_options_init(opts, version); } +#endif #define NOTIFY_PROGRESS(opts, progress_type) \ do { \ diff --git a/src/status.c b/src/status.c index 6a1284415..eca1f4912 100644 --- a/src/status.c +++ b/src/status.c @@ -548,10 +548,12 @@ int git_status_options_init(git_status_options *opts, unsigned int version) return 0; } +#ifndef GIT_DEPRECATE_HARD int git_status_init_options(git_status_options *opts, unsigned int version) { return git_status_options_init(opts, version); } +#endif int git_status_list_get_perfdata( git_diff_perfdata *out, const git_status_list *status) diff --git a/src/strarray.c b/src/strarray.c new file mode 100644 index 000000000..54fe9fbfb --- /dev/null +++ b/src/strarray.c @@ -0,0 +1,63 @@ +/* + * 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 "util.h" + +#include "common.h" + +int git_strarray_copy(git_strarray *tgt, const git_strarray *src) +{ + size_t i; + + assert(tgt && src); + + memset(tgt, 0, sizeof(*tgt)); + + if (!src->count) + return 0; + + tgt->strings = git__calloc(src->count, sizeof(char *)); + GIT_ERROR_CHECK_ALLOC(tgt->strings); + + for (i = 0; i < src->count; ++i) { + if (!src->strings[i]) + continue; + + tgt->strings[tgt->count] = git__strdup(src->strings[i]); + if (!tgt->strings[tgt->count]) { + git_strarray_dispose(tgt); + memset(tgt, 0, sizeof(*tgt)); + return -1; + } + + tgt->count++; + } + + return 0; +} + +void git_strarray_dispose(git_strarray *array) +{ + size_t i; + + if (array == NULL) + return; + + for (i = 0; i < array->count; ++i) + git__free(array->strings[i]); + + git__free(array->strings); + + memset(array, 0, sizeof(*array)); +} + +#ifndef GIT_DEPRECATE_HARD +void git_strarray_free(git_strarray *array) +{ + git_strarray_dispose(array); +} +#endif diff --git a/src/streams/openssl.c b/src/streams/openssl.c index 5b66352ca..6a490d17d 100644 --- a/src/streams/openssl.c +++ b/src/streams/openssl.c @@ -655,15 +655,16 @@ static int openssl_connect(git_stream *stream) static int openssl_certificate(git_cert **out, git_stream *stream) { openssl_stream *st = (openssl_stream *) stream; - int len; X509 *cert = SSL_get_peer_certificate(st->ssl); - unsigned char *guard, *encoded_cert; + unsigned char *guard, *encoded_cert = NULL; + int error, len; /* Retrieve the length of the certificate first */ len = i2d_X509(cert, NULL); if (len < 0) { git_error_set(GIT_ERROR_NET, "failed to retrieve certificate information"); - return -1; + error = -1; + goto out; } encoded_cert = git__malloc(len); @@ -673,18 +674,23 @@ static int openssl_certificate(git_cert **out, git_stream *stream) len = i2d_X509(cert, &guard); if (len < 0) { - git__free(encoded_cert); git_error_set(GIT_ERROR_NET, "failed to retrieve certificate information"); - return -1; + error = -1; + goto out; } st->cert_info.parent.cert_type = GIT_CERT_X509; st->cert_info.data = encoded_cert; st->cert_info.len = len; + encoded_cert = NULL; *out = &st->cert_info.parent; + error = 0; - return 0; +out: + git__free(encoded_cert); + X509_free(cert); + return error; } static int openssl_set_proxy(git_stream *stream, const git_proxy_options *proxy_opts) diff --git a/src/streams/registry.c b/src/streams/registry.c index 330032005..284431207 100644 --- a/src/streams/registry.c +++ b/src/streams/registry.c @@ -5,9 +5,10 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#include "git2/errors.h" - #include "common.h" + +#include "streams/registry.h" + #include "global.h" #include "streams/tls.h" #include "streams/mbedtls.h" @@ -100,7 +101,7 @@ int git_stream_register(git_stream_t type, git_stream_registration *registration return 0; } - +#ifndef GIT_DEPRECATE_HARD int git_stream_register_tls( int GIT_CALLBACK(ctor)(git_stream **out, const char *host, const char *port)) { @@ -116,3 +117,4 @@ int git_stream_register_tls( return git_stream_register(GIT_STREAM_TLS, NULL); } } +#endif diff --git a/src/submodule.c b/src/submodule.c index 1690e08f8..c32b9770a 100644 --- a/src/submodule.c +++ b/src/submodule.c @@ -958,7 +958,7 @@ cleanup: return error; } -const char *git_submodule_update_to_str(git_submodule_update_t update) +static const char *submodule_update_to_str(git_submodule_update_t update) { int i; for (i = 0; i < (int)ARRAY_SIZE(_sm_update_map); ++i) @@ -1240,10 +1240,12 @@ int git_submodule_update_options_init(git_submodule_update_options *opts, unsign return 0; } +#ifndef GIT_DEPRECATE_HARD int git_submodule_update_init_options(git_submodule_update_options *opts, unsigned int version) { return git_submodule_update_options_init(opts, version); } +#endif int git_submodule_update(git_submodule *sm, int init, git_submodule_update_options *_update_options) { @@ -1401,7 +1403,7 @@ int git_submodule_init(git_submodule *sm, int overwrite) /* write "submodule.NAME.update" if not default */ val = (sm->update == GIT_SUBMODULE_UPDATE_CHECKOUT) ? - NULL : git_submodule_update_to_str(sm->update); + NULL : submodule_update_to_str(sm->update); if ((error = git_buf_printf(&key, "submodule.%s.update", sm->name)) < 0 || (error = git_config__update_entry( @@ -1838,7 +1840,7 @@ int git_submodule_parse_update(git_submodule_update_t *out, const char *value) return 0; } -int git_submodule_parse_recurse(git_submodule_recurse_t *out, const char *value) +static int submodule_parse_recurse(git_submodule_recurse_t *out, const char *value) { int val; @@ -1934,7 +1936,7 @@ static int submodule_read_config(git_submodule *sm, git_config *cfg) if ((error = get_value(&value, cfg, &key, sm->name, "fetchRecurseSubmodules")) == 0) { in_config = 1; - if ((error = git_submodule_parse_recurse(&sm->fetch_recurse, value)) < 0) + if ((error = submodule_parse_recurse(&sm->fetch_recurse, value)) < 0) goto cleanup; sm->fetch_recurse_default = sm->fetch_recurse; } else if (error != GIT_ENOTFOUND) { diff --git a/src/sysdir.c b/src/sysdir.c index 9e86dc88c..6dc78c8fd 100644 --- a/src/sysdir.c +++ b/src/sysdir.c @@ -216,25 +216,6 @@ int git_sysdir_get(const git_buf **out, git_sysdir_t which) return 0; } -int git_sysdir_get_str( - char *out, - size_t outlen, - git_sysdir_t which) -{ - const git_buf *path = NULL; - - GIT_ERROR_CHECK_ERROR(git_sysdir_check_selector(which)); - GIT_ERROR_CHECK_ERROR(git_sysdir_get(&path, which)); - - if (!out || path->size >= outlen) { - git_error_set(GIT_ERROR_NOMEMORY, "buffer is too short for the path"); - return GIT_EBUFS; - } - - git_buf_copy_cstr(out, outlen, path); - return 0; -} - #define PATH_MAGIC "$PATH" int git_sysdir_set(git_sysdir_t which, const char *search_path) @@ -317,8 +298,11 @@ static int git_sysdir_find_in_dirlist( } done: + if (name) + git_error_set(GIT_ERROR_OS, "the %s file '%s' doesn't exist", label, name); + else + git_error_set(GIT_ERROR_OS, "the %s directory doesn't exist", label); git_buf_dispose(path); - git_error_set(GIT_ERROR_OS, "the %s file '%s' doesn't exist", label, name); return GIT_ENOTFOUND; } diff --git a/src/sysdir.h b/src/sysdir.h index ce1b4dc71..cc5599e38 100644 --- a/src/sysdir.h +++ b/src/sysdir.h @@ -93,17 +93,6 @@ extern int git_sysdir_global_init(void); */ extern int git_sysdir_get(const git_buf **out, git_sysdir_t which); -/** - * Get search path into a preallocated buffer - * - * @param out String buffer to write into - * @param outlen Size of string buffer - * @param which Which search path to return - * @return 0 on success, GIT_EBUFS if out is too small, <0 on other failure - */ - -extern int git_sysdir_get_str(char *out, size_t outlen, git_sysdir_t which); - /** * Set search paths for global/system/xdg files * diff --git a/src/tag.c b/src/tag.c index a7a005ca1..037dc6664 100644 --- a/src/tag.c +++ b/src/tag.c @@ -524,7 +524,9 @@ int git_tag_peel(git_object **tag_target, const git_tag *tag) /* Deprecated Functions */ +#ifndef GIT_DEPRECATE_HARD int git_tag_create_frombuffer(git_oid *oid, git_repository *repo, const char *buffer, int allow_ref_overwrite) { return git_tag_create_from_buffer(oid, repo, buffer, allow_ref_overwrite); } +#endif diff --git a/src/thread-utils.h b/src/thread-utils.h index 035de699f..ecb4909f5 100644 --- a/src/thread-utils.h +++ b/src/thread-utils.h @@ -7,12 +7,30 @@ #ifndef INCLUDE_thread_utils_h__ #define INCLUDE_thread_utils_h__ -#if defined(__GNUC__) && defined(GIT_THREADS) +#if defined(GIT_THREADS) + +#if defined(__clang__) + +# if (__clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 1)) +# error Atomic primitives do not exist on this version of clang; configure libgit2 with -DTHREADSAFE=OFF +# else +# define GIT_BUILTIN_ATOMIC +# endif + +#elif defined(__GNUC__) + # if (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 1)) # error Atomic primitives do not exist on this version of gcc; configure libgit2 with -DTHREADSAFE=OFF +# elif (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) +# define GIT_BUILTIN_ATOMIC +# else +# define GIT_BUILTIN_SYNC # endif + #endif +#endif /* GIT_THREADS */ + /* Common operations even if threading has been disabled */ typedef struct { #if defined(GIT_WIN32) @@ -26,21 +44,25 @@ typedef struct { typedef struct { #if defined(GIT_WIN32) - __int64 val; + volatile __int64 val; #else - int64_t val; + volatile int64_t val; #endif } git_atomic64; typedef git_atomic64 git_atomic_ssize; +#define git_atomic_ssize_set git_atomic64_set #define git_atomic_ssize_add git_atomic64_add +#define git_atomic_ssize_get git_atomic64_get #else typedef git_atomic git_atomic_ssize; +#define git_atomic_ssize_set git_atomic_set #define git_atomic_ssize_add git_atomic_add +#define git_atomic_ssize_get git_atomic_get #endif @@ -56,7 +78,9 @@ GIT_INLINE(void) git_atomic_set(git_atomic *a, int val) { #if defined(GIT_WIN32) InterlockedExchange(&a->val, (LONG)val); -#elif defined(__GNUC__) +#elif defined(GIT_BUILTIN_ATOMIC) + __atomic_store_n(&a->val, val, __ATOMIC_SEQ_CST); +#elif defined(GIT_BUILTIN_SYNC) __sync_lock_test_and_set(&a->val, val); #else # error "Unsupported architecture for atomic operations" @@ -67,7 +91,9 @@ GIT_INLINE(int) git_atomic_inc(git_atomic *a) { #if defined(GIT_WIN32) return InterlockedIncrement(&a->val); -#elif defined(__GNUC__) +#elif defined(GIT_BUILTIN_ATOMIC) + return __atomic_add_fetch(&a->val, 1, __ATOMIC_SEQ_CST); +#elif defined(GIT_BUILTIN_SYNC) return __sync_add_and_fetch(&a->val, 1); #else # error "Unsupported architecture for atomic operations" @@ -78,7 +104,9 @@ GIT_INLINE(int) git_atomic_add(git_atomic *a, int32_t addend) { #if defined(GIT_WIN32) return InterlockedExchangeAdd(&a->val, addend); -#elif defined(__GNUC__) +#elif defined(GIT_BUILTIN_ATOMIC) + return __atomic_add_fetch(&a->val, addend, __ATOMIC_SEQ_CST); +#elif defined(GIT_BUILTIN_SYNC) return __sync_add_and_fetch(&a->val, addend); #else # error "Unsupported architecture for atomic operations" @@ -89,25 +117,45 @@ GIT_INLINE(int) git_atomic_dec(git_atomic *a) { #if defined(GIT_WIN32) return InterlockedDecrement(&a->val); -#elif defined(__GNUC__) +#elif defined(GIT_BUILTIN_ATOMIC) + return __atomic_sub_fetch(&a->val, 1, __ATOMIC_SEQ_CST); +#elif defined(GIT_BUILTIN_SYNC) return __sync_sub_and_fetch(&a->val, 1); #else # error "Unsupported architecture for atomic operations" #endif } +GIT_INLINE(int) git_atomic_get(git_atomic *a) +{ +#if defined(GIT_WIN32) + return (int)InterlockedCompareExchange(&a->val, 0, 0); +#elif defined(GIT_BUILTIN_ATOMIC) + return __atomic_load_n(&a->val, __ATOMIC_SEQ_CST); +#elif defined(GIT_BUILTIN_SYNC) + return __sync_val_compare_and_swap(&a->val, 0, 0); +#else +# error "Unsupported architecture for atomic operations" +#endif +} + GIT_INLINE(void *) git___compare_and_swap( void * volatile *ptr, void *oldval, void *newval) { - volatile void *foundval; #if defined(GIT_WIN32) + volatile void *foundval; foundval = InterlockedCompareExchangePointer((volatile PVOID *)ptr, newval, oldval); -#elif defined(__GNUC__) + return (foundval == oldval) ? oldval : newval; +#elif defined(GIT_BUILTIN_ATOMIC) + bool success = __atomic_compare_exchange(ptr, &oldval, &newval, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); + return success ? oldval : newval; +#elif defined(GIT_BUILTIN_SYNC) + volatile void *foundval; foundval = __sync_val_compare_and_swap(ptr, oldval, newval); + return (foundval == oldval) ? oldval : newval; #else # error "Unsupported architecture for atomic operations" #endif - return (foundval == oldval) ? oldval : newval; } GIT_INLINE(volatile void *) git___swap( @@ -115,8 +163,30 @@ GIT_INLINE(volatile void *) git___swap( { #if defined(GIT_WIN32) return InterlockedExchangePointer(ptr, newval); -#else +#elif defined(GIT_BUILTIN_ATOMIC) + void * volatile foundval; + __atomic_exchange(ptr, &newval, &foundval, __ATOMIC_SEQ_CST); + return foundval; +#elif defined(GIT_BUILTIN_SYNC) return __sync_lock_test_and_set(ptr, newval); +#else +# error "Unsupported architecture for atomic operations" +#endif +} + +GIT_INLINE(volatile void *) git___load(void * volatile *ptr) +{ +#if defined(GIT_WIN32) + void *newval = NULL, *oldval = NULL; + volatile void *foundval = NULL; + foundval = InterlockedCompareExchangePointer((volatile PVOID *)ptr, newval, oldval); + return foundval; +#elif defined(GIT_BUILTIN_ATOMIC) + return (volatile void *)__atomic_load_n(ptr, __ATOMIC_SEQ_CST); +#elif defined(GIT_BUILTIN_SYNC) + return (volatile void *)__sync_val_compare_and_swap(ptr, 0, 0); +#else +# error "Unsupported architecture for atomic operations" #endif } @@ -126,13 +196,41 @@ GIT_INLINE(int64_t) git_atomic64_add(git_atomic64 *a, int64_t addend) { #if defined(GIT_WIN32) return InterlockedExchangeAdd64(&a->val, addend); -#elif defined(__GNUC__) +#elif defined(GIT_BUILTIN_ATOMIC) + return __atomic_add_fetch(&a->val, addend, __ATOMIC_SEQ_CST); +#elif defined(GIT_BUILTIN_SYNC) return __sync_add_and_fetch(&a->val, addend); #else # error "Unsupported architecture for atomic operations" #endif } +GIT_INLINE(void) git_atomic64_set(git_atomic64 *a, int64_t val) +{ +#if defined(GIT_WIN32) + InterlockedExchange64(&a->val, val); +#elif defined(GIT_BUILTIN_ATOMIC) + __atomic_store_n(&a->val, val, __ATOMIC_SEQ_CST); +#elif defined(GIT_BUILTIN_SYNC) + __sync_lock_test_and_set(&a->val, val); +#else +# error "Unsupported architecture for atomic operations" +#endif +} + +GIT_INLINE(int64_t) git_atomic64_get(git_atomic64 *a) +{ +#if defined(GIT_WIN32) + return (int64_t)InterlockedCompareExchange64(&a->val, 0, 0); +#elif defined(GIT_BUILTIN_ATOMIC) + return __atomic_load_n(&a->val, __ATOMIC_SEQ_CST); +#elif defined(GIT_BUILTIN_SYNC) + return __sync_val_compare_and_swap(&a->val, 0, 0); +#else +# error "Unsupported architecture for atomic operations" +#endif +} + #endif #else @@ -190,6 +288,11 @@ GIT_INLINE(int) git_atomic_dec(git_atomic *a) return --a->val; } +GIT_INLINE(int) git_atomic_get(git_atomic *a) +{ + return (int)a->val; +} + GIT_INLINE(void *) git___compare_and_swap( void * volatile *ptr, void *oldval, void *newval) { @@ -216,15 +319,20 @@ GIT_INLINE(int64_t) git_atomic64_add(git_atomic64 *a, int64_t addend) return a->val; } -#endif - -#endif - -GIT_INLINE(int) git_atomic_get(git_atomic *a) +GIT_INLINE(void) git_atomic64_set(git_atomic64 *a, int64_t val) { - return (int)a->val; + a->val = val; } +GIT_INLINE(int64_t) git_atomic64_get(git_atomic64 *a) +{ + return (int64_t)a->val; +} + +#endif + +#endif + /* Atomically replace oldval with newval * @return oldval if it was replaced or newval if it was not */ @@ -233,14 +341,24 @@ GIT_INLINE(int) git_atomic_get(git_atomic *a) #define git__swap(ptr, val) (void *)git___swap((void * volatile *)&ptr, val) +#define git__load(ptr) (void *)git___load((void * volatile *)&ptr) + extern int git_online_cpus(void); -#if defined(GIT_THREADS) && defined(_MSC_VER) -# define GIT_MEMORY_BARRIER MemoryBarrier() -#elif defined(GIT_THREADS) -# define GIT_MEMORY_BARRIER __sync_synchronize() +#if defined(GIT_THREADS) + +# if defined(GIT_WIN32) +# define GIT_MEMORY_BARRIER MemoryBarrier() +# elif defined(GIT_BUILTIN_ATOMIC) +# define GIT_MEMORY_BARRIER __atomic_thread_fence(__ATOMIC_SEQ_CST) +# elif defined(GIT_BUILTIN_SYNC) +# define GIT_MEMORY_BARRIER __sync_synchronize() +# endif + #else + # define GIT_MEMORY_BARRIER /* noop */ + #endif #endif diff --git a/src/transaction.c b/src/transaction.c index 7367d1240..81af8d831 100644 --- a/src/transaction.c +++ b/src/transaction.c @@ -76,7 +76,8 @@ int git_transaction_new(git_transaction **out, git_repository *repo) assert(out && repo); - git_pool_init(&pool, 1); + if ((error = git_pool_init(&pool, 1)) < 0) + goto on_error; tx = git_pool_mallocz(&pool, sizeof(git_transaction)); if (!tx) { diff --git a/src/transports/credential.c b/src/transports/credential.c index 0cf50a029..7b2836445 100644 --- a/src/transports/credential.c +++ b/src/transports/credential.c @@ -391,6 +391,7 @@ void git_credential_free(git_credential *cred) /* Deprecated credential functions */ +#ifndef GIT_DEPRECATE_HARD int git_cred_has_username(git_credential *cred) { return git_credential_has_username(cred); @@ -474,3 +475,4 @@ void git_cred_free(git_credential *cred) { git_credential_free(cred); } +#endif diff --git a/src/transports/credential_helpers.c b/src/transports/credential_helpers.c index 6b975e126..6d34a4e97 100644 --- a/src/transports/credential_helpers.c +++ b/src/transports/credential_helpers.c @@ -54,6 +54,7 @@ int git_credential_userpass( /* Deprecated credential functions */ +#ifndef GIT_DEPRECATE_HARD int git_cred_userpass( git_credential **out, const char *url, @@ -64,3 +65,4 @@ int git_cred_userpass( return git_credential_userpass(out, url, user_from_url, allowed_types, payload); } +#endif diff --git a/src/transports/httpclient.c b/src/transports/httpclient.c index 010baa604..ee936c81a 100644 --- a/src/transports/httpclient.c +++ b/src/transports/httpclient.c @@ -445,7 +445,7 @@ GIT_INLINE(int) client_write_request(git_http_client *client) 0); } -const char *name_for_method(git_http_method method) +static const char *name_for_method(git_http_method method) { switch (method) { case GIT_HTTP_METHOD_GET: @@ -1120,11 +1120,6 @@ GIT_INLINE(int) client_read_and_parse(git_http_client *client) return -1; } - if (parser->upgrade) { - git_error_set(GIT_ERROR_HTTP, "server requested upgrade"); - return -1; - } - if (ctx->parse_status == PARSE_STATUS_ERROR) { client->connected = 0; return ctx->error ? ctx->error : -1; @@ -1374,8 +1369,11 @@ int git_http_client_read_response( git_http_response_dispose(response); - git_vector_free_deep(&client->server.auth_challenges); - git_vector_free_deep(&client->proxy.auth_challenges); + if (client->current_server == PROXY) { + git_vector_free_deep(&client->proxy.auth_challenges); + } else if(client->current_server == SERVER) { + git_vector_free_deep(&client->server.auth_challenges); + } client->state = READING_RESPONSE; client->keepalive = 0; diff --git a/src/transports/local.c b/src/transports/local.c index 24af7f063..210de9f74 100644 --- a/src/transports/local.c +++ b/src/transports/local.c @@ -185,12 +185,12 @@ static int store_refs(transport_local *t) } t->have_refs = 1; - git_strarray_free(&ref_names); + git_strarray_dispose(&ref_names); return 0; on_error: git_vector_free(&t->refs); - git_strarray_free(&ref_names); + git_strarray_dispose(&ref_names); return -1; } diff --git a/src/transports/smart.c b/src/transports/smart.c index bb4d2a228..5f5919407 100644 --- a/src/transports/smart.c +++ b/src/transports/smart.c @@ -132,7 +132,7 @@ static int git_smart__set_custom_headers( size_t i; if (t->custom_headers.count) - git_strarray_free(&t->custom_headers); + git_strarray_dispose(&t->custom_headers); if (!custom_headers) return 0; @@ -465,7 +465,7 @@ static void git_smart__free(git_transport *transport) git_vector_free(refs); git__free((char *)t->proxy.url); - git_strarray_free(&t->custom_headers); + git_strarray_dispose(&t->custom_headers); git__free(t); } diff --git a/src/transports/winhttp.c b/src/transports/winhttp.c index ee8cb1543..f9736cd07 100644 --- a/src/transports/winhttp.c +++ b/src/transports/winhttp.c @@ -41,14 +41,18 @@ #define WINHTTP_IGNORE_REQUEST_TOTAL_LENGTH 0 #endif -#ifndef WINHTTP_FLAG_SECURE_PROTOCOL_TLS_1_1 +#ifndef WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_1 # define WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_1 0x00000200 #endif -#ifndef WINHTTP_FLAG_SECURE_PROTOCOL_TLS_1_2 +#ifndef WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2 # define WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2 0x00000800 #endif +#ifndef WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_3 +# define WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_3 0x00002000 +#endif + #ifndef HTTP_STATUS_PERMANENT_REDIRECT # define HTTP_STATUS_PERMANENT_REDIRECT 308 #endif @@ -743,7 +747,8 @@ static int winhttp_connect( DWORD protocols = WINHTTP_FLAG_SECURE_PROTOCOL_TLS1 | WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_1 | - WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2; + WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2 | + WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_3; t->session = NULL; t->connection = NULL; @@ -788,14 +793,20 @@ static int winhttp_connect( } /* - * Do a best-effort attempt to enable TLS 1.2 but allow this to - * fail; if TLS 1.2 support is not available for some reason, + * Do a best-effort attempt to enable TLS 1.3 and 1.2 but allow this to + * fail; if TLS 1.2 or 1.3 support is not available for some reason, * ignore the failure (it will keep the default protocols). */ - WinHttpSetOption(t->session, + if (WinHttpSetOption(t->session, WINHTTP_OPTION_SECURE_PROTOCOLS, &protocols, - sizeof(protocols)); + sizeof(protocols)) == FALSE) { + protocols &= ~WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_3; + WinHttpSetOption(t->session, + WINHTTP_OPTION_SECURE_PROTOCOLS, + &protocols, + sizeof(protocols)); + } if (!WinHttpSetTimeouts(t->session, default_timeout, default_connect_timeout, default_timeout, default_timeout)) { git_error_set(GIT_ERROR_OS, "failed to set timeouts for WinHTTP"); diff --git a/src/unix/posix.h b/src/unix/posix.h index 4fa725013..b5527a4a8 100644 --- a/src/unix/posix.h +++ b/src/unix/posix.h @@ -62,11 +62,23 @@ GIT_INLINE(int) p_fsync(int fd) #define p_snprintf snprintf #define p_mkstemp(p) mkstemp(p) #define p_chdir(p) chdir(p) -#define p_chmod(p,m) chmod(p, m) #define p_rmdir(p) rmdir(p) #define p_access(p,m) access(p,m) #define p_ftruncate(fd, sz) ftruncate(fd, sz) +/* + * Pre-Android 5 did not implement a virtual filesystem atop FAT + * partitions for Unix permissions, which causes chmod to fail. However, + * Unix permissions have no effect on Android anyway as file permissions + * are not actually managed this way, so treating it as a no-op across + * all Android is safe. + */ +#ifdef __ANDROID__ +# define p_chmod(p,m) 0 +#else +# define p_chmod(p,m) chmod(p, m) +#endif + /* see win32/posix.h for explanation about why this exists */ #define p_lstat_posixly(p,b) lstat(p,b) diff --git a/src/util.c b/src/util.c index 859e0a82b..2efb212bc 100644 --- a/src/util.c +++ b/src/util.c @@ -22,52 +22,6 @@ # include #endif -void git_strarray_free(git_strarray *array) -{ - size_t i; - - if (array == NULL) - return; - - for (i = 0; i < array->count; ++i) - git__free(array->strings[i]); - - git__free(array->strings); - - memset(array, 0, sizeof(*array)); -} - -int git_strarray_copy(git_strarray *tgt, const git_strarray *src) -{ - size_t i; - - assert(tgt && src); - - memset(tgt, 0, sizeof(*tgt)); - - if (!src->count) - return 0; - - tgt->strings = git__calloc(src->count, sizeof(char *)); - GIT_ERROR_CHECK_ALLOC(tgt->strings); - - for (i = 0; i < src->count; ++i) { - if (!src->strings[i]) - continue; - - tgt->strings[tgt->count] = git__strdup(src->strings[i]); - if (!tgt->strings[tgt->count]) { - git_strarray_free(tgt); - memset(tgt, 0, sizeof(*tgt)); - return -1; - } - - tgt->count++; - } - - return 0; -} - int git__strntol64(int64_t *result, const char *nptr, size_t nptr_len, const char **endptr, int base) { const char *p; @@ -424,35 +378,48 @@ void git__hexdump(const char *buffer, size_t len) last_line = (len % LINE_WIDTH); for (i = 0; i < line_count; ++i) { - line = buffer + (i * LINE_WIDTH); - for (j = 0; j < LINE_WIDTH; ++j, ++line) - printf("%02X ", (unsigned char)*line & 0xFF); + printf("%08" PRIxZ " ", (i * LINE_WIDTH)); - printf("| "); + line = buffer + (i * LINE_WIDTH); + for (j = 0; j < LINE_WIDTH; ++j, ++line) { + printf("%02x ", (unsigned char)*line & 0xFF); + + if (j == (LINE_WIDTH / 2)) + printf(" "); + } + + printf(" |"); line = buffer + (i * LINE_WIDTH); for (j = 0; j < LINE_WIDTH; ++j, ++line) printf("%c", (*line >= 32 && *line <= 126) ? *line : '.'); - printf("\n"); + printf("|\n"); } if (last_line > 0) { + printf("%08" PRIxZ " ", (line_count * LINE_WIDTH)); line = buffer + (line_count * LINE_WIDTH); - for (j = 0; j < last_line; ++j, ++line) - printf("%02X ", (unsigned char)*line & 0xFF); + for (j = 0; j < last_line; ++j, ++line) { + printf("%02x ", (unsigned char)*line & 0xFF); + if (j == (LINE_WIDTH / 2)) + printf(" "); + } + + if (j < (LINE_WIDTH / 2)) + printf(" "); for (j = 0; j < (LINE_WIDTH - last_line); ++j) - printf(" "); + printf(" "); - printf("| "); + printf(" |"); line = buffer + (line_count * LINE_WIDTH); for (j = 0; j < last_line; ++j, ++line) printf("%c", (*line >= 32 && *line <= 126) ? *line : '.'); - printf("\n"); + printf("|\n"); } printf("\n"); @@ -810,7 +777,7 @@ static const int8_t utf8proc_utf8class[256] = { 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0 }; -int git__utf8_charlen(const uint8_t *str, size_t str_len) +static int util_utf8_charlen(const uint8_t *str, size_t str_len) { size_t length, i; @@ -835,7 +802,7 @@ int git__utf8_iterate(const uint8_t *str, int str_len, int32_t *dst) int32_t uc = -1; *dst = -1; - length = git__utf8_charlen(str, str_len); + length = util_utf8_charlen(str, str_len); if (length < 0) return -1; @@ -872,7 +839,7 @@ size_t git__utf8_valid_buf_length(const uint8_t *str, size_t str_len) size_t offset = 0; while (offset < str_len) { - int length = git__utf8_charlen(str + offset, str_len - offset); + int length = util_utf8_charlen(str + offset, str_len - offset); if (length < 0) break; diff --git a/src/util.h b/src/util.h index b49850d23..f49989f7e 100644 --- a/src/util.h +++ b/src/util.h @@ -186,10 +186,10 @@ typedef void (*git_refcount_freeptr)(void *r); } #define GIT_REFCOUNT_OWN(r, o) { \ - (r)->rc.owner = o; \ + (void)git__swap((r)->rc.owner, o); \ } -#define GIT_REFCOUNT_OWNER(r) ((r)->rc.owner) +#define GIT_REFCOUNT_OWNER(r) git__load((r)->rc.owner) #define GIT_REFCOUNT_VAL(r) git_atomic_get((r)->rc.refcount) diff --git a/src/win32/git2.rc b/src/win32/git2.rc index 3571bc683..d273afd70 100644 --- a/src/win32/git2.rc +++ b/src/win32/git2.rc @@ -2,14 +2,29 @@ #include "../../include/git2/version.h" #ifndef LIBGIT2_FILENAME -# define LIBGIT2_FILENAME "git2" +# ifdef __GNUC__ +# define LIBGIT2_FILENAME git2 +# else +# define LIBGIT2_FILENAME "git2" +# endif #endif #ifndef LIBGIT2_COMMENTS # define LIBGIT2_COMMENTS "For more information visit http://libgit2.github.com/" #endif +#ifdef __GNUC__ +# define _STR(x) #x +# define STR(x) _STR(x) +#else +# define STR(x) x +#endif + +#ifdef __GNUC__ +VS_VERSION_INFO VERSIONINFO +#else VS_VERSION_INFO VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE +#endif FILEVERSION LIBGIT2_VER_MAJOR,LIBGIT2_VER_MINOR,LIBGIT2_VER_REVISION,LIBGIT2_VER_PATCH PRODUCTVERSION LIBGIT2_VER_MAJOR,LIBGIT2_VER_MINOR,LIBGIT2_VER_REVISION,LIBGIT2_VER_PATCH FILEFLAGSMASK VS_FFI_FILEFLAGSMASK @@ -29,9 +44,9 @@ BEGIN BEGIN VALUE "FileDescription", "libgit2 - the Git linkable library\0" VALUE "FileVersion", LIBGIT2_VERSION "\0" - VALUE "InternalName", LIBGIT2_FILENAME ".dll\0" + VALUE "InternalName", STR(LIBGIT2_FILENAME) ".dll\0" VALUE "LegalCopyright", "Copyright (C) the libgit2 contributors. All rights reserved.\0" - VALUE "OriginalFilename", LIBGIT2_FILENAME ".dll\0" + VALUE "OriginalFilename", STR(LIBGIT2_FILENAME) ".dll\0" VALUE "ProductName", "libgit2\0" VALUE "ProductVersion", LIBGIT2_VERSION "\0" VALUE "Comments", LIBGIT2_COMMENTS "\0" diff --git a/src/win32/path_w32.c b/src/win32/path_w32.c index 18b43e728..9faddcf3b 100644 --- a/src/win32/path_w32.c +++ b/src/win32/path_w32.c @@ -151,7 +151,7 @@ int git_win32_path_canonicalize(git_win32_path path) return (int)(to - path); } -int git_win32_path__cwd(wchar_t *out, size_t len) +static int win32_path_cwd(wchar_t *out, size_t len) { int cwd_len; @@ -241,7 +241,7 @@ int git_win32_path_from_utf8(git_win32_path out, const char *src) else { int cwd_len; - if ((cwd_len = git_win32_path__cwd(dest, MAX_PATH)) < 0) + if ((cwd_len = win32_path_cwd(dest, MAX_PATH)) < 0) goto on_error; dest[cwd_len++] = L'\\'; diff --git a/src/worktree.c b/src/worktree.c index 74b32f97c..fda9b0b71 100644 --- a/src/worktree.c +++ b/src/worktree.c @@ -271,11 +271,13 @@ int git_worktree_add_options_init(git_worktree_add_options *opts, return 0; } +#ifndef GIT_DEPRECATE_HARD int git_worktree_add_init_options(git_worktree_add_options *opts, unsigned int version) { return git_worktree_add_options_init(opts, version); } +#endif int git_worktree_add(git_worktree **out, git_repository *repo, const char *name, const char *worktree, @@ -506,11 +508,13 @@ int git_worktree_prune_options_init( return 0; } +#ifndef GIT_DEPRECATE_HARD int git_worktree_prune_init_options(git_worktree_prune_options *opts, unsigned int version) { return git_worktree_prune_options_init(opts, version); } +#endif int git_worktree_is_prunable(git_worktree *wt, git_worktree_prune_options *opts) diff --git a/tests/blame/simple.c b/tests/blame/simple.c index 16e7bc400..6b13cccd4 100644 --- a/tests/blame/simple.c +++ b/tests/blame/simple.c @@ -238,6 +238,24 @@ void test_blame_simple__can_restrict_lines_min(void) check_blame_hunk_index(g_repo, g_blame, 1, 11, 5, 0, "aa06ecca", "b.txt"); } +/* + * $ git blame -n c.txt + * orig line no final line no + * commit V author timestamp V + * 702c7aa5 1 (Carl Schwan 2020-01-29 01:52:31 +0100 4 + */ +void test_blame_simple__can_ignore_whitespace_change(void) +{ + git_blame_options opts = GIT_BLAME_OPTIONS_INIT; + + cl_git_pass(git_repository_open(&g_repo, cl_fixture("blametest.git"))); + + opts.flags |= GIT_BLAME_IGNORE_WHITESPACE; + cl_git_pass(git_blame_file(&g_blame, g_repo, "c.txt", &opts)); + cl_assert_equal_i(1, git_blame_get_hunk_count(g_blame)); + check_blame_hunk_index(g_repo, g_blame, 0, 1, 4, 0, "702c7aa5", "c.txt"); +} + /* * $ git blame -n b.txt -L ,6 * orig line no final line no diff --git a/tests/checkout/crlf.c b/tests/checkout/crlf.c index 65e13a6fd..495020161 100644 --- a/tests/checkout/crlf.c +++ b/tests/checkout/crlf.c @@ -108,7 +108,7 @@ done: git_buf details = GIT_BUF_INIT; git_buf_printf(&details, "filename=%s, system=%s, autocrlf=%s, attrs={%s}", git_path_basename(actual_path->ptr), systype, cd->autocrlf, cd->attrs); - clar__fail(__FILE__, __LINE__, + clar__fail(__FILE__, __func__, __LINE__, "checked out contents did not match expected", details.ptr, 0); git_buf_dispose(&details); } diff --git a/tests/checkout/head.c b/tests/checkout/head.c index 799123086..5b3a034e7 100644 --- a/tests/checkout/head.c +++ b/tests/checkout/head.c @@ -109,6 +109,32 @@ void test_checkout_head__do_not_remove_untracked_file_in_subdir(void) cl_assert(git_path_isfile("testrepo/tracked/subdir/untracked")); } +void test_checkout_head__do_remove_untracked_paths(void) +{ + git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT; + git_index *index; + char *paths[] = {"tracked/untracked"}; + + cl_git_pass(p_mkdir("testrepo/tracked", 0755)); + cl_git_pass(p_mkdir("testrepo/tracked/subdir", 0755)); + cl_git_mkfile("testrepo/tracked/tracked", "tracked\n"); + cl_git_mkfile("testrepo/tracked/untracked", "untracked\n"); + + cl_git_pass(git_repository_index(&index, g_repo)); + cl_git_pass(git_index_add_bypath(index, "tracked/tracked")); + cl_git_pass(git_index_write(index)); + + git_index_free(index); + + opts.checkout_strategy = GIT_CHECKOUT_FORCE | GIT_CHECKOUT_REMOVE_UNTRACKED; + opts.paths.strings = paths; + opts.paths.count = 1; + cl_git_pass(git_checkout_head(g_repo, &opts)); + + cl_assert(git_path_isfile("testrepo/tracked/tracked")); + cl_assert(!git_path_isfile("testrepo/tracked/untracked")); +} + void test_checkout_head__do_remove_tracked_subdir(void) { git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT; diff --git a/tests/checkout/index.c b/tests/checkout/index.c index a76c471e8..508975365 100644 --- a/tests/checkout/index.c +++ b/tests/checkout/index.c @@ -89,6 +89,61 @@ void test_checkout_index__can_remove_untracked_files(void) cl_assert_equal_i(false, git_path_isdir("./testrepo/dir")); } +void test_checkout_index__can_disable_pathspec_match(void) +{ + char *files_to_checkout[] = { "test10.txt", "test11.txt"}; + git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT; + git_object *objects; + git_index *index; + + /* reset to beginning of history (i.e. just a README file) */ + opts.checkout_strategy = GIT_CHECKOUT_FORCE | GIT_CHECKOUT_REMOVE_UNTRACKED; + + cl_git_pass(git_revparse_single(&objects, g_repo, "8496071c1b46c854b31185ea97743be6a8774479")); + cl_git_pass(git_checkout_tree(g_repo, objects, &opts)); + cl_git_pass(git_repository_set_head_detached(g_repo, git_object_id(objects))); + git_object_free(objects); + + cl_git_pass(git_repository_index(&index, g_repo)); + + /* We create 4 files and commit them */ + cl_git_mkfile("testrepo/test9.txt", "original\n"); + cl_git_mkfile("testrepo/test10.txt", "original\n"); + cl_git_mkfile("testrepo/test11.txt", "original\n"); + cl_git_mkfile("testrepo/test12.txt", "original\n"); + + cl_git_pass(git_index_add_bypath(index, "test9.txt")); + cl_git_pass(git_index_add_bypath(index, "test10.txt")); + cl_git_pass(git_index_add_bypath(index, "test11.txt")); + cl_git_pass(git_index_add_bypath(index, "test12.txt")); + cl_git_pass(git_index_write(index)); + + cl_repo_commit_from_index(NULL, g_repo, NULL, 0, "commit our test files"); + + /* We modify the content of all 4 of our files */ + cl_git_rewritefile("testrepo/test9.txt", "modified\n"); + cl_git_rewritefile("testrepo/test10.txt", "modified\n"); + cl_git_rewritefile("testrepo/test11.txt", "modified\n"); + cl_git_rewritefile("testrepo/test12.txt", "modified\n"); + + /* We checkout only test10.txt and test11.txt */ + opts.checkout_strategy = + GIT_CHECKOUT_FORCE | + GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH; + opts.paths.strings = files_to_checkout; + opts.paths.count = ARRAY_SIZE(files_to_checkout); + cl_git_pass(git_checkout_index(g_repo, NULL, &opts)); + + /* The only files that have been reverted to their original content + should be test10.txt and test11.txt */ + check_file_contents("testrepo/test9.txt", "modified\n"); + check_file_contents("testrepo/test10.txt", "original\n"); + check_file_contents("testrepo/test11.txt", "original\n"); + check_file_contents("testrepo/test12.txt", "modified\n"); + + git_index_free(index); +} + void test_checkout_index__honor_the_specified_pathspecs(void) { git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT; diff --git a/tests/checkout/tree.c b/tests/checkout/tree.c index 380d25101..f8d9abe55 100644 --- a/tests/checkout/tree.c +++ b/tests/checkout/tree.c @@ -917,7 +917,7 @@ void test_checkout_tree__extremely_long_file_name(void) { /* A utf-8 string with 83 characters, but 249 bytes. */ const char *longname = "\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97\xe5\x8f\x97"; - char path[1024]; + char path[1024] = {0}; g_opts.checkout_strategy = GIT_CHECKOUT_FORCE; cl_git_pass(git_revparse_single(&g_object, g_repo, "long-file-name")); diff --git a/tests/clar.c b/tests/clar.c index ead13f46a..ca508d073 100644 --- a/tests/clar.c +++ b/tests/clar.c @@ -96,6 +96,7 @@ fixture_path(const char *base, const char *fixture_name); struct clar_error { const char *file; + const char *function; size_t line_number; const char *error_msg; char *description; @@ -140,6 +141,8 @@ static struct { int tests_ran; int suites_ran; + enum cl_output_format output_format; + int report_errors_only; int exit_on_error; int report_suite_names; @@ -293,6 +296,7 @@ clar_run_suite(const struct clar_suite *suite, const char *filter) const struct clar_func *test = suite->tests; size_t i, matchlen; struct clar_report *report; + int exact = 0; if (!suite->enabled) return; @@ -317,6 +321,11 @@ clar_run_suite(const struct clar_suite *suite, const char *filter) while (*filter == ':') ++filter; matchlen = strlen(filter); + + if (matchlen && filter[matchlen - 1] == '$') { + exact = 1; + matchlen--; + } } } @@ -324,6 +333,9 @@ clar_run_suite(const struct clar_suite *suite, const char *filter) if (filter && strncmp(test[i].name, filter, matchlen)) continue; + if (exact && strlen(test[i].name) != matchlen) + continue; + _clar.active_test = test[i].name; report = calloc(1, sizeof(struct clar_report)); @@ -361,6 +373,7 @@ clar_usage(const char *arg) printf(" -v Increase verbosity (show suite names)\n"); printf(" -q Only report tests that had an error\n"); printf(" -Q Quit as soon as a test fails\n"); + printf(" -t Display results in tap format\n"); printf(" -l Print suite names\n"); printf(" -r[filename] Write summary file (to the optional filename)\n"); exit(-1); @@ -376,7 +389,7 @@ clar_parse_args(int argc, char **argv) char *argument = argv[i]; if (argument[0] != '-' || argument[1] == '\0' - || strchr("sixvqQlr", argument[1]) == NULL) { + || strchr("sixvqQtlr", argument[1]) == NULL) { clar_usage(argv[0]); } } @@ -459,6 +472,10 @@ clar_parse_args(int argc, char **argv) _clar.exit_on_error = 1; break; + case 't': + _clar.output_format = CL_OUTPUT_TAP; + break; + case 'l': { size_t j; printf("Test suites (use -s to run just one):\n"); @@ -487,6 +504,9 @@ clar_parse_args(int argc, char **argv) void clar_test_init(int argc, char **argv) { + if (argc > 1) + clar_parse_args(argc, argv); + clar_print_init( (int)_clar_callback_count, (int)_clar_suite_count, @@ -498,9 +518,6 @@ clar_test_init(int argc, char **argv) _clar.summary_filename = strdup(_clar.summary_filename); } - if (argc > 1) - clar_parse_args(argc, argv); - if (_clar.write_summary && !(_clar.summary = clar_summary_init(_clar.summary_filename))) { clar_print_onabort("Failed to open the summary file\n"); @@ -596,6 +613,7 @@ void clar__skip(void) void clar__fail( const char *file, + const char *function, size_t line, const char *error_msg, const char *description, @@ -612,6 +630,7 @@ void clar__fail( _clar.last_report->last_error = error; error->file = file; + error->function = function; error->line_number = line; error->error_msg = error_msg; @@ -628,6 +647,7 @@ void clar__fail( void clar__assert( int condition, const char *file, + const char *function, size_t line, const char *error_msg, const char *description, @@ -636,11 +656,12 @@ void clar__assert( if (condition) return; - clar__fail(file, line, error_msg, description, should_abort); + clar__fail(file, function, line, error_msg, description, should_abort); } void clar__assert_equal( const char *file, + const char *function, size_t line, const char *err, int should_abort, @@ -751,7 +772,7 @@ void clar__assert_equal( va_end(args); if (!is_equal) - clar__fail(file, line, err, buf, should_abort); + clar__fail(file, function, line, err, buf, should_abort); } void cl_set_cleanup(void (*cleanup)(void *), void *opaque) diff --git a/tests/clar.h b/tests/clar.h index 20ff4c895..8c22382bd 100644 --- a/tests/clar.h +++ b/tests/clar.h @@ -16,6 +16,11 @@ enum cl_test_status { CL_TEST_NOTRUN, }; +enum cl_output_format { + CL_OUTPUT_CLAP, + CL_OUTPUT_TAP, +}; + /** Setup clar environment */ void clar_test_init(int argc, char *argv[]); int clar_test_run(void); @@ -81,16 +86,16 @@ const char *cl_fixture_basename(const char *fixture_name); /** * Assertion macros with explicit error message */ -#define cl_must_pass_(expr, desc) clar__assert((expr) >= 0, __FILE__, __LINE__, "Function call failed: " #expr, desc, 1) -#define cl_must_fail_(expr, desc) clar__assert((expr) < 0, __FILE__, __LINE__, "Expected function call to fail: " #expr, desc, 1) -#define cl_assert_(expr, desc) clar__assert((expr) != 0, __FILE__, __LINE__, "Expression is not true: " #expr, desc, 1) +#define cl_must_pass_(expr, desc) clar__assert((expr) >= 0, __FILE__, __func__, __LINE__, "Function call failed: " #expr, desc, 1) +#define cl_must_fail_(expr, desc) clar__assert((expr) < 0, __FILE__, __func__, __LINE__, "Expected function call to fail: " #expr, desc, 1) +#define cl_assert_(expr, desc) clar__assert((expr) != 0, __FILE__, __func__, __LINE__, "Expression is not true: " #expr, desc, 1) /** * Check macros with explicit error message */ -#define cl_check_pass_(expr, desc) clar__assert((expr) >= 0, __FILE__, __LINE__, "Function call failed: " #expr, desc, 0) -#define cl_check_fail_(expr, desc) clar__assert((expr) < 0, __FILE__, __LINE__, "Expected function call to fail: " #expr, desc, 0) -#define cl_check_(expr, desc) clar__assert((expr) != 0, __FILE__, __LINE__, "Expression is not true: " #expr, desc, 0) +#define cl_check_pass_(expr, desc) clar__assert((expr) >= 0, __FILE__, __func__, __LINE__, "Function call failed: " #expr, desc, 0) +#define cl_check_fail_(expr, desc) clar__assert((expr) < 0, __FILE__, __func__, __LINE__, "Expected function call to fail: " #expr, desc, 0) +#define cl_check_(expr, desc) clar__assert((expr) != 0, __FILE__, __func__, __LINE__, "Expression is not true: " #expr, desc, 0) /** * Assertion macros with no error message @@ -109,38 +114,39 @@ const char *cl_fixture_basename(const char *fixture_name); /** * Forced failure/warning */ -#define cl_fail(desc) clar__fail(__FILE__, __LINE__, "Test failed.", desc, 1) -#define cl_warning(desc) clar__fail(__FILE__, __LINE__, "Warning during test execution:", desc, 0) +#define cl_fail(desc) clar__fail(__FILE__, __func__, __LINE__, "Test failed.", desc, 1) +#define cl_warning(desc) clar__fail(__FILE__, __func__, __LINE__, "Warning during test execution:", desc, 0) #define cl_skip() clar__skip() /** * Typed assertion macros */ -#define cl_assert_equal_s(s1,s2) clar__assert_equal(__FILE__,__LINE__,"String mismatch: " #s1 " != " #s2, 1, "%s", (s1), (s2)) -#define cl_assert_equal_s_(s1,s2,note) clar__assert_equal(__FILE__,__LINE__,"String mismatch: " #s1 " != " #s2 " (" #note ")", 1, "%s", (s1), (s2)) +#define cl_assert_equal_s(s1,s2) clar__assert_equal(__FILE__,__func__,__LINE__,"String mismatch: " #s1 " != " #s2, 1, "%s", (s1), (s2)) +#define cl_assert_equal_s_(s1,s2,note) clar__assert_equal(__FILE__,__func__,__LINE__,"String mismatch: " #s1 " != " #s2 " (" #note ")", 1, "%s", (s1), (s2)) -#define cl_assert_equal_wcs(wcs1,wcs2) clar__assert_equal(__FILE__,__LINE__,"String mismatch: " #wcs1 " != " #wcs2, 1, "%ls", (wcs1), (wcs2)) -#define cl_assert_equal_wcs_(wcs1,wcs2,note) clar__assert_equal(__FILE__,__LINE__,"String mismatch: " #wcs1 " != " #wcs2 " (" #note ")", 1, "%ls", (wcs1), (wcs2)) +#define cl_assert_equal_wcs(wcs1,wcs2) clar__assert_equal(__FILE__,__func__,__LINE__,"String mismatch: " #wcs1 " != " #wcs2, 1, "%ls", (wcs1), (wcs2)) +#define cl_assert_equal_wcs_(wcs1,wcs2,note) clar__assert_equal(__FILE__,__func__,__LINE__,"String mismatch: " #wcs1 " != " #wcs2 " (" #note ")", 1, "%ls", (wcs1), (wcs2)) -#define cl_assert_equal_strn(s1,s2,len) clar__assert_equal(__FILE__,__LINE__,"String mismatch: " #s1 " != " #s2, 1, "%.*s", (s1), (s2), (int)(len)) -#define cl_assert_equal_strn_(s1,s2,len,note) clar__assert_equal(__FILE__,__LINE__,"String mismatch: " #s1 " != " #s2 " (" #note ")", 1, "%.*s", (s1), (s2), (int)(len)) +#define cl_assert_equal_strn(s1,s2,len) clar__assert_equal(__FILE__,__func__,__LINE__,"String mismatch: " #s1 " != " #s2, 1, "%.*s", (s1), (s2), (int)(len)) +#define cl_assert_equal_strn_(s1,s2,len,note) clar__assert_equal(__FILE__,__func__,__LINE__,"String mismatch: " #s1 " != " #s2 " (" #note ")", 1, "%.*s", (s1), (s2), (int)(len)) -#define cl_assert_equal_wcsn(wcs1,wcs2,len) clar__assert_equal(__FILE__,__LINE__,"String mismatch: " #wcs1 " != " #wcs2, 1, "%.*ls", (wcs1), (wcs2), (int)(len)) -#define cl_assert_equal_wcsn_(wcs1,wcs2,len,note) clar__assert_equal(__FILE__,__LINE__,"String mismatch: " #wcs1 " != " #wcs2 " (" #note ")", 1, "%.*ls", (wcs1), (wcs2), (int)(len)) +#define cl_assert_equal_wcsn(wcs1,wcs2,len) clar__assert_equal(__FILE__,__func__,__LINE__,"String mismatch: " #wcs1 " != " #wcs2, 1, "%.*ls", (wcs1), (wcs2), (int)(len)) +#define cl_assert_equal_wcsn_(wcs1,wcs2,len,note) clar__assert_equal(__FILE__,__func__,__LINE__,"String mismatch: " #wcs1 " != " #wcs2 " (" #note ")", 1, "%.*ls", (wcs1), (wcs2), (int)(len)) -#define cl_assert_equal_i(i1,i2) clar__assert_equal(__FILE__,__LINE__,#i1 " != " #i2, 1, "%d", (int)(i1), (int)(i2)) -#define cl_assert_equal_i_(i1,i2,note) clar__assert_equal(__FILE__,__LINE__,#i1 " != " #i2 " (" #note ")", 1, "%d", (i1), (i2)) -#define cl_assert_equal_i_fmt(i1,i2,fmt) clar__assert_equal(__FILE__,__LINE__,#i1 " != " #i2, 1, (fmt), (int)(i1), (int)(i2)) +#define cl_assert_equal_i(i1,i2) clar__assert_equal(__FILE__,__func__,__LINE__,#i1 " != " #i2, 1, "%d", (int)(i1), (int)(i2)) +#define cl_assert_equal_i_(i1,i2,note) clar__assert_equal(__FILE__,__func__,__LINE__,#i1 " != " #i2 " (" #note ")", 1, "%d", (i1), (i2)) +#define cl_assert_equal_i_fmt(i1,i2,fmt) clar__assert_equal(__FILE__,__func__,__LINE__,#i1 " != " #i2, 1, (fmt), (int)(i1), (int)(i2)) -#define cl_assert_equal_b(b1,b2) clar__assert_equal(__FILE__,__LINE__,#b1 " != " #b2, 1, "%d", (int)((b1) != 0),(int)((b2) != 0)) +#define cl_assert_equal_b(b1,b2) clar__assert_equal(__FILE__,__func__,__LINE__,#b1 " != " #b2, 1, "%d", (int)((b1) != 0),(int)((b2) != 0)) -#define cl_assert_equal_p(p1,p2) clar__assert_equal(__FILE__,__LINE__,"Pointer mismatch: " #p1 " != " #p2, 1, "%p", (p1), (p2)) +#define cl_assert_equal_p(p1,p2) clar__assert_equal(__FILE__,__func__,__LINE__,"Pointer mismatch: " #p1 " != " #p2, 1, "%p", (p1), (p2)) void clar__skip(void); void clar__fail( const char *file, + const char *func, size_t line, const char *error, const char *description, @@ -149,6 +155,7 @@ void clar__fail( void clar__assert( int condition, const char *file, + const char *func, size_t line, const char *error, const char *description, @@ -156,6 +163,7 @@ void clar__assert( void clar__assert_equal( const char *file, + const char *func, size_t line, const char *err, int should_abort, diff --git a/tests/clar/fs.h b/tests/clar/fs.h index 7c7dde6fc..31a536427 100644 --- a/tests/clar/fs.h +++ b/tests/clar/fs.h @@ -1,3 +1,11 @@ +/* + * By default, use a read/write loop to copy files on POSIX systems. + * On Linux, use sendfile by default as it's slightly faster. On + * macOS, we avoid fcopyfile by default because it's slightly slower. + */ +#undef USE_FCOPYFILE +#define USE_SENDFILE 1 + #ifdef _WIN32 #define RM_RETRY_COUNT 5 @@ -254,74 +262,213 @@ cl_fs_cleanup(void) #include #include +#include +#include +#include +#include +#include +#include -static int -shell_out(char * const argv[]) +#if defined(__linux__) +# include +#endif + +#if defined(__APPLE__) +# include +#endif + +static void basename_r(const char **out, int *out_len, const char *in) { - int status, piderr; - pid_t pid; + size_t in_len = strlen(in), start_pos; - pid = fork(); - - if (pid < 0) { - fprintf(stderr, - "System error: `fork()` call failed (%d) - %s\n", - errno, strerror(errno)); - exit(-1); + for (in_len = strlen(in); in_len; in_len--) { + if (in[in_len - 1] != '/') + break; } - if (pid == 0) { - execv(argv[0], argv); + for (start_pos = in_len; start_pos; start_pos--) { + if (in[start_pos - 1] == '/') + break; } - do { - piderr = waitpid(pid, &status, WUNTRACED); - } while (piderr < 0 && (errno == EAGAIN || errno == EINTR)); + cl_assert(in_len - start_pos < INT_MAX); - return WEXITSTATUS(status); + if (in_len - start_pos > 0) { + *out = &in[start_pos]; + *out_len = (in_len - start_pos); + } else { + *out = "/"; + *out_len = 1; + } +} + +static char *joinpath(const char *dir, const char *base, int base_len) +{ + char *out; + int len; + + if (base_len == -1) { + size_t bl = strlen(base); + + cl_assert(bl < INT_MAX); + base_len = (int)bl; + } + + len = strlen(dir) + base_len + 2; + cl_assert(len > 0); + + cl_assert(out = malloc(len)); + cl_assert(snprintf(out, len, "%s/%.*s", dir, base_len, base) < len); + + return out; } static void -fs_copy(const char *_source, const char *dest) +fs_copydir_helper(const char *source, const char *dest, int dest_mode) { - char *argv[5]; - char *source; - size_t source_len; + DIR *source_dir; + struct dirent *d; - source = strdup(_source); - source_len = strlen(source); + mkdir(dest, dest_mode); - if (source[source_len - 1] == '/') - source[source_len - 1] = 0; + cl_assert_(source_dir = opendir(source), "Could not open source dir"); + while ((d = (errno = 0, readdir(source_dir))) != NULL) { + char *child; - argv[0] = "/bin/cp"; - argv[1] = "-R"; - argv[2] = source; - argv[3] = (char *)dest; - argv[4] = NULL; + if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, "..")) + continue; - cl_must_pass_( - shell_out(argv), - "Failed to copy test fixtures to sandbox" - ); + child = joinpath(source, d->d_name, -1); + fs_copy(child, dest); + free(child); + } - free(source); + cl_assert_(errno == 0, "Failed to iterate source dir"); + + closedir(source_dir); } static void -fs_rm(const char *source) +fs_copyfile_helper(const char *source, size_t source_len, const char *dest, int dest_mode) { - char *argv[4]; + int in, out; - argv[0] = "/bin/rm"; - argv[1] = "-Rf"; - argv[2] = (char *)source; - argv[3] = NULL; + cl_must_pass((in = open(source, O_RDONLY))); + cl_must_pass((out = open(dest, O_WRONLY|O_CREAT|O_TRUNC, dest_mode))); - cl_must_pass_( - shell_out(argv), - "Failed to cleanup the sandbox" - ); +#if USE_FCOPYFILE && defined(__APPLE__) + ((void)(source_len)); /* unused */ + cl_must_pass(fcopyfile(in, out, 0, COPYFILE_DATA)); +#elif USE_SENDFILE && defined(__linux__) + { + ssize_t ret = 0; + + while (source_len && (ret = sendfile(out, in, NULL, source_len)) > 0) { + source_len -= (size_t)ret; + } + cl_assert(ret >= 0); + } +#else + { + char buf[131072]; + ssize_t ret; + + ((void)(source_len)); /* unused */ + + while ((ret = read(in, buf, sizeof(buf))) > 0) { + size_t len = (size_t)ret; + + while (len && (ret = write(out, buf, len)) > 0) { + cl_assert(ret <= (ssize_t)len); + len -= ret; + } + cl_assert(ret >= 0); + } + cl_assert(ret == 0); + } +#endif + + close(in); + close(out); +} + +static void +fs_copy(const char *source, const char *_dest) +{ + char *dbuf = NULL; + const char *dest; + struct stat source_st, dest_st; + + cl_must_pass_(lstat(source, &source_st), "Failed to stat copy source"); + + if (lstat(_dest, &dest_st) == 0) { + const char *base; + int base_len; + + /* Target exists and is directory; append basename */ + cl_assert(S_ISDIR(dest_st.st_mode)); + + basename_r(&base, &base_len, source); + cl_assert(base_len < INT_MAX); + + dbuf = joinpath(_dest, base, base_len); + dest = dbuf; + } else if (errno != ENOENT) { + cl_fail("Cannot copy; cannot stat destination"); + } else { + dest = _dest; + } + + if (S_ISDIR(source_st.st_mode)) { + fs_copydir_helper(source, dest, source_st.st_mode); + } else { + fs_copyfile_helper(source, source_st.st_size, dest, source_st.st_mode); + } + + free(dbuf); +} + +static void +fs_rmdir_helper(const char *path) +{ + DIR *dir; + struct dirent *d; + + cl_assert_(dir = opendir(path), "Could not open dir"); + while ((d = (errno = 0, readdir(dir))) != NULL) { + char *child; + + if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, "..")) + continue; + + child = joinpath(path, d->d_name, -1); + fs_rm(child); + free(child); + } + + cl_assert_(errno == 0, "Failed to iterate source dir"); + closedir(dir); + + cl_must_pass_(rmdir(path), "Could not remove directory"); +} + +static void +fs_rm(const char *path) +{ + struct stat st; + + if (lstat(path, &st)) { + if (errno == ENOENT) + return; + + cl_fail("Cannot copy; cannot stat destination"); + } + + if (S_ISDIR(st.st_mode)) { + fs_rmdir_helper(path); + } else { + cl_must_pass(unlink(path)); + } } void diff --git a/tests/clar/print.h b/tests/clar/print.h index 2e2b6202c..dbfd27655 100644 --- a/tests/clar/print.h +++ b/tests/clar/print.h @@ -1,12 +1,13 @@ +/* clap: clar protocol, the traditional clar output format */ -static void clar_print_init(int test_count, int suite_count, const char *suite_names) +static void clar_print_clap_init(int test_count, int suite_count, const char *suite_names) { (void)test_count; printf("Loaded %d suites: %s\n", (int)suite_count, suite_names); printf("Started (test status codes: OK='.' FAILURE='F' SKIPPED='S')\n"); } -static void clar_print_shutdown(int test_count, int suite_count, int error_count) +static void clar_print_clap_shutdown(int test_count, int suite_count, int error_count) { (void)test_count; (void)suite_count; @@ -16,7 +17,7 @@ static void clar_print_shutdown(int test_count, int suite_count, int error_count clar_report_all(); } -static void clar_print_error(int num, const struct clar_report *report, const struct clar_error *error) +static void clar_print_clap_error(int num, const struct clar_report *report, const struct clar_error *error) { printf(" %d) Failure:\n", num); @@ -35,7 +36,7 @@ static void clar_print_error(int num, const struct clar_report *report, const st fflush(stdout); } -static void clar_print_ontest(const char *test_name, int test_number, enum cl_test_status status) +static void clar_print_clap_ontest(const char *test_name, int test_number, enum cl_test_status status) { (void)test_name; (void)test_number; @@ -50,7 +51,7 @@ static void clar_print_ontest(const char *test_name, int test_number, enum cl_te fflush(stdout); } -static void clar_print_onsuite(const char *suite_name, int suite_index) +static void clar_print_clap_onsuite(const char *suite_name, int suite_index) { if (_clar.report_suite_names) printf("\n%s", suite_name); @@ -58,10 +59,142 @@ static void clar_print_onsuite(const char *suite_name, int suite_index) (void)suite_index; } +static void clar_print_clap_onabort(const char *fmt, va_list arg) +{ + vfprintf(stderr, fmt, arg); +} + +/* tap: test anywhere protocol format */ + +static void clar_print_tap_init(int test_count, int suite_count, const char *suite_names) +{ + (void)test_count; + (void)suite_count; + (void)suite_names; + printf("TAP version 13\n"); +} + +static void clar_print_tap_shutdown(int test_count, int suite_count, int error_count) +{ + (void)suite_count; + (void)error_count; + + printf("1..%d\n", test_count); +} + +static void clar_print_tap_error(int num, const struct clar_report *report, const struct clar_error *error) +{ + (void)num; + (void)report; + (void)error; +} + +static void print_escaped(const char *str) +{ + char *c; + + while ((c = strchr(str, '\'')) != NULL) { + printf("%.*s", (int)(c - str), str); + printf("''"); + str = c + 1; + } + + printf("%s", str); +} + +static void clar_print_tap_ontest(const char *test_name, int test_number, enum cl_test_status status) +{ + const struct clar_error *error = _clar.last_report->errors; + + (void)test_name; + (void)test_number; + + switch(status) { + case CL_TEST_OK: + printf("ok %d - %s::%s\n", test_number, _clar.active_suite, test_name); + break; + case CL_TEST_FAILURE: + printf("not ok %d - %s::%s\n", test_number, _clar.active_suite, test_name); + + printf(" ---\n"); + printf(" reason: |\n"); + printf(" %s\n", error->error_msg); + + if (error->description) + printf(" %s\n", error->description); + + printf(" at:\n"); + printf(" file: '"); print_escaped(error->file); printf("'\n"); + printf(" line: %" PRIuZ "\n", error->line_number); + printf(" function: '%s'\n", error->function); + printf(" ---\n"); + + break; + case CL_TEST_SKIP: + case CL_TEST_NOTRUN: + printf("ok %d - # SKIP %s::%s\n", test_number, _clar.active_suite, test_name); + break; + } + + fflush(stdout); +} + +static void clar_print_tap_onsuite(const char *suite_name, int suite_index) +{ + printf("# start of suite %d: %s\n", suite_index, suite_name); +} + +static void clar_print_tap_onabort(const char *fmt, va_list arg) +{ + printf("Bail out! "); + vprintf(fmt, arg); + fflush(stdout); +} + +/* indirection between protocol output selection */ + +#define PRINT(FN, ...) do { \ + switch (_clar.output_format) { \ + case CL_OUTPUT_CLAP: \ + clar_print_clap_##FN (__VA_ARGS__); \ + break; \ + case CL_OUTPUT_TAP: \ + clar_print_tap_##FN (__VA_ARGS__); \ + break; \ + default: \ + abort(); \ + } \ + } while (0) + +static void clar_print_init(int test_count, int suite_count, const char *suite_names) +{ + PRINT(init, test_count, suite_count, suite_names); +} + +static void clar_print_shutdown(int test_count, int suite_count, int error_count) +{ + PRINT(shutdown, test_count, suite_count, error_count); +} + +static void clar_print_error(int num, const struct clar_report *report, const struct clar_error *error) +{ + PRINT(error, num, report, error); +} + +static void clar_print_ontest(const char *test_name, int test_number, enum cl_test_status status) +{ + PRINT(ontest, test_name, test_number, status); +} + +static void clar_print_onsuite(const char *suite_name, int suite_index) +{ + PRINT(onsuite, suite_name, suite_index); +} + static void clar_print_onabort(const char *msg, ...) { va_list argp; va_start(argp, msg); - vfprintf(stderr, msg, argp); + PRINT(onabort, msg, argp); va_end(argp); } diff --git a/tests/clar_libgit2.c b/tests/clar_libgit2.c index 4723a0632..65b8923f5 100644 --- a/tests/clar_libgit2.c +++ b/tests/clar_libgit2.c @@ -4,7 +4,7 @@ #include "git2/sys/repository.h" void cl_git_report_failure( - int error, int expected, const char *file, int line, const char *fncall) + int error, int expected, const char *file, const char *func, int line, const char *fncall) { char msg[4096]; const git_error *last = git_error_last(); @@ -18,7 +18,7 @@ void cl_git_report_failure( else p_snprintf(msg, 4096, "no error, expected non-zero return"); - clar__assert(0, file, line, fncall, msg, 1); + clar__assert(0, file, func, line, fncall, msg, 1); } void cl_git_mkfile(const char *filename, const char *content) @@ -507,6 +507,7 @@ void clar__assert_equal_file( int ignore_cr, const char *path, const char *file, + const char *func, int line) { char buf[4000]; @@ -519,7 +520,7 @@ void clar__assert_equal_file( while ((bytes = p_read(fd, buf, sizeof(buf))) != 0) { clar__assert( - bytes > 0, file, line, "error reading from file", path, 1); + bytes > 0, file, func, line, "error reading from file", path, 1); if (ignore_cr) bytes = strip_cr_from_buf(buf, bytes); @@ -532,7 +533,7 @@ void clar__assert_equal_file( buf, sizeof(buf), "file content mismatch at byte %"PRIdZ, (ssize_t)(total_bytes + pos)); p_close(fd); - clar__fail(file, line, path, buf, 1); + clar__fail(file, func, line, path, buf, 1); } expected_data += bytes; @@ -541,8 +542,8 @@ void clar__assert_equal_file( p_close(fd); - clar__assert(!bytes, file, line, "error reading from file", path, 1); - clar__assert_equal(file, line, "mismatched file length", 1, "%"PRIuZ, + clar__assert(!bytes, file, func, line, "error reading from file", path, 1); + clar__assert_equal(file, func, line, "mismatched file length", 1, "%"PRIuZ, (size_t)expected_bytes, (size_t)total_bytes); } diff --git a/tests/clar_libgit2.h b/tests/clar_libgit2.h index 12175c629..e3b7bd9f8 100644 --- a/tests/clar_libgit2.h +++ b/tests/clar_libgit2.h @@ -12,15 +12,15 @@ * * Use this wrapper around all `git_` library calls that return error codes! */ -#define cl_git_pass(expr) cl_git_expect((expr), 0, __FILE__, __LINE__) +#define cl_git_pass(expr) cl_git_expect((expr), 0, __FILE__, __func__, __LINE__) -#define cl_git_fail_with(error, expr) cl_git_expect((expr), error, __FILE__, __LINE__) +#define cl_git_fail_with(error, expr) cl_git_expect((expr), error, __FILE__, __func__, __LINE__) -#define cl_git_expect(expr, expected, file, line) do { \ +#define cl_git_expect(expr, expected, file, func, line) do { \ int _lg2_error; \ git_error_clear(); \ if ((_lg2_error = (expr)) != expected) \ - cl_git_report_failure(_lg2_error, expected, file, line, "Function call failed: " #expr); \ + cl_git_report_failure(_lg2_error, expected, file, func, line, "Function call failed: " #expr); \ } while (0) /** @@ -31,7 +31,7 @@ #define cl_git_fail(expr) do { \ if ((expr) == 0) \ git_error_clear(), \ - cl_git_report_failure(0, 0, __FILE__, __LINE__, "Function call succeeded: " #expr); \ + cl_git_report_failure(0, 0, __FILE__, __func__, __LINE__, "Function call succeeded: " #expr); \ } while (0) /** @@ -41,7 +41,7 @@ int _win32_res; \ if ((_win32_res = (expr)) == 0) { \ git_error_set(GIT_ERROR_OS, "Returned: %d, system error code: %lu", _win32_res, GetLastError()); \ - cl_git_report_failure(_win32_res, 0, __FILE__, __LINE__, "System call failed: " #expr); \ + cl_git_report_failure(_win32_res, 0, __FILE__, __func__, __LINE__, "System call failed: " #expr); \ } \ } while(0) @@ -58,22 +58,24 @@ typedef struct { int error; const char *file; + const char *func; int line; const char *expr; char error_msg[4096]; } cl_git_thread_err; #ifdef GIT_THREADS -# define cl_git_thread_pass(threaderr, expr) cl_git_thread_pass_(threaderr, (expr), __FILE__, __LINE__) +# define cl_git_thread_pass(threaderr, expr) cl_git_thread_pass_(threaderr, (expr), __FILE__, __func__, __LINE__) #else # define cl_git_thread_pass(threaderr, expr) cl_git_pass(expr) #endif -#define cl_git_thread_pass_(__threaderr, __expr, __file, __line) do { \ +#define cl_git_thread_pass_(__threaderr, __expr, __file, __func, __line) do { \ git_error_clear(); \ if ((((cl_git_thread_err *)__threaderr)->error = (__expr)) != 0) { \ const git_error *_last = git_error_last(); \ ((cl_git_thread_err *)__threaderr)->file = __file; \ + ((cl_git_thread_err *)__threaderr)->func = __func; \ ((cl_git_thread_err *)__threaderr)->line = __line; \ ((cl_git_thread_err *)__threaderr)->expr = "Function call failed: " #__expr; \ p_snprintf(((cl_git_thread_err *)__threaderr)->error_msg, 4096, "thread 0x%" PRIxZ " - error %d - %s", \ @@ -87,38 +89,39 @@ GIT_INLINE(void) cl_git_thread_check(void *data) { cl_git_thread_err *threaderr = (cl_git_thread_err *)data; if (threaderr->error != 0) - clar__assert(0, threaderr->file, threaderr->line, threaderr->expr, threaderr->error_msg, 1); + clar__assert(0, threaderr->file, threaderr->func, threaderr->line, threaderr->expr, threaderr->error_msg, 1); } -void cl_git_report_failure(int, int, const char *, int, const char *); +void cl_git_report_failure(int, int, const char *, const char *, int, const char *); -#define cl_assert_at_line(expr,file,line) \ - clar__assert((expr) != 0, file, line, "Expression is not true: " #expr, NULL, 1) +#define cl_assert_at_line(expr,file,func,line) \ + clar__assert((expr) != 0, file, func, line, "Expression is not true: " #expr, NULL, 1) GIT_INLINE(void) clar__assert_in_range( int lo, int val, int hi, - const char *file, int line, const char *err, int should_abort) + const char *file, const char *func, int line, + const char *err, int should_abort) { if (lo > val || hi < val) { char buf[128]; p_snprintf(buf, sizeof(buf), "%d not in [%d,%d]", val, lo, hi); - clar__fail(file, line, err, buf, should_abort); + clar__fail(file, func, line, err, buf, should_abort); } } #define cl_assert_equal_sz(sz1,sz2) do { \ size_t __sz1 = (size_t)(sz1), __sz2 = (size_t)(sz2); \ - clar__assert_equal(__FILE__,__LINE__,#sz1 " != " #sz2, 1, "%"PRIuZ, __sz1, __sz2); \ + clar__assert_equal(__FILE__,__func__,__LINE__,#sz1 " != " #sz2, 1, "%"PRIuZ, __sz1, __sz2); \ } while (0) #define cl_assert_in_range(L,V,H) \ - clar__assert_in_range((L),(V),(H),__FILE__,__LINE__,"Range check: " #V " in [" #L "," #H "]", 1) + clar__assert_in_range((L),(V),(H),__FILE__,__func__,__LINE__,"Range check: " #V " in [" #L "," #H "]", 1) #define cl_assert_equal_file(DATA,SIZE,PATH) \ - clar__assert_equal_file(DATA,SIZE,0,PATH,__FILE__,(int)__LINE__) + clar__assert_equal_file(DATA,SIZE,0,PATH,__FILE__,__func__,(int)__LINE__) #define cl_assert_equal_file_ignore_cr(DATA,SIZE,PATH) \ - clar__assert_equal_file(DATA,SIZE,1,PATH,__FILE__,(int)__LINE__) + clar__assert_equal_file(DATA,SIZE,1,PATH,__FILE__,__func__,(int)__LINE__) void clar__assert_equal_file( const char *expected_data, @@ -126,10 +129,11 @@ void clar__assert_equal_file( int ignore_cr, const char *path, const char *file, + const char *func, int line); GIT_INLINE(void) clar__assert_equal_oid( - const char *file, int line, const char *desc, + const char *file, const char *func, int line, const char *desc, const git_oid *one, const git_oid *two) { if (git_oid_cmp(one, two)) { @@ -138,12 +142,12 @@ GIT_INLINE(void) clar__assert_equal_oid( git_oid_fmt(&err[1], one); git_oid_fmt(&err[47], two); - clar__fail(file, line, desc, err, 1); + clar__fail(file, func, line, desc, err, 1); } } #define cl_assert_equal_oid(one, two) \ - clar__assert_equal_oid(__FILE__, __LINE__, \ + clar__assert_equal_oid(__FILE__, __func__, __LINE__, \ "OID mismatch: " #one " != " #two, (one), (two)) /* diff --git a/tests/clone/empty.c b/tests/clone/empty.c index 8e59d2b8c..94847bc73 100644 --- a/tests/clone/empty.c +++ b/tests/clone/empty.c @@ -2,6 +2,7 @@ #include "git2/clone.h" #include "repository.h" +#include "repo/repo_helpers.h" static git_clone_options g_options; static git_repository *g_repo; @@ -22,6 +23,7 @@ void test_clone_empty__initialize(void) void test_clone_empty__cleanup(void) { + cl_fixture_cleanup("tmp_global_path"); cl_git_sandbox_cleanup(); } @@ -66,6 +68,21 @@ void test_clone_empty__can_clone_an_empty_local_repo_barely(void) expected_tracked_branch_name)); } +void test_clone_empty__respects_initialbranch_config(void) +{ + git_buf buf = GIT_BUF_INIT; + + create_tmp_global_config("tmp_global_path", "init.defaultbranch", "my_default_branch"); + + cl_set_cleanup(&cleanup_repository, "./empty"); + + g_options.bare = true; + cl_git_pass(git_clone(&g_repo_cloned, "./empty_bare.git", "./empty", &g_options)); + cl_git_pass(git_branch_upstream_name(&buf, g_repo_cloned, "refs/heads/my_default_branch")); + cl_assert_equal_s("refs/remotes/origin/my_default_branch", buf.ptr); + git_buf_dispose(&buf); +} + void test_clone_empty__can_clone_an_empty_local_repo(void) { cl_set_cleanup(&cleanup_repository, "./empty"); diff --git a/tests/config/read.c b/tests/config/read.c index ba97302f7..109908750 100644 --- a/tests/config/read.c +++ b/tests/config/read.c @@ -928,3 +928,79 @@ void test_config_read__nosection(void) git_buf_dispose(&buf); git_config_free(cfg); } + +enum { + MAP_TRUE = 0, + MAP_FALSE = 1, + MAP_ALWAYS = 2 +}; + +static git_configmap _test_map1[] = { + {GIT_CONFIGMAP_STRING, "always", MAP_ALWAYS}, + {GIT_CONFIGMAP_FALSE, NULL, MAP_FALSE}, + {GIT_CONFIGMAP_TRUE, NULL, MAP_TRUE}, +}; + +static git_configmap _test_map2[] = { + {GIT_CONFIGMAP_INT32, NULL, 0}, +}; + +void test_config_read__get_mapped(void) +{ + git_config *cfg; + int val; + int known_good; + + cl_set_cleanup(&clean_test_config, NULL); + cl_git_mkfile("./testconfig", "[header]\n" + " key1 = 1\n" + " key2 = true\n" + " key3\n" + " key4 = always\n" + " key5 = false\n" + " key6 = 0\n" + " key7 = never\n" + " key8 = On\n" + " key9 = off\n"); + cl_git_pass(git_config_open_ondisk(&cfg, "./testconfig")); + + // check parsing bool and string + cl_git_pass(git_config_get_mapped(&val, cfg, "header.key1", _test_map1, ARRAY_SIZE(_test_map1))); + cl_assert_equal_i(val, MAP_TRUE); + cl_git_pass(git_config_get_mapped(&val, cfg, "header.key2", _test_map1, ARRAY_SIZE(_test_map1))); + cl_assert_equal_i(val, MAP_TRUE); + cl_git_pass(git_config_get_mapped(&val, cfg, "header.key3", _test_map1, ARRAY_SIZE(_test_map1))); + cl_assert_equal_i(val, MAP_TRUE); + cl_git_pass(git_config_get_mapped(&val, cfg, "header.key8", _test_map1, ARRAY_SIZE(_test_map1))); + cl_assert_equal_i(val, MAP_TRUE); + + cl_git_pass(git_config_get_mapped(&val, cfg, "header.key4", _test_map1, ARRAY_SIZE(_test_map1))); + cl_assert_equal_i(val, MAP_ALWAYS); + + cl_git_pass(git_config_get_mapped(&val, cfg, "header.key5", _test_map1, ARRAY_SIZE(_test_map1))); + cl_assert_equal_i(val, MAP_FALSE); + cl_git_pass(git_config_get_mapped(&val, cfg, "header.key6", _test_map1, ARRAY_SIZE(_test_map1))); + cl_assert_equal_i(val, MAP_FALSE); + cl_git_pass(git_config_get_mapped(&val, cfg, "header.key9", _test_map1, ARRAY_SIZE(_test_map1))); + cl_assert_equal_i(val, MAP_FALSE); + + cl_git_fail(git_config_get_mapped(&val, cfg, "header.key7", _test_map1, ARRAY_SIZE(_test_map1))); + + // check parsing int values + cl_git_pass(git_config_get_mapped(&val, cfg, "header.key1", _test_map2, ARRAY_SIZE(_test_map2))); + cl_git_pass(git_config_get_int32(&known_good, cfg, "header.key1")); + cl_assert_equal_i(val, known_good); + cl_git_pass(git_config_get_mapped(&val, cfg, "header.key6", _test_map2, ARRAY_SIZE(_test_map2))); + cl_git_pass(git_config_get_int32(&known_good, cfg, "header.key6")); + cl_assert_equal_i(val, known_good); + + cl_git_fail(git_config_get_mapped(&val, cfg, "header.key2", _test_map2, ARRAY_SIZE(_test_map2))); + cl_git_fail(git_config_get_mapped(&val, cfg, "header.key3", _test_map2, ARRAY_SIZE(_test_map2))); + cl_git_fail(git_config_get_mapped(&val, cfg, "header.key4", _test_map2, ARRAY_SIZE(_test_map2))); + cl_git_fail(git_config_get_mapped(&val, cfg, "header.key5", _test_map2, ARRAY_SIZE(_test_map2))); + cl_git_fail(git_config_get_mapped(&val, cfg, "header.key7", _test_map2, ARRAY_SIZE(_test_map2))); + cl_git_fail(git_config_get_mapped(&val, cfg, "header.key8", _test_map2, ARRAY_SIZE(_test_map2))); + cl_git_fail(git_config_get_mapped(&val, cfg, "header.key9", _test_map2, ARRAY_SIZE(_test_map2))); + + git_config_free(cfg); +} diff --git a/tests/config/stress.c b/tests/config/stress.c index 28c3c4ac0..577452e8d 100644 --- a/tests/config/stress.c +++ b/tests/config/stress.c @@ -59,6 +59,11 @@ void test_config_stress__comments(void) assert_config_value(config, "some.section.multi", "hi, this is a ; multiline comment # with ;\n special chars and other stuff !@#"); assert_config_value(config, "some.section.multi2", "good, this is a ; multiline comment # with ;\n special chars and other stuff !@#"); assert_config_value(config, "some.section.back", "this is \ba phrase"); + assert_config_value(config, "some.section.dollar", "some $sign"); + assert_config_value(config, "some.section.multiquotes", "!ls x ls # comment2 $HOME"); + assert_config_value(config, "some.section.multiquotes2", "!ls x ls \"# comment2 $HOME\""); + assert_config_value(config, "some.section.multiquotes3", "hi # ho there are # more quotes"); + assert_config_value(config, "some.section.quotecomment", "hi # ho there are # more"); git_config_free(config); } diff --git a/tests/core/assert.c b/tests/core/assert.c new file mode 100644 index 000000000..ef75624b9 --- /dev/null +++ b/tests/core/assert.c @@ -0,0 +1,94 @@ +#ifdef GIT_ASSERT_HARD +# undef GIT_ASSERT_HARD +#endif + +#define GIT_ASSERT_HARD 0 + +#include "clar_libgit2.h" + +static const char *hello_world = "hello, world"; +static const char *fail = "FAIL"; + +static int dummy_fn(const char *myarg) +{ + GIT_ASSERT_ARG(myarg); + GIT_ASSERT_ARG(myarg != hello_world); + return 0; +} + +static const char *fn_returns_string(const char *myarg) +{ + GIT_ASSERT_ARG_WITH_RETVAL(myarg, fail); + GIT_ASSERT_ARG_WITH_RETVAL(myarg != hello_world, fail); + + return myarg; +} + +static int bad_math(void) +{ + GIT_ASSERT(1 + 1 == 3); + return 42; +} + +static const char *bad_returns_string(void) +{ + GIT_ASSERT_WITH_RETVAL(1 + 1 == 3, NULL); + return hello_world; +} + +void test_core_assert__argument(void) +{ + cl_git_fail(dummy_fn(NULL)); + cl_assert(git_error_last()); + cl_assert_equal_i(GIT_ERROR_INVALID, git_error_last()->klass); + cl_assert_equal_s("invalid argument: 'myarg'", git_error_last()->message); + + cl_git_fail(dummy_fn(hello_world)); + cl_assert(git_error_last()); + cl_assert_equal_i(GIT_ERROR_INVALID, git_error_last()->klass); + cl_assert_equal_s("invalid argument: 'myarg != hello_world'", git_error_last()->message); + + cl_git_pass(dummy_fn("foo")); +} + +void test_core_assert__argument_with_non_int_return_type(void) +{ + const char *foo = "foo"; + + cl_assert_equal_p(fail, fn_returns_string(NULL)); + cl_assert_equal_i(GIT_ERROR_INVALID, git_error_last()->klass); + cl_assert_equal_s("invalid argument: 'myarg'", git_error_last()->message); + + cl_assert_equal_p(fail, fn_returns_string(hello_world)); + cl_assert_equal_i(GIT_ERROR_INVALID, git_error_last()->klass); + cl_assert_equal_s("invalid argument: 'myarg != hello_world'", git_error_last()->message); + + cl_assert_equal_p(foo, fn_returns_string(foo)); +} + +void test_core_assert__argument_with_void_return_type(void) +{ + const char *foo = "foo"; + + git_error_clear(); + fn_returns_string(hello_world); + cl_assert_equal_i(GIT_ERROR_INVALID, git_error_last()->klass); + cl_assert_equal_s("invalid argument: 'myarg != hello_world'", git_error_last()->message); + + git_error_clear(); + cl_assert_equal_p(foo, fn_returns_string(foo)); + cl_assert_equal_p(NULL, git_error_last()); +} + +void test_core_assert__internal(void) +{ + cl_git_fail(bad_math()); + cl_assert(git_error_last()); + cl_assert_equal_i(GIT_ERROR_INTERNAL, git_error_last()->klass); + cl_assert_equal_s("unrecoverable internal error: '1 + 1 == 3'", git_error_last()->message); + + cl_assert_equal_p(NULL, bad_returns_string()); + cl_assert(git_error_last()); + cl_assert_equal_i(GIT_ERROR_INTERNAL, git_error_last()->klass); + cl_assert_equal_s("unrecoverable internal error: '1 + 1 == 3'", git_error_last()->message); +} diff --git a/tests/core/mkdir.c b/tests/core/mkdir.c index ce11953f0..3f04c2ad3 100644 --- a/tests/core/mkdir.c +++ b/tests/core/mkdir.c @@ -150,10 +150,11 @@ static void cleanup_chmod_root(void *ref) git_futils_rmdir_r("r", NULL, GIT_RMDIR_EMPTY_HIERARCHY); } -#define check_mode(X,A) check_mode_at_line((X), (A), __FILE__, __LINE__) +#define check_mode(X,A) check_mode_at_line((X), (A), __FILE__, __func__, __LINE__) static void check_mode_at_line( - mode_t expected, mode_t actual, const char *file, int line) + mode_t expected, mode_t actual, + const char *file, const char *func, int line) { /* FAT filesystems don't support exec bit, nor group/world bits */ if (!cl_is_chmod_supported()) { @@ -162,7 +163,7 @@ static void check_mode_at_line( } clar__assert_equal( - file, line, "expected_mode != actual_mode", 1, + file, func, line, "expected_mode != actual_mode", 1, "%07o", (int)expected, (int)(actual & 0777)); } diff --git a/tests/core/structinit.c b/tests/core/structinit.c index f9da8237c..192096be3 100644 --- a/tests/core/structinit.c +++ b/tests/core/structinit.c @@ -48,7 +48,7 @@ static void options_cmp(void *one, void *two, size_t size, const char *name) p_snprintf(desc, 1024, "Difference in %s at byte %" PRIuZ ": macro=%u / func=%u", name, i, ((char *)one)[i], ((char *)two)[i]); - clar__fail(__FILE__, __LINE__, + clar__fail(__FILE__, __func__, __LINE__, "Difference between macro and function options initializer", desc, 0); return; diff --git a/tests/core/wildmatch.c b/tests/core/wildmatch.c index e7897c6e6..7c56ee7b8 100644 --- a/tests/core/wildmatch.c +++ b/tests/core/wildmatch.c @@ -3,21 +3,21 @@ #include "wildmatch.h" #define assert_matches(string, pattern, wildmatch, iwildmatch, pathmatch, ipathmatch) \ - assert_matches_(string, pattern, wildmatch, iwildmatch, pathmatch, ipathmatch, __FILE__, __LINE__) + assert_matches_(string, pattern, wildmatch, iwildmatch, pathmatch, ipathmatch, __FILE__, __func__, __LINE__) static void assert_matches_(const char *string, const char *pattern, char expected_wildmatch, char expected_iwildmatch, char expected_pathmatch, char expected_ipathmatch, - const char *file, size_t line) + const char *file, const char *func, size_t line) { if (wildmatch(pattern, string, WM_PATHNAME) == expected_wildmatch) - clar__fail(file, line, "Test failed (wildmatch).", string, 1); + clar__fail(file, func, line, "Test failed (wildmatch).", string, 1); if (wildmatch(pattern, string, WM_PATHNAME|WM_CASEFOLD) == expected_iwildmatch) - clar__fail(file, line, "Test failed (iwildmatch).", string, 1); + clar__fail(file, func, line, "Test failed (iwildmatch).", string, 1); if (wildmatch(pattern, string, 0) == expected_pathmatch) - clar__fail(file, line, "Test failed (pathmatch).", string, 1); + clar__fail(file, func, line, "Test failed (pathmatch).", string, 1); if (wildmatch(pattern, string, WM_CASEFOLD) == expected_ipathmatch) - clar__fail(file, line, "Test failed (ipathmatch).", string, 1); + clar__fail(file, func, line, "Test failed (ipathmatch).", string, 1); } /* diff --git a/tests/core/zstream.c b/tests/core/zstream.c index bcbb45fde..3cbcea168 100644 --- a/tests/core/zstream.c +++ b/tests/core/zstream.c @@ -9,7 +9,7 @@ static const char *data = "This is a test test test of This is a test"; static void assert_zlib_equal_( const void *expected, size_t e_len, const void *compressed, size_t c_len, - const char *msg, const char *file, int line) + const char *msg, const char *file, const char *func, int line) { z_stream stream; char *expanded = git__calloc(1, e_len + INFLATE_EXTRA); @@ -26,21 +26,21 @@ static void assert_zlib_equal_( inflateEnd(&stream); clar__assert_equal( - file, line, msg, 1, + file, func, line, msg, 1, "%d", (int)stream.total_out, (int)e_len); clar__assert_equal( - file, line, "Buffer len was not exact match", 1, + file, func, line, "Buffer len was not exact match", 1, "%d", (int)stream.avail_out, (int)INFLATE_EXTRA); clar__assert( memcmp(expanded, expected, e_len) == 0, - file, line, "uncompressed data did not match", NULL, 1); + file, func, line, "uncompressed data did not match", NULL, 1); git__free(expanded); } #define assert_zlib_equal(E,EL,C,CL) \ - assert_zlib_equal_(E, EL, C, CL, #EL " != " #CL, __FILE__, (int)__LINE__) + assert_zlib_equal_(E, EL, C, CL, #EL " != " #CL, __FILE__, __func__, (int)__LINE__) void test_core_zstream__basic(void) { diff --git a/tests/diff/format_email.c b/tests/diff/format_email.c index 28f840ab0..bdfc4cac3 100644 --- a/tests/diff/format_email.c +++ b/tests/diff/format_email.c @@ -487,7 +487,7 @@ void test_diff_format_email__binary(void) "Subject: [PATCH] Modified binary file\n" \ "\n" \ "---\n" \ - " binary.bin | Bin 3 -> 0 bytes\n" \ + " binary.bin | Bin 3 -> 5 bytes\n" \ " 1 file changed, 0 insertions(+), 0 deletions(-)\n" \ "\n" \ "diff --git a/binary.bin b/binary.bin\n" \ @@ -496,7 +496,6 @@ void test_diff_format_email__binary(void) "--\n" \ "libgit2 " LIBGIT2_VERSION "\n" \ "\n"; - /* TODO: Actually 0 bytes here should be 5!. Seems like we don't load the new content for binary files? */ opts.summary = "Modified binary file"; diff --git a/tests/diff/parse.c b/tests/diff/parse.c index b004d1e23..6b6e6645e 100644 --- a/tests/diff/parse.c +++ b/tests/diff/parse.c @@ -2,7 +2,6 @@ #include "patch.h" #include "patch_parse.h" #include "diff_helpers.h" -#include "../src/diff.h" #include "../patch/patch_common.h" @@ -108,6 +107,29 @@ void test_diff_parse__no_extended_headers(void) git_diff_free(diff); } +void test_diff_parse__add_delete_no_index(void) +{ + const char *content = + "diff --git a/file.txt b/file.txt\n" + "new file mode 100644\n" + "--- /dev/null\n" + "+++ b/file.txt\n" + "@@ -0,0 +1,2 @@\n" + "+one\n" + "+two\n" + "diff --git a/otherfile.txt b/otherfile.txt\n" + "deleted file mode 100644\n" + "--- a/otherfile.txt\n" + "+++ /dev/null\n" + "@@ -1,1 +0,0 @@\n" + "-three\n"; + git_diff *diff; + + cl_git_pass(git_diff_from_buffer( + &diff, content, strlen(content))); + git_diff_free(diff); +} + void test_diff_parse__invalid_patches_fails(void) { test_parse_invalid_diff(PATCH_CORRUPT_MISSING_NEW_FILE); @@ -319,20 +341,20 @@ void test_diff_parse__patch_roundtrip_succeeds(void) git_buf_dispose(&diffbuf); } -#define cl_assert_equal_i_src(i1,i2,file,line) clar__assert_equal(file,line,#i1 " != " #i2, 1, "%d", (int)(i1), (int)(i2)) +#define cl_assert_equal_i_src(i1,i2,file,func,line) clar__assert_equal(file,func,line,#i1 " != " #i2, 1, "%d", (int)(i1), (int)(i2)) -static void cl_git_assert_lineinfo_(int old_lineno, int new_lineno, int num_lines, git_patch *patch, size_t hunk_idx, size_t line_idx, const char *file, int lineno) +static void cl_git_assert_lineinfo_(int old_lineno, int new_lineno, int num_lines, git_patch *patch, size_t hunk_idx, size_t line_idx, const char *file, const char *func, int lineno) { const git_diff_line *line; - cl_git_expect(git_patch_get_line_in_hunk(&line, patch, hunk_idx, line_idx), 0, file, lineno); - cl_assert_equal_i_src(old_lineno, line->old_lineno, file, lineno); - cl_assert_equal_i_src(new_lineno, line->new_lineno, file, lineno); - cl_assert_equal_i_src(num_lines, line->num_lines, file, lineno); + cl_git_expect(git_patch_get_line_in_hunk(&line, patch, hunk_idx, line_idx), 0, file, func, lineno); + cl_assert_equal_i_src(old_lineno, line->old_lineno, file, func, lineno); + cl_assert_equal_i_src(new_lineno, line->new_lineno, file, func, lineno); + cl_assert_equal_i_src(num_lines, line->num_lines, file, func, lineno); } #define cl_git_assert_lineinfo(old, new, num, p, h, l) \ - cl_git_assert_lineinfo_(old,new,num,p,h,l,__FILE__,__LINE__) + cl_git_assert_lineinfo_(old,new,num,p,h,l,__FILE__,__func__,__LINE__) void test_diff_parse__issue4672(void) diff --git a/tests/diff/stats.c b/tests/diff/stats.c index 150355686..54572672c 100644 --- a/tests/diff/stats.c +++ b/tests/diff/stats.c @@ -298,9 +298,8 @@ void test_diff_stats__binary(void) { git_buf buf = GIT_BUF_INIT; const char *stat = - " binary.bin | Bin 3 -> 0 bytes\n" + " binary.bin | Bin 3 -> 5 bytes\n" " 1 file changed, 0 insertions(+), 0 deletions(-)\n"; - /* TODO: Actually 0 bytes here should be 5!. Seems like we don't load the new content for binary files? */ diff_stats_from_commit_oid( &_stats, "8d7523f6fcb2404257889abe0d96f093d9f524f9", false); @@ -343,3 +342,38 @@ void test_diff_stats__mode_change(void) cl_assert_equal_s(stat, git_buf_cstr(&buf)); git_buf_dispose(&buf); } + +void test_diff_stats__new_file(void) +{ + git_diff *diff; + git_buf buf = GIT_BUF_INIT; + + const char *input = + "---\n" + " Gurjeet Singh | 1 +\n" + " 1 file changed, 1 insertion(+)\n" + " create mode 100644 Gurjeet Singh\n" + "\n" + "diff --git a/Gurjeet Singh b/Gurjeet Singh\n" + "new file mode 100644\n" + "index 0000000..6d0ecfd\n" + "--- /dev/null\n" + "+++ b/Gurjeet Singh \n" + "@@ -0,0 +1 @@\n" + "+I'm about to try git send-email\n" + "-- \n" + "2.21.0\n"; + + const char *stat = + " Gurjeet Singh | 1 +\n" + " 1 file changed, 1 insertion(+)\n" + " create mode 100644 Gurjeet Singh\n"; + + cl_git_pass(git_diff_from_buffer(&diff, input, strlen(input))); + cl_git_pass(git_diff_get_stats(&_stats, diff)); + cl_git_pass(git_diff_stats_to_buf(&buf, _stats, GIT_DIFF_STATS_FULL | GIT_DIFF_STATS_INCLUDE_SUMMARY, 0)); + cl_assert_equal_s(stat, git_buf_cstr(&buf)); + + git_buf_dispose(&buf); + git_diff_free(diff); +} diff --git a/tests/diff/submodules.c b/tests/diff/submodules.c index 8899d3f9c..93223ef7d 100644 --- a/tests/diff/submodules.c +++ b/tests/diff/submodules.c @@ -18,7 +18,8 @@ void test_diff_submodules__cleanup(void) #define get_buf_ptr(buf) ((buf)->asize ? (buf)->ptr : NULL) static void check_diff_patches_at_line( - git_diff *diff, const char **expected, const char *file, int line) + git_diff *diff, const char **expected, + const char *file, const char *func, int line) { const git_diff_delta *delta; git_patch *patch = NULL; @@ -30,34 +31,34 @@ static void check_diff_patches_at_line( cl_assert((delta = git_patch_get_delta(patch)) != NULL); if (delta->status == GIT_DELTA_UNMODIFIED) { - cl_assert_at_line(expected[d] == NULL, file, line); + cl_assert_at_line(expected[d] == NULL, file, func, line); continue; } if (expected[d] && !strcmp(expected[d], "")) continue; if (expected[d] && !strcmp(expected[d], "")) { - cl_assert_at_line(delta->status == GIT_DELTA_UNTRACKED, file, line); + cl_assert_at_line(delta->status == GIT_DELTA_UNTRACKED, file, func, line); continue; } if (expected[d] && !strcmp(expected[d], "")) { cl_git_pass(git_patch_to_buf(&buf, patch)); - cl_assert_at_line(!strcmp(expected[d], ""), file, line); + cl_assert_at_line(!strcmp(expected[d], ""), file, func, line); } cl_git_pass(git_patch_to_buf(&buf, patch)); clar__assert_equal( - file, line, "expected diff did not match actual diff", 1, + file, func, line, "expected diff did not match actual diff", 1, "%s", expected[d], get_buf_ptr(&buf)); git_buf_dispose(&buf); } - cl_assert_at_line(expected[d] && !strcmp(expected[d], ""), file, line); + cl_assert_at_line(expected[d] && !strcmp(expected[d], ""), file, func, line); } #define check_diff_patches(diff, exp) \ - check_diff_patches_at_line(diff, exp, __FILE__, __LINE__) + check_diff_patches_at_line(diff, exp, __FILE__, __func__, __LINE__) void test_diff_submodules__unmodified_submodule(void) { diff --git a/tests/diff/workdir.c b/tests/diff/workdir.c index 71b2e91a7..f2404958e 100644 --- a/tests/diff/workdir.c +++ b/tests/diff/workdir.c @@ -1876,9 +1876,9 @@ void test_diff_workdir__binary_detection(void) git_buf b = GIT_BUF_INIT; int i; git_buf data[10] = { - { "1234567890", 0, 0 }, /* 0 - all ascii text control */ - { "\xC3\x85\xC3\xBC\xE2\x80\xA0\x48\xC3\xB8\xCF\x80\xCE\xA9", 0, 0 }, /* 1 - UTF-8 multibyte text */ - { "\xEF\xBB\xBF\xC3\x9C\xE2\xA4\x92\xC6\x92\x38\xC2\xA3\xE2\x82\xAC", 0, 0 }, /* 2 - UTF-8 with BOM */ + { "1234567890", 0, 10 }, /* 0 - all ascii text control */ + { "\xC3\x85\xC3\xBC\xE2\x80\xA0\x48\xC3\xB8\xCF\x80\xCE\xA9", 0, 14 }, /* 1 - UTF-8 multibyte text */ + { "\xEF\xBB\xBF\xC3\x9C\xE2\xA4\x92\xC6\x92\x38\xC2\xA3\xE2\x82\xAC", 0, 16 }, /* 2 - UTF-8 with BOM */ { STR999Z, 0, 1000 }, /* 3 - ASCII with NUL at 1000 */ { STR3999Z, 0, 4000 }, /* 4 - ASCII with NUL at 4000 */ { STR4000 STR3999Z "x", 0, 8001 }, /* 5 - ASCII with NUL at 8000 */ diff --git a/tests/ignore/path.c b/tests/ignore/path.c index e23ac7712..5d53c9df9 100644 --- a/tests/ignore/path.c +++ b/tests/ignore/path.c @@ -17,19 +17,20 @@ void test_ignore_path__cleanup(void) } static void assert_is_ignored_( - bool expected, const char *filepath, const char *file, int line) + bool expected, const char *filepath, + const char *file, const char *func, int line) { int is_ignored = 0; cl_git_expect( - git_ignore_path_is_ignored(&is_ignored, g_repo, filepath), 0, file, line); + git_ignore_path_is_ignored(&is_ignored, g_repo, filepath), 0, file, func, line); clar__assert_equal( - file, line, "expected != is_ignored", 1, "%d", + file, func, line, "expected != is_ignored", 1, "%d", (int)(expected != 0), (int)(is_ignored != 0)); } #define assert_is_ignored(expected, filepath) \ - assert_is_ignored_(expected, filepath, __FILE__, __LINE__) + assert_is_ignored_(expected, filepath, __FILE__, __func__, __LINE__) void test_ignore_path__honor_temporary_rules(void) { diff --git a/tests/ignore/status.c b/tests/ignore/status.c index 5e67c1202..188fbe469 100644 --- a/tests/ignore/status.c +++ b/tests/ignore/status.c @@ -17,21 +17,22 @@ void test_ignore_status__cleanup(void) } static void assert_ignored_( - bool expected, const char *filepath, const char *file, int line) + bool expected, const char *filepath, + const char *file, const char *func, int line) { int is_ignored = 0; cl_git_expect( - git_status_should_ignore(&is_ignored, g_repo, filepath), 0, file, line); + git_status_should_ignore(&is_ignored, g_repo, filepath), 0, file, func, line); clar__assert( (expected != 0) == (is_ignored != 0), - file, line, "expected != is_ignored", filepath, 1); + file, func, line, "expected != is_ignored", filepath, 1); } #define assert_ignored(expected, filepath) \ - assert_ignored_(expected, filepath, __FILE__, __LINE__) + assert_ignored_(expected, filepath, __FILE__, __func__, __LINE__) #define assert_is_ignored(filepath) \ - assert_ignored_(true, filepath, __FILE__, __LINE__) + assert_ignored_(true, filepath, __FILE__, __func__, __LINE__) #define refute_is_ignored(filepath) \ - assert_ignored_(false, filepath, __FILE__, __LINE__) + assert_ignored_(false, filepath, __FILE__, __func__, __LINE__) void test_ignore_status__0(void) { diff --git a/tests/index/addall.c b/tests/index/addall.c index c62c3cfe6..d1ef31daf 100644 --- a/tests/index/addall.c +++ b/tests/index/addall.c @@ -75,7 +75,7 @@ static void check_status_at_line( git_repository *repo, size_t index_adds, size_t index_dels, size_t index_mods, size_t wt_adds, size_t wt_dels, size_t wt_mods, size_t ignores, - size_t conflicts, const char *file, int line) + size_t conflicts, const char *file, const char *func, int line) { index_status_counts vals; @@ -84,25 +84,25 @@ static void check_status_at_line( cl_git_pass(git_status_foreach(repo, index_status_cb, &vals)); clar__assert_equal( - file,line,"wrong index adds", 1, "%"PRIuZ, index_adds, vals.index_adds); + file,func,line,"wrong index adds", 1, "%"PRIuZ, index_adds, vals.index_adds); clar__assert_equal( - file,line,"wrong index dels", 1, "%"PRIuZ, index_dels, vals.index_dels); + file,func,line,"wrong index dels", 1, "%"PRIuZ, index_dels, vals.index_dels); clar__assert_equal( - file,line,"wrong index mods", 1, "%"PRIuZ, index_mods, vals.index_mods); + file,func,line,"wrong index mods", 1, "%"PRIuZ, index_mods, vals.index_mods); clar__assert_equal( - file,line,"wrong workdir adds", 1, "%"PRIuZ, wt_adds, vals.wt_adds); + file,func,line,"wrong workdir adds", 1, "%"PRIuZ, wt_adds, vals.wt_adds); clar__assert_equal( - file,line,"wrong workdir dels", 1, "%"PRIuZ, wt_dels, vals.wt_dels); + file,func,line,"wrong workdir dels", 1, "%"PRIuZ, wt_dels, vals.wt_dels); clar__assert_equal( - file,line,"wrong workdir mods", 1, "%"PRIuZ, wt_mods, vals.wt_mods); + file,func,line,"wrong workdir mods", 1, "%"PRIuZ, wt_mods, vals.wt_mods); clar__assert_equal( - file,line,"wrong ignores", 1, "%"PRIuZ, ignores, vals.ignores); + file,func,line,"wrong ignores", 1, "%"PRIuZ, ignores, vals.ignores); clar__assert_equal( - file,line,"wrong conflicts", 1, "%"PRIuZ, conflicts, vals.conflicts); + file,func,line,"wrong conflicts", 1, "%"PRIuZ, conflicts, vals.conflicts); } #define check_status(R,IA,ID,IM,WA,WD,WM,IG,C) \ - check_status_at_line(R,IA,ID,IM,WA,WD,WM,IG,C,__FILE__,__LINE__) + check_status_at_line(R,IA,ID,IM,WA,WD,WM,IG,C,__FILE__,__func__,__LINE__) static void check_stat_data(git_index *index, const char *path, bool match) { diff --git a/tests/index/crlf.c b/tests/index/crlf.c index 7aa6be429..26c19d76d 100644 --- a/tests/index/crlf.c +++ b/tests/index/crlf.c @@ -96,7 +96,7 @@ done: git_buf details = GIT_BUF_INIT; git_buf_printf(&details, "filename=%s, system=%s, autocrlf=%s, safecrlf=%s, attrs={%s}", basename, cd->systype, cd->autocrlf, cd->safecrlf, cd->attrs); - clar__fail(__FILE__, __LINE__, + clar__fail(__FILE__, __func__, __LINE__, "index contents did not match expected", details.ptr, 0); git_buf_dispose(&details); } diff --git a/tests/index/filemodes.c b/tests/index/filemodes.c index af1f8035e..3d2bb4a03 100644 --- a/tests/index/filemodes.c +++ b/tests/index/filemodes.c @@ -51,11 +51,11 @@ static void replace_file_with_mode( git_buf_dispose(&content); } -#define add_and_check_mode(I,F,X) add_and_check_mode_(I,F,X,__FILE__,__LINE__) +#define add_and_check_mode(I,F,X) add_and_check_mode_(I,F,X,__FILE__,__func__,__LINE__) static void add_and_check_mode_( git_index *index, const char *filename, unsigned int expect_mode, - const char *file, int line) + const char *file, const char *func, int line) { size_t pos; const git_index_entry *entry; @@ -63,11 +63,11 @@ static void add_and_check_mode_( cl_git_pass(git_index_add_bypath(index, filename)); clar__assert(!git_index_find(&pos, index, filename), - file, line, "Cannot find index entry", NULL, 1); + file, func, line, "Cannot find index entry", NULL, 1); entry = git_index_get_byindex(index, pos); - clar__assert_equal(file, line, "Expected mode does not match index", + clar__assert_equal(file, func, line, "Expected mode does not match index", 1, "%07o", (unsigned int)entry->mode, (unsigned int)expect_mode); } @@ -153,11 +153,11 @@ void test_index_filemodes__trusted(void) git_index_free(index); } -#define add_entry_and_check_mode(I,FF,X) add_entry_and_check_mode_(I,FF,X,__FILE__,__LINE__) +#define add_entry_and_check_mode(I,FF,X) add_entry_and_check_mode_(I,FF,X,__FILE__,__func__,__LINE__) static void add_entry_and_check_mode_( git_index *index, bool from_file, git_filemode_t mode, - const char *file, int line) + const char *file, const char *func, int line) { size_t pos; const git_index_entry* entry; @@ -169,7 +169,7 @@ static void add_entry_and_check_mode_( if (from_file) { clar__assert(!git_index_find(&pos, index, "exec_off"), - file, line, "Cannot find original index entry", NULL, 1); + file, func, line, "Cannot find original index entry", NULL, 1); entry = git_index_get_byindex(index, pos); @@ -184,21 +184,21 @@ static void add_entry_and_check_mode_( if (from_file) { clar__assert(!git_index_add(index, &new_entry), - file, line, "Cannot add index entry", NULL, 1); + file, func, line, "Cannot add index entry", NULL, 1); } else { const char *content = "hey there\n"; clar__assert(!git_index_add_from_buffer(index, &new_entry, content, strlen(content)), - file, line, "Cannot add index entry from buffer", NULL, 1); + file, func, line, "Cannot add index entry from buffer", NULL, 1); } clar__assert(!git_index_find(&pos, index, "filemodes/explicit_test"), - file, line, "Cannot find new index entry", NULL, 1); + file, func, line, "Cannot find new index entry", NULL, 1); entry = git_index_get_byindex(index, pos); - clar__assert_equal(file, line, "Expected mode does not match index", + clar__assert_equal(file, func, line, "Expected mode does not match index", 1, "%07o", (unsigned int)entry->mode, (unsigned int)mode); } diff --git a/tests/merge/trees/renames.c b/tests/merge/trees/renames.c index c515aaf1b..eef7bc96b 100644 --- a/tests/merge/trees/renames.c +++ b/tests/merge/trees/renames.c @@ -307,7 +307,7 @@ void test_merge_trees_renames__cache_recomputation(void) */ cl_git_pass(git_treebuilder_new(&builder, repo, NULL)); for (i = 0; i < 1000; i++) { - cl_git_pass(git_buf_printf(&path, "%"PRIuMAX".txt", i)); + cl_git_pass(git_buf_printf(&path, "%"PRIuZ".txt", i)); cl_git_pass(git_treebuilder_insert(NULL, builder, path.ptr, &blob, GIT_FILEMODE_BLOB)); git_buf_clear(&path); } diff --git a/tests/network/fetchlocal.c b/tests/network/fetchlocal.c index 804308070..13f03100b 100644 --- a/tests/network/fetchlocal.c +++ b/tests/network/fetchlocal.c @@ -49,7 +49,7 @@ void test_network_fetchlocal__complete(void) cl_assert_equal_i(19, (int)refnames.count); cl_assert(callcount > 0); - git_strarray_free(&refnames); + git_strarray_dispose(&refnames); git_remote_free(origin); git_repository_free(repo); } @@ -77,7 +77,7 @@ void test_network_fetchlocal__prune(void) cl_git_pass(git_reference_list(&refnames, repo)); cl_assert_equal_i(19, (int)refnames.count); cl_assert(callcount > 0); - git_strarray_free(&refnames); + git_strarray_dispose(&refnames); git_remote_free(origin); cl_git_pass(git_reference_lookup(&ref, remote_repo, "refs/heads/br2")); @@ -90,7 +90,7 @@ void test_network_fetchlocal__prune(void) cl_git_pass(git_reference_list(&refnames, repo)); cl_assert_equal_i(18, (int)refnames.count); - git_strarray_free(&refnames); + git_strarray_dispose(&refnames); git_remote_free(origin); cl_git_pass(git_reference_lookup(&ref, remote_repo, "refs/heads/packed")); @@ -103,7 +103,7 @@ void test_network_fetchlocal__prune(void) cl_git_pass(git_reference_list(&refnames, repo)); cl_assert_equal_i(17, (int)refnames.count); - git_strarray_free(&refnames); + git_strarray_dispose(&refnames); git_remote_free(origin); git_repository_free(repo); @@ -168,7 +168,7 @@ void test_network_fetchlocal__prune_overlapping(void) assert_ref_exists(repo, "refs/remotes/origin/pr/42"); cl_git_pass(git_reference_list(&refnames, repo)); cl_assert_equal_i(20, (int)refnames.count); - git_strarray_free(&refnames); + git_strarray_dispose(&refnames); cl_git_pass(git_config_delete_multivar(config, "remote.origin.fetch", "refs")); cl_git_pass(git_config_set_multivar(config, "remote.origin.fetch", "^$", "refs/pull/*/head:refs/remotes/origin/pr/*")); @@ -183,7 +183,7 @@ void test_network_fetchlocal__prune_overlapping(void) assert_ref_exists(repo, "refs/remotes/origin/pr/42"); cl_git_pass(git_reference_list(&refnames, repo)); cl_assert_equal_i(20, (int)refnames.count); - git_strarray_free(&refnames); + git_strarray_dispose(&refnames); cl_git_pass(git_config_delete_multivar(config, "remote.origin.fetch", "refs")); cl_git_pass(git_config_set_multivar(config, "remote.origin.fetch", "^$", "refs/heads/*:refs/remotes/origin/*")); @@ -195,7 +195,7 @@ void test_network_fetchlocal__prune_overlapping(void) cl_git_pass(git_remote_fetch(origin, NULL, &options, NULL)); git_config_free(config); - git_strarray_free(&refnames); + git_strarray_dispose(&refnames); git_remote_free(origin); git_repository_free(repo); } @@ -224,7 +224,7 @@ void test_network_fetchlocal__fetchprune(void) cl_git_pass(git_reference_list(&refnames, repo)); cl_assert_equal_i(19, (int)refnames.count); cl_assert(callcount > 0); - git_strarray_free(&refnames); + git_strarray_dispose(&refnames); git_remote_free(origin); cl_git_pass(git_reference_lookup(&ref, remote_repo, "refs/heads/br2")); @@ -237,7 +237,7 @@ void test_network_fetchlocal__fetchprune(void) cl_git_pass(git_reference_list(&refnames, repo)); cl_assert_equal_i(18, (int)refnames.count); - git_strarray_free(&refnames); + git_strarray_dispose(&refnames); git_remote_free(origin); cl_git_pass(git_reference_lookup(&ref, remote_repo, "refs/heads/packed")); @@ -253,7 +253,7 @@ void test_network_fetchlocal__fetchprune(void) cl_git_pass(git_reference_list(&refnames, repo)); cl_assert_equal_i(17, (int)refnames.count); - git_strarray_free(&refnames); + git_strarray_dispose(&refnames); git_remote_free(origin); git_repository_free(repo); @@ -333,13 +333,13 @@ void test_network_fetchlocal__partial(void) cl_git_pass(git_remote_create(&origin, repo, GIT_REMOTE_ORIGIN, url)); cl_git_pass(git_remote_fetch(origin, NULL, &options, NULL)); - git_strarray_free(&refnames); + git_strarray_dispose(&refnames); cl_git_pass(git_reference_list(&refnames, repo)); cl_assert_equal_i(20, (int)refnames.count); /* 18 remote + 1 local */ cl_assert(callcount > 0); - git_strarray_free(&refnames); + git_strarray_dispose(&refnames); git_remote_free(origin); } @@ -420,7 +420,7 @@ void test_network_fetchlocal__multi_remotes(void) cl_git_pass(git_reference_list(&refnames, repo)); cl_assert_equal_i(33, (int)refnames.count); - git_strarray_free(&refnames); + git_strarray_dispose(&refnames); cl_git_pass(git_remote_set_url(repo, "test_with_pushurl", cl_git_fixture_url("testrepo.git"))); cl_git_pass(git_remote_lookup(&test2, repo, "test_with_pushurl")); @@ -429,7 +429,7 @@ void test_network_fetchlocal__multi_remotes(void) cl_git_pass(git_reference_list(&refnames, repo)); cl_assert_equal_i(45, (int)refnames.count); - git_strarray_free(&refnames); + git_strarray_dispose(&refnames); git_remote_free(test); git_remote_free(test2); } diff --git a/tests/network/remote/remotes.c b/tests/network/remote/remotes.c index a29281d37..0694a6f66 100644 --- a/tests/network/remote/remotes.c +++ b/tests/network/remote/remotes.c @@ -61,7 +61,7 @@ static int urlresolve_callback(git_buf *url_resolved, const char *url, int direc cl_assert(strcmp(url, "git://github.com/libgit2/libgit2") == 0); cl_assert(strcmp(payload, "payload") == 0); cl_assert(url_resolved->size == 0); - + if (direction == GIT_DIRECTION_PUSH) git_buf_sets(url_resolved, "pushresolve"); if (direction == GIT_DIRECTION_FETCH) @@ -215,11 +215,11 @@ void test_network_remote_remotes__dup(void) cl_git_pass(git_remote_get_fetch_refspecs(&array, _remote)); cl_assert_equal_i(1, (int)array.count); cl_assert_equal_s("+refs/heads/*:refs/remotes/test/*", array.strings[0]); - git_strarray_free(&array); + git_strarray_dispose(&array); cl_git_pass(git_remote_get_push_refspecs(&array, _remote)); cl_assert_equal_i(0, (int)array.count); - git_strarray_free(&array); + git_strarray_dispose(&array); git_remote_free(dup); } @@ -318,7 +318,7 @@ void test_network_remote_remotes__list(void) cl_git_pass(git_remote_list(&list, _repo)); cl_assert(list.count == 5); - git_strarray_free(&list); + git_strarray_dispose(&list); cl_git_pass(git_repository_config(&cfg, _repo)); @@ -330,7 +330,7 @@ void test_network_remote_remotes__list(void) cl_git_pass(git_remote_list(&list, _repo)); cl_assert(list.count == 7); - git_strarray_free(&list); + git_strarray_dispose(&list); git_config_free(cfg); } @@ -466,13 +466,13 @@ void test_network_remote_remotes__query_refspecs(void) for (i = 0; i < 3; i++) { cl_assert_equal_s(fetch_refspecs[i], array.strings[i]); } - git_strarray_free(&array); + git_strarray_dispose(&array); cl_git_pass(git_remote_get_push_refspecs(&array, remote)); for (i = 0; i < 3; i++) { cl_assert_equal_s(push_refspecs[i], array.strings[i]); } - git_strarray_free(&array); + git_strarray_dispose(&array); git_remote_free(remote); git_remote_delete(_repo, "test"); diff --git a/tests/network/remote/rename.c b/tests/network/remote/rename.c index 0449575d7..1fd2affba 100644 --- a/tests/network/remote/rename.c +++ b/tests/network/remote/rename.c @@ -25,7 +25,7 @@ void test_network_remote_rename__renaming_a_remote_moves_related_configuration_s cl_git_pass(git_remote_rename(&problems, _repo, _remote_name, "just/renamed")); cl_assert_equal_i(0, problems.count); - git_strarray_free(&problems); + git_strarray_dispose(&problems); assert_config_entry_existence(_repo, "remote.test.fetch", false); assert_config_entry_existence(_repo, "remote.just/renamed.fetch", true); @@ -39,7 +39,7 @@ void test_network_remote_rename__renaming_a_remote_updates_branch_related_config cl_git_pass(git_remote_rename(&problems, _repo, _remote_name, "just/renamed")); cl_assert_equal_i(0, problems.count); - git_strarray_free(&problems); + git_strarray_dispose(&problems); assert_config_entry_value(_repo, "branch.master.remote", "just/renamed"); } @@ -50,7 +50,7 @@ void test_network_remote_rename__renaming_a_remote_updates_default_fetchrefspec( cl_git_pass(git_remote_rename(&problems, _repo, _remote_name, "just/renamed")); cl_assert_equal_i(0, problems.count); - git_strarray_free(&problems); + git_strarray_dispose(&problems); assert_config_entry_value(_repo, "remote.just/renamed.fetch", "+refs/heads/*:refs/remotes/just/renamed/*"); } @@ -71,7 +71,7 @@ void test_network_remote_rename__renaming_a_remote_without_a_fetchrefspec_doesnt cl_git_pass(git_remote_rename(&problems, _repo, _remote_name, "just/renamed")); cl_assert_equal_i(0, problems.count); - git_strarray_free(&problems); + git_strarray_dispose(&problems); assert_config_entry_existence(_repo, "remote.just/renamed.fetch", false); } @@ -90,11 +90,11 @@ void test_network_remote_rename__renaming_a_remote_notifies_of_non_default_fetch cl_git_pass(git_remote_rename(&problems, _repo, _remote_name, "just/renamed")); cl_assert_equal_i(1, problems.count); cl_assert_equal_s("+refs/*:refs/*", problems.strings[0]); - git_strarray_free(&problems); + git_strarray_dispose(&problems); assert_config_entry_value(_repo, "remote.just/renamed.fetch", "+refs/*:refs/*"); - git_strarray_free(&problems); + git_strarray_dispose(&problems); } void test_network_remote_rename__new_name_can_contain_dots(void) @@ -103,7 +103,7 @@ void test_network_remote_rename__new_name_can_contain_dots(void) cl_git_pass(git_remote_rename(&problems, _repo, _remote_name, "just.renamed")); cl_assert_equal_i(0, problems.count); - git_strarray_free(&problems); + git_strarray_dispose(&problems); assert_config_entry_existence(_repo, "remote.just.renamed.fetch", true); } @@ -126,7 +126,7 @@ void test_network_remote_rename__renamed_name_is_persisted(void) cl_git_pass(git_remote_rename(&problems, _repo, _remote_name, "just/renamed")); cl_assert_equal_i(0, problems.count); - git_strarray_free(&problems); + git_strarray_dispose(&problems); cl_git_pass(git_repository_open(&another_repo, "testrepo.git")); cl_git_pass(git_remote_lookup(&renamed, _repo, "just/renamed")); @@ -154,7 +154,7 @@ void test_network_remote_rename__renaming_a_remote_moves_the_underlying_referenc cl_git_pass(git_remote_rename(&problems, _repo, _remote_name, "just/renamed")); cl_assert_equal_i(0, problems.count); - git_strarray_free(&problems); + git_strarray_dispose(&problems); cl_assert_equal_i(GIT_ENOTFOUND, git_reference_lookup(&underlying, _repo, "refs/remotes/test/master")); cl_git_pass(git_reference_lookup(&underlying, _repo, "refs/remotes/just/renamed/master")); @@ -176,7 +176,7 @@ void test_network_remote_rename__overwrite_ref_in_target(void) cl_git_pass(git_remote_rename(&problems, _repo, _remote_name, "renamed")); cl_assert_equal_i(0, problems.count); - git_strarray_free(&problems); + git_strarray_dispose(&problems); /* make sure there's only one remote-tracking branch */ cl_git_pass(git_branch_iterator_new(&iter, _repo, GIT_BRANCH_REMOTE)); @@ -214,7 +214,7 @@ void test_network_remote_rename__symref_head(void) cl_git_pass(git_remote_rename(&problems, _repo, _remote_name, "renamed")); cl_assert_equal_i(0, problems.count); - git_strarray_free(&problems); + git_strarray_dispose(&problems); cl_git_pass(git_vector_init(&refs, 2, (git_vector_cmp) git_reference_cmp)); cl_git_pass(git_branch_iterator_new(&iter, _repo, GIT_BRANCH_REMOTE)); diff --git a/tests/object/commit/commitstagedfile.c b/tests/object/commit/commitstagedfile.c index 63ecfeebe..f7ff05c01 100644 --- a/tests/object/commit/commitstagedfile.c +++ b/tests/object/commit/commitstagedfile.c @@ -49,9 +49,9 @@ void test_object_commit_commitstagedfile__generate_predictable_object_ids(void) * tree 2b297e643c551e76cfa1f93810c50811382f9117 * author nulltoken 1323847743 +0100 * committer nulltoken 1323847743 +0100 - * + * * Initial commit - * + * * diff --git a/test.txt b/test.txt * new file mode 100644 * index 0000000..9daeafb @@ -141,14 +141,14 @@ static void assert_commit_tree_has_n_entries(git_commit *c, int count) git_tree_free(tree); } -static void assert_commit_is_head_(git_commit *c, const char *file, int line) +static void assert_commit_is_head_(git_commit *c, const char *file, const char *func, int line) { git_commit *head; cl_git_pass(git_revparse_single((git_object **)&head, repo, "HEAD")); - clar__assert(git_oid_equal(git_commit_id(c), git_commit_id(head)), file, line, "Commit is not the HEAD", NULL, 1); + clar__assert(git_oid_equal(git_commit_id(c), git_commit_id(head)), file, func, line, "Commit is not the HEAD", NULL, 1); git_commit_free(head); } -#define assert_commit_is_head(C) assert_commit_is_head_((C),__FILE__,__LINE__) +#define assert_commit_is_head(C) assert_commit_is_head_((C),__FILE__,__func__,__LINE__) void test_object_commit_commitstagedfile__amend_commit(void) { diff --git a/tests/object/tag/list.c b/tests/object/tag/list.c index b8d507fe7..8a1a2d26d 100644 --- a/tests/object/tag/list.c +++ b/tests/object/tag/list.c @@ -50,7 +50,7 @@ static void ensure_tag_pattern_match(git_repository *repo, cl_assert_equal_i((int)sucessfully_found, (int)data->expected_matches); exit: - git_strarray_free(&tag_list); + git_strarray_dispose(&tag_list); cl_git_pass(error); } @@ -74,7 +74,7 @@ void test_object_tag_list__list_all(void) cl_assert_equal_i((int)tag_list.count, 6); - git_strarray_free(&tag_list); + git_strarray_dispose(&tag_list); } static const struct pattern_match_t matches[] = { diff --git a/tests/object/tree/write.c b/tests/object/tree/write.c index 7b0b8caca..1bc5a50a0 100644 --- a/tests/object/tree/write.c +++ b/tests/object/tree/write.c @@ -453,7 +453,8 @@ static void test_invalid_objects(bool should_allow_invalid) git_oid valid_blob_id, invalid_blob_id, valid_tree_id, invalid_tree_id; #define assert_allowed(expr) \ - clar__assert(!(expr) == should_allow_invalid, __FILE__, __LINE__, \ + clar__assert(!(expr) == should_allow_invalid, \ + __FILE__, __func__, __LINE__, \ (should_allow_invalid ? \ "Expected function call to succeed: " #expr : \ "Expected function call to fail: " #expr), \ diff --git a/tests/online/clone.c b/tests/online/clone.c index 9107956bd..c62baac2d 100644 --- a/tests/online/clone.c +++ b/tests/online/clone.c @@ -176,7 +176,7 @@ static int fetch_progress(const git_indexer_progress *stats, void *payload) void test_online_clone__can_checkout_a_cloned_repo(void) { git_buf path = GIT_BUF_INIT; - git_reference *head; + git_reference *head, *remote_head; bool checkout_progress_cb_was_called = false, fetch_progress_cb_was_called = false; @@ -195,9 +195,14 @@ void test_online_clone__can_checkout_a_cloned_repo(void) cl_assert_equal_i(GIT_REFERENCE_SYMBOLIC, git_reference_type(head)); cl_assert_equal_s("refs/heads/master", git_reference_symbolic_target(head)); + cl_git_pass(git_reference_lookup(&remote_head, g_repo, "refs/remotes/origin/HEAD")); + cl_assert_equal_i(GIT_REFERENCE_SYMBOLIC, git_reference_type(remote_head)); + cl_assert_equal_s("refs/remotes/origin/master", git_reference_symbolic_target(remote_head)); + cl_assert_equal_i(true, checkout_progress_cb_was_called); cl_assert_equal_i(true, fetch_progress_cb_was_called); + git_reference_free(remote_head); git_reference_free(head); git_buf_dispose(&path); } diff --git a/tests/online/fetchhead.c b/tests/online/fetchhead.c index 32e7419ae..b61993138 100644 --- a/tests/online/fetchhead.c +++ b/tests/online/fetchhead.c @@ -43,7 +43,7 @@ static size_t count_references(void) cl_git_pass(git_reference_list(&array, g_repo)); refs = array.count; - git_strarray_free(&array); + git_strarray_dispose(&array); return refs; } diff --git a/tests/online/remotes.c b/tests/online/remotes.c index d79eb1f59..f7fe4142f 100644 --- a/tests/online/remotes.c +++ b/tests/online/remotes.c @@ -32,7 +32,7 @@ void test_online_remotes__single_branch(void) } cl_assert_equal_i(1, count); - git_strarray_free(&refs); + git_strarray_dispose(&refs); cl_git_pass(git_remote_lookup(&remote, repo, "origin")); cl_git_pass(git_remote_get_fetch_refspecs(&refs, remote)); @@ -40,7 +40,7 @@ void test_online_remotes__single_branch(void) cl_assert_equal_i(1, refs.count); cl_assert_equal_s(REFSPEC, refs.strings[0]); - git_strarray_free(&refs); + git_strarray_dispose(&refs); git_remote_free(remote); git_repository_free(repo); } diff --git a/tests/pack/filelimit.c b/tests/pack/filelimit.c new file mode 100644 index 000000000..044679f3b --- /dev/null +++ b/tests/pack/filelimit.c @@ -0,0 +1,136 @@ +#include "clar_libgit2.h" +#include "mwindow.h" +#include "global.h" + +#include +#include "git2/sys/commit.h" +#include "git2/sys/mempack.h" + +static size_t expected_open_mwindow_files = 0; +static size_t original_mwindow_file_limit = 0; + +extern git_mwindow_ctl git_mwindow__mem_ctl; + +void test_pack_filelimit__initialize_tiny(void) +{ + expected_open_mwindow_files = 1; + cl_git_pass(git_libgit2_opts(GIT_OPT_GET_MWINDOW_FILE_LIMIT, &original_mwindow_file_limit)); + cl_git_pass(git_libgit2_opts(GIT_OPT_SET_MWINDOW_FILE_LIMIT, expected_open_mwindow_files)); +} + +void test_pack_filelimit__initialize_medium(void) +{ + expected_open_mwindow_files = 10; + cl_git_pass(git_libgit2_opts(GIT_OPT_GET_MWINDOW_FILE_LIMIT, &original_mwindow_file_limit)); + cl_git_pass(git_libgit2_opts(GIT_OPT_SET_MWINDOW_FILE_LIMIT, expected_open_mwindow_files)); +} + +void test_pack_filelimit__initialize_unlimited(void) +{ + expected_open_mwindow_files = 15; + cl_git_pass(git_libgit2_opts(GIT_OPT_GET_MWINDOW_FILE_LIMIT, &original_mwindow_file_limit)); + cl_git_pass(git_libgit2_opts(GIT_OPT_SET_MWINDOW_FILE_LIMIT, 0)); +} + +void test_pack_filelimit__cleanup(void) +{ + git_buf path = GIT_BUF_INIT; + cl_git_pass(git_libgit2_opts(GIT_OPT_SET_MWINDOW_FILE_LIMIT, original_mwindow_file_limit)); + + cl_git_pass(git_buf_joinpath(&path, clar_sandbox_path(), "repo.git")); + cl_fixture_cleanup(path.ptr); + git_buf_dispose(&path); +} + +/* + * Create a packfile with one commit, one tree, and two blobs. The first blob + * (README.md) has the same content in all commits, but the second one + * (file.txt) has a different content in each commit. + */ +void create_packfile_commit( + git_repository *repo, + git_oid *out_commit_id, + git_oid *parent_id, + size_t commit_index, + size_t commit_count) +{ + git_buf file_contents = GIT_BUF_INIT; + git_treebuilder *treebuilder; + git_packbuilder *packbuilder; + git_signature *s; + git_oid oid, tree_id, commit_id; + const git_oid *parents[] = { parent_id }; + size_t parent_count = parent_id ? 1 : 0; + + cl_git_pass(git_treebuilder_new(&treebuilder, repo, NULL)); + + cl_git_pass(git_blob_create_from_buffer(&oid, repo, "", 0)); + cl_git_pass(git_treebuilder_insert(NULL, treebuilder, "README.md", &oid, 0100644)); + + cl_git_pass(git_buf_printf(&file_contents, "Commit %zd/%zd", commit_index, commit_count)); + cl_git_pass(git_blob_create_from_buffer(&oid, repo, file_contents.ptr, file_contents.size)); + cl_git_pass(git_treebuilder_insert(NULL, treebuilder, "file.txt", &oid, 0100644)); + + cl_git_pass(git_treebuilder_write(&tree_id, treebuilder)); + cl_git_pass(git_signature_now(&s, "alice", "alice@example.com")); + cl_git_pass(git_commit_create_from_ids(&commit_id, repo, "refs/heads/master", s, s, + NULL, file_contents.ptr, &tree_id, parent_count, parents)); + + cl_git_pass(git_packbuilder_new(&packbuilder, repo)); + cl_git_pass(git_packbuilder_insert_commit(packbuilder, &commit_id)); + cl_git_pass(git_packbuilder_write(packbuilder, NULL, 0, NULL, NULL)); + + cl_git_pass(git_oid_cpy(out_commit_id, &commit_id)); + + git_buf_dispose(&file_contents); + git_treebuilder_free(treebuilder); + git_packbuilder_free(packbuilder); + git_signature_free(s); +} + +void test_pack_filelimit__open_repo_with_multiple_packfiles(void) +{ + git_buf path = GIT_BUF_INIT; + git_mwindow_ctl *ctl = &git_mwindow__mem_ctl; + git_repository *repo; + git_revwalk *walk; + git_oid id, *parent_id = NULL; + size_t i; + const size_t commit_count = 16; + unsigned int open_windows; + + /* + * Create a repository and populate it with 16 commits, each in its own + * packfile. + */ + cl_git_pass(git_buf_joinpath(&path, clar_sandbox_path(), "repo.git")); + cl_git_pass(git_repository_init(&repo, path.ptr, true)); + for (i = 0; i < commit_count; ++i) { + create_packfile_commit(repo, &id, parent_id, i + 1, commit_count); + parent_id = &id; + } + + cl_git_pass(git_revwalk_new(&walk, repo)); + cl_git_pass(git_revwalk_sorting(walk, GIT_SORT_TOPOLOGICAL)); + cl_git_pass(git_revwalk_push_ref(walk, "refs/heads/master")); + + /* Walking the repository requires eventually opening each of the packfiles. */ + i = 0; + while (git_revwalk_next(&id, walk) == 0) + ++i; + cl_assert_equal_i(commit_count, i); + + cl_git_pass(git_mutex_lock(&git__mwindow_mutex)); + /* + * Adding an assert while holding a lock will cause the whole process to + * deadlock. Copy the value and do the assert after releasing the lock. + */ + open_windows = ctl->open_windows; + cl_git_pass(git_mutex_unlock(&git__mwindow_mutex)); + + cl_assert_equal_i(expected_open_mwindow_files, open_windows); + + git_buf_dispose(&path); + git_revwalk_free(walk); + git_repository_free(repo); +} diff --git a/tests/pack/midx.c b/tests/pack/midx.c new file mode 100644 index 000000000..1f47d9502 --- /dev/null +++ b/tests/pack/midx.c @@ -0,0 +1,29 @@ +#include "clar_libgit2.h" + +#include + +#include "midx.h" + +void test_pack_midx__parse(void) +{ + git_repository *repo; + struct git_midx_file *idx; + struct git_midx_entry e; + git_oid id; + git_buf midx_path = GIT_BUF_INIT; + + cl_git_pass(git_repository_open(&repo, cl_fixture("testrepo.git"))); + cl_git_pass(git_buf_joinpath(&midx_path, git_repository_path(repo), "objects/pack/multi-pack-index")); + cl_git_pass(git_midx_open(&idx, git_buf_cstr(&midx_path))); + + cl_git_pass(git_oid_fromstr(&id, "5001298e0c09ad9c34e4249bc5801c75e9754fa5")); + cl_git_pass(git_midx_entry_find(&e, idx, &id, GIT_OID_HEXSZ)); + cl_assert_equal_oid(&e.sha1, &id); + cl_assert_equal_s( + (const char *)git_vector_get(&idx->packfile_names, e.pack_index), + "pack-d7c6adf9f61318f041845b01440d09aa7a91e1b5.idx"); + + git_midx_free(idx); + git_repository_free(repo); + git_buf_dispose(&midx_path); +} diff --git a/tests/pack/packbuilder.c b/tests/pack/packbuilder.c index 32f061232..5f5441a5d 100644 --- a/tests/pack/packbuilder.c +++ b/tests/pack/packbuilder.c @@ -151,6 +151,15 @@ void test_pack_packbuilder__get_hash(void) cl_assert_equal_s(hex, "7f5fa362c664d68ba7221259be1cbd187434b2f0"); } +void test_pack_packbuilder__write_default_path(void) +{ + seed_packbuilder(); + + cl_git_pass(git_packbuilder_write(_packbuilder, NULL, 0, NULL, NULL)); + cl_assert(git_path_exists("objects/pack/pack-7f5fa362c664d68ba7221259be1cbd187434b2f0.idx")); + cl_assert(git_path_exists("objects/pack/pack-7f5fa362c664d68ba7221259be1cbd187434b2f0.pack")); +} + static void test_write_pack_permission(mode_t given, mode_t expected) { struct stat statbuf; diff --git a/tests/patch/patch_common.h b/tests/patch/patch_common.h index 731524767..1e03889fc 100644 --- a/tests/patch/patch_common.h +++ b/tests/patch/patch_common.h @@ -579,6 +579,14 @@ "rename from file.txt\n" \ "rename to newfile.txt\n" +#define PATCH_RENAME_EXACT_WITH_MODE \ + "diff --git a/RENAMED.md b/README.md\n" \ + "old mode 100644\n" \ + "new mode 100755\n" \ + "similarity index 100%\n" \ + "rename from RENAMED.md\n" \ + "rename to README.md\n" + #define PATCH_RENAME_SIMILAR \ "diff --git a/file.txt b/newfile.txt\n" \ "similarity index 77%\n" \ diff --git a/tests/patch/print.c b/tests/patch/print.c index c4ff479e9..b0a933943 100644 --- a/tests/patch/print.c +++ b/tests/patch/print.c @@ -107,6 +107,12 @@ void test_patch_print__rename_exact(void) strlen(PATCH_RENAME_EXACT)); } +void test_patch_print__rename_exact_with_mode(void) +{ + patch_print_from_patchfile(PATCH_RENAME_EXACT_WITH_MODE, + strlen(PATCH_RENAME_EXACT_WITH_MODE)); +} + void test_patch_print__rename_similar(void) { patch_print_from_patchfile(PATCH_RENAME_SIMILAR, diff --git a/tests/refs/create.c b/tests/refs/create.c index 20ac579b3..01eb62a52 100644 --- a/tests/refs/create.c +++ b/tests/refs/create.c @@ -212,17 +212,12 @@ void test_refs_create__oid_unknown_fails_by_default(void) void test_refs_create__propagate_eexists(void) { - int error; git_oid oid; - git_reference *ref; /* Make sure it works for oid and for symbolic both */ - git_oid_fromstr(&oid, current_master_tip); - error = git_reference_create(&ref, g_repo, current_head_target, &oid, false, NULL); - cl_assert(error == GIT_EEXISTS); - - error = git_reference_symbolic_create(&ref, g_repo, "HEAD", current_head_target, false, NULL); - cl_assert(error == GIT_EEXISTS); + cl_git_pass(git_oid_fromstr(&oid, current_master_tip)); + cl_git_fail_with(GIT_EEXISTS, git_reference_create(NULL, g_repo, current_head_target, &oid, false, NULL)); + cl_git_fail_with(GIT_EEXISTS, git_reference_symbolic_create(NULL, g_repo, "HEAD", current_head_target, false, NULL)); } void test_refs_create__existing_dir_propagates_edirectory(void) diff --git a/tests/refs/list.c b/tests/refs/list.c index 725d38161..8085ff84b 100644 --- a/tests/refs/list.c +++ b/tests/refs/list.c @@ -38,7 +38,7 @@ void test_refs_list__all(void) * loose, but we only list it once */ cl_assert_equal_i((int)ref_list.count, 19); - git_strarray_free(&ref_list); + git_strarray_dispose(&ref_list); } void test_refs_list__do_not_retrieve_references_which_name_end_with_a_lock_extension(void) @@ -53,5 +53,5 @@ void test_refs_list__do_not_retrieve_references_which_name_end_with_a_lock_exten cl_git_pass(git_reference_list(&ref_list, g_repo)); cl_assert_equal_i((int)ref_list.count, 19); - git_strarray_free(&ref_list); + git_strarray_dispose(&ref_list); } diff --git a/tests/refs/listall.c b/tests/refs/listall.c index c696fbb2e..9da8d1ac3 100644 --- a/tests/refs/listall.c +++ b/tests/refs/listall.c @@ -16,7 +16,7 @@ static void ensure_no_refname_starts_with_a_forward_slash(const char *path) for (i = 0; i < ref_list.count; i++) cl_assert(git__prefixcmp(ref_list.strings[i], "/") != 0); - git_strarray_free(&ref_list); + git_strarray_dispose(&ref_list); git_repository_free(repo); } @@ -42,6 +42,6 @@ void test_refs_listall__from_repository_with_no_trailing_newline(void) cl_assert(ref_list.count > 0); - git_strarray_free(&ref_list); + git_strarray_dispose(&ref_list); git_repository_free(repo); } diff --git a/tests/refs/namespaces.c b/tests/refs/namespaces.c index bb6bb1ce0..19456b5a4 100644 --- a/tests/refs/namespaces.c +++ b/tests/refs/namespaces.c @@ -32,5 +32,5 @@ void test_refs_namespaces__namespace_doesnt_show_normal_refs(void) cl_git_pass(git_repository_set_namespace(g_repo, "namespace")); cl_git_pass(git_reference_list(&ref_list, g_repo)); cl_assert_equal_i(0, ref_list.count); - git_strarray_free(&ref_list); + git_strarray_dispose(&ref_list); } diff --git a/tests/refs/reflog/messages.c b/tests/refs/reflog/messages.c index 43f59a84b..53b8c6f3e 100644 --- a/tests/refs/reflog/messages.c +++ b/tests/refs/reflog/messages.c @@ -24,11 +24,8 @@ void test_refs_reflog_messages__cleanup(void) void test_refs_reflog_messages__setting_head_updates_reflog(void) { git_object *tag; - git_signature *sig; git_annotated_commit *annotated; - cl_git_pass(git_signature_now(&sig, "me", "foo@example.com")); - cl_git_pass(git_repository_set_head(g_repo, "refs/heads/haacked")); /* 4 */ cl_git_pass(git_repository_set_head(g_repo, "refs/heads/unborn")); cl_git_pass(git_revparse_single(&tag, g_repo, "tags/test")); @@ -68,7 +65,6 @@ void test_refs_reflog_messages__setting_head_updates_reflog(void) git_annotated_commit_free(annotated); git_object_free(tag); - git_signature_free(sig); } void test_refs_reflog_messages__setting_head_to_same_target_ignores_reflog(void) @@ -87,12 +83,9 @@ void test_refs_reflog_messages__setting_head_to_same_target_ignores_reflog(void) void test_refs_reflog_messages__detaching_writes_reflog(void) { - git_signature *sig; git_oid id; const char *msg; - cl_git_pass(git_signature_now(&sig, "me", "foo@example.com")); - msg = "checkout: moving from master to e90810b8df3e80c413d903f631643c716887138d"; git_oid_fromstr(&id, "e90810b8df3e80c413d903f631643c716887138d"); cl_git_pass(git_repository_set_head_detached(g_repo, &id)); @@ -107,8 +100,6 @@ void test_refs_reflog_messages__detaching_writes_reflog(void) "e90810b8df3e80c413d903f631643c716887138d", "258f0e2a959a364e40ed6603d5d44fbb24765b10", NULL, msg); - - git_signature_free(sig); } void test_refs_reflog_messages__orphan_branch_does_not_count(void) diff --git a/tests/refs/reflog/reflog_helpers.c b/tests/refs/reflog/reflog_helpers.c index 6eba8ecf9..aecb78b02 100644 --- a/tests/refs/reflog/reflog_helpers.c +++ b/tests/refs/reflog/reflog_helpers.c @@ -29,7 +29,8 @@ size_t reflog_entrycount(git_repository *repo, const char *name) void cl_reflog_check_entry_(git_repository *repo, const char *reflog, size_t idx, const char *old_spec, const char *new_spec, - const char *email, const char *message, const char *file, int line) + const char *email, const char *message, + const char *file, const char *func, int line) { git_reflog *log; const git_reflog_entry *entry; @@ -38,7 +39,7 @@ void cl_reflog_check_entry_(git_repository *repo, const char *reflog, size_t idx cl_git_pass(git_reflog_read(&log, repo, reflog)); entry = git_reflog_entry_byindex(log, idx); if (entry == NULL) - clar__fail(file, line, "Reflog has no such entry", NULL, 1); + clar__fail(file, func, line, "Reflog has no such entry", NULL, 1); if (old_spec) { git_object *obj = NULL; @@ -92,7 +93,7 @@ void cl_reflog_check_entry_(git_repository *repo, const char *reflog, size_t idx git_buf_printf(&result, "\tMessage: \"%s\" != \"%s\"\n", message, entry_msg); } if (git_buf_len(&result) != 0) - clar__fail(file, line, "Reflog entry mismatch", git_buf_cstr(&result), 1); + clar__fail(file, func, line, "Reflog entry mismatch", git_buf_cstr(&result), 1); git_buf_dispose(&result); git_reflog_free(log); diff --git a/tests/remote/create.c b/tests/remote/create.c index 510962314..f92be9dfc 100644 --- a/tests/remote/create.c +++ b/tests/remote/create.c @@ -117,7 +117,7 @@ void test_remote_create__with_fetchspec(void) cl_assert_equal_i(1, array.count); cl_assert_equal_i(section_count + 2, count_config_entries_match(_repo, "remote\\.")); - git_strarray_free(&array); + git_strarray_dispose(&array); git_remote_free(remote); } @@ -132,7 +132,7 @@ void test_remote_create__with_empty_fetchspec(void) cl_assert_equal_i(0, array.count); cl_assert_equal_i(section_count + 1, count_config_entries_match(_repo, "remote\\.")); - git_strarray_free(&array); + git_strarray_dispose(&array); git_remote_free(remote); } @@ -167,7 +167,7 @@ void test_remote_create__anonymous(void) cl_assert_equal_i(0, array.count); cl_assert_equal_i(section_count, count_config_entries_match(_repo, "remote\\.")); - git_strarray_free(&array); + git_strarray_dispose(&array); git_remote_free(remote); } @@ -195,7 +195,7 @@ void test_remote_create__detached(void) cl_assert_equal_i(0, array.count); cl_assert_equal_i(section_count, count_config_entries_match(_repo, "remote\\.")); - git_strarray_free(&array); + git_strarray_dispose(&array); git_remote_free(remote); } @@ -225,7 +225,7 @@ void test_remote_create__with_opts_named(void) cl_assert_equal_i(1, array.count); cl_assert_equal_s("+refs/heads/*:refs/remotes/test-new/*", array.strings[0]); - git_strarray_free(&array); + git_strarray_dispose(&array); git_remote_free(remote); } @@ -248,7 +248,7 @@ void test_remote_create__with_opts_named_and_fetchspec(void) cl_assert_equal_i(1, array.count); cl_assert_equal_s("+refs/*:refs/*", array.strings[0]); - git_strarray_free(&array); + git_strarray_dispose(&array); git_remote_free(remote); } @@ -270,7 +270,7 @@ void test_remote_create__with_opts_named_no_fetchspec(void) cl_git_pass(git_remote_get_fetch_refspecs(&array, remote)); cl_assert_equal_i(0, array.count); - git_strarray_free(&array); + git_strarray_dispose(&array); git_remote_free(remote); } @@ -290,7 +290,7 @@ void test_remote_create__with_opts_anonymous(void) cl_git_pass(git_remote_get_fetch_refspecs(&array, remote)); cl_assert_equal_i(0, array.count); - git_strarray_free(&array); + git_strarray_dispose(&array); git_remote_free(remote); } @@ -308,7 +308,7 @@ void test_remote_create__with_opts_detached(void) cl_git_pass(git_remote_get_fetch_refspecs(&array, remote)); cl_assert_equal_i(0, array.count); - git_strarray_free(&array); + git_strarray_dispose(&array); git_remote_free(remote); @@ -320,7 +320,7 @@ void test_remote_create__with_opts_detached(void) cl_git_pass(git_remote_get_fetch_refspecs(&array, remote)); cl_assert_equal_i(0, array.count); - git_strarray_free(&array); + git_strarray_dispose(&array); git_remote_free(remote); } diff --git a/tests/remote/list.c b/tests/remote/list.c index 5abb95106..4a6be3d1b 100644 --- a/tests/remote/list.c +++ b/tests/remote/list.c @@ -25,17 +25,17 @@ void test_remote_list__always_checks_disk_config(void) cl_git_pass(git_remote_list(&remotes, _repo)); cl_assert_equal_sz(remotes.count, 1); - git_strarray_free(&remotes); + git_strarray_dispose(&remotes); cl_git_pass(git_remote_create(&remote, _repo, "valid-name", TEST_URL)); cl_git_pass(git_remote_list(&remotes, _repo)); cl_assert_equal_sz(remotes.count, 2); - git_strarray_free(&remotes); + git_strarray_dispose(&remotes); cl_git_pass(git_remote_list(&remotes, repo)); cl_assert_equal_sz(remotes.count, 2); - git_strarray_free(&remotes); + git_strarray_dispose(&remotes); git_repository_free(repo); git_remote_free(remote); diff --git a/tests/repo/env.c b/tests/repo/env.c index 024661692..43defc168 100644 --- a/tests/repo/env.c +++ b/tests/repo/env.c @@ -53,44 +53,44 @@ static int GIT_FORMAT_PRINTF(2, 3) cl_setenv_printf(const char *name, const char * from the caller rather than those of the helper. The expression strings * distinguish between the possible failures within the helper. */ -static void env_pass_(const char *path, const char *file, int line) +static void env_pass_(const char *path, const char *file, const char *func, int line) { git_repository *repo; - cl_git_expect(git_repository_open_ext(NULL, path, GIT_REPOSITORY_OPEN_FROM_ENV, NULL), 0, file, line); - cl_git_expect(git_repository_open_ext(&repo, path, GIT_REPOSITORY_OPEN_FROM_ENV, NULL), 0, file, line); - cl_assert_at_line(git__suffixcmp(git_repository_path(repo), "attr/.git/") == 0, file, line); - cl_assert_at_line(git__suffixcmp(git_repository_workdir(repo), "attr/") == 0, file, line); - cl_assert_at_line(!git_repository_is_bare(repo), file, line); + cl_git_expect(git_repository_open_ext(NULL, path, GIT_REPOSITORY_OPEN_FROM_ENV, NULL), 0, file, func, line); + cl_git_expect(git_repository_open_ext(&repo, path, GIT_REPOSITORY_OPEN_FROM_ENV, NULL), 0, file, func, line); + cl_assert_at_line(git__suffixcmp(git_repository_path(repo), "attr/.git/") == 0, file, func, line); + cl_assert_at_line(git__suffixcmp(git_repository_workdir(repo), "attr/") == 0, file, func, line); + cl_assert_at_line(!git_repository_is_bare(repo), file, func, line); git_repository_free(repo); } -#define env_pass(path) env_pass_((path), __FILE__, __LINE__) +#define env_pass(path) env_pass_((path), __FILE__, __func__, __LINE__) -#define cl_git_fail_at_line(expr, file, line) clar__assert((expr) < 0, file, line, "Expected function call to fail: " #expr, NULL, 1) +#define cl_git_fail_at_line(expr, file, func, line) clar__assert((expr) < 0, file, func, line, "Expected function call to fail: " #expr, NULL, 1) -static void env_fail_(const char *path, const char *file, int line) +static void env_fail_(const char *path, const char *file, const char *func, int line) { git_repository *repo; - cl_git_fail_at_line(git_repository_open_ext(NULL, path, GIT_REPOSITORY_OPEN_FROM_ENV, NULL), file, line); - cl_git_fail_at_line(git_repository_open_ext(&repo, path, GIT_REPOSITORY_OPEN_FROM_ENV, NULL), file, line); + cl_git_fail_at_line(git_repository_open_ext(NULL, path, GIT_REPOSITORY_OPEN_FROM_ENV, NULL), file, func, line); + cl_git_fail_at_line(git_repository_open_ext(&repo, path, GIT_REPOSITORY_OPEN_FROM_ENV, NULL), file, func, line); } -#define env_fail(path) env_fail_((path), __FILE__, __LINE__) +#define env_fail(path) env_fail_((path), __FILE__, __func__, __LINE__) static void env_cd_( const char *path, - void (*passfail_)(const char *, const char *, int), - const char *file, int line) + void (*passfail_)(const char *, const char *, const char *, int), + const char *file, const char *func, int line) { git_buf cwd_buf = GIT_BUF_INIT; cl_git_pass(git_path_prettify_dir(&cwd_buf, ".", NULL)); cl_must_pass(p_chdir(path)); - passfail_(NULL, file, line); + passfail_(NULL, file, func, line); cl_must_pass(p_chdir(git_buf_cstr(&cwd_buf))); git_buf_dispose(&cwd_buf); } -#define env_cd_pass(path) env_cd_((path), env_pass_, __FILE__, __LINE__) -#define env_cd_fail(path) env_cd_((path), env_fail_, __FILE__, __LINE__) +#define env_cd_pass(path) env_cd_((path), env_pass_, __FILE__, __func__, __LINE__) +#define env_cd_fail(path) env_cd_((path), env_fail_, __FILE__, __func__, __LINE__) -static void env_check_objects_(bool a, bool t, bool p, const char *file, int line) +static void env_check_objects_(bool a, bool t, bool p, const char *file, const char *func, int line) { git_repository *repo; git_oid oid_a, oid_t, oid_p; @@ -98,32 +98,32 @@ static void env_check_objects_(bool a, bool t, bool p, const char *file, int lin cl_git_pass(git_oid_fromstr(&oid_a, "45141a79a77842c59a63229403220a4e4be74e3d")); cl_git_pass(git_oid_fromstr(&oid_t, "1385f264afb75a56a5bec74243be9b367ba4ca08")); cl_git_pass(git_oid_fromstr(&oid_p, "0df1a5865c8abfc09f1f2182e6a31be550e99f07")); - cl_git_expect(git_repository_open_ext(&repo, "attr", GIT_REPOSITORY_OPEN_FROM_ENV, NULL), 0, file, line); + cl_git_expect(git_repository_open_ext(&repo, "attr", GIT_REPOSITORY_OPEN_FROM_ENV, NULL), 0, file, func, line); if (a) { - cl_git_expect(git_object_lookup(&object, repo, &oid_a, GIT_OBJECT_BLOB), 0, file, line); + cl_git_expect(git_object_lookup(&object, repo, &oid_a, GIT_OBJECT_BLOB), 0, file, func, line); git_object_free(object); } else { - cl_git_fail_at_line(git_object_lookup(&object, repo, &oid_a, GIT_OBJECT_BLOB), file, line); + cl_git_fail_at_line(git_object_lookup(&object, repo, &oid_a, GIT_OBJECT_BLOB), file, func, line); } if (t) { - cl_git_expect(git_object_lookup(&object, repo, &oid_t, GIT_OBJECT_BLOB), 0, file, line); + cl_git_expect(git_object_lookup(&object, repo, &oid_t, GIT_OBJECT_BLOB), 0, file, func, line); git_object_free(object); } else { - cl_git_fail_at_line(git_object_lookup(&object, repo, &oid_t, GIT_OBJECT_BLOB), file, line); + cl_git_fail_at_line(git_object_lookup(&object, repo, &oid_t, GIT_OBJECT_BLOB), file, func, line); } if (p) { - cl_git_expect(git_object_lookup(&object, repo, &oid_p, GIT_OBJECT_COMMIT), 0, file, line); + cl_git_expect(git_object_lookup(&object, repo, &oid_p, GIT_OBJECT_COMMIT), 0, file, func, line); git_object_free(object); } else { - cl_git_fail_at_line(git_object_lookup(&object, repo, &oid_p, GIT_OBJECT_COMMIT), file, line); + cl_git_fail_at_line(git_object_lookup(&object, repo, &oid_p, GIT_OBJECT_COMMIT), file, func, line); } git_repository_free(repo); } -#define env_check_objects(a, t, t2) env_check_objects_((a), (t), (t2), __FILE__, __LINE__) +#define env_check_objects(a, t, t2) env_check_objects_((a), (t), (t2), __FILE__, __func__, __LINE__) void test_repo_env__open(void) { diff --git a/tests/repo/init.c b/tests/repo/init.c index 5a95229e6..ba00d2918 100644 --- a/tests/repo/init.c +++ b/tests/repo/init.c @@ -665,3 +665,19 @@ void test_repo_init__unwriteable_directory(void) clar__skip(); #endif } + +void test_repo_init__defaultbranch_config(void) +{ + git_reference *head; + + cl_set_cleanup(&cleanup_repository, "repo"); + + create_tmp_global_config("tmp_global_path", "init.defaultbranch", "my_default_branch"); + + cl_git_pass(git_repository_init(&_repo, "repo", 0)); + cl_git_pass(git_reference_lookup(&head, _repo, "HEAD")); + + cl_assert_equal_s("refs/heads/my_default_branch", git_reference_symbolic_target(head)); + + git_reference_free(head); +} diff --git a/tests/repo/open.c b/tests/repo/open.c index 448ccdc87..881a23d34 100644 --- a/tests/repo/open.c +++ b/tests/repo/open.c @@ -35,7 +35,53 @@ void test_repo_open__format_version_1(void) git_config_free(config); git_repository_free(repo); + + cl_git_pass(git_repository_open(&repo, "empty_bare.git")); + cl_assert(git_repository_path(repo) != NULL); + cl_assert(git__suffixcmp(git_repository_path(repo), "/") == 0); + git_repository_free(repo); +} + +void test_repo_open__format_version_1_with_valid_extension(void) +{ + git_repository *repo; + git_config *config; + + repo = cl_git_sandbox_init("empty_bare.git"); + + cl_git_pass(git_repository_open(&repo, "empty_bare.git")); + cl_git_pass(git_repository_config(&config, repo)); + + cl_git_pass(git_config_set_int32(config, "core.repositoryformatversion", 1)); + cl_git_pass(git_config_set_int32(config, "extensions.noop", 1)); + + git_config_free(config); + git_repository_free(repo); + + cl_git_pass(git_repository_open(&repo, "empty_bare.git")); + cl_assert(git_repository_path(repo) != NULL); + cl_assert(git__suffixcmp(git_repository_path(repo), "/") == 0); + git_repository_free(repo); +} + +void test_repo_open__format_version_1_with_invalid_extension(void) +{ + git_repository *repo; + git_config *config; + + repo = cl_git_sandbox_init("empty_bare.git"); + + cl_git_pass(git_repository_open(&repo, "empty_bare.git")); + cl_git_pass(git_repository_config(&config, repo)); + + cl_git_pass(git_config_set_int32(config, "core.repositoryformatversion", 1)); + cl_git_pass(git_config_set_int32(config, "extensions.invalid", 1)); + + git_config_free(config); + git_repository_free(repo); + cl_git_fail(git_repository_open(&repo, "empty_bare.git")); + git_repository_free(repo); } void test_repo_open__standard_empty_repo_through_gitdir(void) diff --git a/tests/resources/blametest.git/objects/1d/81379086fd6d91ee027e883cf6f4703a107dfb b/tests/resources/blametest.git/objects/1d/81379086fd6d91ee027e883cf6f4703a107dfb new file mode 100644 index 000000000..a35dd56ce Binary files /dev/null and b/tests/resources/blametest.git/objects/1d/81379086fd6d91ee027e883cf6f4703a107dfb differ diff --git a/tests/resources/blametest.git/objects/34/73c3e21e76492d09b80b7c75569edc275dffcf b/tests/resources/blametest.git/objects/34/73c3e21e76492d09b80b7c75569edc275dffcf new file mode 100644 index 000000000..887deff34 Binary files /dev/null and b/tests/resources/blametest.git/objects/34/73c3e21e76492d09b80b7c75569edc275dffcf differ diff --git a/tests/resources/blametest.git/objects/40/fcae7fb84378fdb037dc6a3ccbb33669c3f26d b/tests/resources/blametest.git/objects/40/fcae7fb84378fdb037dc6a3ccbb33669c3f26d new file mode 100644 index 000000000..27fc76b18 Binary files /dev/null and b/tests/resources/blametest.git/objects/40/fcae7fb84378fdb037dc6a3ccbb33669c3f26d differ diff --git a/tests/resources/blametest.git/objects/46/ef45f4ae55c1f5dca64b9e1d7ca77c1798069b b/tests/resources/blametest.git/objects/46/ef45f4ae55c1f5dca64b9e1d7ca77c1798069b new file mode 100644 index 000000000..487ac57f1 Binary files /dev/null and b/tests/resources/blametest.git/objects/46/ef45f4ae55c1f5dca64b9e1d7ca77c1798069b differ diff --git a/tests/resources/blametest.git/objects/4b/0ca755f5bfd69ed6074f268b05bb0542a42c68 b/tests/resources/blametest.git/objects/4b/0ca755f5bfd69ed6074f268b05bb0542a42c68 new file mode 100644 index 000000000..698f5b135 Binary files /dev/null and b/tests/resources/blametest.git/objects/4b/0ca755f5bfd69ed6074f268b05bb0542a42c68 differ diff --git a/tests/resources/blametest.git/objects/4d/8400b7ce2d15ef5045c2775ed33e82a326786e b/tests/resources/blametest.git/objects/4d/8400b7ce2d15ef5045c2775ed33e82a326786e new file mode 100644 index 000000000..6e754df84 Binary files /dev/null and b/tests/resources/blametest.git/objects/4d/8400b7ce2d15ef5045c2775ed33e82a326786e differ diff --git a/tests/resources/blametest.git/objects/6b/52ee554131a5e7bacd15553fbd22408c5a8a6f b/tests/resources/blametest.git/objects/6b/52ee554131a5e7bacd15553fbd22408c5a8a6f new file mode 100644 index 000000000..b53aa0484 Binary files /dev/null and b/tests/resources/blametest.git/objects/6b/52ee554131a5e7bacd15553fbd22408c5a8a6f differ diff --git a/tests/resources/blametest.git/objects/70/2c7aa5250abc42be69ef78ee8fa47a346cb2ce b/tests/resources/blametest.git/objects/70/2c7aa5250abc42be69ef78ee8fa47a346cb2ce new file mode 100644 index 000000000..1f6f2da43 Binary files /dev/null and b/tests/resources/blametest.git/objects/70/2c7aa5250abc42be69ef78ee8fa47a346cb2ce differ diff --git a/tests/resources/blametest.git/objects/77/c796837eb003c81d2cd8a6577ef4e7edc61222 b/tests/resources/blametest.git/objects/77/c796837eb003c81d2cd8a6577ef4e7edc61222 new file mode 100644 index 000000000..ae5f740c1 Binary files /dev/null and b/tests/resources/blametest.git/objects/77/c796837eb003c81d2cd8a6577ef4e7edc61222 differ diff --git a/tests/resources/blametest.git/objects/7e/135d94af53b6c5edbae6a77df8a0f09375e823 b/tests/resources/blametest.git/objects/7e/135d94af53b6c5edbae6a77df8a0f09375e823 new file mode 100644 index 000000000..b374ed185 Binary files /dev/null and b/tests/resources/blametest.git/objects/7e/135d94af53b6c5edbae6a77df8a0f09375e823 differ diff --git a/tests/resources/blametest.git/objects/92/5bddd7a536a66eecb32faa41abd5bc9c192311 b/tests/resources/blametest.git/objects/92/5bddd7a536a66eecb32faa41abd5bc9c192311 new file mode 100644 index 000000000..aba34fa3c Binary files /dev/null and b/tests/resources/blametest.git/objects/92/5bddd7a536a66eecb32faa41abd5bc9c192311 differ diff --git a/tests/resources/blametest.git/objects/a3/4ead35680be7b9704fc4c6d750d182e228e02b b/tests/resources/blametest.git/objects/a3/4ead35680be7b9704fc4c6d750d182e228e02b new file mode 100644 index 000000000..121934e79 Binary files /dev/null and b/tests/resources/blametest.git/objects/a3/4ead35680be7b9704fc4c6d750d182e228e02b differ diff --git a/tests/resources/blametest.git/objects/a4/641ad869ffad601aa8347e0770e949bb6d90df b/tests/resources/blametest.git/objects/a4/641ad869ffad601aa8347e0770e949bb6d90df new file mode 100644 index 000000000..e54827c91 Binary files /dev/null and b/tests/resources/blametest.git/objects/a4/641ad869ffad601aa8347e0770e949bb6d90df differ diff --git a/tests/resources/blametest.git/objects/ba/9089263dce882885ad84513f31495bf9d31132 b/tests/resources/blametest.git/objects/ba/9089263dce882885ad84513f31495bf9d31132 new file mode 100644 index 000000000..4610c2649 Binary files /dev/null and b/tests/resources/blametest.git/objects/ba/9089263dce882885ad84513f31495bf9d31132 differ diff --git a/tests/resources/blametest.git/objects/c3/8d3c99946b74173f9b037279f07d505195563f b/tests/resources/blametest.git/objects/c3/8d3c99946b74173f9b037279f07d505195563f new file mode 100644 index 000000000..04fd9ccd3 Binary files /dev/null and b/tests/resources/blametest.git/objects/c3/8d3c99946b74173f9b037279f07d505195563f differ diff --git a/tests/resources/blametest.git/objects/c4/c13c153a611418325c70d6e630fed373546c4d b/tests/resources/blametest.git/objects/c4/c13c153a611418325c70d6e630fed373546c4d new file mode 100644 index 000000000..ba52060e4 Binary files /dev/null and b/tests/resources/blametest.git/objects/c4/c13c153a611418325c70d6e630fed373546c4d differ diff --git a/tests/resources/blametest.git/objects/d2/bc4f27cbb72260eeec350087d81a60a122efe9 b/tests/resources/blametest.git/objects/d2/bc4f27cbb72260eeec350087d81a60a122efe9 new file mode 100644 index 000000000..b4d6c6d5f Binary files /dev/null and b/tests/resources/blametest.git/objects/d2/bc4f27cbb72260eeec350087d81a60a122efe9 differ diff --git a/tests/resources/blametest.git/objects/d3/c7316f0075debfe53b25e58f56b0a4b46e18c3 b/tests/resources/blametest.git/objects/d3/c7316f0075debfe53b25e58f56b0a4b46e18c3 new file mode 100644 index 000000000..73f00ee33 Binary files /dev/null and b/tests/resources/blametest.git/objects/d3/c7316f0075debfe53b25e58f56b0a4b46e18c3 differ diff --git a/tests/resources/blametest.git/objects/d6/7268771ef5244f4aa224df29d4e4ae0bed2fd8 b/tests/resources/blametest.git/objects/d6/7268771ef5244f4aa224df29d4e4ae0bed2fd8 new file mode 100644 index 000000000..ee4847819 Binary files /dev/null and b/tests/resources/blametest.git/objects/d6/7268771ef5244f4aa224df29d4e4ae0bed2fd8 differ diff --git a/tests/resources/blametest.git/objects/d6/afeea2c4657c743dedab24a8a62da96f63547d b/tests/resources/blametest.git/objects/d6/afeea2c4657c743dedab24a8a62da96f63547d new file mode 100644 index 000000000..f3e52be6b Binary files /dev/null and b/tests/resources/blametest.git/objects/d6/afeea2c4657c743dedab24a8a62da96f63547d differ diff --git a/tests/resources/blametest.git/objects/d9/3e87a0863c7ec5e772f99e72ca9efddf0ca718 b/tests/resources/blametest.git/objects/d9/3e87a0863c7ec5e772f99e72ca9efddf0ca718 new file mode 100644 index 000000000..e1c0f0095 Binary files /dev/null and b/tests/resources/blametest.git/objects/d9/3e87a0863c7ec5e772f99e72ca9efddf0ca718 differ diff --git a/tests/resources/blametest.git/objects/f0/5190494260c2f6b6d045ac9bf27cb6d7e0abcc b/tests/resources/blametest.git/objects/f0/5190494260c2f6b6d045ac9bf27cb6d7e0abcc new file mode 100644 index 000000000..6df7d3495 Binary files /dev/null and b/tests/resources/blametest.git/objects/f0/5190494260c2f6b6d045ac9bf27cb6d7e0abcc differ diff --git a/tests/resources/blametest.git/objects/f4/f4b926582a2c23c6e3ba05309eaa89244c1d68 b/tests/resources/blametest.git/objects/f4/f4b926582a2c23c6e3ba05309eaa89244c1d68 new file mode 100644 index 000000000..32c1cdfdd Binary files /dev/null and b/tests/resources/blametest.git/objects/f4/f4b926582a2c23c6e3ba05309eaa89244c1d68 differ diff --git a/tests/resources/blametest.git/objects/fa/01940156471352d5483b4f26b7c849dfaa7eef b/tests/resources/blametest.git/objects/fa/01940156471352d5483b4f26b7c849dfaa7eef new file mode 100644 index 000000000..b392e4494 Binary files /dev/null and b/tests/resources/blametest.git/objects/fa/01940156471352d5483b4f26b7c849dfaa7eef differ diff --git a/tests/resources/blametest.git/refs/heads/master b/tests/resources/blametest.git/refs/heads/master index 994877a20..9d1715881 100644 Binary files a/tests/resources/blametest.git/refs/heads/master and b/tests/resources/blametest.git/refs/heads/master differ diff --git a/tests/resources/config/config12 b/tests/resources/config/config12 index 6917880b5..2e92762df 100644 Binary files a/tests/resources/config/config12 and b/tests/resources/config/config12 differ diff --git a/tests/resources/testrepo.git/objects/pack/multi-pack-index b/tests/resources/testrepo.git/objects/pack/multi-pack-index new file mode 100644 index 000000000..95102aeb4 Binary files /dev/null and b/tests/resources/testrepo.git/objects/pack/multi-pack-index differ diff --git a/tests/status/status_helpers.h b/tests/status/status_helpers.h index 242076cc9..464266af3 100644 --- a/tests/status/status_helpers.h +++ b/tests/status/status_helpers.h @@ -9,6 +9,7 @@ typedef struct { const char** expected_paths; int expected_entry_count; const char *file; + const char *func; int line; bool debug; } status_entry_counts; @@ -18,6 +19,7 @@ typedef struct { (counts).expected_statuses = (statuses); \ (counts).expected_paths = (paths); \ (counts).file = __FILE__; \ + (counts).func = __func__; \ (counts).line = __LINE__; \ } while (0) diff --git a/tests/status/submodules.c b/tests/status/submodules.c index 12edce2b2..38a39471a 100644 --- a/tests/status/submodules.c +++ b/tests/status/submodules.c @@ -71,12 +71,12 @@ static int cb_status__match(const char *p, unsigned int s, void *payload) int idx = counts->entry_count++; clar__assert_equal( - counts->file, counts->line, + counts->file, counts->func, counts->line, "Status path mismatch", 1, "%s", counts->expected_paths[idx], p); clar__assert_equal( - counts->file, counts->line, + counts->file, counts->func, counts->line, "Status code mismatch", 1, "%o", counts->expected_statuses[idx], s); diff --git a/tests/status/worktree.c b/tests/status/worktree.c index 7711b2da4..d2842485b 100644 --- a/tests/status/worktree.c +++ b/tests/status/worktree.c @@ -949,7 +949,7 @@ void test_status_worktree__sorting_by_case(void) void test_status_worktree__long_filenames(void) { - char path[260*4+1]; + char path[260*4+1] = {0}; const char *expected_paths[] = {path}; const unsigned int expected_statuses[] = {GIT_STATUS_WT_NEW}; diff --git a/tests/stream/deprecated.c b/tests/stream/deprecated.c index 2c2bbfdc3..fecd1be03 100644 --- a/tests/stream/deprecated.c +++ b/tests/stream/deprecated.c @@ -1,19 +1,18 @@ -#undef GIT_DEPRECATE_HARD - #include "clar_libgit2.h" #include "git2/sys/stream.h" #include "streams/tls.h" #include "streams/socket.h" #include "stream.h" -static git_stream test_stream; -static int ctor_called; - void test_stream_deprecated__cleanup(void) { cl_git_pass(git_stream_register(GIT_STREAM_TLS | GIT_STREAM_STANDARD, NULL)); } +#ifndef GIT_DEPRECATE_HARD +static git_stream test_stream; +static int ctor_called; + static int test_stream_init(git_stream **out, const char *host, const char *port) { GIT_UNUSED(host); @@ -24,9 +23,11 @@ static int test_stream_init(git_stream **out, const char *host, const char *port return 0; } +#endif void test_stream_deprecated__register_tls(void) { +#ifndef GIT_DEPRECATE_HARD git_stream *stream; int error; @@ -55,4 +56,5 @@ void test_stream_deprecated__register_tls(void) cl_assert(&test_stream != stream); git_stream_free(stream); +#endif } diff --git a/tests/submodule/add.c b/tests/submodule/add.c index f4d1e3b79..fc458f826 100644 --- a/tests/submodule/add.c +++ b/tests/submodule/add.c @@ -90,7 +90,7 @@ void test_submodule_add__url_relative(void) /* make sure we don't default to origin - rename origin -> test_remote */ cl_git_pass(git_remote_rename(&problems, g_repo, "origin", "test_remote")); cl_assert_equal_i(0, problems.count); - git_strarray_free(&problems); + git_strarray_dispose(&problems); cl_git_fail(git_remote_lookup(&remote, g_repo, "origin")); cl_git_pass( diff --git a/tests/submodule/submodule_helpers.c b/tests/submodule/submodule_helpers.c index 4bb064899..1d4759616 100644 --- a/tests/submodule/submodule_helpers.c +++ b/tests/submodule/submodule_helpers.c @@ -199,22 +199,22 @@ git_repository *setup_fixture_submodule_with_path(void) void assert__submodule_exists( git_repository *repo, const char *name, - const char *msg, const char *file, int line) + const char *msg, const char *file, const char *func, int line) { git_submodule *sm; int error = git_submodule_lookup(&sm, repo, name); if (error) - cl_git_report_failure(error, 0, file, line, msg); - cl_assert_at_line(sm != NULL, file, line); + cl_git_report_failure(error, 0, file, func, line, msg); + cl_assert_at_line(sm != NULL, file, func, line); git_submodule_free(sm); } void refute__submodule_exists( git_repository *repo, const char *name, int expected_error, - const char *msg, const char *file, int line) + const char *msg, const char *file, const char *func, int line) { clar__assert_equal( - file, line, msg, 1, "%i", + file, func, line, msg, 1, "%i", expected_error, (int)(git_submodule_lookup(NULL, repo, name))); } diff --git a/tests/submodule/submodule_helpers.h b/tests/submodule/submodule_helpers.h index d112b0c77..3c3f062ae 100644 --- a/tests/submodule/submodule_helpers.h +++ b/tests/submodule/submodule_helpers.h @@ -10,16 +10,16 @@ extern git_repository *setup_fixture_submodule_with_path(void); extern unsigned int get_submodule_status(git_repository *, const char *); -extern void assert__submodule_exists( - git_repository *, const char *, const char *, const char *, int); +extern void assert__submodule_exists(git_repository *, const char *, + const char *, const char *, const char *, int); #define assert_submodule_exists(repo,name) \ - assert__submodule_exists(repo, name, "git_submodule_lookup(" #name ") failed", __FILE__, __LINE__) + assert__submodule_exists(repo, name, "git_submodule_lookup(" #name ") failed", __FILE__, __func__, __LINE__) -extern void refute__submodule_exists( - git_repository *, const char *, int err, const char *, const char *, int); +extern void refute__submodule_exists(git_repository *, const char *, + int err, const char *, const char *, const char *, int); #define refute_submodule_exists(repo,name,code) \ - refute__submodule_exists(repo, name, code, "expected git_submodule_lookup(" #name ") to fail with error " #code, __FILE__, __LINE__) + refute__submodule_exists(repo, name, code, "expected git_submodule_lookup(" #name ") to fail with error " #code, __FILE__, __func__, __LINE__) extern void dump_submodules(git_repository *repo); diff --git a/tests/worktree/bare.c b/tests/worktree/bare.c index 2a0e88239..7234dfffd 100644 --- a/tests/worktree/bare.c +++ b/tests/worktree/bare.c @@ -28,7 +28,7 @@ void test_worktree_bare__list(void) cl_git_pass(git_worktree_list(&wts, g_repo)); cl_assert_equal_i(wts.count, 0); - git_strarray_free(&wts); + git_strarray_dispose(&wts); } void test_worktree_bare__add(void) @@ -48,7 +48,7 @@ void test_worktree_bare__add(void) cl_assert_equal_i(0, git_repository_is_bare(wtrepo)); cl_assert_equal_i(1, git_repository_is_worktree(wtrepo)); - git_strarray_free(&wts); + git_strarray_dispose(&wts); git_worktree_free(wt); git_repository_free(wtrepo); } diff --git a/tests/worktree/refs.c b/tests/worktree/refs.c index e62149d2e..27dc667ea 100644 --- a/tests/worktree/refs.c +++ b/tests/worktree/refs.c @@ -56,8 +56,8 @@ void test_worktree_refs__list(void) } exit: - git_strarray_free(&refs); - git_strarray_free(&wtrefs); + git_strarray_dispose(&refs); + git_strarray_dispose(&wtrefs); cl_git_pass(error); } @@ -163,7 +163,10 @@ void test_worktree_refs__renaming_reference_updates_worktree_heads(void) cl_git_pass(git_branch_lookup(&branch, fixture.repo, "testrepo-worktree", GIT_BRANCH_LOCAL)); cl_git_pass(git_reference_rename(&renamed, branch, "refs/heads/renamed", 0, NULL)); - cl_git_pass(git_repository_head(&head, fixture.worktree)); + + cl_git_pass(git_reference_lookup(&head, fixture.worktree, GIT_HEAD_FILE)); + cl_assert_equal_i(git_reference_type(head), GIT_REFERENCE_SYMBOLIC); + cl_assert_equal_s(git_reference_symbolic_target(head), "refs/heads/renamed"); git_reference_free(head); git_reference_free(branch); diff --git a/tests/worktree/repository.c b/tests/worktree/repository.c index ca56413b7..c4eeadd35 100644 --- a/tests/worktree/repository.c +++ b/tests/worktree/repository.c @@ -50,9 +50,12 @@ void test_worktree_repository__head_detached(void) cl_assert(git_repository_head_detached(fixture.worktree)); cl_assert(git_repository_head_detached_for_worktree(fixture.repo, "testrepo-worktree")); - cl_git_fail(git_repository_head_for_worktree(&head, fixture.repo, "testrepo-worktree")); + cl_git_pass(git_repository_head_for_worktree(&head, fixture.repo, "testrepo-worktree")); + + cl_assert_equal_oid(&ref->target.oid, &head->target.oid); git_reference_free(ref); + git_reference_free(head); } void test_worktree_repository__head_detached_fails_for_invalid_worktree(void) diff --git a/tests/worktree/worktree.c b/tests/worktree/worktree.c index 5e99dbf61..cd20bed82 100644 --- a/tests/worktree/worktree.c +++ b/tests/worktree/worktree.c @@ -30,7 +30,7 @@ void test_worktree_worktree__list(void) cl_assert_equal_i(wts.count, 1); cl_assert_equal_s(wts.strings[0], "testrepo-worktree"); - git_strarray_free(&wts); + git_strarray_dispose(&wts); } void test_worktree_worktree__list_with_invalid_worktree_dirs(void) @@ -61,7 +61,7 @@ void test_worktree_worktree__list_with_invalid_worktree_dirs(void) cl_git_pass(git_worktree_list(&wts, fixture.worktree)); cl_assert_equal_i(wts.count, 1); cl_assert_equal_s(wts.strings[0], "testrepo-worktree"); - git_strarray_free(&wts); + git_strarray_dispose(&wts); for (j = 0; j < ARRAY_SIZE(filesets[i]); j++) { git_buf_truncate(&path, len); @@ -81,7 +81,7 @@ void test_worktree_worktree__list_in_worktree_repo(void) cl_assert_equal_i(wts.count, 1); cl_assert_equal_s(wts.strings[0], "testrepo-worktree"); - git_strarray_free(&wts); + git_strarray_dispose(&wts); } void test_worktree_worktree__list_without_worktrees(void) @@ -380,7 +380,7 @@ void test_worktree_worktree__name(void) cl_git_pass(git_worktree_lookup(&wt, fixture.repo, "testrepo-worktree")); cl_assert_equal_s(git_worktree_name(wt), "testrepo-worktree"); - + git_worktree_free(wt); } @@ -581,45 +581,32 @@ void test_worktree_worktree__prune_worktree(void) git_worktree_free(wt); } -static int read_head_ref(git_repository *repo, const char *path, void *payload) +static int foreach_worktree_cb(git_repository *worktree, void *payload) { - git_vector *refs = (git_vector *) payload; - git_reference *head; + int *counter = (int *)payload; - GIT_UNUSED(repo); + switch (*counter) { + case 0: + cl_assert_equal_s(git_repository_path(fixture.repo), + git_repository_path(worktree)); + cl_assert(!git_repository_is_worktree(worktree)); + break; + case 1: + cl_assert_equal_s(git_repository_path(fixture.worktree), + git_repository_path(worktree)); + cl_assert(git_repository_is_worktree(worktree)); + break; + default: + cl_fail("more worktrees found than expected"); + } - cl_git_pass(git_reference__read_head(&head, repo, path)); - - git_vector_insert(refs, head); + (*counter)++; return 0; } -void test_worktree_worktree__foreach_head_gives_same_results_in_wt_and_repo(void) +void test_worktree_worktree__foreach_worktree_lists_all_worktrees(void) { - git_vector repo_refs = GIT_VECTOR_INIT, worktree_refs = GIT_VECTOR_INIT; - git_reference *heads[2]; - size_t i; - - cl_git_pass(git_reference_lookup(&heads[0], fixture.repo, GIT_HEAD_FILE)); - cl_git_pass(git_reference_lookup(&heads[1], fixture.worktree, GIT_HEAD_FILE)); - - cl_git_pass(git_repository_foreach_head(fixture.repo, read_head_ref, 0, &repo_refs)); - cl_git_pass(git_repository_foreach_head(fixture.worktree, read_head_ref, 0, &worktree_refs)); - - cl_assert_equal_i(repo_refs.length, ARRAY_SIZE(heads)); - cl_assert_equal_i(worktree_refs.length, ARRAY_SIZE(heads)); - - for (i = 0; i < ARRAY_SIZE(heads); i++) { - cl_assert_equal_s(heads[i]->name, ((git_reference *) repo_refs.contents[i])->name); - cl_assert_equal_s(heads[i]->name, ((git_reference *) repo_refs.contents[i])->name); - cl_assert_equal_s(heads[i]->name, ((git_reference *) worktree_refs.contents[i])->name); - - git_reference_free(heads[i]); - git_reference_free(repo_refs.contents[i]); - git_reference_free(worktree_refs.contents[i]); - } - - git_vector_free(&repo_refs); - git_vector_free(&worktree_refs); + int counter = 0; + cl_git_pass(git_repository_foreach_worktree(fixture.repo, foreach_worktree_cb, &counter)); }