1. 27 Feb, 2023 1 commit
    • fs_path: let root run the ownership tests · 5c1d7649
      The `git_fs_path_owner_is_current_user` expects the root dir on unix
      (`/`) to be owned by a non-current user. This makes sense unless root
      (or euid == 0) is running the tests, which often happens during distro
      build / packaging scripts. Allow them to run the tests.
      Edward Thomson committed
  2. 11 Apr, 2022 1 commit
  3. 23 Feb, 2022 2 commits
  4. 18 Jan, 2022 1 commit
  5. 09 Nov, 2021 1 commit
  6. 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
  7. 27 Nov, 2020 1 commit
  8. 20 Jul, 2019 1 commit
  9. 25 Sep, 2018 1 commit
  10. 10 Jun, 2018 1 commit
  11. 08 Feb, 2017 2 commits
    • path: ensure dirname on Win32 prefix always has a trailing '/' · 9e8d75c7
      When calling `git_path_dirname_r` on a Win32 prefix, e.g. a drive
      or network share prefix, we always want to return the trailing
      '/'. This does not work currently when passing in a path like
      'C:', where the '/' would not be appended correctly.
      
      Fix this by appending a '/' if we try to normalize a Win32 prefix
      and there is no trailing '/'.
      Patrick Steinhardt committed
    • path: get correct dirname for Windows root · 5d59520c
      Getting the dirname of a filesystem root should return the filesystem
      root itself. E.g. the dirname of "/" is always "/". On Windows, we
      emulate this behavior and as such, we should return e.g. "C:/" if
      calling dirname on "C:/". But we currently fail to do so and instead
      return ".", as we do not check if we actually have a Windows prefix
      before stripping off the last directory component.
      
      Fix this by calling out to `win32_prefix_length` immediately after
      stripping trailing slashes, returning early if we have a prefix.
      Patrick Steinhardt committed
  12. 24 Mar, 2016 1 commit
  13. 02 Jun, 2015 1 commit
  14. 17 Sep, 2014 1 commit
  15. 11 Dec, 2013 2 commits
    • Remove converting user error to GIT_EUSER · 25e0b157
      This changes the behavior of callbacks so that the callback error
      code is not converted into GIT_EUSER and instead we propagate the
      return value through to the caller.  Instead of using the
      giterr_capture and giterr_restore functions, we now rely on all
      functions to pass back the return value from a callback.
      
      To avoid having a return value with no error message, the user
      can call the public giterr_set_str or some such function to set
      an error message.  There is a new helper 'giterr_set_callback'
      that functions can invoke after making a callback which ensures
      that some error message was set in case the callback did not set
      one.
      
      In places where the sign of the callback return value is
      meaningful (e.g. positive to skip, negative to abort), only the
      negative values are returned back to the caller, obviously, since
      the other values allow for continuing the loop.
      
      The hardest parts of this were in the checkout code where positive
      return values were overloaded as meaningful values for checkout.
      I fixed this by adding an output parameter to many of the internal
      checkout functions and removing the overload.  This added some
      code, but it is probably a better implementation.
      
      There is some funkiness in the network code where user provided
      callbacks could be returning a positive or a negative value and
      we want to rely on that to cancel the loop.  There are still a
      couple places where an user error might get turned into GIT_EUSER
      there, I think, though none exercised by the tests.
      Russell Belfer committed
    • Further EUSER and error propagation fixes · dab89f9b
      This continues auditing all the places where GIT_EUSER is being
      returned and making sure to clear any existing error using the
      new giterr_user_cancel helper.  As a result, places that relied
      on intercepting GIT_EUSER but having the old error preserved also
      needed to be cleaned up to correctly stash and then retrieve the
      actual error.
      
      Additionally, as I encountered places where error codes were not
      being propagated correctly, I tried to fix them up.  A number of
      those fixes are included in the this commit as well.
      Russell Belfer committed
  16. 14 Nov, 2013 1 commit
  17. 03 Oct, 2013 1 commit
    • Wrap iconv stuff and write tests · 618b7689
      This adds a simple wrapper around the iconv APIs and uses it
      instead of the old code that was inlining the iconv stuff.  This
      makes it possible for me to test the iconv logic in isolation.
      A "no iconv" version of the API was defined with macros so that
      I could have fewer ifdefs in the code itself.
      Russell Belfer committed
  18. 03 Sep, 2013 3 commits
  19. 11 Feb, 2013 1 commit
  20. 26 Dec, 2012 2 commits
  21. 11 Jul, 2012 1 commit
    • Add path utilities to resolve relative paths · b0fe1129
      This makes it easy to take a buffer containing a path with relative
      references (i.e. .. or . path segments) and resolve all of those
      into a clean path.  This can be applied to URLs as well as file
      paths which can be useful.
      
      As part of this, I made the drive-letter detection apply on all
      platforms, not just windows.  If you give a path that looks like
      "c:/..." on any platform, it seems like we might as well detect
      that as a rooted path.  I suppose if you create a directory named
      "x:" on another platform and want to use that as the beginning
      of a relative path under the root directory of your repo, this
      could cause a problem, but then it seems like you're asking for
      trouble.
      Russell Belfer committed
  22. 17 May, 2012 2 commits
  23. 08 May, 2012 1 commit
  24. 17 Apr, 2012 1 commit
  25. 16 Mar, 2012 2 commits
  26. 27 Feb, 2012 1 commit
    • buffer: Unify `git_fbuffer` and `git_buf` · 13224ea4
      This makes so much sense that I can't believe it hasn't been done
      before. Kill the old `git_fbuffer` and read files straight into
      `git_buf` objects.
      
      Also: In order to fully support 4GB files in 32-bit systems, the
      `git_buf` implementation has been changed from using `ssize_t` for
      storage and storing negative values on allocation failure, to using
      `size_t` and changing the buffer pointer to a magical pointer on
      allocation failure.
      
      Hopefully this won't break anything.
      Vicent Martí committed
  27. 25 Jan, 2012 1 commit
  28. 12 Jan, 2012 1 commit
  29. 11 Jan, 2012 1 commit
    • Initial implementation of gitignore support · df743c7d
      Adds support for .gitignore files to git_status_foreach() and
      git_status_file().  This includes refactoring the gitattributes
      code to share logic where possible.  The GIT_STATUS_IGNORED flag
      will now be passed in for files that are ignored (provided they
      are not already in the index or the head of repo).
      Russell Belfer committed
  30. 28 Dec, 2011 2 commits
  31. 14 Dec, 2011 1 commit
    • Allow git_buf_joinpath to accept self-joins · b5daae68
      It was not safe for git_buf_joinpath to be used with a pointer
      into the buf itself because a reallocation could invalidate
      the input parameter that pointed into the buffer.  This patch
      makes it safe to self join, at least for the leading input to
      the join, which is the common "append" case for self joins.
      
      Also added unit tests to explicitly cover this case.
      
      This should actually fix #511
      Russell Belfer committed