/// <summary>Parse the committer identity from the raw buffer.</summary> /// <remarks> /// Parse the committer identity from the raw buffer. /// <p> /// 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. /// <p> /// RevFilter implementations should try to use /// <see cref="NGit.Util.RawParseUtils">NGit.Util.RawParseUtils</see> /// to scan /// the /// <see cref="RawBuffer()">RawBuffer()</see> /// instead, as this will allow faster evaluation /// of commits. /// </remarks> /// <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)); }
// Don't permit us to be created. internal static RawCharSequence TextFor(RevCommit cmit) { byte[] raw = cmit.RawBuffer; int b = RawParseUtils.Committer(raw, 0); if (b < 0) { return(RawCharSequence.EMPTY); } int e = RawParseUtils.NextLF(raw, b, '>'); return(new RawCharSequence(raw, b, e)); }
internal virtual void ParseCanonical(RevWalk walk, byte[] raw) { MutableObjectId idBuffer = walk.idBuffer; idBuffer.FromString(raw, 5); tree = walk.LookupTree(idBuffer); int ptr = 46; if (parents == null) { NGit.Revwalk.RevCommit[] pList = new NGit.Revwalk.RevCommit[1]; int nParents = 0; for (; ;) { if (raw[ptr] != 'p') { break; } idBuffer.FromString(raw, ptr + 7); NGit.Revwalk.RevCommit p = walk.LookupCommit(idBuffer); if (nParents == 0) { pList[nParents++] = p; } else { if (nParents == 1) { pList = new NGit.Revwalk.RevCommit[] { pList[0], p }; nParents = 2; } else { if (pList.Length <= nParents) { NGit.Revwalk.RevCommit[] old = pList; pList = new NGit.Revwalk.RevCommit[pList.Length + 32]; System.Array.Copy(old, 0, pList, 0, nParents); } pList[nParents++] = p; } } ptr += 48; } if (nParents != pList.Length) { NGit.Revwalk.RevCommit[] old = pList; pList = new NGit.Revwalk.RevCommit[nParents]; System.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, '>'); // In 2038 commitTime will overflow unless it is changed to long. commitTime = RawParseUtils.ParseBase10(raw, ptr, null); } if (walk.IsRetainBody()) { buffer = raw; } flags |= PARSED; }