1. 12 Jul, 2020 13 commits
    • Merge pull request #5570 from libgit2/pks/refdb-refactorings · 26b9e489
      refdb: a set of preliminary refactorings for the reftable backend
      Edward Thomson committed
    • refdb: avoid unlimited spinning in case of symref cycles · 34987447
      To determine whether another reflog entry needs to be written for HEAD
      on a reference update, we need to see whether HEAD directly or
      indirectly points to the reference we're updating. The resolve logic is
      currently completely unbounded except an error occurs, which effectively
      means that we'd be spinning forever in case we have a symref loop in the
      repository refdb.
      
      Let's fix the issue by using `git_refdb_resolve` instead, which is
      always bounded.
      Patrick Steinhardt committed
    • refs: replace reimplementation of reference resolver · b895547c
      The refs code currently has a second implementation that resolves
      references in order to find any final symbolic reference pointing to a
      nonexistent target branch. As we've just extended `git_refdb_resolve` to
      also return such references, let's use that one instead in order to
      reduce code duplication.
      Patrick Steinhardt committed
    • refdb: return resolved symbolic refs pointing to nonexistent refs · cf7dd05b
      In some cases, resolving references requires us to also know about the
      final symbolic reference that's pointing to a nonexistent branch, e.g.
      in an empty repository where the main branch is yet unborn but HEAD
      already points to it. Right now, the resolving logic is thus split up
      into two, where one is the new refdb implementation and the second one
      is an ad-hoc implementation inside "refs.c".
      
      Let's extend `git_refdb_resolve` to also return such final dangling
      references pointing to nonexistent branches so we can deduplicate the
      resolving logic.
      Patrick Steinhardt committed
    • refs: move resolving of references into the refdb · c54f40e4
      Resolving of symbolic references is currently implemented inside the
      "refs" layer. As a result, it's hard to call this function from
      low-level parts that only have a refdb available, but no repository, as
      the "refs" layer always operates on the repository-level. So let's move
      the function into the generic "refdb" implementation to lift this
      restriction.
      Patrick Steinhardt committed
    • Merge pull request #5547 from pks-t/pks/cmake-modernization-pt2 · ae30009e
      CMake modernization pt2
      Patrick Steinhardt committed
    • tests: reflog: remove unused signature · 9703d26f
      There's two tests that create a commit signature, but never make any use
      of it. Let's remove these to avoid any confusion.
      Patrick Steinhardt committed
    • refdb: extract function to check whether to append HEAD to the reflog · 1f39593b
      The logic to determine whether a reflog entry should be for the HEAD
      reference is non-trivial. Currently, the only user of this is the
      filesystem-based refdb, but with the advent of the reftable refdb we're
      going to add a second user that's interested in having the same
      behaviour.
      
      Let's pull out a new function that checks whether a given reference
      should cause a entry to be written to the HEAD reflog as a preparatory
      step.
      Patrick Steinhardt committed
    • refdb: extract function to check whether a reflog should be written · e02478b1
      The logic to determine whether a reflog should be written is
      non-trivial. Currently, the only user of this is the filesystem-based
      refdb, but with the advent of the reftable refdb we're going to add a
      second user that's interested in having the same behaviour.
      
      Let's pull out a new function that checks whether a given reference
      should cause a reflog to be written as a preparatory step.
      Patrick Steinhardt committed
    • cmake: remove CheckPrototypeDefinition module · 9bc6e655
      In the past, we've imported the CheckPrototypeDefinition into our own
      module directory as it wasn't yet available in all supported CMake
      versions. Now that we require at least CMake v3.5, we don't need to
      bundle it anymore as it's included with the distribution already.
      
      Let's drop the included modules and always use upstream's version.
      Patrick Steinhardt committed
    • cmake: use target-specific compile definitions · 4218403e
      We set up some compile definitions as part of our src/CMakeLists.txt.
      While the definitions are global, we really only need them as part of
      the git2internal target which compiles all the objects. Let's thus use
      `target_compile_definitions` instead of `add_definitions`.
      Patrick Steinhardt committed
    • cmake: use git2internal target to populate sources · 53911edd
      Modern CMake is usually target-driven in that a target is first defined
      and then the likes of `target_sources`, `target_include_directories`
      etc. are used to further populate the target. We still use old-style
      CMake, where we first set up a set of variables and then populate the
      target in a single call.
      
      Let's migrate to modern CMake usage by starting to populate the sources
      of our git2internal target piece-by-piece. While this is a small step,
      it allows us to convert to target-based build instructions
      piece-by-piece.
      Patrick Steinhardt committed
    • cmake: specify project version · 19eb1e4b
      We currently do not set up a project version within CMake, meaning that
      it can't be use by other projects including libgit2 as a sub-project and
      also not by other tools like IDEs.
      
      This commit changes this to always set up a project version, but instead
      of extracting it from the "version.h" header we now set it up directly.
      This is mostly to avoid mis-use of the previous `LIBGIT2_VERSION`
      variables, as we should now always use the `libgit2_VERSION` ones that
      are set up by CMake if one provides the "VERSION" keyword to the
      `project()` call. While this is one more moving target we need to adjust
      on releases, this commit also adjusts our release script to verify that
      the project version was incremented as expected.
      Patrick Steinhardt committed
  2. 09 Jul, 2020 3 commits
  3. 02 Jul, 2020 1 commit
  4. 01 Jul, 2020 3 commits
  5. 30 Jun, 2020 3 commits
    • Make NTLMClient Memory and UndefinedBehavior Sanitizer-clean · 7c964416
      This change makes the code pass the libgit2 tests cleanly when
      MSan/UBSan are enabled. Notably:
      
      * Changes malloc/memset combos into calloc for easier auditing.
      * Makes `write_buf` return early if the buffer length is empty to avoid
        arithmetic with NULL pointers (which UBSan does not like).
      * Initializes a few arrays that were sometimes being read before being
        written to.
      lhchavez committed
    • Make the tests pass cleanly with MemorySanitizer · 3a197ea7
      This change:
      
      * Initializes a few variables that were being read before being
        initialized.
      * Includes https://github.com/madler/zlib/pull/393. As such,
        it only works reliably with `-DUSE_BUNDLED_ZLIB=ON`.
      lhchavez committed
    • Make the tests run cleanly under UndefinedBehaviorSanitizer · d0656ac8
      This change makes the tests run cleanly under
      `-fsanitize=undefined,nullability` and comprises of:
      
      * Avoids some arithmetic with NULL pointers (which UBSan does not like).
      * Avoids an overflow in a shift, due to an uint8_t being implicitly
        converted to a signed 32-bit signed integer after being shifted by a
        32-bit signed integer.
      * Avoids a unaligned read in libgit2.
      * Ignores unaligned reads in the SHA1 library, since it only happens on
        Intel processors, where it is _still_ undefined behavior, but the
        semantics are moderately well-understood.
      
      Of notable omission is `-fsanitize=integer`, since there are lots of
      warnings in zlib and the SHA1 library which probably don't make sense to
      fix and I could not figure out how to silence easily. libgit2 itself
      also has ~100s of warnings which are mostly innocuous (e.g. use of enum
      constants that only fit on an `uint32_t`, but there is no way to do that
      in a simple fashion because the data type chosen for enumerated types is
      implementation-defined), and investigating whether there are worrying
      warnings would need reducing the noise significantly.
      lhchavez committed
  6. 23 Jun, 2020 1 commit
  7. 17 Jun, 2020 5 commits
  8. 16 Jun, 2020 2 commits
    • Merge pull request #5550 from libgit2/ethomson/github_actions · d60bf002
      Introduce CI with GitHub Actions
      Edward Thomson committed
    • Introduce CI with GitHub Actions · 47fb33ba
      Add CI using GitHub Actions and GitHub Packages:
      
      * This moves our Linux build containers into GitHub Packages; we will
        identify the most recent commit that updated the docker descriptions,
        and then look for a docker image in libgit2's GitHub Packages registry
        for a container with the tag corresponding to that description.  If
        there is not one, we will build the container and then push it to
        GitHub Packages.
      
      * We no longer need to manage authentication with our own credentials or
        PAT tokens.  GitHub Actions provides a GITHUB_TOKEN that can publish
        artifacts, packages and commits to our repository within a workflow
        run.
      
      * We will use a matrix to build our various CI steps.  This allows us
        to keep configuration in a single place without multiple YAML files.
      Edward Thomson committed
  9. 13 Jun, 2020 1 commit
  10. 12 Jun, 2020 1 commit
  11. 11 Jun, 2020 1 commit
  12. 10 Jun, 2020 2 commits
  13. 09 Jun, 2020 4 commits
    • cmake: enable warnings for missing function declarations · 03c4f86c
      Over time, we have accumulated quite a lot of functions with missing
      prototypes, missing `static` keywords or which were completely unused.
      It's easy to miss these mistakes, but luckily GCC and Clang both have
      the `-Wmissing-declarations` warning. Enabling this will cause them to
      emit warnings for every not-static function that doesn't have a previous
      declaration. This is a very sane thing to enable, and with the preceding
      commits all these new warnings have been fixed.
      
      So let's always enable this warning so we won't introduce new instances
      of them.
      Patrick Steinhardt committed
    • refs: add missing function declaration · fd1f0940
      The function `git_reference__is_note` is not declared anywhere. Let's
      add the declaration to avoid having non-static functions without
      declaration.
      Patrick Steinhardt committed
    • tree-wide: do not compile deprecated functions with hard deprecation · c6184f0c
      When compiling libgit2 with -DDEPRECATE_HARD, we add a preprocessor
      definition `GIT_DEPRECATE_HARD` which causes the "git2/deprecated.h"
      header to be empty. As a result, no function declarations are made
      available to callers, but the implementations are still available to
      link against. This has the problem that function declarations also
      aren't visible to the implementations, meaning that the symbol's
      visibility will not be set up correctly. As a result, the resulting
      library may not expose those deprecated symbols at all on some platforms
      and thus cause linking errors.
      
      Fix the issue by conditionally compiling deprecated functions, only.
      While it becomes impossible to link against such a library in case one
      uses deprecated functions, distributors of libgit2 aren't expected to
      pass -DDEPRECATE_HARD anyway. Instead, users of libgit2 should manually
      define GIT_DEPRECATE_HARD to hide deprecated functions. Using "real"
      hard deprecation still makes sense in the context of CI to test we don't
      use deprecated symbols ourselves and in case a dependant uses libgit2 in
      a vendored way and knows it won't ever use any of the deprecated symbols
      anyway.
      Patrick Steinhardt committed
    • tree-wide: add missing header includes · 6e1efcd6
      We're missing some header includes leading to missing function
      prototypes. While we currently don't warn about these, we should have
      their respective headers included in order to detect the case where a
      function signature change results in an incompatibility.
      Patrick Steinhardt committed