1. 17 May, 2013 1 commit
  2. 15 May, 2013 1 commit
  3. 10 May, 2013 1 commit
    • Fix diff output for renames and copies · e9ba61f3
      If you use rename detection, the renamed and copied files would
      not show any text diffs because the function that decides if
      data should be loaded didn't know which sides of the diff to
      load for those cases.
      
      This adds a test that looks at the patch generated for diff
      entries that are COPIED or RENAMED.
      Russell Belfer committed
  4. 07 May, 2013 2 commits
    • Fix line numbering for patches with eofnl · c2f602f8
      When a patch contained an eofnl change (i.e. the last line either
      gained or lost a newline), the oldno and newno line number values
      for the lines in the last hunk of the patch were not useful.  This
      makes them behave in a more expected manner.
      Russell Belfer committed
    • Add GIT_DIFF_LINE_CONTEXT_EOFNL · e35e2684
      This adds a new line origin constant for the special line that
      is used when both files end without a newline.
      
      In the course of writing the tests for this, I was having problems
      with modifying a file but not having diff notice because it was
      the same size and modified less than one second from the start of
      the test, so I decided to start working on nanosecond timestamp
      support.  This commit doesn't contain the nanosecond support, but
      it contains the reorganization of maybe_modified and the hooks so
      that if the nanosecond data were being read by stat() (or rather
      being copied by git_index_entry__init_from_stat), then the nsec
      would be taken into account.
      
      This new stuff could probably use some more tests, although there
      is some amount of it here.
      Russell Belfer committed
  5. 01 May, 2013 1 commit
  6. 30 Apr, 2013 1 commit
  7. 29 Apr, 2013 1 commit
  8. 23 Apr, 2013 1 commit
    • Improve diff config options handling · b1ff7004
      This makes diff use the cvar cache for config options where
      possible, and also adds support for a number of other config
      options to diff including "diff.context", "diff.ignoreSubmodules",
      "diff.noprefix", "diff.mnemonicprefix", and "core.abbrev".
      
      To make this natural, this involved a rearrangement of the code
      that allocates the diff object vs. the code that initializes it
      based on the combination of options passed in by the user and
      read from the config.
      
      This commit includes tests for most of these new options as well.
      Russell Belfer committed
  9. 09 Apr, 2013 2 commits
    • Tests and more fixes for submodule diffs · ad26434b
      This adds tests for diffs with submodules in them and (perhaps
      unsurprisingly) requires further fixes to be made.  Specifically,
      this fixes:
      
      - when considering if a submodule is dirty in the workdir, it was
        being treated as dirty even if only the index was dirty.
      - git_diff_patch_to_str (and git_diff_patch_print) were "printing"
        the headers for files (and submodules) that were unmodified or
        had no meaningful content.
      - added comment to previous fix and removed unneeded parens.
      Russell Belfer committed
    • Fix submodule dirty states not showing if submodules comes before files, or… · 94750e8a
      Fix submodule dirty states not showing if submodules comes before files, or there are only dirty submodules but no changed files
      
      GIT_DIFF_PATCH_DIFFABLE was not set, so the diff content was not shown
      
      When submodule is dirty, the hash may be the same, but the length is different because -dirty is appended
      
      We can therefore compare the length or hash
      Linquize committed
  10. 25 Mar, 2013 1 commit
    • Move crlf conversion into buf_text · 3658e81e
      This adds crlf/lf conversion functions into buf_text with more
      efficient implementations that bypass the high level buffer
      functions.  They attempt to minimize the number of reallocations
      done and they directly write the buffer data as needed if they
      know that there is enough memory allocated to memcpy data.
      
      Tests are added for these new functions.  The crlf.c code is
      updated to use the new functions.
      
      Removed the include of buf_text.h from filter.h and just include
      it more narrowly in the places that need it.
      Russell Belfer committed
  11. 19 Mar, 2013 1 commit
    • Three submodule status bug fixes · 65025cb8
      1. Fix sort order problem with submodules where "mod" was sorting
         after "mod-plus" because they were being sorted as "mod/" and
         "mod-plus/".  This involved pushing the "contains a .git entry"
         test significantly lower in the stack.
      2. Reinstate behavior that a directory which contains a .git entry
         will be treated as a submodule during iteration even if it is
         not yet added to the .gitmodules.
      3. Now that any directory containing .git is reported as submodule,
         we have to be more careful checking for GIT_EEXISTS when we
         do a submodule lookup, because that is the error code that is
         returned by git_submodule_lookup when you try to look up a
         directory containing .git that has no record in gitmodules or
         the index.
      Russell Belfer committed
  12. 17 Mar, 2013 1 commit
  13. 14 Mar, 2013 1 commit
    • Fix valgrind issues (and mmap fallback for diff) · d85296ab
      This fixes a number of issues identified by valgrind - mostly
      missed free calls.  Inside valgrind, mmap() may fail which causes
      some of the diff tests to fail.  This adds a fallback code path
      to diff_output.c:get_workdir_content() where is the mmap() fails
      the code will now try to read the file data directly into allocated
      memory (which is what it would do if the data needed to be filtered
      anyhow).
      Russell Belfer committed
  14. 09 Mar, 2013 1 commit
  15. 03 Mar, 2013 1 commit
    • Fix a few leaks · 323bb885
      `git_diff_get_patch()` would unconditionally load the patch object and
      then simply leak it if the user hadn't requested it. Short-circuit
      loading the object if the user doesn't want it.
      
      The rest of the plugs are simply calling the free functions of objects
      allocated during the tests.
      Carlos Martín Nieto committed
  16. 21 Feb, 2013 1 commit
    • Initial integration of similarity metric to diff · 960a04dd
      This is the initial integration of the similarity metric into
      the `git_diff_find_similar()` code path.  The existing tests all
      pass, but the new functionality isn't currently well tested.  The
      integration does go through the pluggable metric interface, so it
      should be possible to drop in an alternative to the internal
      metric that libgit2 implements.
      
      This comes along with a behavior change for an existing interface;
      namely, passing two NULLs to git_diff_blobs (or passing NULLs to
      git_diff_blob_to_buffer) will now call the file_cb parameter zero
      times instead of one time.  I know it's strange that that change
      is paired with this other change, but it emerged from some
      initialization changes that I ended up making.
      Russell Belfer committed
  17. 20 Feb, 2013 1 commit
    • Replace diff delta binary with flags · 71a3d27e
      Previously the git_diff_delta recorded if the delta was binary.
      This replaces that (with no net change in structure size) with
      a full set of flags.  The flag values that were already in use
      for individual git_diff_file objects are reused for the delta
      flags, too (along with renaming those flags to make it clear that
      they are used more generally).
      
      This (a) makes things somewhat more consistent (because I was
      using a -1 value in the "boolean" binary field to indicate unset,
      whereas now I can just use the flags that are easier to understand),
      and (b) will make it easier for me to add some additional flags to
      the delta object in the future, such as marking the results of a
      copy/rename detection or other deltas that might want a special
      indicator.
      
      While making this change, I officially moved some of the flags that
      were internal only into the private diff header.
      
      This also allowed me to remove a gross hack in rename/copy detect
      code where I was overwriting the status field with an internal
      value.
      Russell Belfer committed
  18. 16 Feb, 2013 1 commit
    • Clear up warnings from cppcheck · 56543a60
      The cppcheck static analyzer generates warnings for a bunch of
      places in the libgit2 code base.  All the ones fixed in this
      commit are actually false positives, but I've reorganized the
      code to hopefully make it easier for static analysis tools to
      correctly understand the structure.  I wouldn't do this if I
      felt like it was making the code harder to read or worse for
      humans, but in this case, these fixes don't seem too bad and will
      hopefully make it easier for better analysis tools to get at any
      real issues.
      Russell Belfer committed
  19. 11 Feb, 2013 2 commits
  20. 05 Feb, 2013 1 commit
  21. 30 Jan, 2013 1 commit
    • Add helper for diff line stats · f1e2735c
      This adds a `git_diff_patch_line_stats()` API that gets the total
      number of adds, deletes, and context lines in a patch.  This will
      make it a little easier to emulate `git diff --stat` and the like.
      
      Right now, this relies on generating the `git_diff_patch` object,
      which is a pretty heavyweight way to get stat information.  At
      some future point, it would probably be nice to be able to get
      this information without allocating the entire `git_diff_patch`,
      but that's a much larger project.
      Russell Belfer committed
  22. 15 Jan, 2013 2 commits
  23. 13 Jan, 2013 1 commit
  24. 11 Jan, 2013 2 commits
    • Match binary file check of core git in diff · 0d65acad
      Core git just looks for NUL bytes in files when deciding about
      is-binary inside diff (although it uses a better algorithm in
      checkout, when deciding if CRLF conversion should be done).
      Libgit2 was using the better algorithm in both places, but that
      is causing some confusion.  For now, this makes diff just look
      for NUL bytes to decide if a file is binary by content in diff.
      Russell Belfer committed
    • Fix diff patch line number calculation · 805c476c
      This was just wrong.  Added a test that verifying patch line
      numbers even for hunks further into a file and then fixed the
      algorithm.  I needed to add a little extra state into the patch
      so that I could track old and new file numbers independently,
      but it should be okay.
      Russell Belfer committed
  25. 09 Jan, 2013 1 commit
    • Resolve crash with diff against empty file · de590550
      It is not legal inside our `p_mmap` function to mmap a zero length
      file.  This adds a test that exercises that case inside diff and
      fixes the code path where we would try to do that.
      
      The fix turns out not to be a lot of code since our default file
      content is already initialized to "" which works in this case.
      
      Fixes #1210
      Russell Belfer committed
  26. 08 Jan, 2013 1 commit
  27. 07 Jan, 2013 2 commits
  28. 01 Dec, 2012 1 commit
  29. 30 Nov, 2012 1 commit
  30. 28 Nov, 2012 1 commit
    • Consolidate text buffer functions · 7bf87ab6
      There are many scattered functions that look into the contents of
      buffers to do various text manipulations (such as escaping or
      unescaping data, calculating text stats, guessing if content is
      binary, etc).  This groups all those functions together into a
      new file and converts the code to use that.
      
      This has two enhancements to existing functionality.  The old
      text stats function is significantly rewritten and the BOM
      detection code was extended (although largely we can't deal with
      anything other than a UTF8 BOM).
      Russell Belfer committed
  31. 27 Nov, 2012 4 commits