示例#1
0
        ///	<summary>
        /// Parse the committer identity from the raw buffer.
        /// <para />
        /// This method parses and returns the content of the committer line, after
        /// taking the commit's character set into account and decoding the committer
        /// name and email address. This method is fairly expensive and produces a
        /// new PersonIdent instance on each invocation. Callers should invoke this
        /// method only if they are certain they will be outputting the result, and
        /// should cache the return value for as long as necessary to use all
        /// information from it.
        /// <para />
        /// <see cref="RevFilter"/> implementations should try to use <seealso cref="RawParseUtils"/> to scan
        /// the <seealso cref="RawBuffer"/> instead, as this will allow faster evaluation
        /// of commits.
        /// </summary>
        /// <returns>
        /// Identity of the committer (name, email) and the time the commit
        /// was made by the committer; null if no committer line was found.
        /// </returns>
        public PersonIdent getCommitterIdent()
        {
            byte[] raw   = _buffer;
            int    nameB = RawParseUtils.committer(raw, 0);

            if (nameB < 0)
            {
                return(null);
            }
            return(RawParseUtils.parsePersonIdent(raw, nameB));
        }
示例#2
0
        private static string TextFor(RevCommit cmit)
        {
            byte[] raw = cmit.RawBuffer;
            int    b   = RawParseUtils.committer(raw, 0);

            if (b < 0)
            {
                return(string.Empty);
            }
            int e = RawParseUtils.nextLF(raw, b, (byte)'>');

            return(Constants.CHARSET.GetString(raw, b, e));
        }
示例#3
0
        public void parseCanonical(RevWalk walk, byte[] raw)
        {
            MutableObjectId idBuffer = walk.IdBuffer;

            idBuffer.FromString(raw, 5);
            _tree = walk.lookupTree(idBuffer);

            int ptr = 46;

            if (Parents == null)
            {
                var pList    = new RevCommit[1];
                int nParents = 0;

                while (true)
                {
                    if (raw[ptr] != (byte)'p')
                    {
                        break;
                    }
                    idBuffer.FromString(raw, ptr + 7);
                    RevCommit p = walk.lookupCommit(idBuffer);
                    if (nParents == 0)
                    {
                        pList[nParents++] = p;
                    }
                    else if (nParents == 1)
                    {
                        pList    = new[] { pList[0], p };
                        nParents = 2;
                    }
                    else
                    {
                        if (pList.Length <= nParents)
                        {
                            RevCommit[] old = pList;
                            pList = new RevCommit[pList.Length + 32];
                            Array.Copy(old, 0, pList, 0, nParents);
                        }
                        pList[nParents++] = p;
                    }
                    ptr += 48;
                }
                if (nParents != pList.Length)
                {
                    RevCommit[] old = pList;
                    pList = new RevCommit[nParents];
                    Array.Copy(old, 0, pList, 0, nParents);
                }
                Parents = pList;
            }

            // extract time from "committer "
            ptr = RawParseUtils.committer(raw, ptr);
            if (ptr > 0)
            {
                ptr = RawParseUtils.nextLF(raw, ptr, (byte)'>');

                // In 2038 commitTime will overflow unless it is changed to long.
                CommitTime = RawParseUtils.parseBase10(raw, ptr, null);
            }

            if (walk.isRetainBody())
            {
                _buffer = raw;
            }
            Flags |= PARSED;
        }