1. 23 Feb, 2022 1 commit
  2. 30 Jan, 2022 1 commit
  3. 17 Jan, 2022 1 commit
  4. 05 Jan, 2022 1 commit
  5. 15 Nov, 2021 1 commit
  6. 09 Nov, 2021 3 commits
  7. 17 Oct, 2021 1 commit
    • str: introduce `git_str` for internal, `git_buf` is external · f0e693b1
      libgit2 has two distinct requirements that were previously solved by
      `git_buf`.  We require:
      
      1. A general purpose string class that provides a number of utility APIs
         for manipulating data (eg, concatenating, truncating, etc).
      2. A structure that we can use to return strings to callers that they
         can take ownership of.
      
      By using a single class (`git_buf`) for both of these purposes, we have
      confused the API to the point that refactorings are difficult and
      reasoning about correctness is also difficult.
      
      Move the utility class `git_buf` to be called `git_str`: this represents
      its general purpose, as an internal string buffer class.  The name also
      is an homage to Junio Hamano ("gitstr").
      
      The public API remains `git_buf`, and has a much smaller footprint.  It
      is generally only used as an "out" param with strict requirements that
      follow the documentation.  (Exceptions exist for some legacy APIs to
      avoid breaking callers unnecessarily.)
      
      Utility functions exist to convert a user-specified `git_buf` to a
      `git_str` so that we can call internal functions, then converting it
      back again.
      Edward Thomson committed
  8. 25 Sep, 2021 1 commit
  9. 22 Jul, 2021 1 commit
    • filter: filter options are now "filter sessions" · 1db5b219
      Filters use a short-lived structure to keep state during an operation to
      allow for caching and avoid unnecessary reallocations.  This was
      previously called the "filter options", despite the fact that they
      contain no configurable options.  Rename them to a "filter session" in
      keeping with an "attribute session", which more accurately describes
      their use (and allows us to create "filter options" in the future).
      Edward Thomson committed
  10. 11 May, 2021 1 commit
  11. 06 May, 2021 1 commit
    • filter: internal git_buf filter handling function · 31d9c24b
      Introduce `git_filter_list__convert_buf` which behaves like the old
      implementation of `git_filter_list__apply_data`, where it might move the
      input data buffer over into the output data buffer space for efficiency.
      
      This new implementation will do so in a more predictible way, always
      freeing the given input buffer (either moving it to the output buffer or
      filtering it into the output buffer first).
      
      Convert internal users to it.
      Edward Thomson committed
  12. 28 Apr, 2021 2 commits
  13. 14 Apr, 2021 2 commits
  14. 27 Nov, 2020 1 commit
  15. 09 Jun, 2020 2 commits
    • 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: 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
  16. 08 Jun, 2020 1 commit
    • checkout: remove unused code for deferred removals · 46637b5e
      With commit 05f69012 (checkout: remove blocking dir when FORCEd,
      2015-03-31), the last case was removde that actually queued a deferred
      removal. This is now more than five years in the past and nobody
      complained, so we can rest quite assured that the deferred removal is
      not really needed at all.
      
      Let's remove all related code to simplify the already complicated
      checkout logic.
      Patrick Steinhardt committed
  17. 01 Jun, 2020 1 commit
  18. 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
  19. 10 May, 2020 2 commits
  20. 10 Dec, 2019 2 commits
    • path: protect NTFS everywhere · e4034dfa
      Enable core.protectNTFS by default everywhere and in every codepath, not
      just on checkout.
      Edward Thomson committed
    • Protect against 8.3 "short name" attacks also on Linux/macOS · 64c612cc
      The Windows Subsystem for Linux (WSL) is getting increasingly popular,
      in particular because it makes it _so_ easy to run Linux software on
      Windows' files, via the auto-mounted Windows drives (`C:\` is mapped to
      `/mnt/c/`, no need to set that up manually).
      
      Unfortunately, files/directories on the Windows drives can be accessed
      via their _short names_, if that feature is enabled (which it is on the
      `C:` drive by default).
      
      Which means that we have to safeguard even our Linux users against the
      short name attacks.
      
      Further, while the default options of CIFS/SMB-mounts seem to disallow
      accessing files on network shares via their short names on Linux/macOS,
      it _is_ possible to do so with the right options.
      
      So let's just safe-guard against short name attacks _everywhere_.
      
      Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
      Johannes Schindelin committed
  21. 06 Nov, 2019 1 commit
  22. 20 Jul, 2019 1 commit
    • checkout: postpone creation of symlinks to the end · 6be5ac23
      On most platforms it's fine to create symlinks to nonexisting files. Not
      so on Windows, where the type of a symlink (file or directory) needs to
      be set at creation time. So depending on whether the target file exists
      or not, we may end up with different symlink types. This creates a
      problem when performing checkouts, where we simply iterate over all blobs
      that need to be updated without treating symlinks any special. If the
      target file of the symlink is going to be checked out after the symlink
      itself, then the symlink will be created as directory symlink and not as
      file symlink.
      
      Fix the issue by iterating over blobs twice: once to perform postponed
      deletions and updates to non-symlink blobs, and once to perform updates
      to symlink blobs.
      Patrick Steinhardt committed
  23. 18 Jul, 2019 1 commit
  24. 14 Jun, 2019 1 commit
    • Rename opt init functions to `options_init` · 0b5ba0d7
      In libgit2 nomenclature, when we need to verb a direct object, we name
      a function `git_directobject_verb`.  Thus, if we need to init an options
      structure named `git_foo_options`, then the name of the function that
      does that should be `git_foo_options_init`.
      
      The previous names of `git_foo_init_options` is close - it _sounds_ as
      if it's initializing the options of a `foo`, but in fact
      `git_foo_options` is its own noun that should be respected.
      
      Deprecate the old names; they'll now call directly to the new ones.
      Edward Thomson committed
  25. 15 Feb, 2019 1 commit
    • maps: use uniform lifecycle management functions · 351eeff3
      Currently, the lifecycle functions for maps (allocation, deallocation, resize)
      are not named in a uniform way and do not have a uniform function signature.
      Rename the functions to fix that, and stick to libgit2's naming scheme of saying
      `git_foo_new`. This results in the following new interface for allocation:
      
      - `int git_<t>map_new(git_<t>map **out)` to allocate a new map, returning an
        error code if we ran out of memory
      
      - `void git_<t>map_free(git_<t>map *map)` to free a map
      
      - `void git_<t>map_clear(git<t>map *map)` to remove all entries from a map
      
      This commit also fixes all existing callers.
      Patrick Steinhardt committed
  26. 22 Jan, 2019 1 commit
  27. 01 Dec, 2018 1 commit
  28. 29 Jun, 2018 2 commits
  29. 26 Jun, 2018 1 commit
  30. 10 Jun, 2018 1 commit
  31. 23 May, 2018 1 commit
  32. 24 Feb, 2018 1 commit