1. 23 Feb, 2022 1 commit
  2. 05 Jan, 2022 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. 31 Jan, 2021 1 commit
  5. 27 Nov, 2020 1 commit
  6. 01 Jun, 2020 1 commit
  7. 07 Feb, 2020 1 commit
    • push: check error code returned by `git_revwalk_hide` · 6eebfc06
      When queueing objects we want to push, we call `git_revwalk_hide` to
      hide all objects already known to the remote from our revwalk. We do not
      check its return value though, where the orginial intent was to ignore
      the case where the pushed OID is not a known committish. As
      `git_revwalk_hide` can fail due to other reasons like out-of-memory
      exceptions, we should still check its return value.
      
      Fix the issue by checking the function's return value, ignoring
      errors hinting that it's not a committish. As `git_revwalk__push_commit`
      currently clobbers these error codes, we need to adjust it as well in
      order to make it available downstream.
      Patrick Steinhardt committed
  8. 24 Jan, 2020 1 commit
  9. 23 Aug, 2019 2 commits
  10. 12 May, 2019 1 commit
  11. 10 May, 2019 1 commit
  12. 03 May, 2019 1 commit
  13. 15 Feb, 2019 3 commits
    • 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
    • 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
  14. 22 Jan, 2019 1 commit
  15. 01 Dec, 2018 1 commit
  16. 28 Nov, 2018 2 commits
  17. 17 Sep, 2018 2 commits
    • revwalk: only check the first commit in the list for an earlier timestamp · 12a1790d
      This is not a big deal, but it does make us match git more closely by checking
      only the first. The lists are sorted already, so there should be no functional
      difference other than removing a possible check from every iteration in the
      loop.
      Carlos Martín Nieto committed
    • revwalk: use the max value for a signed integer · 46f35127
      When porting, we overlooked that the difference between git's and our's time
      representation and copied their way of getting the max value.
      
      Unfortunately git was using unsigned integers, so `~0ll` does correspond to
      their max value, whereas for us it corresponds to `-1`. This means that we
      always consider the last date to be smaller than the current commit's and always
      think commits are interesting.
      
      Change the initial value to the macro that gives us the maximum value on each
      platform so we can accurately consider commits interesting or not.
      Carlos Martín Nieto committed
  18. 20 Aug, 2018 1 commit
  19. 29 Jul, 2018 1 commit
  20. 22 Jun, 2018 1 commit
  21. 18 Jun, 2018 1 commit
  22. 10 Jun, 2018 1 commit
  23. 12 Apr, 2018 2 commits
    • revwalk: fix uninteresting revs sometimes not limiting graphwalk · 54fd80e3
      When we want to limit our graphwalk, we use the heuristic of checking
      whether the newest limiting (uninteresting) revision is newer than the
      oldest interesting revision. We do so by inspecting whether the first
      item's commit time of the user-supplied list of revisions is newer than
      the last added interesting revision. This is wrong though, as the user
      supplied list is in no way guaranteed to be sorted by increasing commit
      dates. This could lead us to abort the revwalk early before applying all
      relevant limiting revisions, outputting revisions which should in fact
      have been hidden.
      
      Fix the heuristic by instead checking whether _any_ of the limiting
      commits was made earlier than the last interesting commit. Add a test.
      Patrick Steinhardt committed
    • revwalk: remove one useless layer of functions · ef682410
      We don't currently need to have anything that's different between `get_revision`
      and `get_one_revision` so let's just remove the inner function and make the code
      more straightforward.
      Carlos Martín Nieto committed
  24. 01 Apr, 2018 1 commit
    • revwalk: avoid walking the entire history when output is unsorted · 2a6d0956
      As part of reducing our divergence from git, its code for revwalk was ported
      into our codebase. A detail about when to limit the list was lost and we ended
      up always calling that code.
      
      Limiting the list means performing the walk and creating the final list of
      commits to be output during the preparation stage. This is unavoidable when
      sorting and when there are negative refs.
      
      We did this even when asked for unsorted output with no negative refs, which you
      might do to retrieve something like the "last 10 commits on HEAD" for a
      nominally unsorted meaning of "last".
      
      This commit adds and sets a flag indicating when we do need to limit the list,
      letting us avoid doing so when we can. The previously mentioned query thus no
      longer loads the entire history of the project during the prepare stage, but
      loads it iteratively during the walk.
      Carlos Martín Nieto committed
  25. 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
  26. 09 Mar, 2017 1 commit
  27. 17 Feb, 2017 7 commits
  28. 29 Dec, 2016 1 commit