1. 17 Jun, 2013 3 commits
    • Always do tree to index diffs case sensitively · eefef642
      Trees are always case sensitive.  The index is always case
      preserving and will be case sensitive when it is turned into a
      tree.  Therefore the tree and the index can and should always
      be compared to one another case sensitively.
      
      This will restore the index to case insensitive order after the
      diff has been generated.
      
      Consider this a short-term fix.  The long term fix is to have the
      index always stored both case sensitively and case insensitively
      (at least on platforms that sometimes require case insensitivity).
      Russell Belfer committed
    • Improve case handling in git_diff__paired_foreach · 351888cf
      This commit reinstates some changes to git_diff__paired_foreach
      that were discarded during the rebase (because the diff_output.c
      file had gone away), and also adjusts the case insensitively
      logic slightly to hopefully deal with either mismatched icase
      diffs and other case insensitivity scenarios.
      Russell Belfer committed
    • Be more careful about the path with diffs · a3e8dbb4
      This makes diff more careful about picking the canonical path
      when generating a delta so that it won't accidentally pick up a
      case-mismatched path on a case-insensitive file system.  This
      should make sure we use the "most accurate" case correct version
      of the path (i.e. from the tree if possible, or the index if
      need be).
      Russell Belfer committed
  2. 12 Jun, 2013 1 commit
  3. 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
  4. 07 Jun, 2013 1 commit
  5. 31 May, 2013 2 commits
    • Zero memory for major objects before freeing · f658dc43
      By zeroing out the memory when we free larger objects (i.e. those
      that serve as collections of other data, such as repos, odb, refdb),
      I'm hoping that it will be easier for libgit2 bindings to find
      errors in their object management code.
      Russell Belfer committed
    • Make iterators use GIT_ITEROVER & smart advance · cee695ae
      1. internal iterators now return GIT_ITEROVER when you go past the
         last item in the iteration.
      2. git_iterator_advance will "advance" to the first item in the
         iteration if it is called immediately after creating the
         iterator, which allows a simpler idiom for basic iteration.
      3. if git_iterator_advance encounters an error reading data (e.g.
         a missing tree or an unreadable file), it returns the error
         but also attempts to advance past the invalid data to prevent
         an infinite loop.
      
      Updated all tests and internal usage of iterators to account for
      these new behaviors.
      Russell Belfer committed
  6. 24 May, 2013 1 commit
  7. 17 May, 2013 1 commit
  8. 15 May, 2013 1 commit
  9. 08 May, 2013 1 commit
  10. 07 May, 2013 1 commit
    • 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
  11. 03 May, 2013 1 commit
  12. 30 Apr, 2013 3 commits
    • Update diff handling of untracked directories · e26b14c0
      When diff encounters an untracked directory, there was a shortcut
      that it took which is not compatible with core git.  This makes
      the default behavior no longer take that shortcut and instead look
      inside the untracked directory to see if there are any untracked
      files within it.  If there are not, then the directory is treated
      as an ignore directory instead of an untracked directory.  This
      has implications for the git_status APIs.
      Russell Belfer committed
    • Reorganize diff code into functions · fdb3034e
      In preparation for more changes to the internal diff logic, it
      seemed wise to split the very large git_diff__from_iterators into
      separate functions that handle the four main cases (unmatched old
      item, unmatched new item, unmatched new directory, and matched
      old and new items).  Hopefully this will keep the logic easier to
      follow even as more cases have to be added to this code.
      Russell Belfer committed
  13. 29 Apr, 2013 1 commit
  14. 23 Apr, 2013 4 commits
  15. 09 Apr, 2013 1 commit
    • 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
  16. 26 Mar, 2013 2 commits
    • Fix some diff ignores and submodule dirty workdir · ccfa6805
      This started out trying to look at the problems from issue #1425
      and gradually grew to a broader set of fixes.  There are two core
      things fixed here:
      
      1. When you had an ignore like "/bin" which is rooted at the top
         of your tree, instead of immediately adding the "bin/" entry
         as an ignored item in the diff, we were returning all of the
         direct descendants of the directory as ignored items.  This
         changes things to immediately ignore the directory.  Note that
         this effects the behavior in test_status_ignore__subdirectories
         so that we no longer exactly match core gits ignore behavior,
         but the new behavior probably makes more sense (i.e. we now
         will include an ignored directory inside an untracked directory
         that we previously would have left off).
      2. When a submodule only contained working directory changes, the
         diff code was always considering it unmodified which was just
         an outright bug. The HEAD SHA of the submodule matches the SHA
         in the parent repo index, and since the SHAs matches, the diff
         code was overwriting the actual status with UNMODIFIED.
      
      These fixes broke existing tests test_diff_workdir__submodules and
      test_status_ignore__subdirectories but looking it over, I actually
      think the new results are correct and the old results were wrong.
      @nulltoken had actually commented on the subdirectory ignore issue
      previously.
      
      I also included in the tests some debugging versions of the
      shared iteration callback routines that print status or diff
      information.  These aren't used actively in the tests, but can be
      quickly swapped in to test code to give a better picture of what
      is being scanned in some of the complex test scenarios.
      Russell Belfer committed
    • Implement GIT_STATUS_OPT_EXCLUDE_SUBMODULES · 37ee70fa
      This option has been sitting unimplemented for a while, so I
      finally went through and implemented it along with some tests.
      
      As part of this, I improved the implementation of
      GIT_DIFF_IGNORE_SUBMODULES so it be more diligent about avoiding
      extra work and about leaving off delta records for submodules to
      the greatest extent possible (though it may include them still
      if you are request TYPECHANGE records).
      Russell Belfer committed
  17. 25 Mar, 2013 1 commit
    • Recursing into ignored dirs for diff and status · 0c289dd7
      This implements working versions of GIT_DIFF_RECURSE_IGNORED_DIRS
      and GIT_STATUS_OPT_RECURSE_IGNORED_DIRS along with some tests for
      the newly available behaviors.  This is not turned on by default
      for status, but can be accessed via the options to the extended
      version of the command.
      Russell Belfer committed
  18. 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
  19. 09 Mar, 2013 1 commit
  20. 07 Mar, 2013 3 commits
    • Add INCLUDE_TREES, DONT_AUTOEXPAND iterator flags · 9bea03ce
      This standardizes iterator behavior across all three iterators
      (index, tree, and working directory).  Previously the working
      directory iterator behaved differently from the other two.
      
      Each iterator can now operate in one of three modes:
      
      1. *No tree results, auto expand trees* means that only non-
         tree items will be returned and when a tree/directory is
         encountered, we will automatically descend into it.
      2. *Tree results, auto expand trees* means that results will
         be given for every item found, including trees, but you
         only need to call normal git_iterator_advance to yield
         every item (i.e. trees returned with pre-order iteration).
      3. *Tree results, no auto expand* means that calling the
         normal git_iterator_advance when looking at a tree will
         not descend into the tree, but will skip over it to the
         next entry in the parent.
      
      Previously, behavior 1 was the only option for index and tree
      iterators, and behavior 3 was the only option for workdir.
      
      The main public API implications of this are that the
      `git_iterator_advance_into()` call is now valid for all
      iterators, not just working directory iterators, and all the
      existing uses of working directory iterators explicitly use
      the GIT_ITERATOR_DONT_AUTOEXPAND (for now).
      
      Interestingly, the majority of the implementation was in the
      index iterator, since there are no tree entries there and now
      have to fake them.  The tree and working directory iterators
      only required small modifications.
      Russell Belfer committed
    • Retire spoolandsort iterator · cc216a01
      Since the case sensitivity is moved into the respective iterators,
      this removes the spoolandsort iterator code.
      Russell Belfer committed
    • Make iterator APIs consistent with standards · 169dc616
      The iterator APIs are not currently consistent with the parameter
      ordering of the rest of the codebase.  This rearranges the order
      of parameters, simplifies the naming of a number of functions, and
      makes somewhat better use of macros internally to clean up the
      iterator code.
      
      This also expands the test coverage of iterator functionality,
      making sure that case sensitive range-limited iteration works
      correctly.
      Russell Belfer committed
  21. 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
  22. 07 Feb, 2013 2 commits
    • diff: add a notify callback to `git_diff__from_iterators` · 0d64ba48
      The callback will be called for each file, just before the `git_delta_t` gets inserted into the diff list.
      
      When the callback:
      - returns < 0, the diff process will be aborted
      - returns > 0, the delta will not be inserted into the diff list, but the diff process continues
      - returns 0, the delta is inserted into the diff list, and the diff process continues
      yorah committed
    • Return the matched pathspec pattern in `git_pathspec_match_path` · 943700ec
      Instead of returning directly the pattern as the return value, I used an
      out parameter, because the function also tests if the passed pathspecs
      vector is empty. If yes, it considers that the path "matches", but in
      that case there is no matched pattern per se.
      yorah committed
  23. 15 Jan, 2013 1 commit
    • Update iterator API with flags for ignore_case · 134d8c91
      This changes the iterator API so that flags can be passed in to
      the constructor functions to control the ignore_case behavior.
      At this point, the flags are not supported on tree iterators (i.e.
      there is no functional change over the old API), but the API
      changes are all made to accomodate this.
      
      By the way, I went with a flags parameter because in the future
      I have a couple of other ideas for iterator flags that will make
      it easier to fix some diff/status/checkout bugs.
      Russell Belfer committed
  24. 08 Jan, 2013 1 commit
  25. 04 Jan, 2013 2 commits
    • Fix up spoolandsort iterator usage · 546d65a8
      The spoolandsort iterator changes got sort-of cherry picked out of
      this branch and so I dropped the commit when rebasing; however,
      there were a few small changes that got dropped as well (since the
      version merged upstream wasn't quite the same as what I dropped).
      Russell Belfer committed
    • More checkout improvements · 7e5c8a5b
      This flips checkout back to be driven off the changes between
      the baseline and the target trees.  This reinstates the complex
      code for tracking the contents of the working directory, but
      overall, I think the resulting logic is easier to follow.
      Russell Belfer committed
  26. 28 Dec, 2012 1 commit
    • Make spoolandsort a pushable iterator behavior · f616a36b
      An earlier change to `git_diff_from_iterators` introduced a
      memory leak where the allocated spoolandsort iterator was not
      returned to the caller and thus not freed.
      
      One proposal changes all iterator APIs to use git_iterator** so
      we can reallocate the iterator at will, but that seems unexpected.
      This commit makes it so that an iterator can be changed in place.
      The callbacks are isolated in a separate structure and a pointer
      to that structure can be reassigned by the spoolandsort extension.
      
      This means that spoolandsort doesn't create a new iterator; it
      just allocates a new block of callbacks (along with space for its
      own extra data) and swaps that into the iterator.
      
      Additionally, since spoolandsort is only needed to switch the
      case sensitivity of an iterator, this simplifies the API to only
      take the ignore_case boolean and to be a no-op if the iterator
      already matches the requested case sensitivity.
      Russell Belfer committed
  27. 17 Dec, 2012 1 commit
    • Fix diff constructor name order confusion · 56c72b75
      The diff constructor functions had some confusing names, where the
      "old" side of the diff was coming after the "new" side.  This
      reverses the order in the function name to make it less confusing.
      
      Specifically...
      
      * git_diff_index_to_tree becomes git_diff_tree_to_index
      * git_diff_workdir_to_index becomes git_diff_index_to_workdir
      * git_diff_workdir_to_tree becomes git_diff_tree_to_workdir
      Russell Belfer committed