1. 27 Jun, 2020 4 commits
  2. 17 Jun, 2020 4 commits
  3. 09 Jun, 2020 5 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
    • tree-wide: mark local functions as static · a6c9e0b3
      We've accumulated quite some functions which are never used outside of
      their respective code unit, but which are lacking the `static` keyword.
      Add it to reduce their linkage scope and allow the compiler to optimize
      better.
      Patrick Steinhardt committed
  4. 08 Jun, 2020 4 commits
  5. 01 Jun, 2020 7 commits
    • httpclient: clear the read_buf on new requests · 04c7bdb4
      The httpclient implementation keeps a `read_buf` that holds the data
      in the body of the response after the headers have been written.  We
      store that data for subsequent calls to `git_http_client_read_body`.  If
      we want to stop reading body data and send another request, we need to
      clear that cached data.
      
      Clear the cached body data on new requests, just like we read any
      outstanding data from the socket.
      Edward Thomson committed
    • httpclient: don't read more than the client wants · aa8b2c0f
      When `git_http_client_read_body` is invoked, it provides the size of the
      buffer that can be read into.  This will be set as the parser context's
      `output_size` member.  Use this as an upper limit on our reads, and
      ensure that we do not read more than the client requests.
      Edward Thomson committed
    • strarray: we should `dispose` instead of `free` · 51eff5a5
      We _dispose_ the contents of objects; we _free_ objects (and their
      contents).  Update `git_strarray_free` to be `git_strarray_dispose`.
      `git_strarray_free` remains as a deprecated proxy function.
      Edward Thomson committed
    • httpclient: read_body should return 0 at EOF · 570f0340
      When users call `git_http_client_read_body`, it should return 0 at the
      end of a message.  When the `on_message_complete` callback is called,
      this will set `client->state` to `DONE`.  In our read loop, we look for
      this condition and exit.
      
      Without this, when there is no data left except the end of message chunk
      (`0\r\n`) in the http stream, we would block by reading the three bytes
      off the stream but not making progress in any `on_body` callbacks.
      Listening to the `on_message_complete` callback allows us to stop trying
      to read from the socket when we've read the end of message chunk.
      Edward Thomson committed
    • git_pool_init: handle failure cases · 0f35efeb
      Propagate failures caused by pool initialization errors.
      Edward Thomson committed
    • config: ignore unreadable configuration files · d1409f48
      Modified `config_file_open()` so it returns 0 if the config file is
      not readable, which happens on global config files under macOS
      sandboxing (note that for some reason `access(F_OK)` DOES work with
      sandboxing, but it is lying). Without this read check sandboxed
      applications on macOS can not open any repository, because
      `config_file_read()` will return GIT_ERROR when it cannot read the
      global /Users/username/.gitconfig file, and the upper layers will
      just completely abort on GIT_ERROR when attempting to load the
      global config file, so no repositories can be opened.
      Wil Shipley committed
  6. 25 May, 2020 1 commit
  7. 23 May, 2020 4 commits
  8. 16 May, 2020 1 commit
    • checkout: fix file being treated as unmodified due to racy index · 3f201f75
      When trying to determine whether a file changed, we try to avoid heavy
      operations by fist taking a look at the index, seeing whether the index
      entry is modified already. This doesn't seem to cut it, though, as we
      currently have the racy checkout::index::can_disable_pathspec_match test
      case: sometimes the files get restored to their original contents,
      sometimes they aren't.
      
      The issue is caused by a racy index [1]: in case we modify a file, add
      it to the index and then modify it again in-place without changing its
      file, then we may end up with a modified file that has the same stat(3P)
      info as we've currently got it in its corresponding index entry. The
      mitigation for this is to treat files with the same mtime as the index
      are treated as racily modified. We already have this logic in place for
      the index, but not when doing a checkout.
      
      Fix the issue by only consulting the index entry in case it has an older
      mtime as the index. Previously, the following script reliably had at
      least 20 failures, while now there is no failure to be observed anymore:
      
      ```bash
      j=0
      for i in $(seq 100)
      do
      	if ! ./libgit2_clar -scheckout::index::can_disable_pathspec_match >/dev/null
      	then
      		j=$(($j + 1))
      	fi
      done
      echo "Failures: $j"
      ```
      
      [1]: https://git-scm.com/docs/racy-git
      Patrick Steinhardt committed
  9. 15 May, 2020 2 commits
    • cmake: Sort source files for reproducible builds · b85eefb4
      We currently use `FILE(GLOB ...)` in most places to find source and
      header files. This is problematic in that the order of files returned
      depends on the operating system's directory iteration order and may thus
      not be deterministic. As a result, we link object files in unspecified
      order, which may cause the linker to emit different code across runs.
      
      Fix this issue by sorting all code used as input to the libgit2 library
      to improve the reliability of reproducible builds.
      Patrick Steinhardt committed
    • streams: openssl: fix memleak due to us not free'ing certs · b43a9e66
      When creating a `git_cert` from the OpenSSL X509 certificate of a given
      stream, we do not call `X509_free()` on the certificate, leading to a
      memory leak as soon as the certificate is requested e.g. by the
      certificate check callback.
      
      Fix the issue by properly calling `X509_free()`.
      Patrick Steinhardt committed
  10. 12 May, 2020 1 commit
    • futils: fix order of declared parameters for `git_futils_fake_symlink` · a2eca682
      While the function `git_futils_fake_symlink` is declared with arguments
      `new, old`, the implementation uses the reverse order `old, new`. Let's
      fix the ordering issues to be `new, old` for both, which matches what
      symlink(3P) has. While at it, we also rename these parameters: `old` and
      `new` doesn't really make a lot of sense in the context of symlinks,
      which is why this commit renames them to be called `target` and `path`.
      Patrick Steinhardt committed
  11. 11 May, 2020 4 commits
  12. 10 May, 2020 2 commits
  13. 14 Apr, 2020 1 commit