1. 26 Mar, 2020 1 commit
  2. 22 Jan, 2019 1 commit
  3. 10 Jun, 2018 1 commit
  4. 18 Nov, 2017 1 commit
    • refcount: make refcounting conform to aliasing rules · 585b5dac
      Strict aliasing rules dictate that for most data types, you are not
      allowed to cast them to another data type and then access the casted
      pointers. While this works just fine for most compilers, technically we
      end up in undefined behaviour when we hurt that rule.
      
      Our current refcounting code makes heavy use of casting and thus
      violates that rule. While we didn't have any problems with that code,
      Travis started spitting out a lot of warnings due to a change in their
      toolchain. In the refcounting case, the code is also easy to fix:
      as all refcounting-statements are actually macros, we can just access
      the `rc` field directly instead of casting.
      
      There are two outliers in our code where that doesn't work. Both the
      `git_diff` and `git_patch` structures have specializations for generated
      and parsed diffs/patches, which directly inherit from them. Because of
      that, the refcounting code is only part of the base structure and not of
      the children themselves. We can help that by instead passing their base
      into `GIT_REFCOUNT_INC`, though.
      Patrick Steinhardt committed
  5. 10 Jul, 2017 1 commit
    • patch_generate: represent buffers as void pointers · 9093ced6
      Pointers to general data should usually be used as a void pointer such
      that it is possible to hand in variables of a different pointer type
      without the need to cast. This is the same when creating patches from
      buffers, where the buffers may contain arbitrary data. Instead of
      requiring the caller to care whether his buffer is e.g. `char *` or
      `unsigned char *`, we should instead just accept a `void *`. This is
      also consistent in how we tread other types like for example `git_blob`,
      which also just has a void pointer as its raw contents.
      Patrick Steinhardt committed
  6. 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
  7. 14 Mar, 2017 3 commits
    • patch_generate: move `git_diff_foreach` to diff.c · 62a2fc06
      Now that the `git_diff_foreach` function does not depend on internals of
      the `git_patch_generated` structure anymore, we can easily move it to
      the actual diff code.
      Patrick Steinhardt committed
    • patch_generate: fix `git_diff_foreach` only working with generated diffs · ace3508f
      The current logic of `git_diff_foreach` makes the assumption that all
      diffs passed in are actually derived from generated diffs. With these
      assumptions we try to derive the actual diff by inspecting either the
      working directory files or blobs of a repository. This obviously cannot
      work for diffs parsed from a file, where we do not necessarily have a
      repository at hand.
      
      Since the introduced split of parsed and generated patches, there are
      multiple functions which help us to handle patches generically, being
      indifferent from where they stem from. Use these functions and remove
      the old logic specific to generated patches. This allows re-using the
      same code for invoking the callbacks on the deltas.
      Patrick Steinhardt committed
    • patch_generate: remove duplicated logic · 41019152
      Under the existing logic, we try to load patch contents differently,
      depending on whether the patch files stem from the working directory or
      not. But actually, the executed code paths are completely equal to each
      other -- so we were always the code despite the condition.
      
      Remove the condition altogether and conflate both code paths.
      Patrick Steinhardt committed
  8. 13 Jan, 2017 1 commit
  9. 29 Dec, 2016 1 commit
  10. 12 Dec, 2016 1 commit
  11. 05 Sep, 2016 1 commit
  12. 01 Sep, 2016 1 commit
    • patch_generate: only calculate binary diffs if requested · 4b34f687
      When generating diffs for binary files, we load and decompress
      the blobs in order to generate the actual diff, which can be very
      costly. While we cannot avoid this for the case when we are
      called with the `GIT_DIFF_SHOW_BINARY` flag, we do not have to
      load the blobs in the case where this flag is not set, as the
      caller is expected to have no interest in the actual content of
      binary files.
      
      Fix the issue by only generating a binary diff when the caller is
      actually interested in the diff. As libgit2 uses heuristics to
      determine that a blob contains binary data by inspecting its size
      without loading from the ODB, this saves us quite some time when
      diffing in a repository with binary files.
      Patrick Steinhardt committed
  13. 24 Aug, 2016 1 commit
  14. 24 Jul, 2016 1 commit
  15. 26 May, 2016 7 commits
  16. 05 Oct, 2015 1 commit
  17. 26 Jun, 2015 1 commit
  18. 24 Jun, 2015 1 commit
    • diff: determine DIFFABLE-ness for binaries · 54077091
      Always set `GIT_DIFF_PATCH_DIFFABLE` for all files, regardless of
      binary-ness, so that the binary callback is invoked to either
      show the binary contents, or just print the standard "Binary files
      differ" message.  We may need to do deeper inspection for binary
      files where we have avoided loading the contents into a file map.
      Edward Thomson committed
  19. 15 Jun, 2015 1 commit
  20. 12 Jun, 2015 2 commits
  21. 13 Feb, 2015 2 commits
  22. 25 Jan, 2015 1 commit
  23. 20 Jan, 2015 1 commit
  24. 26 Sep, 2014 1 commit
  25. 24 Sep, 2014 1 commit
  26. 11 Apr, 2014 1 commit
  27. 27 Feb, 2014 1 commit
    • Add buffer to buffer diff and patch APIs · 6789b7a7
      This adds `git_diff_buffers` and `git_patch_from_buffers`.  This
      also includes a bunch of internal refactoring to increase the
      shared code between these functions and the blob-to-blob and
      blob-to-buffer APIs, as well as some higher level assert helpers
      in the tests to also remove redundancy.
      Russell Belfer committed
  28. 25 Jan, 2014 1 commit
  29. 11 Dec, 2013 2 commits
    • 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