Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jgit-dev] Iterator issues

I reported a false conflict in https://bugs.eclipse.org/bugs/show_bug.cgi?id=396127
making it hard to use Eclipse on certain projects, i.e. Git.

While trying to understand it i wrote the following snippet with the output:

Why does it recurse after reset? This might be related to the bug, because
in the bug the iterator recurses when trying to go back(), where the
NameConflictIterator expects the iterator to stay at the same level.

-- robin

Output:

dci=a.
dci=a
dci=a0b
Reset
dci=a.
dci=a/b
dci=a/c/e
dci=a/c/f
dci=a/d
dci=a0b

Code:

	@Test
	public void testTwoLevelSubtree_XXX() throws Exception {
		final DirCache dc = DirCache.newInCore();

		final FileMode mode = FileMode.REGULAR_FILE;
		final String[] paths = { "a.", "a/b", "a/c/e", "a/c/f", "a/d", "a0b" };
		final DirCacheEntry[] ents = new DirCacheEntry[paths.length];
		for (int i = 0; i < paths.length; i++) {
			ents[i] = new DirCacheEntry(paths[i]);
			ents[i].setFileMode(mode);
		}

		final DirCacheBuilder b = dc.builder();
		for (int i = 0; i < ents.length; i++)
			b.add(ents[i]);
		b.finish();

		DirCacheIterator dci = new DirCacheIterator(dc);
		while (!dci.eof()) {
			System.out.println("dci=" + dci.getEntryPathString());
			dci.next(1);
		}
		System.out.println("Reset");
		dci.reset();
		while (!dci.eof()) {
			System.out.println("dci=" + dci.getEntryPathString());
			dci.next(1);
		}
	}



Back to the top