GitSharp.Core.Commit.Decode C# (CSharp) Метод

Decode() приватный Метод

private Decode ( ) : void
Результат void
        private void Decode()
        {
            if (_raw == null) return;

            int pos = 0;

            ByteArrayExtensions.ParsedLine res = _raw.ReadLine(pos);
            if (res.Buffer == null || !res.Buffer.StartsWith("tree ".getBytes()))
            {
                throw new CorruptObjectException(CommitId, "no tree");
            }

            bool skip;
            do
            {
                skip = false;

                res = _raw.ReadLine(res.NextIndex);

                if ((res.Buffer == null) || !res.Buffer.StartsWith("parent ".getBytes()))
                {
                    skip = true;
                }

            } while (!skip);

            const string authorPrefix = "author ";
            if (res.Buffer == null || !res.Buffer.StartsWith(authorPrefix.getBytes()))
            {
                throw new CorruptObjectException(CommitId, "no author");
            }

            byte[] rawAuthor = ExtractTrailingBytes(res.Buffer, authorPrefix);

            res = _raw.ReadLine(res.NextIndex);

            const string committerPrefix = "committer ";
            if (res.Buffer == null || !res.Buffer.StartsWith(committerPrefix.getBytes()))
            {
                throw new CorruptObjectException(CommitId, "no committer");
            }

            byte[] rawCommitter = ExtractTrailingBytes(res.Buffer, committerPrefix);

            res = _raw.ReadLine(res.NextIndex);

            const string encodingPrefix = "encoding ";
            if (res.Buffer != null && res.Buffer.StartsWith(encodingPrefix.getBytes()))
            {
                byte[] rawEncoding = ExtractTrailingBytes(res.Buffer, encodingPrefix);
                Encoding = Charset.forName(new ASCIIEncoding().GetString(rawEncoding));
            }
            else if (res.Buffer == null || res.Buffer.Length != 0)
            {
                throw new CorruptObjectException(CommitId, "malformed header:" + new ASCIIEncoding().GetString(res.Buffer ?? new byte[0]));
            }

            pos = res.NextIndex;

            var readBuf = new byte[_raw.Length - pos];
            Array.Copy(_raw, pos, readBuf, 0, _raw.Length - pos);
            int msgstart = readBuf.Length != 0 ? (readBuf[0] == '\n' ? 1 : 0) : 0;

            // If encoding is not specified, the default for commit is UTF-8
            if (Encoding == null) Encoding = Constants.CHARSET;

            // TODO: this isn't reliable so we need to guess the encoding from the actual content
            Author = new PersonIdent(Encoding.GetString(rawAuthor));
            Committer = new PersonIdent(Encoding.GetString(rawCommitter));
            Message = Encoding.GetString(readBuf, msgstart, readBuf.Length - msgstart);

            _raw = null;
        }