1. 23 Feb, 2022 1 commit
  2. 30 Jan, 2022 1 commit
    • xdiff: include new xdiff from git · 1458fb56
      Update to the xdiff used in git v2.35.0, with updates to our build
      configuration to ignore the sort of warnings that we normally care
      about (signed/unsigned mismatch, unused, etc.)
      
      Any git-specific abstraction bits are now redefined for our use in
      `git-xdiff.h`.  It is a (wildly optimistic) hope that we can use that
      indirection layer to standardize on a shared xdiff implementation.
      Edward Thomson committed
  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. 27 Nov, 2020 1 commit
  5. 18 Apr, 2020 1 commit
  6. 20 Jul, 2019 1 commit
  7. 11 Jul, 2019 1 commit
  8. 22 Jan, 2019 1 commit
  9. 10 Jun, 2018 1 commit
  10. 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
  11. 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
  12. 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
  13. 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
  14. 13 Jan, 2017 1 commit
  15. 29 Dec, 2016 1 commit
  16. 12 Dec, 2016 1 commit
  17. 05 Sep, 2016 1 commit
  18. 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
  19. 24 Aug, 2016 1 commit
  20. 24 Jul, 2016 1 commit
  21. 26 May, 2016 7 commits
  22. 05 Oct, 2015 1 commit
  23. 26 Jun, 2015 1 commit
  24. 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
  25. 15 Jun, 2015 1 commit
  26. 12 Jun, 2015 2 commits
  27. 13 Feb, 2015 2 commits
  28. 25 Jan, 2015 1 commit
  29. 20 Jan, 2015 1 commit
  30. 26 Sep, 2014 1 commit