1. 30 Dec, 2017 1 commit
  2. 29 Dec, 2017 1 commit
  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. 24 Mar, 2016 3 commits
  5. 23 Mar, 2016 5 commits
  6. 11 Feb, 2016 1 commit
  7. 31 Aug, 2015 1 commit
    • iterator: saner pathlist matching for idx iterator · d53c8880
      Some nicer refactoring for index iteration walks.
      
      The index iterator doesn't binary search through the pathlist space,
      since it lacks directory entries, and would have to binary search
      each index entry and all its parents (eg, when presented with an index
      entry of `foo/bar/file.c`, you would have to look in the pathlist for
      `foo/bar/file.c`, `foo/bar` and `foo`).  Since the index entries and the
      pathlist are both nicely sorted, we walk the index entries in lockstep
      with the pathlist like we do for other iteration/diff/merge walks.
      Edward Thomson committed
  8. 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
  9. 28 Aug, 2015 2 commits
  10. 25 Jun, 2015 1 commit
  11. 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
  12. 28 May, 2015 1 commit
  13. 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
  14. 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
  15. 02 May, 2014 3 commits
  16. 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
  17. 03 Oct, 2013 1 commit
  18. 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
  19. 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
  20. 18 Apr, 2013 1 commit
  21. 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
  22. 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
  23. 08 Jan, 2013 1 commit
  24. 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
  25. 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