CompareNames() public static method

Compare two names represented as bytes. Since git treats names of trees and blobs differently we have one parameter that represents a '/' for trees. For other objects the value should be NUL. The names are compare by their positive byte value (0..255). A blob and a tree with the same name will not compare equal.
public static CompareNames ( byte a, byte b, int lastA, int lastB ) : int
a byte name
b byte name
lastA int '/' if a is a tree, else NULL.
lastB int '/' if b is a tree, else NULL.
return int
Ejemplo n.º 1
0
 private static int Compare(TreeEntry t1, TreeEntry t2)
 {
     if ((((t1 != null) && (t1.Parent == null)) && (t2 != null)) && (t2.Parent == null))
     {
         return(0);
     }
     if ((t1 != null) && (t1.Parent == null))
     {
         return(-1);
     }
     if ((t2 != null) && (t2.Parent == null))
     {
         return(1);
     }
     if ((t1 == null) && (t2 == null))
     {
         return(0);
     }
     if (t1 == null)
     {
         return(1);
     }
     if (t2 == null)
     {
         return(-1);
     }
     return(Tree.CompareNames(t1.FullNameUTF8, t2.FullNameUTF8, TreeEntry.LastChar(t1), TreeEntry.LastChar(t2)));
 }
Ejemplo n.º 2
0
 public int CompareTo(TreeEntry other)
 {
     if (other != null)
     {
         return(Tree.CompareNames(NameUTF8, other.NameUTF8, LastChar(this), LastChar(other)));
     }
     return(-1);
 }
Ejemplo n.º 3
0
 private static int Compare(TreeEntry t, GitIndex.Entry i)
 {
     if ((t == null) && (i == null))
     {
         return(0);
     }
     if (t == null)
     {
         return(1);
     }
     if (i == null)
     {
         return(-1);
     }
     return(Tree.CompareNames(t.FullNameUTF8, i.NameUTF8, TreeEntry.LastChar(t), TreeEntry.LastChar(i)));
 }