示例#1
0
 private void Resort()
 {
     Arrays.Sort(entries, 0, entryCnt, DirCache.ENT_CMP);
     for (int entryIdx = 1; entryIdx < entryCnt; entryIdx++)
     {
         DirCacheEntry pe = entries[entryIdx - 1];
         DirCacheEntry ce = entries[entryIdx];
         int           cr = DirCache.Cmp(pe, ce);
         if (cr == 0)
         {
             // Same file path; we can only allow this if the stages
             // are 1-3 and no 0 exists.
             //
             int peStage = pe.Stage;
             int ceStage = ce.Stage;
             if (peStage == ceStage)
             {
                 throw Bad(ce, JGitText.Get().duplicateStagesNotAllowed);
             }
             if (peStage == 0 || ceStage == 0)
             {
                 throw Bad(ce, JGitText.Get().mixedStagesNotAllowed);
             }
         }
     }
     sorted = true;
 }
示例#2
0
 private void BeforeAdd(DirCacheEntry newEntry)
 {
     if (sorted && entryCnt > 0)
     {
         DirCacheEntry lastEntry = entries[entryCnt - 1];
         int           cr        = DirCache.Cmp(lastEntry, newEntry);
         if (cr > 0)
         {
             // The new entry sorts before the old entry; we are
             // no longer sorted correctly. We'll need to redo
             // the sorting before we can close out the build.
             //
             sorted = false;
         }
         else
         {
             if (cr == 0)
             {
                 // Same file path; we can only insert this if the
                 // stages won't be violated.
                 //
                 int peStage  = lastEntry.Stage;
                 int dceStage = newEntry.Stage;
                 if (peStage == dceStage)
                 {
                     throw Bad(newEntry, JGitText.Get().duplicateStagesNotAllowed);
                 }
                 if (peStage == 0 || dceStage == 0)
                 {
                     throw Bad(newEntry, JGitText.Get().mixedStagesNotAllowed);
                 }
                 if (peStage > dceStage)
                 {
                     sorted = false;
                 }
             }
         }
     }
 }
示例#3
0
 public int Compare(DirCacheEditor.PathEdit o1, DirCacheEditor.PathEdit o2)
 {
     byte[] a = o1.path;
     byte[] b = o2.path;
     return(DirCache.Cmp(a, a.Length, b, b.Length));
 }