1. 23 Feb, 2016 1 commit
    • diff_print: assert patch is non-NULL · be8479c9
      When invoking `diff_print_info_init_frompatch` it is obvious that
      the patch should be non-NULL. We explicitly check if the variable
      is set and continue afterwards, happily dereferencing the
      potential NULL-pointer.
      
      Fix this by instead asserting that patch is set. This also
      silences Coverity.
      Patrick Steinhardt committed
  2. 25 Sep, 2015 1 commit
    • Fix binary diffs · e4b2b919
      git expects an empty line after the binary data:
      
      literal X
      ...binary data...
      <empty_line>
      
      The last literal block of the generated patches were not containing the required empty line. Example:
      
      	diff --git a/binary_file b/binary_file
      	index 3f1b3f9098131cfecea4a50ff8afab349ea66d22..86e5c1008b5ce635d3e3fffa4434c5eccd8f00b6 100644
      	GIT binary patch
      	literal 8
      	Pc${NM&PdElPvrst3ey5{
      
      	literal 6
      	Nc${NM%g@i}0ssZ|0lokL
      	diff --git a/binary_file2 b/binary_file2
      	index 31be99be19470da4af5b28b21e27896a2f2f9ee2..86e5c1008b5ce635d3e3fffa4434c5eccd8f00b6 100644
      	GIT binary patch
      	literal 8
      	Pc${NM&PdElPvrst3ey5{
      
      	literal 13
      	Sc${NMEKbZyOexL+Qd|HZV+4u-
      
      git apply of that diff results in:
      
      	error: corrupt binary patch at line 9: diff --git a/binary_file2 b/binary_file2
      	fatal: patch with only garbage at line 10
      
      The proper formating is:
      
      	diff --git a/binary_file b/binary_file
      	index 3f1b3f9098131cfecea4a50ff8afab349ea66d22..86e5c1008b5ce635d3e3fffa4434c5eccd8f00b6 100644
      	GIT binary patch
      	literal 8
      	Pc${NM&PdElPvrst3ey5{
      
      	literal 6
      	Nc${NM%g@i}0ssZ|0lokL
      	diff --git a/binary_file2 b/binary_file2
      	index 31be99be19470da4af5b28b21e27896a2f2f9ee2..86e5c1008b5ce635d3e3fffa4434c5eccd8f00b6 100644
      	GIT binary patch
      	literal 8
      	Pc${NM&PdElPvrst3ey5{
      
      	literal 13
      	Sc${NMEKbZyOexL+Qd|HZV+4u-
      Guille -bisho- committed
  3. 30 Jun, 2015 1 commit
  4. 26 Jun, 2015 1 commit
  5. 15 Jun, 2015 1 commit
  6. 12 Jun, 2015 1 commit
    • diff: introduce binary diff callbacks · 8147b1af
      Introduce a new binary diff callback to provide the actual binary
      delta contents to callers.  Create this data from the diff contents
      (instead of directly from the ODB) to support binary diffs including
      the workdir, not just things coming out of the ODB.
      Edward Thomson committed
  7. 15 Aug, 2014 1 commit
  8. 23 Jul, 2014 1 commit
  9. 31 May, 2014 2 commits
  10. 20 May, 2014 1 commit
  11. 17 May, 2014 2 commits
  12. 08 May, 2014 1 commit
    • Be more careful with user-supplied buffers · 1e4976cb
      This adds in missing calls to `git_buf_sanitize` and fixes a
      number of places where `git_buf` APIs could inadvertently write
      NUL terminator bytes into invalid buffers.  This also changes the
      behavior of `git_buf_sanitize` to NUL terminate a buffer if it can
      and of `git_buf_shorten` to do nothing if it can.
      
      Adds tests of filtering code with zeroed (i.e. unsanitized) buffer
      which was previously triggering a segfault.
      Russell Belfer committed
  13. 23 Apr, 2014 1 commit
  14. 22 Apr, 2014 1 commit
    • Some doc and examples/diff.c changes · 12e422a0
      I was playing with "git diff-index" and wanted to be able to
      emulate that behavior a little more closely with the diff example.
      
      Also, I wanted to play with running `git_diff_tree_to_workdir`
      directly even though core Git doesn't exactly have the equivalent,
      so I added a command line option for that and tweaked some other
      things in the example code.
      
      This changes a minor output thing in that the "raw" print helper
      function will no longer add ellipses (...) if the OID is not
      actually abbreviated.
      Russell Belfer committed
  15. 17 Apr, 2014 1 commit
  16. 25 Jan, 2014 2 commits
  17. 22 Jan, 2014 2 commits
    • Drop git_patch_to_str · c05cd792
      It's hard or even impossible to correctly free the string buffer
      allocated by git_patch_to_str in some circumstances. Drop the function
      so people have to use git_patch_to_buf instead - git_buf has a dedicated
      destructor.
      Nicolas Hake committed
    • Expose patch serialization to git_buf · 450e8e9e
      Returning library-allocated strings from libgit2 works fine on Linux,
      but may cause problems on Windows because there is no one C Runtime that
      everything links against. With libgit2 not exposing its own allocator,
      freeing the string is a gamble.
      
      git_patch_to_str already serializes to a buffer, then returns the
      underlying memory. Expose the functionality directly, so callers can use
      the git_buf_free function to free the memory later.
      Nicolas Hake committed
  18. 11 Dec, 2013 3 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
    • Improve GIT_EUSER handling · 96869a4e
      This adds giterr_user_cancel to return GIT_EUSER and clear any
      error message that is sitting around.  As a result of using that
      in places, we need to be more thorough with capturing errors that
      happen inside a callback when used internally.  To help with that,
      this also adds giterr_capture and giterr_restore so that when we
      internally use a foreach-type function that clears errors and
      converts them to GIT_EUSER, it is easier to restore not just the
      return value, but the actual error message text.
      Russell Belfer committed
  19. 21 Oct, 2013 1 commit
    • Create git_diff_line and extend git_diff_hunk · 3b5f7954
      Instead of having functions with so very many parameters to pass
      hunk and line data, this takes the existing git_diff_hunk struct
      and extends it with more hunk data, plus adds a git_diff_line.
      Those structs are used to pass back hunk and line data instead of
      the old APIs that took tons of parameters.
      
      Some work that was previously only being done for git_diff_patch
      creation (scanning the diff content for exact line counts) is now
      done for all callbacks, but the performance difference should not
      be noticable.
      Russell Belfer committed
  20. 15 Oct, 2013 1 commit
    • Diff API cleanup · 10672e3e
      This lays groundwork for separating formatting options from diff
      creation options.  This groups the formatting flags separately
      from the diff list creation flags and reorders the options.  This
      also tweaks some APIs to further separate code that uses patches
      from code that just looks at git_diffs.
      Russell Belfer committed
  21. 11 Oct, 2013 1 commit
  22. 24 Sep, 2013 1 commit
  23. 05 Sep, 2013 2 commits
  24. 23 Jul, 2013 3 commits
  25. 18 Jun, 2013 2 commits
    • Fix rename looped reference issues · e4acc3ba
      This makes the diff rename tracking code more careful about the
      order in which it processes renames and more thorough in updating
      the mapping of correct renames when an earlier rename update
      alters the index of a later matched pair.
      Russell Belfer committed
    • Add "as_path" parameters to blob and buffer diffs · 74ded024
      This adds parameters to the four functions that allow for blob-to-
      blob and blob-to-buffer differencing (either via callbacks or by
      making a git_diff_patch object).  These parameters let you say
      that filename we should pretend the blob has while doing the diff.
      If you pass NULL, there should be no change from the existing
      behavior, which is to skip using attributes for file type checks
      and just look at content.  With the parameters, you can plug into
      the new diff driver functionality and get binary or non-binary
      behavior, plus function context regular expressions, etc.
      
      This commit also fixes things so that the git_diff_delta that is
      generated by these functions will actually be populated with the
      data that we know about the blobs (or buffers) so you can use it
      appropriately.  It also fixes a bug in generating patches from
      the git_diff_patch objects created via these functions.
      
      Lastly, there is one other behavior change that may matter.  If
      there is no difference between the two blobs, these functions no
      longer generate any diff callbacks / patches unless you have
      passed in GIT_DIFF_INCLUDE_UNMODIFIED.  This is pretty natural,
      but could potentially change the behavior of existing usage.
      Russell Belfer committed
  26. 17 Jun, 2013 1 commit
    • More tests and bug fixes for status with rename · a1683f28
      This changes the behavior of the status RENAMED flags so that they
      will be combined with the MODIFIED flags if appropriate.  If a file
      is modified in the index and also renamed, then the status code
      will have both the GIT_STATUS_INDEX_MODIFIED and INDEX_RENAMED bits
      set.  If it is renamed but the OID has not changed, then just the
      GIT_STATUS_INDEX_RENAMED bit will be set.  Similarly, the flags
      GIT_STATUS_WT_MODIFIED and GIT_STATUS_WT_RENAMED can both be set
      independently of one another.
      
      This fixes a serious bug where the check for unmodified files that
      was done at data load time could end up erasing the RENAMED state
      of a file that was renamed with no changes.
      
      Lastly, this contains a bunch of new tests for status with renames,
      including tests where the only rename changes are case changes.
      The expected results of these tests have to vary by whether the
      platform uses a case sensitive filesystem or not, so the expected
      data covers those platform differences separately.
      Russell Belfer committed
  27. 12 Jun, 2013 1 commit
    • Fix diff header naming issues · 360f42f4
      This makes the git_diff_patch definition private to diff_patch.c
      and fixes a number of other header file naming inconsistencies to
      use `git_` prefixes on functions and structures that are shared
      between files.
      Russell Belfer committed
  28. 10 Jun, 2013 1 commit
    • Reorganize diff and add basic diff driver · 114f5a6c
      This is a significant reorganization of the diff code to break it
      into a set of more clearly distinct files and to document the new
      organization.  Hopefully this will make the diff code easier to
      understand and to extend.
      
      This adds a new `git_diff_driver` object that looks of diff driver
      information from the attributes and the config so that things like
      function content in diff headers can be provided.  The full driver
      spec is not implemented in the commit - this is focused on the
      reorganization of the code and putting the driver hooks in place.
      
      This also removes a few #includes from src/repository.h that were
      overbroad, but as a result required extra #includes in a variety
      of places since including src/repository.h no longer results in
      pulling in the whole world.
      Russell Belfer committed
  29. 05 Jun, 2013 1 commit