public virtual void testDF_NoGap()
        {
            DirCache tree0 = DirCache.read(db);
            DirCache tree1 = DirCache.read(db);
            {
                DirCacheBuilder b0 = tree0.builder();
                DirCacheBuilder b1 = tree1.builder();

                b0.add(makeEntry("a", REGULAR_FILE));
                b0.add(makeEntry("a.b", EXECUTABLE_FILE));
                b1.add(makeEntry("a/b", REGULAR_FILE));
                b0.add(makeEntry("a0b", SYMLINK));

                b0.finish();
                b1.finish();
                Assert.AreEqual(3, tree0.getEntryCount());
                Assert.AreEqual(1, tree1.getEntryCount());
            }

            NameConflictTreeWalk tw = new NameConflictTreeWalk(db);

            tw.reset();
            tw.addTree(new DirCacheIterator(tree0));
            tw.addTree(new DirCacheIterator(tree1));

            assertModes("a", REGULAR_FILE, TREE, tw);
            Assert.IsTrue(tw.isSubtree());
            tw.enterSubtree();
            assertModes("a/b", MISSING, REGULAR_FILE, tw);
            assertModes("a.b", EXECUTABLE_FILE, MISSING, tw);
            assertModes("a0b", SYMLINK, MISSING, tw);
        }
            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);
                }
            }