public virtual void testNoDF_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());
            }

            GitSharp.Core.TreeWalk.TreeWalk tw = new GitSharp.Core.TreeWalk.TreeWalk(db);
            tw.reset();
            tw.addTree(new DirCacheIterator(tree0));
            tw.addTree(new DirCacheIterator(tree1));

            assertModes("a", REGULAR_FILE, MISSING, tw);
            assertModes("a.b", EXECUTABLE_FILE, MISSING, tw);
            assertModes("a", MISSING, TREE, tw);
            tw.enterSubtree();
            assertModes("a/b", MISSING, REGULAR_FILE, tw);
            assertModes("a0b", SYMLINK, MISSING, tw);
        }
		public virtual void testNoDF_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());
			}

			GitSharp.Core.TreeWalk.TreeWalk tw = new GitSharp.Core.TreeWalk.TreeWalk(db);
			tw.reset();
			tw.addTree(new DirCacheIterator(tree0));
			tw.addTree(new DirCacheIterator(tree1));

			assertModes("a", REGULAR_FILE, MISSING, tw);
			assertModes("a.b", EXECUTABLE_FILE, MISSING, tw);
			assertModes("a", MISSING, TREE, tw);
			tw.enterSubtree();
			assertModes("a/b", MISSING, REGULAR_FILE, tw);
			assertModes("a0b", SYMLINK, MISSING, tw);
		}
Beispiel #3
0
        /**
         * Open a tree walk and filter to exactly one path.
         * <para />
         * The returned tree walk is already positioned on the requested path, so
         * the caller should not need to invoke {@link #next()} unless they are
         * looking for a possible directory/file name conflict.
         *
         * @param db
         *            repository to Read tree object data from.
         * @param path
         *            single path to advance the tree walk instance into.
         * @param trees
         *            one or more trees to walk through, all with the same root.
         * @return a new tree walk configured for exactly this one path; null if no
         *         path was found in any of the trees.
         * @throws IOException
         *             reading a pack file or loose object failed.
         * @throws CorruptObjectException
         *             an tree object could not be Read as its data stream did not
         *             appear to be a tree, or could not be inflated.
         * @throws IncorrectObjectTypeException
         *             an object we expected to be a tree was not a tree.
         * @throws MissingObjectException
         *             a tree object was not found.
         */

        public static TreeWalk ForPath(Repository db, string path, params AnyObjectId[] trees)
        {
            var r = new TreeWalk(db);

            r.Recursive = r.getFilter().shouldBeRecursive();

            r.setFilter(PathFilterGroup.createFromStrings(new HashSet <string> {
                path
            }));
            r.reset(trees);
            return(r.next() ? r : null);
        }