/// <summary>Open a tree walk and filter to exactly one path.</summary> /// <remarks> /// Open a tree walk and filter to exactly one path. /// <p> /// The returned tree walk is already positioned on the requested path, so /// the caller should not need to invoke /// <see cref="Next()">Next()</see> /// unless they are /// looking for a possible directory/file name conflict. /// </remarks> /// <param name="reader">the reader the walker will obtain tree data from.</param> /// <param name="path">single path to advance the tree walk instance into.</param> /// <param name="trees">one or more trees to walk through, all with the same root.</param> /// <returns> /// a new tree walk configured for exactly this one path; null if no /// path was found in any of the trees. /// </returns> /// <exception cref="System.IO.IOException">reading a pack file or loose object failed. /// </exception> /// <exception cref="NGit.Errors.CorruptObjectException"> /// an tree object could not be read as its data stream did not /// appear to be a tree, or could not be inflated. /// </exception> /// <exception cref="NGit.Errors.IncorrectObjectTypeException">an object we expected to be a tree was not a tree. /// </exception> /// <exception cref="NGit.Errors.MissingObjectException">a tree object was not found. /// </exception> public static NGit.Treewalk.TreeWalk ForPath(NGit.ObjectReader reader, string path , params AnyObjectId[] trees) { NGit.Treewalk.TreeWalk tw = new NGit.Treewalk.TreeWalk(reader); PathFilter f = PathFilter.Create(path); tw.Filter = f; tw.Reset(trees); tw.Recursive = false; while (tw.Next()) { if (f.IsDone(tw)) { return(tw); } else { if (tw.IsSubtree) { tw.EnterSubtree(); } } } return(null); }
/// <summary>Open a tree walk and filter to exactly one path.</summary> /// <remarks> /// Open a tree walk and filter to exactly one path. /// <p> /// The returned tree walk is already positioned on the requested path, so /// the caller should not need to invoke /// <see cref="Next()">Next()</see> /// unless they are /// looking for a possible directory/file name conflict. /// </remarks> /// <param name="db">repository to read tree object data from.</param> /// <param name="path">single path to advance the tree walk instance into.</param> /// <param name="trees">one or more trees to walk through, all with the same root.</param> /// <returns> /// a new tree walk configured for exactly this one path; null if no /// path was found in any of the trees. /// </returns> /// <exception cref="System.IO.IOException">reading a pack file or loose object failed. /// </exception> /// <exception cref="NGit.Errors.CorruptObjectException"> /// an tree object could not be read as its data stream did not /// appear to be a tree, or could not be inflated. /// </exception> /// <exception cref="NGit.Errors.IncorrectObjectTypeException">an object we expected to be a tree was not a tree. /// </exception> /// <exception cref="NGit.Errors.MissingObjectException">a tree object was not found. /// </exception> public static NGit.Treewalk.TreeWalk ForPath(Repository db, string path, params AnyObjectId [] trees) { NGit.ObjectReader reader = db.NewObjectReader(); try { return(ForPath(reader, path, trees)); } finally { reader.Release(); } }
/// <summary>Create a new tree walker for a given repository.</summary> /// <remarks>Create a new tree walker for a given repository.</remarks> /// <param name="or">the reader the walker will obtain tree data from.</param> public TreeWalk(NGit.ObjectReader or) { reader = or; filter = TreeFilter.ALL; trees = NO_TREES; }