summaryrefslogtreecommitdiff
path: root/src/iterator.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix workdir iterator bugsRussell Belfer2013-03-131-6/+10
| | | | | | | | | | | | | | | 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.
* Stabilize order for equiv tree iterator entriesRussell Belfer2013-03-111-3/+15
| | | | | | | | | | | 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.
* Fix tree iterator advance using wrong name compareRussell Belfer2013-03-111-39/+43
| | | | | | | Tree iterator advance was moving forward without taking the filemode of the entries into account, equating "a" and "a/". This makes the tree entry comparison code more easily reusable and fixes the problem.
* Fix tree iterator path for tree issue + cleanupsRussell Belfer2013-03-111-60/+51
| | | | | | | This fixes an off by one error for generating full paths for tree entries in tree iterators when INCLUDE_TREES is set. Also, contains a bunch of small code cleanups with a couple of small utility functions and macro changes to eliminate redundant code.
* Use correct case path in icase tree iteratorRussell Belfer2013-03-101-30/+65
| | | | | | | | | If there are case-ambiguities in the path of a case insensitive tree iterator, it will now rewrite the entire path when it gives the path name to an entry, so a tree with "A/b/C/d.txt" and "a/B/c/E.txt" will give the true full paths (instead of case- folding them both to "A/B/C/d.txt" or "a/b/c/E.txt" or something like that.
* Make tree iterator handle icase equivalenceRussell Belfer2013-03-081-227/+260
| | | | | | | | | | | | | | | | | | | | | | | | There is a serious bug in the previous tree iterator implementation. If case insensitivity resulted in member elements being equivalent to one another, and those member elements were trees, then the children of the colliding elements would be processed in sequence instead of in a single flattened list. This meant that the tree iterator was not truly acting like a case-insensitive list. This completely reworks the tree iterator to manage lists with case insensitive equivalence classes and advance through the items in a unified manner in a single sorted frame. It is possible that at a future date we might want to update this to separate the case insensitive and case sensitive tree iterators so that the case sensitive one could be a minimal amount of code and the insensitive one would always know what it needed to do without checking flags. But there would be so much shared code between the two, that I'm not sure it that's a win. For now, this gets what we need. More tests are needed, though.
* Add INCLUDE_TREES, DONT_AUTOEXPAND iterator flagsRussell Belfer2013-03-061-62/+253
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Retire spoolandsort iteratorRussell Belfer2013-03-061-166/+19
| | | | | Since the case sensitivity is moved into the respective iterators, this removes the spoolandsort iterator code.
* Make iterator APIs consistent with standardsRussell Belfer2013-03-061-116/+141
| | | | | | | | | | | | 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.
* Vector improvements and their falloutPhilip Kelley2013-01-271-1/+1
|
* Fix case sensitivity bug with tree iteratorsRussell Belfer2013-01-221-3/+5
| | | | | | | | With the new code to make tree iterators support ignore_case, there is a bug in setting the start entry for range bounded iterators where memcmp was being used instead of strncasecmp. This fixes that and expands the tree iterator test to cover the cases that were broken.
* Shortcut spool and sort for empty iteratorRussell Belfer2013-01-151-0/+5
|
* Support case insensitive tree iterators and statusRussell Belfer2013-01-151-28/+102
| | | | | | | | | | | 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.
* Update iterator API with flags for ignore_caseRussell Belfer2013-01-151-40/+78
| | | | | | | | | | | | 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.
* Minor iterator API cleanupsRussell Belfer2013-01-151-14/+16
| | | | | | | | | 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
* update copyrightsEdward Thomson2013-01-081-1/+1
|
* Fix up spoolandsort iterator usageRussell Belfer2013-01-041-16/+9
| | | | | | | 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).
* Add index updating to checkoutRussell Belfer2013-01-041-0/+27
| | | | | | | 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.
* Make spoolandsort a pushable iterator behaviorRussell Belfer2012-12-271-88/+118
| | | | | | | | | | | | | | | | | | | | | 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.
* Fix iterator reset and add reset rangesRussell Belfer2012-12-101-100/+150
| | | | | | | 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.
* Clean up iterator APIsRussell Belfer2012-12-101-8/+6
| | | | | | | | 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.
* status should ignore conflicts entries in the indexEdward Thomson2012-12-031-10/+30
|
* Merge pull request #1090 from arrbee/ignore-invalid-by-defaultVicent Martí2012-11-291-4/+23
|\ | | | | Ignore invalid entries by default
| * Improve iterator ignoring .git fileRussell Belfer2012-11-191-4/+23
| | | | | | | | | | | | | | | | | | | | | | | | The workdir iterator has always tried to ignore .git files, but it turns out there were some bugs. This makes it more robust at ignoring .git files. This also makes iterators always check ".git" case insensitively regardless of the properties of the system. This will make libgit2 skip ".GIT" and the like. This is different from core git, but on systems with case insensitive but case preserving file systems, allowing ".GIT" to be added is problematic.
* | Fix warnings on Win64 buildRussell Belfer2012-11-271-1/+1
| |
* | Fix up some missing consts in tree & indexRussell Belfer2012-11-271-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | This fixes some missed places where we can apply const-ness to various public APIs. There are still some index and tree APIs that cannot take const pointers because we sort our `git_vectors` lazily and so we can't reliably bsearch the index and tree content without applying a `git_vector_sort()` first. This also fixes some missed places where size_t can be used and where const can be applied to a couple internal functions.
* | API updates for index.hBen Straub2012-11-271-1/+1
| |
* | API review / update for tree.hRussell Belfer2012-11-271-1/+1
|/
* Add iterator for git_index objectRussell Belfer2012-11-141-18/+31
| | | | | | The index iterator could previously only be created from a repo object, but this allows creating an iterator from a `git_index` object instead (while keeping, though renaming, the old function).
* Some diff refactorings to help code reuseRussell Belfer2012-11-091-1/+1
| | | | | | | | | | | | | | | | | There are some diff functions that are useful in a rewritten checkout and this lays some groundwork for that. This contains three main things: 1. Share the function diff uses to calculate the OID for a file in the working directory (now named `git_diff__oid_for_file` 2. Add a `git_diff__paired_foreach` function to iterator over two diff lists concurrently. Convert status to use it. 3. Move all the string/prefix/index entry comparisons into function pointers inside the `git_diff_list` object so they can be switched between case sensitive and insensitive versions. This makes them easier to reuse in various functions without replicating logic. As part of this, move a couple of index functions out of diff.c and into index.c.
* Make iterator ignore eval lazyRussell Belfer2012-11-091-10/+17
| | | | | | | | This makes it so that the check if a file is ignored will be deferred until requested on the workdir iterator, instead of aggressively evaluating the ignore rules for each entry. This should improve performance because there will be no need to check ignore rules for files that are already in the index.
* index refactoringEdward Thomson2012-10-291-1/+1
|
* Add complex checkout test and then fix checkoutRussell Belfer2012-10-091-5/+47
| | | | | | | | | | | | | | | | 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.
* Fix a few diff bugs with directory contentRussell Belfer2012-10-081-0/+12
| | | | | | | | | | | | | | | 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.
* Support for core.ignorecasePhilip Kelley2012-09-171-12/+177
|
* errors: deploy GIT_EBAREREPO usagenulltoken2012-09-061-5/+2
|
* Working implementation of git_submodule_statusRussell Belfer2012-08-241-12/+9
| | | | | | | | | | | | | This is a big redesign of the git_submodule_status API and the implementation of the redesigned API. It also fixes a number of bugs that I found in other parts of the submodule API while writing the tests for the status part. This also fixes a couple of bugs in the iterators that had not been noticed before - one with iterating when there is a gitlink (i.e. separate-work-dir) and one where I was treating anything even vaguely submodule-like as a submodule, more aggressively than core git does.
* Fix workdir iterators on empty directoriesRussell Belfer2012-05-171-4/+12
| | | | | | | Creating a workdir iterator on a directory with absolutely no files was returning an error (GIT_ENOTFOUND) instead of an iterator for nothing. This fixes that and includes two new tests that cover that case.
* tree: Naming conventionsVicent Martí2012-05-161-4/+4
|
* Ranged iterators and rewritten git_status_fileRussell Belfer2012-05-151-62/+241
| | | | | | | | | | | | | | | | | | | | | 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.
* Add support for diffing index with no HEADRussell Belfer2012-05-081-1/+48
| | | | | | | When a repo is first created, there is no HEAD yet and attempting to diff files in the index was showing nothing because a tree iterator could not be constructed. This adds an "empty" iterator and falls back on that when the head cannot be looked up.
* Added submodule API and use in statusRussell Belfer2012-03-281-8/+22
| | | | | | | | | | When processing status for a newly checked out repo, it is possible that there will be submodules that have not yet been initialized. The only way to distinguish these from untracked directories is to have some knowledge of submodules. This commit adds a new submodule API which, given a name or path, can determine if it appears to be a submodule and can give information about the submodule.
* Fix error in tree iterator when popping up treesRussell Belfer2012-03-251-1/+0
| | | | | | | | | | There was an error in the tree iterator where it would delete two tree levels instead of just one when popping up a tree level. Unfortunately the test data for the tree iterator did not have any deep trees with subtrees in the middle of the tree items, so this problem went unnoticed. This contains the 1-line fix plus new test data and tests that reveal the issue.
* New status fixesRussell Belfer2012-03-221-0/+5
| | | | | | | This adds support for roughly-right tracking of submodules (although it does not recurse into submodules to detect internal modifications a la core git), and it adds support for including unmodified files in diff iteration if requested.
* Migrate index, oid, and utils to new errorsRussell Belfer2012-03-191-12/+5
| | | | | | | | | | | | This includes a few cleanups that came up while converting these files. This commit introduces a could new git error classes, including the catchall class: GITERR_INVALID which I'm using as the class for invalid and out of range values which are detected at too low a level of library to use a higher level classification. For example, an overflow error in parsing an integer or a bad letter in parsing an OID string would generate an error in this class.
* Convert attr, ignore, mwindow, status to new errorsRussell Belfer2012-03-161-56/+46
| | | | | Also cleaned up some previously converted code that still had little things to polish.
* Continue error conversionRussell Belfer2012-03-141-1/+1
| | | | | | | This converts blob.c, fileops.c, and all of the win32 files. Also, various minor cleanups throughout the code. Plus, in testing the win32 build, I cleaned up a bunch (although not all) of the warnings with the 64-bit build.
* diff: Fix rebase breackageVicent Martí2012-03-061-1/+1
|
* Update diff to use iteratorsRussell Belfer2012-03-021-38/+59
| | | | | | | | | | | | | 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.
* Fix -Wuninitialized warningschu2012-02-231-1/+1
| | | | Signed-off-by: schu <schu-github@schulog.org>