/// <exception cref="NGit.Errors.CorruptObjectException"></exception> internal virtual AbstractTreeIterator Min() { int i = 0; AbstractTreeIterator minRef = trees[i]; while (minRef.Eof && ++i < trees.Length) { minRef = trees[i]; } if (minRef.Eof) { return(minRef); } minRef.matches = minRef; while (++i < trees.Length) { AbstractTreeIterator t = trees[i]; if (t.Eof) { continue; } int cmp = t.PathCompare(minRef); if (cmp < 0) { t.matches = t; minRef = t; } else { if (cmp == 0) { t.matches = minRef; } } } return(minRef); }
private static bool NameEqual(AbstractTreeIterator a, AbstractTreeIterator b) { return(a.PathCompare(b, TREE_MODE) == 0); }
private AbstractTreeIterator FastMin() { fastMinHasMatch = true; int i = 0; AbstractTreeIterator minRef = trees[i]; while (minRef.Eof && ++i < trees.Length) { minRef = trees[i]; } if (minRef.Eof) { return(minRef); } bool hasConflict = false; minRef.matches = minRef; while (++i < trees.Length) { AbstractTreeIterator t = trees[i]; if (t.Eof) { continue; } int cmp = t.PathCompare(minRef); if (cmp < 0) { if (fastMinHasMatch && IsTree(minRef) && !IsTree(t) && NameEqual(minRef, t)) { // We used to be at a tree, but now we are at a file // with the same name. Allow the file to match the // tree anyway. // t.matches = minRef; hasConflict = true; } else { fastMinHasMatch = false; t.matches = t; minRef = t; } } else { if (cmp == 0) { // Exact name/mode match is best. // t.matches = minRef; } else { if (fastMinHasMatch && IsTree(t) && !IsTree(minRef) && NameEqual(t, minRef)) { // The minimum is a file (non-tree) but the next entry // of this iterator is a tree whose name matches our file. // This is a classic D/F conflict and commonly occurs like // this, with no gaps in between the file and directory. // // Use the tree as the minimum instead (see combineDF). // for (int k = 0; k < i; k++) { AbstractTreeIterator p = trees[k]; if (p.matches == minRef) { p.matches = t; } } t.matches = t; minRef = t; hasConflict = true; } else { fastMinHasMatch = false; } } } } if (hasConflict && fastMinHasMatch && dfConflict == null) { dfConflict = minRef; } return(minRef); }
private static bool NameEqual(AbstractTreeIterator a, AbstractTreeIterator b) { return a.PathCompare(b, TREE_MODE) == 0; }