1. 15 Oct, 2018 1 commit
  2. 09 Oct, 2018 1 commit
  3. 05 Oct, 2018 2 commits
    • config_file: properly ignore includes without "path" value · d06d4220
      In case a configuration includes a key "include.path=" without any
      value, the generated configuration entry will have its value set to
      `NULL`. This is unexpected by the logic handling includes, and as soon
      as we try to calculate the included path we will unconditionally
      dereference that `NULL` pointer and thus segfault.
      
      Fix the issue by returning early in both `parse_include` and
      `parse_conditional_include` in case where the `file` argument is `NULL`.
      Add a test to avoid future regression.
      
      The issue has been found by the oss-fuzz project, issue 10810.
      Patrick Steinhardt committed
    • tests: always unlink created config files · bf662f7c
      While our tests in config::include create a plethora of configuration
      files, most of them do not get removed at the end of each test. This can
      cause weird interactions with tests that are being run at a later stage
      if these later tests try to create files or directories with the same
      name as any of the created configuration files.
      
      Fix the issue by unlinking all created files at the end of these tests.
      Patrick Steinhardt committed
  4. 28 Sep, 2018 2 commits
    • config: introduce new read-only in-memory backend · 2be39cef
      Now that we have abstracted away how to store and retrieve config
      entries, it became trivial to implement a new in-memory backend by
      making use of this. And thus we do so.
      
      This commit implements a new read-only in-memory backend that can parse
      a chunk of memory into a `git_config_backend` structure.
      Patrick Steinhardt committed
    • config: rename "config_file.h" to "config_backend.h" · b944e137
      The header "config_file.h" has a list of inline-functions to access the
      contents of a config backend without directly messing with the struct's
      function pointers. While all these functions are called
      "git_config_file_*", they are in fact completely backend-agnostic and
      don't care whether it is a file or not. Rename all the function to
      instead be backend-agnostic versions called "git_config_backend_*" and
      rename the header to match.
      Patrick Steinhardt committed
  5. 14 Aug, 2018 2 commits
  6. 13 Jul, 2018 1 commit
    • treewide: remove use of C++ style comments · 9994cd3f
      C++ style comment ("//") are not specified by the ISO C90 standard and
      thus do not conform to it. While libgit2 aims to conform to C90, we did
      not enforce it until now, which is why quite a lot of these
      non-conforming comments have snuck into our codebase. Do a tree-wide
      conversion of all C++ style comments to the supported C style comments
      to allow us enforcing strict C90 compliance in a later commit.
      Patrick Steinhardt committed
  7. 10 Jun, 2018 1 commit
  8. 26 Mar, 2018 1 commit
  9. 08 Feb, 2018 2 commits
    • config_parse: fix reading files with BOM · 2eea5f1c
      The function `skip_bom` is being used to detect and skip BOM marks
      previously to parsing a configuration file. To do so, it simply uses
      `git_buf_text_detect_bom`. But since the refactoring to use the parser
      interface in commit 9e66590b (config_parse: use common parser
      interface, 2017-07-21), the BOM detection was actually broken.
      
      The issue stems from a misunderstanding of `git_buf_text_detect_bom`. It
      was assumed that its third parameter limits the length of the character
      sequence that is to be analyzed, while in fact it was an offset at which
      we want to detect the BOM. Fix the parameter to be `0` instead of the
      buffer length, as we always want to check the beginning of the
      configuration file.
      Patrick Steinhardt committed
    • config_parse: handle empty lines with CRLF · 848153f3
      Currently, the configuration parser will fail reading empty lines with
      just an CRLF-style line ending. Special-case the '\r' character in order
      to handle it the same as Unix-style line endings. Add tests to spot this
      regression in the future.
      Patrick Steinhardt committed
  10. 31 Oct, 2017 1 commit
  11. 30 Oct, 2017 1 commit
  12. 09 Oct, 2017 3 commits
    • config_file: implement "gitdir/i" conditional · f7d837c8
      Next to the "gitdir" conditional for including other configuration
      files, there's also a "gitdir/i" conditional. In contrast to the former
      one, path matching with "gitdir/i" is done case-insensitively. This
      commit implements the case-insensitive condition.
      Patrick Steinhardt committed
    • config_file: implement conditional "gitdir" includes · 071b6c06
      Upstream git.git has implemented the ability to include other
      configuration files based on conditions. Right now, this only includes
      the ability to include a file based on the gitdir-location of the
      repository the currently parsed configuration file belongs to. This
      commit implements handling these conditional includes for the
      case-sensitive "gitdir" condition.
      Patrick Steinhardt committed
    • 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
  13. 15 Jul, 2017 4 commits
    • config_file: refuse modifying included variables · 1b329089
      Modifying variables pulled in by an included file currently succeeds,
      but it doesn't actually do what one would expect, as refreshing the
      configuration will cause the values to reappear. As we are currently not
      really able to support this use case, we will instead just return an
      error for deleting and setting variables which were included via an
      include.
      Patrick Steinhardt committed
    • config_file: move reader into `config_read` only · 28c2cc3d
      Right now, we have multiple call sites which initialize a `reader`
      structure. As the structure is only actually used inside of
      `config_read`, we can instead just move the reader inside of the
      `config_read` function. Instead, we can just pass in the configuration
      file into `config_read`, which eases code readability.
      Patrick Steinhardt committed
    • config_file: refresh all files if includes were modified · 83bcd3a1
      Currently, we only re-parse the top-level configuration file when it has
      changed itself. This can cause problems when an include is changed, as
      we were not updating all values correctly.
      
      Instead of conditionally reparsing only refreshed files, the logic
      becomes much clearer and easier to follow if we always re-parse the
      top-level configuration file when either the file itself or one of its
      included configuration files has changed on disk. This commit implements
      this logic.
      
      Note that this might impact performance in some cases, as we need to
      re-read all configuration files whenever any of the included files
      changed. It could increase performance to just re-parse include files
      which have actually changed, but this would compromise maintainability
      of the code without much gain. The only case where we will gain anything
      is when we actually use includes and when only these includes are
      updated, which will probably be quite an unusual scenario to actually be
      worthwhile to optimize.
      Patrick Steinhardt committed
  14. 05 Jul, 2017 1 commit
    • tests: config: fix missing declaration causing error · 1f7af277
      On systems where we pull in our distributed version of the regex
      library, all tests in config::readonly fail. This error is actually
      quite interesting: the test suite is unable to find the declaration of
      `git_path_exists` and assumes it has a signature of `int
      git_path_exists(const char *)`. But actually, it has a `bool` return
      value. Due to this confusion, some wrong conversion is done by the
      compiler and the `cl_assert(!git_path_exists("file"))` checks
      erroneously fail, even when the function does in fact return the correct
      value.
      
      The error is actually introduced by 56893bb9 (cmake: consistently use
      TARGET_INCLUDE_DIRECTORIES if available, 2017-06-28), unfortunately
      introduced by myself. Due to the delayed addition of include
      directories, we will now find the "config.h" header inside of the
      "deps/regex" directory instead of inside the "src/" directory, where it
      should be. As such, we are missing definitions for the
      `git_config_file__ondisk` and `git_path_exists` symbols.
      
      The correct fix here would be to fix the order in which include search
      directories are added. But due to the current restructuring of
      CMakeBuild.txt, I'm refraining from doing so and delay the proper fix a
      bit. Instead, we paper over the issue by explicitly including "path.h"
      to fix its prototype. This ignores the issue that
      `git_config_file__ondisk` is undeclared, as its signature is correctly
      identified by the compiler.
      Patrick Steinhardt committed
  15. 26 Apr, 2017 1 commit
  16. 23 Mar, 2017 2 commits
  17. 31 Mar, 2016 1 commit
  18. 28 Mar, 2016 2 commits
  19. 21 Mar, 2016 1 commit
  20. 24 Nov, 2015 2 commits
  21. 17 Nov, 2015 1 commit
  22. 30 Oct, 2015 1 commit
  23. 21 Oct, 2015 1 commit
  24. 18 Sep, 2015 1 commit
  25. 17 Sep, 2015 1 commit
    • git_futils_mkdir_*: make a relative-to-base mkdir · ac2fba0e
      Untangle git_futils_mkdir from git_futils_mkdir_ext - the latter
      assumes that we own everything beneath the base, as if it were
      being called with a base of the repository or working directory,
      and is tailored towards checkout and ensuring that there is no
      bogosity beneath the base that must be cleaned up.
      
      This is (at best) slow and (at worst) unsafe in the larger context
      of a filesystem where we do not own things and cannot do things like
      unlink symlinks that are in our way.
      Edward Thomson committed
  26. 13 Sep, 2015 1 commit
  27. 12 Aug, 2015 2 commits