1. 18 Jan, 2022 2 commits
    • win32: improve impl & tests for system path / g4w interop · 475c6eba
      We look for a Git for Windows installation to use its git config,
      so that clients built on libgit2 can interoperate with the Git for
      Windows CLI (and clients that are built on top of _it_).
      
      Look for `git` both in the `PATH` and in the registry.  Use the _first_
      git install in the path, and the first git install in the registry.
      
      Look in both the `etc` dir and the architecture-specific `etc` dirs
      (`mingw64/etc` and `mingw32/etc`) beneath the installation root.
      
      Prefer the git in the `PATH` to the git location in the registry so that
      users can override that.
      
      Include more tests for this behavior.
      Edward Thomson committed
  2. 09 Nov, 2021 1 commit
  3. 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
  4. 27 Nov, 2020 1 commit
  5. 11 Oct, 2020 1 commit
  6. 18 Sep, 2020 1 commit
    • sysdir: fix formatting error message with NULL string · b254a585
      When trying to the template dir, we pass in a `NULL` pointer for the
      filename. That's perfectly fine, but if we're failing to find the
      template directory then we'll creat an error message with the `NULL`
      pointer passed in.
      
      Fix the issue by setting different error messages based on whether the
      filename is given or not. This even makes sense, as we're not searching
      for a file in case we have no `name`, but for a directory. So the error
      would've been misleading anyway.
      Patrick Steinhardt committed
  7. 05 Apr, 2020 1 commit
  8. 01 Aug, 2019 1 commit
  9. 22 Jan, 2019 1 commit
  10. 10 Jun, 2018 1 commit
  11. 02 Feb, 2018 1 commit
    • sysdir: do not use environment in setuid case · 0967459e
      In order to derive the location of some Git directories, we currently
      use the environment variables $HOME and $XDG_CONFIG_HOME. This might
      prove to be problematic whenever the binary is run with setuid, that is
      when the effective user does not equal the real user. In case the
      environment variables do not get sanitized by the caller, we thus might
      end up using the real user's configuration when doing stuff as the
      effective user.
      
      The fix is to use the passwd entry's directory instead of $HOME in this
      situation. As this might break scenarios where the user explicitly sets
      $HOME to another path, this fix is only applied in case the effective
      user does not equal the real user.
      Patrick Steinhardt committed
  12. 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
  13. 23 Mar, 2017 1 commit
    • Introduce `git_sysdir_expand_global_file` · 5135ddaa
      Provide a mechanism for callers to expand the full path of a file in the
      global configuration directory (that is to say, the home directory) even
      if the file doesn't necessarily exist.  This lets callers use their own
      logic for building paths separate from handling file existence.
      Edward Thomson committed
  14. 29 Dec, 2016 1 commit
  15. 18 Dec, 2016 1 commit
  16. 04 Aug, 2016 1 commit
    • sysdir: use the standard `init` pattern · 031d34b7
      Don't try to determine when sysdirs are uninitialized.  Instead, simply
      initialize them all at `git_libgit2_init` time and never try to
      reinitialize, except when consumers explicitly call `git_sysdir_set`.
      
      Looking at the buffer length is especially problematic, since there may
      no appropriate path for that value.  (For example, the Windows-specific
      programdata directory has no value on non-Windows machines.)
      
      Previously we would continually trying to re-lookup these values,
      which could get racy if two different threads are each calling
      `git_sysdir_get` and trying to lookup / clear the value simultaneously.
      Edward Thomson committed
  17. 21 Oct, 2015 1 commit
  18. 02 Jul, 2015 1 commit
  19. 06 May, 2014 1 commit
  20. 02 May, 2014 1 commit
    • Improve handling of fake home directory · 0f603132
      There are a few tests that set up a fake home directory and a
      fake GLOBAL search path so that we can test things in global
      ignore or attribute or config files.  This cleans up that code to
      work more robustly even if there is a test failure.  This also
      fixes some valgrind warnings where scanning search paths for
      separators could end up doing a little bit of sketchy data access
      when coming to the end of search list.
      Russell Belfer committed
  21. 21 Apr, 2014 1 commit
  22. 25 Feb, 2014 1 commit