private static void AssertParse(FileHeader fh) { int ptr = fh.ParseGitFileName(0, fh.buf.Length); NUnit.Framework.Assert.IsTrue(ptr > 0); ptr = fh.ParseGitHeaders(ptr, fh.buf.Length); NUnit.Framework.Assert.IsTrue(ptr > 0); }
private int ParseDiffGit(byte[] buf, int start, int end) { FileHeader fh = new FileHeader(buf, start); int ptr = fh.ParseGitFileName(start + DIFF_GIT.Length, end); if (ptr < 0) { return(SkipFile(buf, start)); } ptr = fh.ParseGitHeaders(ptr, end); ptr = ParseHunks(fh, ptr, end); fh.endOffset = ptr; AddFile(fh); return(ptr); }
public virtual void TestParseCopy100() { FileHeader fh = Data("diff --git a/a b/ c/\\303\\205ngstr\\303\\266m\n" + "similarity index 100%\n" + "copy from a\n" + "copy to \" c/\\303\\205ngstr\\303\\266m\"\n"); int ptr = fh.ParseGitFileName(0, fh.buf.Length); NUnit.Framework.Assert.IsTrue(ptr > 0); NUnit.Framework.Assert.IsNull(fh.GetOldPath()); // can't parse names on a copy NUnit.Framework.Assert.IsNull(fh.GetNewPath()); ptr = fh.ParseGitHeaders(ptr, fh.buf.Length); NUnit.Framework.Assert.IsTrue(ptr > 0); NUnit.Framework.Assert.AreEqual("a", fh.GetOldPath()); NUnit.Framework.Assert.AreEqual(" c/\u00c5ngstr\u00f6m", fh.GetNewPath()); NUnit.Framework.Assert.AreEqual(DiffEntry.ChangeType.COPY, fh.GetChangeType()); NUnit.Framework.Assert.AreEqual(FileHeader.PatchType.UNIFIED, fh.GetPatchType()); NUnit.Framework.Assert.IsTrue(fh.HasMetaDataChanges()); NUnit.Framework.Assert.IsNull(fh.GetOldId()); NUnit.Framework.Assert.IsNull(fh.GetNewId()); NUnit.Framework.Assert.IsNull(fh.GetOldMode()); NUnit.Framework.Assert.IsNull(fh.GetNewMode()); NUnit.Framework.Assert.AreEqual(100, fh.GetScore()); }
private int ParseDiffGit(byte[] buf, int start, int end) { FileHeader fh = new FileHeader(buf, start); int ptr = fh.ParseGitFileName(start + DIFF_GIT.Length, end); if (ptr < 0) { return SkipFile(buf, start); } ptr = fh.ParseGitHeaders(ptr, end); ptr = ParseHunks(fh, ptr, end); fh.endOffset = ptr; AddFile(fh); return ptr; }