1. 09 Sep, 2021 1 commit
    • Fix multiline strip_comments logic · 574c590f
      The strip_comments function uses the count of quotes to know if a
      comment char (';' or '#') is the start of a comment or part of the
      multiline as a string.
      Unfortunately converting the count of quotes from previous lines to a
      boolean meant that it would only work as expected in some cases
      (0 quotes or an odd number of quotes).
      Basile Henry committed
  2. 11 May, 2021 2 commits
  3. 27 Nov, 2020 1 commit
  4. 18 Sep, 2020 1 commit
  5. 11 Jul, 2019 3 commits
    • config_parse: provide parser init and dispose functions · dbeadf8a
      Right now, all configuration file backends are expected to
      directly mess with the configuration parser's internals in order
      to set it up. Let's avoid doing that by implementing both a
      `git_config_parser_init` and `git_config_parser_dispose` function
      to clearly define the interface between configuration backends
      and the parser.
      
      Ideally, we would make the `git_config_parser` structure
      definition private to its implementation. But as that would
      require an additional memory allocation that was not required
      before we just live with it being visible to others.
      Patrick Steinhardt committed
    • config_parse: remove use of `git_config_file` · 6e6da75f
      The config parser code needs to keep track of the current parsed
      file's name so that we are able to provide proper error messages
      to the user. Right now, we do that by storing a `git_config_file`
      in the parser structure, but as that is a specific backend and
      the parser aims to be generic, it is a layering violation.
      
      Switch over to use a simple string to fix that.
      Patrick Steinhardt committed
    • config_parse: rename `data` parameter to `payload` for clarity · 76749dfb
      By convention, parameters that get passed to callbacks are
      usually named `payload` in our codebase. Rename the `data`
      parameters in the configuration parser callbacks to `payload` to
      avoid confusion.
      Patrick Steinhardt committed
  6. 24 Jun, 2019 1 commit
  7. 22 May, 2019 4 commits
    • config: rename subsection header parser func · 355b02a1
      The `parse_section_header_ext` name suggests that it as an extended
      function for parsing the section header.  It is not.  Rename it to
      `parse_subsection_header` to better reflect its true mission.
      Edward Thomson committed
    • 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
    • config: don't write invalid column · b83bd037
      When we don't specify a particular column, don't write it in the error
      message.  (column "0" is unhelpful.)
      Edward Thomson committed
    • config: lowercase error messages · 42dd38dd
      Update the configuration parsing error messages to be lower-cased for
      consistency with the rest of the library.
      Edward Thomson committed
  8. 22 Jan, 2019 1 commit
  9. 15 Oct, 2018 1 commit
  10. 28 Sep, 2018 1 commit
    • 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
  11. 21 Sep, 2018 1 commit
    • config_parse: avoid unused static declared values · b9affa32
      The variables `git_config_escaped` and `git_config_escapes` are both
      defined as static const character pointers in "config_parse.h". In case
      where "config_parse.h" is included but those two variables are not being
      used, the compiler will thus complain about defined but unused
      variables. Fix this by declaring them as external and moving the actual
      initialization to the C file.
      
      Note that it is not possible to simply make this a #define, as we are
      indexing into those arrays.
      Patrick Steinhardt committed
  12. 03 Sep, 2018 1 commit
  13. 01 Sep, 2018 1 commit
  14. 25 Aug, 2018 1 commit
  15. 05 Aug, 2018 1 commit
  16. 22 Jun, 2018 2 commits
    • config_parse: always sanitize out-parameters in `parse_variable` · 83b5f161
      The `parse_variable` function has two out parameters `var_name` and
      `var_value`. Currently, those are not being sanitized to `NULL`. when.
      any error happens inside of the `parse_variable` function. Fix that.
      While at it, the coding style is improved to match our usual coding
      practices more closely.
      Patrick Steinhardt committed
    • config_parse: have `git_config_parse` own entry value and name · e51e29e8
      The function `git_config_parse` uses several callbacks to pass data
      along to the caller as it parses the file. One design shortcoming here
      is that strings passed to those callbacks are expected to be freed by
      them, which is really confusing.
      
      Fix the issue by changing memory ownership here. Instead of expecting
      the `on_variable` callbacks to free memory for `git_config_parse`, just
      do it inside of `git_config_parse`. While this obviously requires a bit
      more memory allocation churn due to having to copy both name and value
      at some places, this shouldn't be too much of a burden.
      Patrick Steinhardt committed
  17. 10 Jun, 2018 1 commit
  18. 08 Feb, 2018 4 commits
    • buf_text: remove `offset` parameter of BOM detection function · ba4faf6e
      The function to detect a BOM takes an offset where it shall look for a
      BOM. No caller uses that, and searching for the BOM in the middle of a
      buffer seems to be very unlikely, as a BOM should only ever exist at
      file start.
      
      Remove the parameter, as it has already caused confusion due to its
      weirdness.
      Patrick Steinhardt committed
    • 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
    • config_parse: add comment to clarify logic getting next character · 5340ca77
      Upon each line, the configuration parser tries to get either the first
      non-whitespace character or the first whitespace character, in case
      there is no non-whitespace character. The logic handling this looks
      rather odd and doesn't immediately convey this meaning, so add a comment
      to clarify what happens.
      Patrick Steinhardt committed
  19. 11 Nov, 2017 2 commits
    • config_parse: use common parser interface · 9e66590b
      As the config parser is now cleanly separated from the config file code,
      we can easily refactor the code and make use of the common parser
      module. This removes quite a lot of duplicated functionality previously
      used for handling the actual parser state and replaces it with the
      generic interface provided by the parser context.
      Patrick Steinhardt committed
    • config_file: split out module to parse config files · 1953c68b
      The configuration file code grew quite big and intermingles both actual
      configuration logic as well as the parsing logic of the configuration
      syntax. This makes it hard to refactor the parsing logic on its own and
      convert it to make use of our new parsing context module.
      
      Refactor the code and split it up into two parts. The config file code
      will only handle actual handling of configuration files, includes and
      writing new files. The newly created config parser module is then only
      responsible for parsing the actual contents of a configuration file,
      leaving everything else to callbacks provided to its provided function
      `git_config_parse`.
      Patrick Steinhardt committed