1. 18 Sep, 2021 3 commits
  2. 27 Nov, 2020 1 commit
  3. 09 Jun, 2020 2 commits
    • tree-wide: do not compile deprecated functions with hard deprecation · c6184f0c
      When compiling libgit2 with -DDEPRECATE_HARD, we add a preprocessor
      definition `GIT_DEPRECATE_HARD` which causes the "git2/deprecated.h"
      header to be empty. As a result, no function declarations are made
      available to callers, but the implementations are still available to
      link against. This has the problem that function declarations also
      aren't visible to the implementations, meaning that the symbol's
      visibility will not be set up correctly. As a result, the resulting
      library may not expose those deprecated symbols at all on some platforms
      and thus cause linking errors.
      
      Fix the issue by conditionally compiling deprecated functions, only.
      While it becomes impossible to link against such a library in case one
      uses deprecated functions, distributors of libgit2 aren't expected to
      pass -DDEPRECATE_HARD anyway. Instead, users of libgit2 should manually
      define GIT_DEPRECATE_HARD to hide deprecated functions. Using "real"
      hard deprecation still makes sense in the context of CI to test we don't
      use deprecated symbols ourselves and in case a dependant uses libgit2 in
      a vendored way and knows it won't ever use any of the deprecated symbols
      anyway.
      Patrick Steinhardt committed
    • tree-wide: mark local functions as static · a6c9e0b3
      We've accumulated quite some functions which are never used outside of
      their respective code unit, but which are lacking the `static` keyword.
      Add it to reduce their linkage scope and allow the compiler to optimize
      better.
      Patrick Steinhardt committed
  4. 08 Jun, 2020 1 commit
  5. 28 Nov, 2019 1 commit
  6. 26 Sep, 2019 1 commit
    • Don't use enum for flags · 452b7f8f
      Using an `enum` causes trouble when used with C++ as bitwise operations are not possible w/o casting (e.g., `opts.flags &= ~GIT_BLOB_FILTER_CHECK_FOR_BINARY;` is invalid as there is no `&=` operator for `enum`).
      
      Signed-off-by: Sven Strickroth <email@cs-ware.de>
      Sven Strickroth committed
  7. 11 Jul, 2019 1 commit
  8. 14 Jun, 2019 1 commit
    • Rename opt init functions to `options_init` · 0b5ba0d7
      In libgit2 nomenclature, when we need to verb a direct object, we name
      a function `git_directobject_verb`.  Thus, if we need to init an options
      structure named `git_foo_options`, then the name of the function that
      does that should be `git_foo_options_init`.
      
      The previous names of `git_foo_init_options` is close - it _sounds_ as
      if it's initializing the options of a `foo`, but in fact
      `git_foo_options` is its own noun that should be respected.
      
      Deprecate the old names; they'll now call directly to the new ones.
      Edward Thomson committed
  9. 25 Jan, 2019 1 commit
  10. 22 Jan, 2019 1 commit
  11. 10 Jun, 2018 1 commit
  12. 30 Nov, 2017 1 commit
    • diff: remove unused macros `DIFF_FLAG_*` · 90fc7f53
      In commit 9be638ec (git_diff_generated: abstract generated diffs,
      2016-04-19), the code for generated diffs was moved out of the generic
      "diff.c" and instead into its own module. During that conversion, it was
      forgotten to remove the macros `DIFF_FLAG_IS_SET`, `DIFF_FLAG_ISNT_SET`
      and `DIFF_FLAG_SET`, which are now only used in "diff_generated.c".
      
      Remove those macros now.
      Patrick Steinhardt committed
  13. 15 Sep, 2017 1 commit
    • diff: cleanup hash ctx in `git_diff_patchid` · 046b081a
      After initializing the hash context in `git_diff_patchid`, we never
      proceed to call `git_hash_ctx_cleanup` on it. While this doesn't really
      matter on most hash implementations, this causes a memory leak on Win32
      due to CNG system requiring a `malloc` call.
      
      Fix the memory leak by always calling `git_hash_ctx_cleanup` before
      exiting.
      Patrick Steinhardt committed
  14. 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
  15. 26 Jun, 2017 1 commit
    • diff: implement function to calculate patch ID · 89a34828
      The upstream git project provides the ability to calculate a so-called
      patch ID. Quoting from git-patch-id(1):
      
          A "patch ID" is nothing but a sum of SHA-1 of the file diffs
          associated with a patch, with whitespace and line numbers ignored."
      
      Patch IDs can be used to identify two patches which are probably the
      same thing, e.g. when a patch has been cherry-picked to another branch.
      
      This commit implements a new function `git_diff_patchid`, which gets a
      patch and derives an OID from the diff. Note the different terminology
      here: a patch in libgit2 are the differences in a single file and a diff
      can contain multiple patches for different files. The implementation
      matches the upstream implementation and should derive the same OID for
      the same diff. In fact, some code has been directly derived from the
      upstream implementation.
      
      The upstream implementation has two different modes to calculate patch
      IDs, which is the stable and unstable mode. The old way of calculating
      the patch IDs was unstable in a sense that a different ordering the
      diffs was leading to different results. This oversight was fixed in git
      1.9, but as git tries hard to never break existing workflows, the old
      and unstable way is still default. The newer and stable way does not
      care for ordering of the diff hunks, and in fact it is the mode that
      should probably be used today. So right now, we only implement the
      stable way of generating the patch ID.
      Patrick Steinhardt committed
  16. 14 Mar, 2017 1 commit
  17. 26 May, 2016 3 commits
  18. 03 May, 2016 1 commit
    • diff: simplify code for handling empty dirs · fe3057b4
      When determining diffs between two iterators we may need to
      recurse into an unmatched directory for the "new" iterator when
      it is either a prefix to the current item of the "old" iterator
      or when untracked/ignored changes are requested by the user and
      the directory is untracked/ignored.
      
      When advancing into the directory and no files are found, we will
      get back `GIT_ENOTFOUND`. If so, we simply skip the directory,
      handling resulting unmatched old items in the next iteration. The
      other case of `iterator_advance_into` returning either
      `GIT_NOERROR` or any other error but `GIT_ENOTFOUND` will be
      handled by the caller, which will now either compare the first
      directory entry of the "new" iterator in case of `GIT_ENOERROR`
      or abort on other cases.
      
      Improve readability of the code to make the above logic more
      clear.
      Patrick Steinhardt committed
  19. 24 Mar, 2016 1 commit
  20. 23 Mar, 2016 2 commits
    • diff: stop processing nitem when its removed · 67885532
      When a directory is removed out from underneath us, stop trying to
      manipulate it.
      Edward Thomson committed
    • iterator: combine fs+workdir iterators more completely · 0e0589fc
      Drop some of the layers of indirection between the workdir and the
      filesystem iterators.  This makes the code a little bit easier to
      follow, and reduces the number of unnecessary allocations a bit as
      well.  (Prior to this, when we filter entries, we would allocate them,
      filter them and then free them; now we do the filtering before
      allocation.)
      
      Also, rename `git_iterator_advance_over_with_status` to just
      `git_iterator_advance_over`.  Mostly because it's a fucking long-ass
      function name otherwise.
      Edward Thomson committed
  21. 11 Feb, 2016 1 commit
  22. 01 Dec, 2015 1 commit
  23. 23 Nov, 2015 1 commit
    • checkout: only consider nsecs when built that way · 25e84f95
      When examining the working directory and determining whether it's
      up-to-date, only consider the nanoseconds in the index entry when
      built with `GIT_USE_NSEC`.  This prevents us from believing that
      the working directory is always dirty when the index was originally
      written with a git client that uinderstands nsecs (like git 2.x).
      Edward Thomson committed
  24. 02 Nov, 2015 1 commit
  25. 28 Oct, 2015 1 commit
  26. 22 Oct, 2015 1 commit
    • diff: ignore nsecs when diffing · 7499eae9
      Although our index contains the literal time present in the index,
      we do not read nanoseconds from disk, and thus we should not use
      them in any comparisons, lest we always think our working directory
      is dirty.
      
      Guard this behind a `GIT_USE_NSECS` for future improvement.
      Edward Thomson committed
  27. 02 Oct, 2015 1 commit
  28. 19 Sep, 2015 2 commits
  29. 12 Sep, 2015 1 commit
    • diff: check pathspec on non-files · 8ab4d0e1
      When we're not doing pathspec matching, we let the iterator handle
      file matching for us.  However, we can only trust the iterator to
      return *files* that match the pattern, because the iterator must
      return directories that are not strictly in the pathlist, but that
      are the parents of files that match the pattern, so that diff can
      later recurse into them.
      
      Thus, diff must examine non-files explicitly before including them
      in the delta list.
      Edward Thomson committed
  30. 30 Aug, 2015 1 commit
    • diff: use new iterator pathlist handling · 4a0dbeb0
      When using literal pathspecs in diff with `GIT_DIFF_DISABLE_PATHSPEC_MATCH`
      turn on the faster iterator pathlist handling.
      
      Updates iterator pathspecs to include directory prefixes (eg, `foo/`)
      for compatibility with `GIT_DIFF_DISABLE_PATHSPEC_MATCH`.
      Edward Thomson committed
  31. 28 Aug, 2015 2 commits
  32. 30 Jun, 2015 1 commit