1. 23 Nov, 2014 1 commit
  2. 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
  3. 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
  4. 02 May, 2014 5 commits
  5. 24 Apr, 2014 1 commit
  6. 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
  7. 17 Apr, 2014 4 commits
  8. 31 Mar, 2014 2 commits
  9. 25 Mar, 2014 1 commit
    • Update behavior for untracked sub-repos · d3bc95fd
      When a directory containing a .git directory (or even just a plain
      gitlink) was found, libgit2 was going out of its way to treat it
      specially.  This seemed like it was necessary because the diff
      code was not originally emulating Git's behavior for untracked
      directories correctly (i.e. scanning for ignored vs untracked items
      inside).  Now that libgit2 diff mimics Git's untracked directory
      behavior, the special handling for contained Git repos is actually
      incorrect and this commit rips it out.
      Russell Belfer committed
  10. 25 Jan, 2014 1 commit
  11. 12 Dec, 2013 1 commit
    • Cleanups, renames, and leak fixes · 9cfce273
      This renames git_vector_free_all to the better git_vector_free_deep
      and also contains a couple of memory leak fixes based on valgrind
      checks.  The fixes are specifically: failure to free global dir
      path variables when not compiled with threading on and failure to
      free filters from the filter registry that had not be initialized
      fully.
      Russell Belfer committed
  12. 11 Dec, 2013 2 commits
    • Add git_vector_free_all · fcd324c6
      There are a lot of places that we call git__free on each item in
      a vector and then call git_vector_free on the vector itself.  This
      just wraps that up into one convenient helper function.
      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
  13. 05 Nov, 2013 1 commit
  14. 04 Nov, 2013 1 commit
    • Preserve file error in iterator · 3b259cbd
      When the filesystem iterator encounters an error with a file, it
      returns the error but because of the cleanup code, it was in some
      cases erasing the error message.  This uses the giterr_detach API
      to make sure that the actual error message is restored after the
      cleanup code has been run.
      Russell Belfer committed
  15. 08 Oct, 2013 1 commit
    • More filemode cleanups for FAT on MacOS · 14997dc5
      This cleans up some additional issues.  The main change is that
      on a filesystem that doesn't support mode bits, libgit2 will now
      create new blobs with GIT_FILEMODE_BLOB always instead of being
      at the mercy to the filesystem driver to report executable or not.
      This means that if "core.filemode" lies and claims that filemode
      is not supported, then we will ignore the executable bit from the
      filesystem.  Previously we would have allowed it.
      
      This adds an option to the new git_repository_reset_filesystem to
      recurse through submodules if desired.  There may be other types
      of APIs that would like a "recurse submodules" option, but this
      one is particularly useful.
      
      This also has a number of cleanups, etc., for related things
      including trying to give better error messages when problems come
      up from the filesystem.  For example, the FAT filesystem driver on
      MacOS appears to return errno EINVAL if you attempt to write a
      filename with invalid UTF-8 in it.  We try to capture that with a
      better error message now.
      Russell Belfer committed
  16. 03 Oct, 2013 2 commits
    • Initial iconv hookup for precomposed unicode · 219d3457
      This hooks up git_path_direach and git_path_dirload so that they
      will take a flag indicating if directory entry names should be
      tested and converted from decomposed unicode to precomposed form.
      This code will only come into play on the Apple platform and even
      then, only when certain types of filesystems are used.
      
      This involved adding a flag to these functions which involved
      changing a lot of places in the code.
      
      This was an opportunity to do a bit of code cleanup here and there,
      for example, getting rid of the git_futils_cleanupdir_r function in
      favor of a simple flag to git_futils_rmdir_r to not remove the top
      level entry.  That ended up adding depth tracking during rmdir_r
      which led to a safety check for infinite directory recursion.  Yay.
      
      This hasn't actually been tested on the Mac filesystems where the
      issue occurs.  I still need to get test environment for that.
      Russell Belfer committed
    • Put hooks in place for precompose in dirload fn · 2fe54afa
      This doesn't actual do string precompose but it puts the hooks in
      place into the iterators and the git_path_dirload function so that
      the actual precompose work is ready to go.
      Russell Belfer committed
  17. 09 Aug, 2013 1 commit
    • Improve building ignore file lists · ba8b8c04
      The routines to push and pop ignore files while traversing a
      directory had some issues. In particular, setting up the initial
      list would sometimes push an ignore file before it ought to be
      applied if the starting path was a directory containing an ignore
      file. Also, the pop function was not always matching the right
      part of the path and would fail to pop ignores from the list in
      some cases.
      
      This adds some tests that exercise a particular problematic case
      and then fixes the problems that I could find related to this.
      
      At some point, I'd like to isolate this ignore rule management
      code and rewrite it, but that's a larger project and right now,
      I'll opt to just try to fix the broken behaviors.
      Russell Belfer committed
  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. 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
  20. 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
  21. 18 Apr, 2013 4 commits
  22. 10 Apr, 2013 1 commit
  23. 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
  24. 14 Mar, 2013 1 commit
    • Improved tree iterator internals · 0c468633
      This updates the tree iterator internals to be more efficient.
      
      The tree_iterator_entry objects are now kept as pointers that are
      allocated from a git_pool, so that we may use git__tsort_r for
      sorting (which is better than qsort, given that the tree is
      likely mostly ordered already).
      
      Those tree_iterator_entry objects now keep direct pointers to the
      data they refer to instead of keeping indirect index values.  This
      simplifies a lot of the data structure traversal code.
      
      This also adds bsearch to find the start item position for range-
      limited tree iterators, and is more explicit about using
      git_path_cmp instead of reimplementing it.  The git_path_cmp
      changed a bit to make it easier for tree_iterators to use it (but
      it was barely being used previously, so not a big deal).
      
      This adds a git_pool_free_array function that efficiently frees a
      list of pool allocated pointers (which the tree_iterator keeps).
      Also, added new tests for the git_pool free list functionality
      that was not previously being tested (or used).
      Russell Belfer committed
  25. 13 Mar, 2013 1 commit
    • Fix workdir iterator bugs · bbb13646
      This fixes two bugs with the workdir iterator depth check: first
      that the depth was not being decremented and second that empty
      directories were counting against the depth even though a frame
      was not being created for them.
      
      This also fixes a bug with the ENOTFOUND return code for workdir
      iterators when you attempt to advance_into an empty directory.
      Actually, that works correctly, but it was incorrectly being
      propogated into regular advance() calls in some circumstances.
      
      Added new tests for the above that create a huge hierarchy on
      the fly and try using the workdir iterator to traverse it.
      Russell Belfer committed
  26. 11 Mar, 2013 1 commit
    • Stabilize order for equiv tree iterator entries · a5eea2d7
      Given a group of case-insensitively equivalent tree iterator
      entries, this ensures that the case-sensitively first trees will
      be used as the representative items.  I.e. if you have conflicting
      entries "A/B/x", "a/b/x", and "A/b/x", this change ensures that
      the earliest entry "A/B/x" will be returned.  The actual choice
      is not that important, but it is nice to have it stable and to
      have it been either the first or last item, as opposed to a
      random item from within the equivalent span.
      Russell Belfer committed