Commit Graph

22 Commits

Author SHA1 Message Date
Edward Thomson
a4f520a6f6 iterator: skip unreadable directories in fs iterator
Do not abort iteration in the middle when encountering an unreadable
directory.  Instead, skip it, as if it didn't exist.
2016-03-23 17:08:37 -04:00
Edward Thomson
be30387e8b iterators: refactored tree iterator
Refactored the tree iterator to never recurse; simply process the
next entry in order in `advance`.  Additionally, reduce the number of
allocations and sorting as much as possible to provide a ~30% speedup
on case-sensitive iteration.  (The gains for case-insensitive iteration
are less majestic.)
2016-03-23 17:08:37 -04:00
Edward Thomson
277c85eb1c repo::iterator: don't go out of bounds 2016-03-23 17:08:37 -04:00
Edward Thomson
684b35c41b iterator: disambiguate reset and reset_range
Disambiguate the reset and reset_range functions.  Now reset_range
with a NULL path will clear the start or end; reset will leave the
existing start and end unchanged.
2016-03-23 17:08:37 -04:00
Arthur Schreiber
3679ebaef5 Horrible fix for #3173. 2016-02-11 23:41:34 +01:00
Edward Thomson
ac2fba0ecd git_futils_mkdir_*: make a relative-to-base mkdir
Untangle git_futils_mkdir from git_futils_mkdir_ext - the latter
assumes that we own everything beneath the base, as if it were
being called with a base of the repository or working directory,
and is tailored towards checkout and ensuring that there is no
bogosity beneath the base that must be cleaned up.

This is (at best) slow and (at worst) unsafe in the larger context
of a filesystem where we do not own things and cannot do things like
unlink symlinks that are in our way.
2015-09-17 10:00:35 -04:00
Edward Thomson
03210cfa00 iterator test: handle case (in)sensitivity 2015-08-31 12:16:16 -04:00
Edward Thomson
4d19bced3f iterator test: use new iter opts in fifo test 2015-08-31 11:48:12 -04:00
Edward Thomson
d53c888069 iterator: saner pathlist matching for idx iterator
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.
2015-08-31 11:48:06 -04:00
Edward Thomson
1af84271dd tree_iterator: use a pathlist 2015-08-30 18:55:18 -04:00
Edward Thomson
4a0dbeb0d3 diff: use new iterator pathlist handling
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`.
2015-08-30 17:06:26 -04:00
Edward Thomson
6c9352bf30 iterator: sort subdirs properly with pathlist
When given a pathlist, don't assume that directories sort before
files.  Walk through any list of entries sorting before us to make
sure that we've exhausted all entries that *aren't* directories.

Eg, if we're searching for 'foo/bar', and we have a 'foo.c', keep
advancing the pathlist to keep looking for an entry prefixed with
'foo/'.
2015-08-28 18:40:02 -04:00
Edward Thomson
ef206124de Move filelist into the iterator handling itself. 2015-08-28 18:39:52 -04:00
Edward Thomson
ed1c64464a iterator: use an options struct instead of args 2015-08-28 18:39:47 -04:00
Carlos Martín Nieto
0e391d8526 iterator: adjust unreadable-dir test to new behaviour
We don't want the iterator to make us stop whenever we hit an unreadable
dir. We should instead move over to the next item.
2015-07-27 13:31:06 +02:00
Edward Thomson
60561d5446 tests: update for new test data 2015-02-02 22:46:43 -05:00
Carlos Martín Nieto
208a2c8aef treebuilder: rename _create() to _new()
This function is a constructor, so let's name it like one and leave
_create() for the reference functions, which do create/write the
reference.
2014-12-27 12:09:11 +00:00
Edward Thomson
dce7b1a4e7 treebuilder: take a repository for path validation
Path validation may be influenced by `core.protectHFS` and
`core.protectNTFS` configuration settings, thus treebuilders
can take a repository to influence their configuration.
2014-12-17 13:05:27 -05:00
Carlos Martín Nieto
62a617dc68 iterator: submodules are determined by an index or tree
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.
2014-11-07 08:33:27 +01:00
Russell Belfer
f18234fad6 Don't report status on named pipes
Git skips entries in directories that are not S_ISDIR, S_ISREG, or
S_ISLNK, so let's make libgit2 do the same thing.
2014-08-08 13:17:50 -07:00
Russell Belfer
72556cc63b Address PR comments
* Make GIT_INLINE an internal definition so it cannot be used in
  public headers
* Fix language in CONTRIBUTING
* Make index caps API use signed instead of unsigned values
2014-02-20 14:27:10 -08:00
Ben Straub
1782038144 Rename tests-clar to tests 2013-11-14 14:05:52 -08:00