tests-clar/repo/iterator.c


Log

Author Commit Date CI Message
Russell Belfer d85296ab 2013-03-14T13:50:54 Fix valgrind issues (and mmap fallback for diff) This fixes a number of issues identified by valgrind - mostly missed free calls. Inside valgrind, mmap() may fail which causes some of the diff tests to fail. This adds a fallback code path to diff_output.c:get_workdir_content() where is the mmap() fails the code will now try to read the file data directly into allocated memory (which is what it would do if the data needed to be filtered anyhow).
Russell Belfer bbb13646 2013-03-13T14:59:51 Fix workdir iterator bugs 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 a5eea2d7 2013-03-11T11:31:50 Stabilize order for equiv tree iterator entries 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 aec4f663 2013-03-11T10:37:12 Fix tree iterator advance using wrong name compare 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.
Russell Belfer 92028ea5 2013-03-11T09:53:49 Fix tree iterator path for tree issue + cleanups 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.
Russell Belfer 61c7b61e 2013-03-10T22:38:53 Use correct case path in icase tree iterator 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.
Russell Belfer a03beb7b 2013-03-10T21:04:35 Add tests for case insensitive tree iterator This adds a test case for ci tree iteration when there is a name conflict. This points out a behavior quirk in the current version that I'd like to fix - namely, all tree entries get mapped to one version of the case pattern in the ci code - i.e. even if you have A/1.txt and a/2.txt, both will be reported as a/1.txt and a/2.txt because we only copy the name of a file at a given frame once. It would be nice to fix this, but I'm worried about how complex that is if you get a/B/c/1.txt and A/b/C/2.txt. It may require a walk up the frames whenever you advance to the next item in a blended equivalence class.
Russell Belfer e40f1c2d 2013-03-08T16:39:57 Make tree iterator handle icase equivalence 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.
Russell Belfer 9bea03ce 2013-03-06T15:16:34 Add INCLUDE_TREES, DONT_AUTOEXPAND iterator flags 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 169dc616 2013-03-05T16:10:05 Make iterator APIs consistent with standards 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.