1. 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
  2. 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
  3. 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
  4. 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
  5. 14 Mar, 2017 1 commit
  6. 26 May, 2016 3 commits
  7. 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
  8. 24 Mar, 2016 1 commit
  9. 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
  10. 11 Feb, 2016 1 commit
  11. 01 Dec, 2015 1 commit
  12. 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
  13. 02 Nov, 2015 1 commit
  14. 28 Oct, 2015 1 commit
  15. 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
  16. 02 Oct, 2015 1 commit
  17. 19 Sep, 2015 2 commits
  18. 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
  19. 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
  20. 28 Aug, 2015 2 commits
  21. 30 Jun, 2015 1 commit
  22. 26 Jun, 2015 1 commit
  23. 23 Jun, 2015 1 commit
    • Fixed GIT_DELTA_CONFLICTED not returned in some cases · 8d8a2eef
      If an index entry for a file that is not in HEAD is in conflicted state,
      when diffing HEAD with the index, the status field of the corresponding git_diff_delta was incorrectly reported as GIT_DELTA_ADDED instead of GIT_DELTA_CONFLICTED.
      
      This was due to handle_unmatched_new_item() initially setting the status
      to GIT_DELTA_CONFLICTED but then overriding it later with GIT_DELTA_ADDED.
      Pierre-Olivier Latour committed
  24. 22 Jun, 2015 1 commit
    • diff: check files with the same or newer timestamps · ff475375
      When a file on the workdir has the same or a newer timestamp than the
      index, we need to perform a full check of the contents, as the update of
      the file may have happened just after we wrote the index.
      
      The iterator changes are such that we can reach inside the workdir
      iterator from the diff, though it may be better to have an accessor
      instead of moving these structs into the header.
      Carlos Martín Nieto committed
  25. 20 Jun, 2015 1 commit
  26. 28 May, 2015 7 commits
  27. 04 May, 2015 1 commit
  28. 15 Apr, 2015 2 commits