1. 06 Dec, 2021 2 commits
  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. 09 Sep, 2021 1 commit
  5. 29 Aug, 2021 1 commit
  6. 09 Sep, 2020 4 commits
  7. 01 Jun, 2020 1 commit
  8. 22 May, 2019 1 commit
    • config: validate quoted section value · 23c5699e
      When we reach a whitespace after a section name, we assume that what
      will follow will be a quoted subsection name.  Pass the current position
      of the line being parsed to the subsection parser, so that it can
      validate that subsequent characters are additional whitespace or a
      single quote.
      
      Previously we would begin parsing after the section name, looking for
      the first quotation mark.  This allows invalid characters to embed
      themselves between the end of the section name and the first quotation
      mark, eg `[section foo "subsection"]`, which is illegal.
      Edward Thomson committed
  9. 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
  10. 15 Oct, 2018 1 commit
  11. 14 Aug, 2018 2 commits
  12. 10 Jun, 2018 1 commit
  13. 26 Mar, 2018 1 commit
  14. 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
  15. 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
  16. 23 Apr, 2015 1 commit
  17. 20 Apr, 2015 2 commits
  18. 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
  19. 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
  20. 14 Jan, 2015 1 commit
  21. 11 Dec, 2013 1 commit
    • 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
  22. 14 Nov, 2013 1 commit
  23. 01 Oct, 2013 2 commits
  24. 07 Sep, 2013 1 commit
  25. 12 Aug, 2013 2 commits
  26. 07 Aug, 2013 1 commit
  27. 07 May, 2013 1 commit
    • repo: unconditionally create a global config backend · a4b75dcf
      When a repository is initialised, we need to probe to see if there is
      a global config to load. If this is not the case, the user isn't able
      to write to the global config without creating the backend and adding
      it themselves, which is inconvenient and overly complex.
      
      Unconditionally create and add a backend for the global config file
      regardless of whether it exists as a convenience for users.
      
      To enable this, we allow creating backends to files that do not exist
      yet, changing the semantics somewhat, and making some tests invalid.
      Carlos Martín Nieto committed
  28. 25 Jan, 2013 1 commit
  29. 03 Jan, 2013 3 commits