1. 22 Feb, 2019 2 commits
  2. 21 Feb, 2019 1 commit
    • tests: apply: verify that we correctly truncate the source buffer · 966b9440
      Previously, we would fail to correctly truncate the source buffer
      if the source has more than one line and ends with a non-newline
      character. In the following call, we thus truncate the source
      string in the middle of the second line. Without the bug fixed,
      we would successfully apply the patch to the source and return
      success. With the overflow being fixed, we should return an
      error now.
      Patrick Steinhardt committed
  3. 20 Feb, 2019 1 commit
  4. 15 Feb, 2019 9 commits
    • oidmap: remove legacy low-level interface · bd66925a
      Remove the low-level interface that was exposing implementation details of
      `git_oidmap` to callers. From now on, only the high-level functions shall be
      used to retrieve or modify values of a map. Adjust remaining existing callers.
      Patrick Steinhardt committed
    • strmap: remove legacy low-level interface · fdfabdc4
      Remove the low-level interface that was exposing implementation details of
      `git_strmap` to callers. From now on, only the high-level functions shall be
      used to retrieve or modify values of a map. Adjust remaining existing callers.
      Patrick Steinhardt committed
    • maps: provide high-level iteration interface · 18cf5698
      Currently, our headers need to leak some implementation details of maps due to
      their direct use of indices in the implementation of their foreach macros. This
      makes it impossible to completely hide the map structures away, and also makes
      it impossible to include the khash implementation header in the C files of the
      respective map only.
      
      This is now being fixed by providing a high-level iteration interface
      `map_iterate`, which takes as inputs the map that shall be iterated over, an
      iterator as well as the locations where keys and values shall be put into. For
      simplicity's sake, the iterator is a simple `size_t` that shall initialized to
      `0` on the first call. All existing foreach macros are then adjusted to make use
      of this new function.
      Patrick Steinhardt committed
    • oidmap: introduce high-level setter for key/value pairs · 2e0a3048
      Currently, one would use either `git_oidmap_insert` to insert key/value pairs
      into a map or `git_oidmap_put` to insert a key only. These function have
      historically been macros, which is why their syntax is kind of weird: instead of
      returning an error code directly, they instead have to be passed a pointer to
      where the return value shall be stored. This does not match libgit2's common
      idiom of directly returning error codes.Furthermore, `git_oidmap_put` is tightly
      coupled with implementation details of the map as it exposes the index of
      inserted entries.
      
      Introduce a new function `git_oidmap_set`, which takes as parameters the map,
      key and value and directly returns an error code. Convert all trivial callers of
      `git_oidmap_insert` and `git_oidmap_put` to make use of it.
      Patrick Steinhardt committed
    • oidmap: introduce high-level getter for values · 9694ef20
      The current way of looking up an entry from a map is tightly coupled with the
      map implementation, as one first has to look up the index of the key and then
      retrieve the associated value by using the index. As a caller, you usually do
      not care about any indices at all, though, so this is more complicated than
      really necessary. Furthermore, it invites for errors to happen if the correct
      error checking sequence is not being followed.
      
      Introduce a new high-level function `git_oidmap_get` that takes a map and a key
      and returns a pointer to the associated value if such a key exists. Otherwise,
      a `NULL` pointer is returned. Adjust all callers that can trivially be
      converted.
      Patrick Steinhardt committed
    • strmap: introduce high-level setter for key/value pairs · 03555830
      Currently, one would use the function `git_strmap_insert` to insert key/value
      pairs into a map. This function has historically been a macro, which is why its
      syntax is kind of weird: instead of returning an error code directly, it instead
      has to be passed a pointer to where the return value shall be stored. This does
      not match libgit2's common idiom of directly returning error codes.
      
      Introduce a new function `git_strmap_set`, which takes as parameters the map,
      key and value and directly returns an error code. Convert all callers of
      `git_strmap_insert` to make use of it.
      Patrick Steinhardt committed
    • strmap: introduce `git_strmap_get` and use it throughout the tree · ef507bc7
      The current way of looking up an entry from a map is tightly coupled with the
      map implementation, as one first has to look up the index of the key and then
      retrieve the associated value by using the index. As a caller, you usually do
      not care about any indices at all, though, so this is more complicated than
      really necessary. Furthermore, it invites for errors to happen if the correct
      error checking sequence is not being followed.
      
      Introduce a new high-level function `git_strmap_get` that takes a map and a key
      and returns a pointer to the associated value if such a key exists. Otherwise,
      a `NULL` pointer is returned. Adjust all callers that can trivially be
      converted.
      Patrick Steinhardt committed
    • maps: provide a uniform entry count interface · 7e926ef3
      There currently exist two different function names for getting the entry count
      of maps, where offmaps offset and string maps use `num_entries` and OID maps use
      `size`. In most programming languages with built-in map types, this is simply
      called `size`, which is also shorter to type. Thus, this commit renames the
      other two functions `num_entries` to match the common way and adjusts all
      callers.
      Patrick Steinhardt committed
    • maps: use uniform lifecycle management functions · 351eeff3
      Currently, the lifecycle functions for maps (allocation, deallocation, resize)
      are not named in a uniform way and do not have a uniform function signature.
      Rename the functions to fix that, and stick to libgit2's naming scheme of saying
      `git_foo_new`. This results in the following new interface for allocation:
      
      - `int git_<t>map_new(git_<t>map **out)` to allocate a new map, returning an
        error code if we ran out of memory
      
      - `void git_<t>map_free(git_<t>map *map)` to free a map
      
      - `void git_<t>map_clear(git<t>map *map)` to remove all entries from a map
      
      This commit also fixes all existing callers.
      Patrick Steinhardt committed
  5. 14 Feb, 2019 5 commits
    • branch: fix `branch_is_checked_out` with bare repos · bf013fc0
      In a bare repository, HEAD usually points to the branch that is
      considered the "default" branch. As the current implementation for
      `git_branch_is_checked_out` only does a comparison of HEAD with the
      branch that is to be checked, it will say that the branch pointed to by
      HEAD in such a bare repo is checked out.
      
      Fix this by skipping the main repo's HEAD when it is bare.
      Patrick Steinhardt committed
    • branches: introduce flag to skip enumeration of certain HEADs · efb20825
      Right now, the function `git_repository_foreach_head` will always
      iterate over all HEADs of the main repository and its worktrees. In some
      cases, it might be required to skip either of those, though. Add a flag
      in preparation for the following commit that enables this behaviour.
      Patrick Steinhardt committed
    • branches: do not assert that the given ref is a branch · 788cd2d5
      Libraries should use assert(3P) only very scarcely. First, we usually
      shouldn't cause the caller of our library to abort in case where the
      assert fails. Second, if code is compiled with -DNDEBUG, then the assert
      will not be included at all.
      
      In our `git_branch_is_checked_out` function, we have an assert that
      verifies that the given reference parameter is non-NULL and in fact a
      branch. While the first check is fine, the second is not. E.g. when
      compiled with -DNDEBUG, we'd proceed and treat the given reference as a
      branch in all cases.
      
      Fix the issue by instead treating a non-branch reference as not being
      checked out. This is the obvious solution, as references other than
      branches cannot be directly checked out.
      Patrick Steinhardt committed
    • branches: add tests for `git_branch_is_checked_out` · a0f87e16
      We currently do not have any tests at all for the
      `git_branch_is_checked_out` function. Add some basic ones.
      Patrick Steinhardt committed
    • deprecation: ensure we GIT_EXTERN deprecated funcs · 24ac9e0c
      Although the error functions were deprecated, we did not properly mark
      them as deprecated.  We need to include the `deprecated.h` file in order
      to ensure that the functions get their export attributes.
      
      Similarly, do not define `GIT_DEPRECATE_HARD` within the library, or
      those functions will also not get their export attributes.  Define that
      only on the tests and examples.
      Edward Thomson committed
  6. 02 Feb, 2019 1 commit
  7. 25 Jan, 2019 4 commits
  8. 24 Jan, 2019 1 commit
    • index: preserve extension parsing errors · 0bf7e043
      Previously, we would clobber any extension-specific error message with
      an "extension is truncated" message. This makes `read_extension`
      correctly preserve those errors, takes responsibility for truncation
      errors, and adds a new message with the actual extension signature for
      unsupported mandatory extensions.
      Etienne Samson committed
  9. 22 Jan, 2019 1 commit
  10. 20 Jan, 2019 1 commit
  11. 19 Jan, 2019 1 commit
  12. 17 Jan, 2019 2 commits
  13. 15 Jan, 2019 1 commit
  14. 14 Jan, 2019 3 commits
  15. 11 Jan, 2019 1 commit
  16. 09 Jan, 2019 1 commit
  17. 06 Jan, 2019 3 commits
  18. 04 Jan, 2019 1 commit
  19. 19 Dec, 2018 1 commit