public void testReadACK_ACKcontinue1() { ObjectId expid = ObjectId.FromString("fcfcfb1fd94829c1a1704f894fc111d14770d34e"); MutableObjectId actid = new MutableObjectId(); actid.FromString(expid.Name); init("003aACK fcfcfb1fd94829c1a1704f894fc111d14770d34e continue\n"); Assert.AreEqual(PacketLineIn.AckNackResult.ACK_CONTINUE, pckIn.readACK(actid)); Assert.IsTrue(actid.Equals(expid)); assertEOF(); }
public virtual void TestReadACK_NAK() { ObjectId expid = ObjectId.FromString("fcfcfb1fd94829c1a1704f894fc111d14770d34e"); MutableObjectId actid = new MutableObjectId(); actid.FromString(expid.Name); Init("0008NAK\n"); NUnit.Framework.Assert.AreEqual(PacketLineIn.AckNackResult.NAK, @in.ReadACK(actid )); NUnit.Framework.Assert.IsTrue(actid.Equals(expid)); AssertEOF(); }
private bool ParseObjectId(MutableObjectId id) { if (pathLen == pathPadding + Constants.OBJECT_ID_STRING_LENGTH) { try { id.FromString(path, pathPadding); return(true); } catch (IndexOutOfRangeException) { return(false); } } return(false); }
/// <exception cref="System.IO.IOException"></exception> internal virtual PacketLineIn.AckNackResult ReadACK(MutableObjectId returnedId) { string line = ReadString(); if (line.Length == 0) { throw new PackProtocolException(JGitText.Get().expectedACKNAKFoundEOF); } if ("NAK".Equals(line)) { return(PacketLineIn.AckNackResult.NAK); } if (line.StartsWith("ACK ")) { returnedId.FromString(Sharpen.Runtime.Substring(line, 4, 44)); if (line.Length == 44) { return(PacketLineIn.AckNackResult.ACK); } string arg = Sharpen.Runtime.Substring(line, 44); if (arg.Equals(" continue")) { return(PacketLineIn.AckNackResult.ACK_CONTINUE); } else { if (arg.Equals(" common")) { return(PacketLineIn.AckNackResult.ACK_COMMON); } else { if (arg.Equals(" ready")) { return(PacketLineIn.AckNackResult.ACK_READY); } } } } if (line.StartsWith("ERR ")) { throw new PackProtocolException(Sharpen.Runtime.Substring(line, 4)); } throw new PackProtocolException(MessageFormat.Format(JGitText.Get().expectedACKNAKGot , line)); }
public AckNackResult readACK(MutableObjectId returnedId) { string line = ReadString(); if (line.Length == 0) { throw new PackProtocolException("Expected ACK/NAK, found EOF"); } if ("NAK".Equals(line)) { return(AckNackResult.NAK); } if (line.StartsWith("ACK ")) { returnedId.FromString(line.Slice(4, 44)); if (line.IndexOf("continue", 44) != -1) { return(AckNackResult.ACK_CONTINUE); } return(AckNackResult.ACK); } throw new PackProtocolException("Expected ACK/NAK, got: " + line); }
public AckNackResult readACK(MutableObjectId returnedId) { string line = ReadString(); if (line.Length == 0) { throw new PackProtocolException("Expected ACK/NAK, found EOF"); } if ("NAK".Equals(line)) { return(AckNackResult.NAK); } if (line.StartsWith("ACK ")) { returnedId.FromString(line.Slice(4, 44)); if (line.Length == 44) { return(AckNackResult.ACK); } string arg = line.Substring(44); if (arg.Equals(" continue")) { return(AckNackResult.ACK_CONTINUE); } else if (arg.Equals(" common")) { return(AckNackResult.ACK_COMMON); } else if (arg.Equals(" ready")) { return(AckNackResult.ACK_READY); } } throw new PackProtocolException("Expected ACK/NAK, got: " + line); }
public AckNackResult readACK(MutableObjectId returnedId) { string line = ReadString(); if (line.Length == 0) throw new PackProtocolException("Expected ACK/NAK, found EOF"); if ("NAK".Equals(line)) return AckNackResult.NAK; if (line.StartsWith("ACK ")) { returnedId.FromString(line.Slice(4, 44)); if (line.IndexOf("continue", 44) != -1) { return AckNackResult.ACK_CONTINUE; } return AckNackResult.ACK; } throw new PackProtocolException("Expected ACK/NAK, got: " + line); }
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; }
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; }
public AckNackResult readACK(MutableObjectId returnedId) { string line = ReadString(); if (line.Length == 0) throw new PackProtocolException("Expected ACK/NAK, found EOF"); if ("NAK".Equals(line)) return AckNackResult.NAK; if (line.StartsWith("ACK ")) { returnedId.FromString(line.Slice(4, 44)); if (line.Length == 44) return AckNackResult.ACK; string arg = line.Substring(44); if (arg.Equals(" continue")) return AckNackResult.ACK_CONTINUE; else if (arg.Equals(" common")) return AckNackResult.ACK_COMMON; else if (arg.Equals(" ready")) return AckNackResult.ACK_READY; } throw new PackProtocolException("Expected ACK/NAK, got: " + line); }