1. 23 Feb, 2022 1 commit
  2. 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
  3. 30 Aug, 2021 1 commit
  4. 09 Dec, 2020 1 commit
    • alloc: set up an allocator that fails before library init · 08f28ff5
      We require the library to be initialized with git_libgit2_init before it
      is functional.  However, if a user tries to uses the library without
      doing so - as they might when getting started with the library for the
      first time - we will likely crash.
      
      This commit introduces some guard rails - now instead of having _no_
      allocator by default, we'll have an allocator that always fails, and
      never tries to set an error message (since the thread-local state is
      set up by git_libgit2_init).  We've modified the error retrieval
      function to (try to) ensure that the library has been initialized before
      getting the thread-local error message.
      
      (Unfortunately, we cannot determine if the thread local storage has
      actually been configured, this does require initialization by
      git_libgit2_init.  But a naive attempt should be good enough for most
      cases.)
      Edward Thomson committed
  5. 27 Nov, 2020 1 commit
  6. 11 Oct, 2020 1 commit
    • global: separate global state from thread-local state · 4853d94c
      Our "global initialization" has accumulated some debris over the years.
      It was previously responsible for both running the various global
      initializers (that set up various subsystems) _and_ setting up the
      "global state", which is actually the thread-local state for things
      like error reporting.
      
      Separate the thread local state out into "threadstate".  Use the normal
      subsystem initialization functions that we already have to set it up.
      This makes both the global initialization system and the threadstate
      system simpler to reason about.
      Edward Thomson committed
  7. 09 Jun, 2020 1 commit
    • 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
  8. 24 Jan, 2020 1 commit
  9. 21 Sep, 2019 1 commit
  10. 01 Aug, 2019 1 commit
    • errors: introduce `git_error_vset` function · c8e63812
      Right now, we only provide a `git_error_set` that has a variadic
      function signature. It's impossible to drive this function in a
      C89-compliant way from other functions that have a variadic
      signature, though, like for example `git_parse_error`.
      
      Implement a new `git_error_vset` function that gets a `va_list`
      as parameter, fixing the above problem.
      Patrick Steinhardt committed
  11. 19 May, 2019 1 commit
  12. 24 Jan, 2019 1 commit
  13. 22 Jan, 2019 3 commits
  14. 03 Jul, 2017 1 commit
    • Make sure to always include "common.h" first · 0c7f49dd
      Next to including several files, our "common.h" header also declares
      various macros which are then used throughout the project. As such, we
      have to make sure to always include this file first in all
      implementation files. Otherwise, we might encounter problems or even
      silent behavioural differences due to macros or defines not being
      defined as they should be. So in fact, our header and implementation
      files should make sure to always include "common.h" first.
      
      This commit does so by establishing a common include pattern. Header
      files inside of "src" will now always include "common.h" as its first
      other file, separated by a newline from all the other includes to make
      it stand out as special. There are two cases for the implementation
      files. If they do have a matching header file, they will always include
      this one first, leading to "common.h" being transitively included as
      first file. If they do not have a matching header file, they instead
      include "common.h" as first file themselves.
      
      This fixes the outlined problems and will become our standard practice
      for header and source files inside of the "src/" from now on.
      Patrick Steinhardt committed
  15. 03 Aug, 2015 4 commits
  16. 28 Jul, 2015 1 commit
  17. 13 Aug, 2014 1 commit
  18. 25 Feb, 2014 1 commit
  19. 11 Dec, 2013 1 commit
    • Improve GIT_EUSER handling · 96869a4e
      This adds giterr_user_cancel to return GIT_EUSER and clear any
      error message that is sitting around.  As a result of using that
      in places, we need to be more thorough with capturing errors that
      happen inside a callback when used internally.  To help with that,
      this also adds giterr_capture and giterr_restore so that when we
      internally use a foreach-type function that clears errors and
      converts them to GIT_EUSER, it is easier to restore not just the
      return value, but the actual error message text.
      Russell Belfer committed
  20. 05 Nov, 2013 1 commit
  21. 04 Nov, 2013 1 commit
  22. 08 Oct, 2013 1 commit
    • More filemode cleanups for FAT on MacOS · 14997dc5
      This cleans up some additional issues.  The main change is that
      on a filesystem that doesn't support mode bits, libgit2 will now
      create new blobs with GIT_FILEMODE_BLOB always instead of being
      at the mercy to the filesystem driver to report executable or not.
      This means that if "core.filemode" lies and claims that filemode
      is not supported, then we will ignore the executable bit from the
      filesystem.  Previously we would have allowed it.
      
      This adds an option to the new git_repository_reset_filesystem to
      recurse through submodules if desired.  There may be other types
      of APIs that would like a "recurse submodules" option, but this
      one is particularly useful.
      
      This also has a number of cleanups, etc., for related things
      including trying to give better error messages when problems come
      up from the filesystem.  For example, the FAT filesystem driver on
      MacOS appears to return errno EINVAL if you attempt to write a
      filename with invalid UTF-8 in it.  We try to capture that with a
      better error message now.
      Russell Belfer committed
  23. 14 Mar, 2013 1 commit
    • Fix valgrind issues (and mmap fallback for diff) · d85296ab
      This fixes a number of issues identified by valgrind - mostly
      missed free calls.  Inside valgrind, mmap() may fail which causes
      some of the diff tests to fail.  This adds a fallback code path
      to diff_output.c:get_workdir_content() where is the mmap() fails
      the code will now try to read the file data directly into allocated
      memory (which is what it would do if the data needed to be filtered
      anyhow).
      Russell Belfer committed
  24. 22 Feb, 2013 1 commit
  25. 01 Feb, 2013 4 commits
  26. 08 Jan, 2013 1 commit
  27. 01 Dec, 2012 1 commit
  28. 02 Nov, 2012 2 commits
  29. 21 Sep, 2012 1 commit
    • Make giterr_set_str public · 1a628100
      There has been discussion for a while about making some set of
      the `giterr_set` type functions part of the public API for code
      that is implementing new backends to libgit2.  This makes the
      `giterr_set_str()` and `giterr_set_oom()` functions public.
      Russell Belfer committed
  30. 24 Aug, 2012 1 commit
  31. 03 May, 2012 1 commit