public void testNonRecursiveFiltering()
        {
            var             ow        = new ObjectWriter(db);
            ObjectId        aSth      = ow.WriteBlob("a.sth".getBytes());
            ObjectId        aTxt      = ow.WriteBlob("a.txt".getBytes());
            DirCache        dc        = DirCache.read(db);
            DirCacheBuilder builder   = dc.builder();
            var             aSthEntry = new DirCacheEntry("a.sth");

            aSthEntry.setFileMode(FileMode.RegularFile);
            aSthEntry.setObjectId(aSth);
            var aTxtEntry = new DirCacheEntry("a.txt");

            aTxtEntry.setFileMode(FileMode.RegularFile);
            aTxtEntry.setObjectId(aTxt);
            builder.add(aSthEntry);
            builder.add(aTxtEntry);
            builder.finish();
            ObjectId treeId = dc.writeTree(ow);


            var tw = new GitSharp.Core.TreeWalk.TreeWalk(db);

            tw.setFilter(PathSuffixFilter.create(".txt"));
            tw.addTree(treeId);

            var paths = new LinkedList <string>();

            while (tw.next())
            {
                paths.AddLast(tw.getPathString());
            }

            var expected = new LinkedList <string>();

            expected.AddLast("a.txt");

            Assert.AreEqual(expected, paths);
        }
            protected override bool MergeImpl()
            {
                _tw.reset();
                _tw.addTree(MergeBase());
                _tw.addTree(SourceTrees[0]);
                _tw.addTree(SourceTrees[1]);

                bool hasConflict = false;

                _builder = _cache.builder();
                while (_tw.next())
                {
                    int modeO = _tw.getRawMode(Ours);
                    int modeT = _tw.getRawMode(Theirs);
                    if (modeO == modeT && _tw.idEqual(Ours, Theirs))
                    {
                        Add(Ours, DirCacheEntry.STAGE_0);
                        continue;
                    }

                    int modeB = _tw.getRawMode(Base);
                    if (modeB == modeO && _tw.idEqual(Base, Ours))
                    {
                        Add(Theirs, DirCacheEntry.STAGE_0);
                    }
                    else if (modeB == modeT && _tw.idEqual(Base, Theirs))
                    {
                        Add(Ours, DirCacheEntry.STAGE_0);
                    }
                    else if (_tw.isSubtree())
                    {
                        if (NonTree(modeB))
                        {
                            Add(Base, DirCacheEntry.STAGE_1);
                            hasConflict = true;
                        }
                        if (NonTree(modeO))
                        {
                            Add(Ours, DirCacheEntry.STAGE_2);
                            hasConflict = true;
                        }
                        if (NonTree(modeT))
                        {
                            Add(Theirs, DirCacheEntry.STAGE_3);
                            hasConflict = true;
                        }
                        _tw.enterSubtree();
                    }
                    else
                    {
                        Add(Base, DirCacheEntry.STAGE_1);
                        Add(Ours, DirCacheEntry.STAGE_2);
                        Add(Theirs, DirCacheEntry.STAGE_3);
                        hasConflict = true;
                    }
                }
                _builder.finish();
                _builder = null;

                if (hasConflict)
                {
                    return(false);
                }
                try
                {
                    _resultTree = _cache.writeTree(GetObjectWriter());
                    return(true);
                }
                catch (UnmergedPathException)
                {
                    _resultTree = null;
                    return(false);
                }
            }