summaryrefslogtreecommitdiff
path: root/src/iterator.c
Commit message (Collapse)AuthorAgeFilesLines
* pool: Simplify implementationVicent Marti2015-10-281-3/+4
|
* iterator: loop fs_iterator advance (don't recurse)Edward Thomson2015-09-131-35/+50
|
* iterator: advance the tree iterator smartlyEdward Thomson2015-09-111-42/+56
| | | | | | | | | | | | | | | | | | | | | | | | While advancing the tree iterator, if we advance over things that we aren't interested in, then call `current`. Which may *itself* call advance. While advancing the tree iterator, if we advance over things that we aren't interested in, then call `current`. Which may *itself* call advance. While advancing the tree iterator, if we advance over things that we aren't interested in, then call `current`. Which may *itself* call advance. While advancing the tree iterator, if we advance over things that we aren't interested in, then call `current`. Which may *itself* call advance. While advancing the tree iterator, if we advance over things that we aren't interested in, then call `current`. Which may *itself* call advance. Error: stack overflow.
* iterator: saner pathlist matching for idx iteratorEdward Thomson2015-08-311-62/+76
| | | | | | | | | | | | 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.
* tree_iterator: use a pathlistEdward Thomson2015-08-301-1/+34
|
* diff: use new iterator pathlist handlingEdward Thomson2015-08-301-106/+186
| | | | | | | | 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`.
* iterator: sort subdirs properly with pathlistEdward Thomson2015-08-281-6/+15
| | | | | | | | | | 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/'.
* Move filelist into the iterator handling itself.Edward Thomson2015-08-281-8/+107
|
* iterator: use an options struct instead of argsEdward Thomson2015-08-281-25/+20
|
* errors: tighten up git_error_state OOMs a bit moreEdward Thomson2015-08-031-2/+2
| | | | | When an error state is an OOM, make sure that we treat is specially and do not try to free it.
* iterator: skip over errors in diriter initCarlos Martín Nieto2015-07-261-1/+4
| | | | | | | | | An error here will typically mean that the directory was removed between the time we iterated the parent and the time we wanted to visit it in which case we should ignore it. Other kinds of errors such as permissions (or transient errors) also better dealt with by pretending we didn't see it.
* iterator_walk: cast away constness for freeEdward Thomson2015-07-021-2/+2
|
* iterator_walk: drop unused variableEdward Thomson2015-06-291-5/+0
|
* index, iterator, fetchhead: plug leaksleaksCarlos Martín Nieto2015-06-261-0/+3
|
* iterator: provide git_iterator_walkEdward Thomson2015-06-251-0/+88
| | | | | Provide `git_iterator_walk` to walk each iterator in lockstep, returning each iterator's idea of the contents of the next path.
* diff: check files with the same or newer timestampsCarlos Martín Nieto2015-06-221-0/+12
| | | | | | | | | | 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.
* Merge pull request #3165 from ethomson/downcaseCarlos Martín Nieto2015-06-081-4/+4
|\ | | | | Downcase
| * git__tolower: a tolower() that isn't dumbEdward Thomson2015-05-291-4/+4
| | | | | | | | | | | | | | | | Some brain damaged tolower() implementations appear to want to take the locale into account, and this may require taking some insanely aggressive lock on the locale and slowing down what should be the most trivial of trivial calls for people who just want to downcase ASCII.
* | introduce `git_index_entry_is_conflict`Edward Thomson2015-05-281-1/+1
| | | | | | | | | | | | | | | | | | It's not always obvious the mapping between stage level and conflict-ness. More importantly, this can lead otherwise sane people to write constructs like `if (!git_index_entry_stage(entry))`, which (while technically correct) is unreadable. Provide a nice method to help avoid such messy thinking.
* | index iterator: optionally include conflictsEdward Thomson2015-05-281-7/+11
|/
* git_path_diriter: use FindFirstFile in win32Edward Thomson2015-05-011-1/+1
| | | | | | | Using FindFirstFile and FindNextFile in win32 allows us to use the directory information that is returned, instead of us having to get the file attributes all over again, which is a distinct cost savings on win32.
* git_path_diriter: next shouldn't take path ptrEdward Thomson2015-05-011-1/+1
| | | | | | | | The _next method shouldn't take a path pointer (and a path_len pointer) as 100% of current users use the full path and ignore the filename. Plus let's add some docs and a unit test.
* git_path_dirload_with_stat: moved to fs_iteratorEdward Thomson2015-05-011-7/+116
|
* git_win32_path_dirload_with_stat: removedEdward Thomson2015-05-011-16/+1
|
* Improvements to status performance on Windows.J Wyman2015-04-281-1/+17
| | | | Changed win32/path_w32.c to utilize NTFS' FindFirst..FindNext data instead of doing an lstat per file. Avoiding unnecessary directory opens and file scans reduces IO, improving overall performance. Effect is magnified due to NTFS being a kernel mode file system (as opposed to user mode).
* Improvements to ignore performance on Windows.J Wyman2015-04-281-5/+16
| | | | Minimizing the number directory and file opens, minimizes the amount of IO thus reducing the overall cost of performing ignore operations.
* Make our overflow check look more like gcc/clang'sEdward Thomson2015-02-131-5/+2
| | | | | | | | | Make our overflow checking look more like gcc and clang's, so that we can substitute it out with the compiler instrinsics on platforms that support it. This means dropping the ability to pass `NULL` as an out parameter. As a result, the macros also get updated to reflect this as well.
* allocations: test for overflow of requested sizeEdward Thomson2015-02-121-3/+8
| | | | | Introduce some helper macros to test integer overflow from arithmetic and set error message appropriately.
* Plug leaksCarlos Martín Nieto2014-11-231-0/+1
| | | | Valgrind is now clean except for libssl and libgcrypt.
* iterator: submodules are determined by an index or treecmn/submodule-and-dirCarlos Martín Nieto2014-11-071-1/+70
| | | | | | | | | | | | 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.
* Improve checks for ignore containmentrb/how-broken-can-ignores-beRussell Belfer2014-05-061-18/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Remove trace / add git_diff_perfdata struct + apiRussell Belfer2014-05-021-4/+1
|
* Add payloads, bitmaps to trace APIRussell Belfer2014-05-021-2/+2
| | | | | | | | | This is a proposed adjustment to the trace APIs. This makes the trace levels into a bitmask so that they can be selectively enabled and adds a callback-level payload, plus a message-level payload. This makes it easier for me to a GIT_TRACE_PERF callbacks that are simply bypassed if the PERF level is not set.
* Add GIT_STATUS_OPT_UPDATE_INDEX and use trace APIRussell Belfer2014-05-021-2/+3
| | | | | | This adds an option to refresh the stat cache while generating status. It also rips out the GIT_PERF stuff I had an makes use of the trace API to keep statistics about what happens during diff.
* Skip diff oid calc when size definitely changedRussell Belfer2014-05-021-1/+1
| | | | | | | | | | | | | When we think the stat cache in the index seems valid and the size or mode of a file has definitely changed, then don't bother trying to recalculate the OID of the workdir bits to confirm that it is modified - just accept that it is modified. This can result in files that show as modified with no actual diff, but the behavior actually appears to match Git on the command line. This also includes a minor optimization to not perform a submodule lookup on the ".git" directory itself.
* Add build option for diff internal statisticsRussell Belfer2014-05-021-3/+7
|
* Handle explicitly ignored dir slightly differentlyrb/stash-skip-submodulesRussell Belfer2014-04-241-8/+9
| | | | | | | When considering status of untracked directories, if we find an explicitly ignored item, even if it is a directory, treat the parent as an IGNORED item. It was accidentally being treated as an EMPTY item because we were not looking into the ignored subdir.
* Treat ignored, empty, and untracked dirs differentRussell Belfer2014-04-231-6/+11
| | | | | | 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.
* Make checkout match diff for untracked/ignored dirRussell Belfer2014-04-221-0/+68
| | | | | | | | | | | | | | | | | | 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.
* Clean up index snapshot function namingRussell Belfer2014-04-171-4/+3
| | | | | Clear up some of the various "find" functions and the snapshot API naming to be things I like more.
* Decouple index iterator sort from indexRussell Belfer2014-04-171-5/+9
| | | | | | | | This makes the index iterator honor the GIT_ITERATOR_IGNORE_CASE and GIT_ITERATOR_DONT_IGNORE_CASE flags without modifying the index data itself. To take advantage of this, I had to export a number of the internal index entry comparison functions. I also wrote some new tests to exercise the capability.
* Add index snapshot and use it for iteratorRussell Belfer2014-04-171-13/+22
|
* Some index internals refactoringRussell Belfer2014-04-171-2/+4
| | | | | | | | Again, laying groundwork for some index iterator changes, this contains a bunch of code refactorings for index internals that should make it easier down the line to add locking around index modifications. Also this removes the redundant prefix_position function and fixes some potential memory leaks.
* CleanupsRussell Belfer2014-03-311-1/+1
|
* Fix submodule sorting in workdir iteratorRussell Belfer2014-03-311-16/+25
| | | | | | | | | With the changes to how git_path_dirload_with_stat handles things that look like submodules, submodules could end up sorted in the wrong order with the workdir iterator. This moves the submodule check earlier in the iterator processing of a new directory so that the submodule name updates will happen immediately and the sort order will be correct.
* Update behavior for untracked sub-reposRussell Belfer2014-03-251-2/+2
| | | | | | | | | | | 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.
* index: rename an entry's id to 'id'Carlos Martín Nieto2014-01-251-1/+1
| | | | This was not converted when we converted the rest, so do it now.
* Cleanups, renames, and leak fixesRussell Belfer2013-12-121-1/+1
| | | | | | | | | 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.
* Add git_vector_free_allRussell Belfer2013-12-111-6/+1
| | | | | | 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.
* Improve GIT_EUSER handlingRussell Belfer2013-12-111-9/+3
| | | | | | | | | | | 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.