1. 21 Sep, 2019 1 commit
  2. 13 Aug, 2019 1 commit
    • config: validate ownership of C:\ProgramData\Git\config before using it · cb1439c9
      When the VirtualStore feature is in effect, it is safe to let random
      users write into C:\ProgramData because other users won't see those
      files. This seemed to be the case when we introduced support for
      C:\ProgramData\Git\config.
      
      However, when that feature is not in effect (which seems to be the case
      in newer Windows 10 versions), we'd rather not use those files unless
      they come from a trusted source, such as an administrator.
      
      This change imitates the strategy chosen by PowerShell's native OpenSSH
      port to Windows regarding host key files: if a system file is owned
      neither by an administrator, a system account, or the current user, it
      is ignored.
      Johannes Schindelin committed
  3. 18 Jul, 2019 1 commit
  4. 19 May, 2019 1 commit
  5. 22 Jan, 2019 1 commit
  6. 04 Jan, 2019 1 commit
  7. 28 Nov, 2018 1 commit
    • config: fix adding files if their parent directory is a file · 43cbe6b7
      When we try to add a configuration file with `git_config_add_file_ondisk`, we
      treat nonexisting files as empty. We do this by performing a stat call, ignoring
      ENOENT errors. This works just fine in case the file or any of its parents
      simply does not exist, but there is also the case where any of the parent
      directories is not a directory, but a file. So e.g. trying to add a
      configuration file "/dev/null/.gitconfig" will fail, as `errno` will be ENOTDIR
      instead of ENOENT.
      
      Catch ENOTDIR in addition to ENOENT to fix the issue. Add a test that verifies
      we are able to add configuration files with such an invalid path file just fine.
      Patrick Steinhardt committed
  8. 02 Nov, 2018 1 commit
  9. 18 Oct, 2018 1 commit
    • config: remove last instance of `git__strntol64` · 1a2efd10
      When parsing integers from configuration values, we use `git__strtol64`.
      This is fine to do, as we always sanitize values and can thus be sure
      that they'll have a terminating `NUL` byte. But as this is the last
      call-site of `git__strtol64`, let's just pass in the length explicitly
      by calling `strlen` on the value to be able to remove `git__strtol64`
      altogether.
      Patrick Steinhardt committed
  10. 28 Sep, 2018 3 commits
  11. 21 Sep, 2018 2 commits
    • config: rename `file_internal` and its `file` member · 83733aeb
      Same as with the previous commit, the `file_internal` struct is used to
      keep track of all the backends that are added to a `git_config` struct.
      Rename it to `backend_internal` and rename its `file` member to
      `backend` to make the implementation more backend-agnostic.
      Patrick Steinhardt committed
    • config: rename `files` vector to `backends` · 633cf40c
      Originally, the `git_config` struct is a collection of all the parsed
      configuration files from different scopes (system-wide config,
      user-specific config as well as the repo-specific config files).
      Historically, we didn't and don't yet have any other configuration
      backends than the one for files, which is why the field holding the
      config backends is called `files`. But in fact, nothing dictates that
      the vector of backends actually holds file backends only, as they are
      generic and custom backends can be implemented by users.
      
      Rename the member to be called `backends` to clarify that there is
      nothing specific to files here.
      Patrick Steinhardt committed
  12. 10 Jun, 2018 1 commit
  13. 09 Oct, 2017 1 commit
    • config: pass repository when opening config files · 529e873c
      Our current configuration logic is completely oblivious of any
      repository, but only cares for actual file paths. Unfortunately, we are
      forced to break this assumption by the introduction of conditional
      includes, which are evaluated in the context of a repository. Right now,
      only one conditional exists with "gitdir:" -- it will only include the
      configuration if the current repository's git directory matches the
      value passed to "gitdir:".
      
      To support these conditionals, we have to break our API and make the
      repository available when opening a configuration file. This commit
      extends the `open` call of configuration backends to include another
      repository and adjusts existing code to have it available. This includes
      the user-visible functions `git_config_add_file_ondisk` and
      `git_config_add_backend`.
      Patrick Steinhardt committed
  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. 26 Apr, 2017 1 commit
    • config: skip r/o backends when writing · 95f29fb3
      Configuration backends have a readonly-flag which is currently used to
      distinguish configuration snapshots. But somewhat unexpectedly, we do
      not use the flag to prevent writing to a readonly backend but happily
      proceed to do so.
      
      This commit modifies logic to also honor the readonly flag for
      configuration setters. We will now traverse through all backends and
      pick the first one which is not marked as read-only whenever we want to
      write new configuration.
      Patrick Steinhardt committed
  16. 23 Mar, 2017 1 commit
  17. 29 Dec, 2016 1 commit
  18. 06 Oct, 2016 1 commit
  19. 21 Oct, 2015 1 commit
  20. 17 Aug, 2015 1 commit
  21. 12 Aug, 2015 2 commits
  22. 22 Jun, 2015 1 commit
  23. 29 Apr, 2015 1 commit
  24. 10 Apr, 2015 1 commit
    • Fix checking of return value for regcomp. · 129022ee
      The regcomp function returns a non-zero value if compilation of
      a regular expression fails. In most places we only check for
      negative values, but positive values indicate an error, as well.
      Fix this tree-wide, fixing a segmentation fault when calling
      git_config_iterator_glob_new with an invalid regexp.
      Patrick Steinhardt committed
  25. 03 Mar, 2015 1 commit
    • config: borrow refcounted references · 9a97f49e
      This changes the get_entry() method to return a refcounted version of
      the config entry, which you have to free when you're done.
      
      This allows us to avoid freeing the memory in which the entry is stored
      on a refresh, which may happen at any time for a live config.
      
      For this reason, get_string() has been forbidden on live configs and a
      new function get_string_buf() has been added, which stores the string in
      a git_buf which the user then owns.
      
      The functions which parse the string value takea advantage of the
      borrowing to parse safely and then release the entry.
      Carlos Martín Nieto committed
  26. 14 Jan, 2015 1 commit
  27. 23 Oct, 2014 1 commit
  28. 30 May, 2014 1 commit
  29. 13 May, 2014 1 commit
  30. 08 May, 2014 1 commit
    • Be more careful with user-supplied buffers · 1e4976cb
      This adds in missing calls to `git_buf_sanitize` and fixes a
      number of places where `git_buf` APIs could inadvertently write
      NUL terminator bytes into invalid buffers.  This also changes the
      behavior of `git_buf_sanitize` to NUL terminate a buffer if it can
      and of `git_buf_shorten` to do nothing if it can.
      
      Adds tests of filtering code with zeroed (i.e. unsanitized) buffer
      which was previously triggering a segfault.
      Russell Belfer committed
  31. 02 May, 2014 2 commits
    • 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
    • Fix remaining init_options inconsistencies · bc91347b
      There were a couple of "init_opts()" functions a few more cases
      of structure initialization that I somehow missed.
      Russell Belfer committed
  32. 30 Apr, 2014 1 commit
  33. 18 Apr, 2014 1 commit
    • config: implement config snapshotting · 55ebd7d3
      In order to have consistent views of the config files for remotes,
      submodules et al. and a configuration that represents what is currently
      stored on-disk, we need a way to provide a view of the configuration
      that does not change.
      
      The goal here is to provide the snapshotting part by creating a
      read-only copy of the state of the configuration at a particular point
      in time, which does not change when a repository's main config changes.
      Carlos Martín Nieto committed
  34. 01 Apr, 2014 1 commit
    • Fix git_submodule_sync and add new config helper · 8286300a
      This fixes `git_submodule_sync` to correctly update the remote URL
      of the default branch of the submodule along with the URL in the
      parent repository config (i.e. match core Git's behavior).
      
      Also move some useful helper logic from the submodule code into
      a shared config API `git_config__update_entry` that can either set
      or delete an entry with constraints like not overwriting or not
      creating a new entry.  I used that helper to update a couple other
      places in the code.
      Russell Belfer committed
  35. 06 Mar, 2014 1 commit