コード例 #1
0
            public Entry(byte[] raw, int pos)
            {
                oldId = ObjectId.FromString(raw, pos);
                pos  += Constants.OBJECT_ID_LENGTH * 2;
                if (raw[pos++] != ' ')
                {
                    throw new ArgumentException("Raw log message does not parse as log entry");
                }
                newId = ObjectId.FromString(raw, pos);
                pos  += Constants.OBJECT_ID_LENGTH * 2;
                if (raw[pos++] != ' ')
                {
                    throw new ArgumentException("Raw log message does not parse as log entry");
                }
                who = RawParseUtils.parsePersonIdentOnly(raw, pos);
                int p0 = RawParseUtils.next(raw, pos, (byte)'\t');

                if (p0 == -1)
                {
                    throw new ArgumentException("Raw log message does not parse as log entry");
                }

                int p1 = RawParseUtils.nextLF(raw, p0);

                if (p1 == -1)
                {
                    throw new ArgumentException("Raw log message does not parse as log entry");
                }

                comment = RawParseUtils.decode(raw, p0, p1 - 1);
            }
コード例 #2
0
        public DirCacheTree(byte[] @in, MutableInteger off, DirCacheTree myParent)
        {
            _parent = myParent;

            int ptr     = RawParseUtils.next(@in, off.value, (byte)'\0');
            int nameLen = ptr - off.value - 1;

            if (nameLen > 0)
            {
                _encodedName = new byte[nameLen];
                Array.Copy(@in, off.value, _encodedName, 0, nameLen);
            }
            else
            {
                _encodedName = NoName;
            }

            _entrySpan = RawParseUtils.parseBase10(@in, ptr, off);
            int subcnt = RawParseUtils.parseBase10(@in, off.value, off);

            off.value = RawParseUtils.next(@in, off.value, (byte)'\n');

            if (_entrySpan >= 0)
            {
                // Valid trees have a positive entry count and an id of a
                // tree object that should exist in the object database.
                //
                _id        = ObjectId.FromRaw(@in, off.value);
                off.value += Constants.OBJECT_ID_LENGTH;
            }

            if (subcnt > 0)
            {
                bool alreadySorted = true;
                _children = new DirCacheTree[subcnt];
                for (int i = 0; i < subcnt; i++)
                {
                    _children[i] = new DirCacheTree(@in, off, this);

                    // C Git's ordering differs from our own; it prefers to
                    // sort by Length first. This sometimes produces a sort
                    // we do not desire. On the other hand it may have been
                    // created by us, and be sorted the way we want.
                    //
                    if (alreadySorted && i > 0 &&
                        TreeComparison(_children[i - 1], _children[i]) > 0)
                    {
                        alreadySorted = false;
                    }
                }

                if (!alreadySorted)
                {
                    Array.Sort(_children, TreeComparison);
                }
            }
            else
            {
                // Leaf level trees have no children, only (file) entries.
                //
                _children = NoChildren;
            }
            _childCount = subcnt;
        }