private static void assertModes(string path, FileMode mode0, FileMode mode1, GitSharp.Core.TreeWalk.TreeWalk tw) { Assert.IsTrue(tw.next(), "has " + path); Assert.AreEqual(path, tw.getPathString()); Assert.AreEqual(mode0, tw.getFileMode(0)); Assert.AreEqual(mode1, tw.getFileMode(1)); }
/** * 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); }