/// <exception cref="NGit.Errors.UnmergedPathException"></exception>
        /// <exception cref="System.IO.IOException"></exception>
        private int ComputeSize(DirCacheEntry[] cache, int cIdx, int pathOffset, ObjectInserter
                                ow)
        {
            int endIdx   = cIdx + entrySpan;
            int childIdx = 0;
            int entryIdx = cIdx;
            int size     = 0;

            while (entryIdx < endIdx)
            {
                DirCacheEntry e = cache[entryIdx];
                if (e.Stage != 0)
                {
                    throw new UnmergedPathException(e);
                }
                byte[] ep = e.path;
                if (childIdx < childCnt)
                {
                    NGit.Dircache.DirCacheTree st = children[childIdx];
                    if (st.Contains(ep, pathOffset, ep.Length))
                    {
                        int stOffset = pathOffset + st.NameLength() + 1;
                        st.WriteTree(cache, entryIdx, stOffset, ow);
                        size     += TreeFormatter.EntrySize(FileMode.TREE, st.NameLength());
                        entryIdx += st.entrySpan;
                        childIdx++;
                        continue;
                    }
                }
                size += TreeFormatter.EntrySize(e.FileMode, ep.Length - pathOffset);
                entryIdx++;
            }
            return(size);
        }
Example #2
0
        private int TreeSize()
        {
            int sz = cnt * TreeFormatter.EntrySize(FileMode.TREE, 2);

            for (NonNoteEntry e = nonNotes; e != null; e = e.next)
            {
                sz += e.TreeEntrySize();
            }
            return(sz);
        }
Example #3
0
 internal virtual int TreeEntrySize()
 {
     return(TreeFormatter.EntrySize(mode, name.Length));
 }