1. 07 Nov, 2014 1 commit
    • iterator: submodules are determined by an index or tree · 62a617dc
      We cannot know from looking at .gitmodules whether a directory is a
      submodule or not. We need the index or tree we are comparing against to
      tell us. Otherwise we have to assume the entry in .gitmodules is stale
      or otherwise invalid.
      
      Thus we pass the index of the repository into the workdir iterator, even
      if we do not want to compare against it. This follows what git does,
      which even for `git diff <tree>`, it will consider staged submodules as
      such.
      Carlos Martín Nieto committed
  2. 06 May, 2014 1 commit
    • Improve checks for ignore containment · f554611a
      The diff code was using an "ignored_prefix" directory to track if
      a parent directory was ignored that contained untracked files
      alongside tracked files. Unfortunately, when negative ignore rules
      were used for directories inside ignored parents, the wrong rules
      were applied to untracked files inside the negatively ignored
      child directories.
      
      This commit moves the logic for ignore containment into the workdir
      iterator (which is a better place for it), so the ignored-ness of
      a directory is contained in the frame stack during traversal.  This
      allows a child directory to override with a negative ignore and yet
      still restore the ignored state of the parent when we traverse out
      of the child.
      
      Along with this, there are some problems with "directory only"
      ignore rules on container directories.  Given "a/*" and "!a/b/c/"
      (where the second rule is a directory rule but the first rule is
      just a generic prefix rule), then the directory only constraint
      was having "a/b/c/d/file" match the first rule and not the second.
      This was fixed by having ignore directory-only rules test a rule
      against the prefix of a file with LEADINGDIR enabled.
      
      Lastly, spot checks for ignores using `git_ignore_path_is_ignored`
      were tested from the top directory down to the bottom to deal with
      the containment problem, but this is wrong. We have to test bottom
      to top so that negative subdirectory rules will be checked before
      parent ignore rules.
      
      This does change the behavior of some existing tests, but it seems
      only to bring us more in line with core Git, so I think those
      changes are acceptable.
      Russell Belfer committed
  3. 02 May, 2014 3 commits
  4. 23 Apr, 2014 2 commits
    • Treat ignored, empty, and untracked dirs different · 219c89d1
      In the iterator, distinguish between ignores and empty directories
      so that diff and status can ignore empty directories, but checkout
      and stash can treat them as untracked items.
      Russell Belfer committed
    • Make checkout match diff for untracked/ignored dir · 37da3685
      When diff finds an untracked directory, it emulates Git behavior
      by looking inside the directory to see if there are any untracked
      items inside it. If there are only ignored items inside the dir,
      then diff considers it ignored, even if there is no direct ignore
      rule for it.
      
      Checkout was not copying this behavior - when it found an untracked
      directory, it just treated it as untracked.  Unfortunately, when
      combined with GIT_CHECKOUT_REMOVE_UNTRACKED, this made is seem that
      checkout (and stash, which uses checkout) was removing ignored
      items when you had only asked it to remove untracked ones.
      
      This commit moves the logic for advancing past an untracked dir
      while scanning for non-ignored items into an iterator helper fn,
      and uses that for both diff and checkout.
      Russell Belfer committed
  5. 03 Oct, 2013 1 commit
  6. 21 Jun, 2013 1 commit
    • Add target directory to checkout · 9094ae5a
      This adds the ability for checkout to write to a target directory
      instead of having to use the working directory of the repository.
      This makes it easier to do exports of repository data and the like.
      
      This is similar to, but not quite the same as, the --prefix option
      to `git checkout-index` (this will always be treated as a directory
      name, not just as a simple text prefix).
      
      As part of this, the workdir iterator was extended to take the
      path to the working directory as a parameter and fallback on the
      git_repository_workdir result only if it's not specified.
      
      Fixes #1332
      Russell Belfer committed
  7. 31 May, 2013 1 commit
    • 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
  8. 18 Apr, 2013 1 commit
  9. 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
  10. 15 Jan, 2013 3 commits
    • Support case insensitive tree iterators and status · 25423d03
      This makes tree iterators directly support case insensitivity by
      using a secondary index that can be sorted by icase.  Also, this
      fixes the ambiguity check in the git_status_file API to also be
      case insensitive.  Lastly, this adds new test cases for case
      insensitive range boundary checking for all types of iterators.
      
      With this change, it should be possible to deprecate the spool
      and sort iterator, but I haven't done that yet.
      Russell Belfer committed
    • 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
    • Minor iterator API cleanups · 4b181037
      In preparation for further iterator changes, this cleans up a few
      small things in the iterator API:
      
      * removed the git_iterator_for_repo_index_range API
      * made git_iterator_free not be inlined
      * minor param name and test function name tweaks
      Russell Belfer committed
  11. 08 Jan, 2013 1 commit
  12. 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
    • Add index updating to checkout · 5cf9875a
      Make checkout update entries in the index for all files that are
      updated and/or removed, unless flag GIT_CHECKOUT_DONT_UPDATE_INDEX
      is given.  To do this, iterators were extended to allow a little
      more introspection into the index being iterated over, etc.
      Russell Belfer committed
  13. 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
  14. 10 Dec, 2012 2 commits
    • Fix iterator reset and add reset ranges · 91e7d263
      The `git_iterator_reset` command has not been working in all cases
      particularly when there is a start and end range.  This fixes it
      and adds tests for it, and also extends it with the ability to
      update the start/end range strings when an iterator is reset.
      Russell Belfer committed
    • Clean up iterator APIs · 9950d27a
      This removes the need to explicitly pass the repo into iterators
      where the repo is implied by the other parameters.  This moves
      the repo to be owned by the parent struct.  Also, this has some
      iterator related updates to the internal diff API to lay the
      groundwork for checkout improvements.
      Russell Belfer committed
  15. 15 Nov, 2012 1 commit
  16. 09 Oct, 2012 1 commit
    • Add complex checkout test and then fix checkout · 0d64bef9
      This started as a complex new test for checkout going through the
      "typechanges" test repository, but that revealed numerous issues
      with checkout, including:
      
      * complete failure with submodules
      * failure to create blobs with exec bits
      * problems when replacing a tree with a blob because the tree
        "example/" sorts after the blob "example" so the delete was
        being processed after the single file blob was created
      
      This fixes most of those problems and includes a number of other
      minor changes that made it easier to do that, including improving
      the TYPECHANGE support in diff/status, etc.
      Russell Belfer committed
  17. 08 Oct, 2012 1 commit
    • Fix a few diff bugs with directory content · dfbff793
      There are a few cases where diff should leave directories in
      the diff list if we want to match core git, such as when the
      directory contains a .git dir.  That feature was lost when I
      introduced some of the new submodule handling.
      
      This restores that and then fixes a couple of related to diff
      output that are triggered by having diffs with directories in
      them.
      
      Also, this adds a new flag that can be passed to diff if you
      want diff output to actually include the file content of any
      untracked files.
      Russell Belfer committed
  18. 17 Sep, 2012 2 commits
  19. 15 May, 2012 1 commit
    • Ranged iterators and rewritten git_status_file · 41a82592
      The goal of this work is to rewrite git_status_file to use the
      same underlying code as git_status_foreach.
      
      This is done in 3 phases:
      
      1. Extend iterators to allow ranged iteration with start and
         end prefixes for the range of file names to be covered.
      2. Improve diff so that when there is a pathspec and there is
         a common non-wildcard prefix of the pathspec, it will use
         ranged iterators to minimize excess iteration.
      3. Rewrite git_status_file to call git_status_foreach_ext
         with a pathspec that covers just the one file being checked.
      
      Since ranged iterators underlie the status & diff implementation,
      this is actually fairly efficient.  The workdir iterator does
      end up loading the contents of all the directories down to the
      single file, which should ideally be avoided, but it is pretty
      good.
      Russell Belfer committed
  20. 13 May, 2012 1 commit
  21. 08 May, 2012 1 commit
  22. 02 Mar, 2012 1 commit
    • Update diff to use iterators · 74fa4bfa
      This is a major reorganization of the diff code.  This changes
      the diff functions to use the iterators for traversing the
      content.  This allowed a lot of code to be simplified.  Also,
      this moved the functions relating to outputting a diff into a
      new file (diff_output.c).
      
      This includes a number of other changes - adding utility
      functions, extending iterators, etc. plus more tests for the
      diff code.  This also takes the example diff.c program much
      further in terms of emulating git-diff command line options.
      Russell Belfer committed
  23. 22 Feb, 2012 1 commit
    • Iterator improvements from diff implementation · da337c80
      This makes two changes to iterator behavior: first, advance
      can optionally do the work of returning the new current value.
      This is such a common pattern that it really cleans up usage.
      
      Second, for workdir iterators, this removes automatically
      iterating into directories.  That seemed like a good idea,
      but when an entirely new directory hierarchy is introduced
      into the workdir, there is no reason to iterate into it if
      there are no corresponding entries in the tree/index that it
      is being compared to.
      
      This second change actually wasn't a lot of code because not
      descending into directories was already the behavior for
      ignored directories.  This just extends that to all directories.
      Russell Belfer committed
  24. 21 Feb, 2012 1 commit
    • Uniform iterators for trees, index, and workdir · b6c93aef
      This create a new git_iterator type of object that provides a
      uniform interface for iterating over the index, an arbitrary
      tree, or the working directory of a repository.
      
      As part of this, git ignore support was extended to support
      push and pop of directory-based ignore files as the working
      directory is being traversed (so the array of ignores does
      not have to be recreated at each directory during traveral).
      
      There are a number of other small utility functions in buffer,
      path, vector, and fileops that are included in this patch
      that made the iterator implementation cleaner.
      Russell Belfer committed