/// <summary>Parse an annotated tag from its canonical format.</summary> /// <remarks> /// Parse an annotated tag from its canonical format. /// This method inserts the tag directly into the caller supplied revision /// pool, making it appear as though the tag exists in the repository, even /// if it doesn't. The repository under the pool is not affected. /// </remarks> /// <param name="rw"> /// the revision pool to allocate the tag within. The tag's object /// pointer will be obtained from this pool. /// </param> /// <param name="raw">the canonical formatted tag to be parsed.</param> /// <returns> /// the parsed tag, in an isolated revision pool that is not /// available to the caller. /// </returns> /// <exception cref="NGit.Errors.CorruptObjectException">the tag contains a malformed header that cannot be handled. /// </exception> public static NGit.Revwalk.RevTag Parse(RevWalk rw, byte[] raw) { ObjectInserter.Formatter fmt = new ObjectInserter.Formatter(); bool retain = rw.IsRetainBody(); rw.SetRetainBody(true); NGit.Revwalk.RevTag r = rw.LookupTag(fmt.IdFor(Constants.OBJ_TAG, raw)); r.ParseCanonical(rw, raw); rw.SetRetainBody(retain); return(r); }
/// <exception cref="NGit.Errors.CorruptObjectException"></exception> internal virtual void ParseCanonical(RevWalk walk, byte[] rawTag) { MutableInteger pos = new MutableInteger(); int oType; pos.value = 53; // "object $sha1\ntype " oType = Constants.DecodeTypeString(this, rawTag, unchecked ((byte)'\n'), pos); walk.idBuffer.FromString(rawTag, 7); @object = walk.LookupAny(walk.idBuffer, oType); int p = pos.value += 4; // "tag " int nameEnd = RawParseUtils.NextLF(rawTag, p) - 1; tagName = RawParseUtils.Decode(Constants.CHARSET, rawTag, p, nameEnd); if (walk.IsRetainBody()) { buffer = rawTag; } flags |= PARSED; }
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; }
/// <exception cref="NGit.Errors.CorruptObjectException"></exception> internal virtual void ParseCanonical(RevWalk walk, byte[] rawTag) { MutableInteger pos = new MutableInteger(); int oType; pos.value = 53; // "object $sha1\ntype " oType = Constants.DecodeTypeString(this, rawTag, unchecked((byte)'\n'), pos); walk.idBuffer.FromString(rawTag, 7); @object = walk.LookupAny(walk.idBuffer, oType); int p = pos.value += 4; // "tag " int nameEnd = RawParseUtils.NextLF(rawTag, p) - 1; tagName = RawParseUtils.Decode(Constants.CHARSET, rawTag, p, nameEnd); if (walk.IsRetainBody()) { buffer = rawTag; } flags |= PARSED; }
/// <summary>Parse an annotated tag from its canonical format.</summary> /// <remarks> /// Parse an annotated tag from its canonical format. /// This method inserts the tag directly into the caller supplied revision /// pool, making it appear as though the tag exists in the repository, even /// if it doesn't. The repository under the pool is not affected. /// </remarks> /// <param name="rw"> /// the revision pool to allocate the tag within. The tag's object /// pointer will be obtained from this pool. /// </param> /// <param name="raw">the canonical formatted tag to be parsed.</param> /// <returns> /// the parsed tag, in an isolated revision pool that is not /// available to the caller. /// </returns> /// <exception cref="NGit.Errors.CorruptObjectException">the tag contains a malformed header that cannot be handled. /// </exception> public static NGit.Revwalk.RevTag Parse(RevWalk rw, byte[] raw) { ObjectInserter.Formatter fmt = new ObjectInserter.Formatter(); bool retain = rw.IsRetainBody(); rw.SetRetainBody(true); NGit.Revwalk.RevTag r = rw.LookupTag(fmt.IdFor(Constants.OBJ_TAG, raw)); r.ParseCanonical(rw, raw); rw.SetRetainBody(retain); return r; }
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; }