internal virtual void ParseHeader() { // Parse "@@ -236,9 +236,9 @@ protected boolean" // byte[] buf = file.buf; MutableInteger ptr = new MutableInteger(); ptr.value = RawParseUtils.NextLF(buf, startOffset, ' '); old.startLine = -RawParseUtils.ParseBase10(buf, ptr.value, ptr); if (buf[ptr.value] == ',') { old.lineCount = RawParseUtils.ParseBase10(buf, ptr.value + 1, ptr); } else { old.lineCount = 1; } newStartLine = RawParseUtils.ParseBase10(buf, ptr.value + 1, ptr); if (buf[ptr.value] == ',') { newLineCount = RawParseUtils.ParseBase10(buf, ptr.value + 1, ptr); } else { newLineCount = 1; } }
internal override void ParseHeader() { // Parse "@@@ -55,12 -163,13 +163,15 @@@ protected boolean" // byte[] buf = file.buf; MutableInteger ptr = new MutableInteger(); ptr.value = RawParseUtils.NextLF(buf, startOffset, ' '); for (int n = 0; n < old.Length; n++) { old[n].startLine = -RawParseUtils.ParseBase10(buf, ptr.value, ptr); if (buf[ptr.value] == ',') { old[n].lineCount = RawParseUtils.ParseBase10(buf, ptr.value + 1, ptr); } else { old[n].lineCount = 1; } } newStartLine = RawParseUtils.ParseBase10(buf, ptr.value + 1, ptr); if (buf[ptr.value] == ',') { newLineCount = RawParseUtils.ParseBase10(buf, ptr.value + 1, ptr); } else { newLineCount = 1; } }
internal DirCacheTree(byte[] @in, MutableInteger off, NGit.Dircache.DirCacheTree myParent) { parent = myParent; int ptr = RawParseUtils.Next(@in, off.value, '\0'); int nameLen = ptr - off.value - 1; if (nameLen > 0) { encodedName = new byte[nameLen]; System.Array.Copy(@in, off.value, encodedName, 0, nameLen); } else { encodedName = NO_NAME; } entrySpan = RawParseUtils.ParseBase10(@in, ptr, off); int subcnt = RawParseUtils.ParseBase10(@in, off.value, off); off.value = RawParseUtils.Next(@in, off.value, '\n'); if (entrySpan >= 0) { // Valid trees have a positive entry count and an id of a // tree object that should exist in the object database. // id = ObjectId.FromRaw(@in, off.value); off.value += Constants.OBJECT_ID_LENGTH; } if (subcnt > 0) { bool alreadySorted = true; children = new NGit.Dircache.DirCacheTree[subcnt]; for (int i = 0; i < subcnt; i++) { children[i] = new NGit.Dircache.DirCacheTree(@in, off, this); // C Git's ordering differs from our own; it prefers to // sort by length first. This sometimes produces a sort // we do not desire. On the other hand it may have been // created by us, and be sorted the way we want. // if (alreadySorted && i > 0 && TREE_CMP.Compare(children[i - 1], children[i]) > 0) { alreadySorted = false; } } if (!alreadySorted) { Arrays.Sort(children, 0, subcnt, TREE_CMP); } } else { // Leaf level trees have no children, only (file) entries. // children = NO_CHILDREN; } childCnt = subcnt; }
internal virtual int ParseHunk(int ptr, int end) { byte[] buf = file.buf; if (RawParseUtils.Match(buf, ptr, LITERAL) >= 0) { type = BinaryHunk.Type.LITERAL_DEFLATED; length = RawParseUtils.ParseBase10(buf, ptr + LITERAL.Length, null); } else { if (RawParseUtils.Match(buf, ptr, DELTA) >= 0) { type = BinaryHunk.Type.DELTA_DEFLATED; length = RawParseUtils.ParseBase10(buf, ptr + DELTA.Length, null); } else { // Not a valid binary hunk. Signal to the caller that // we cannot parse any further and that this line should // be treated otherwise. // return(-1); } } ptr = RawParseUtils.NextLF(buf, ptr); // Skip until the first blank line; that is the end of the binary // encoded information in this hunk. To save time we don't do a // validation of the binary data at this point. // while (ptr < end) { bool empty = (buf[ptr] == '\n') || (buf[ptr] == '\r' && ptr + 1 < end && buf[ptr + 1] == '\n'); ptr = RawParseUtils.NextLF(buf, ptr); if (empty) { break; } } return(ptr); }
private int PersonIdent(byte[] raw, int ptr) { int emailB = RawParseUtils.NextLF(raw, ptr, '<'); if (emailB == ptr || raw[emailB - 1] != '<') { return(-1); } int emailE = RawParseUtils.NextLF(raw, emailB, '>'); if (emailE == emailB || raw[emailE - 1] != '>') { return(-1); } if (emailE == raw.Length || raw[emailE] != ' ') { return(-1); } RawParseUtils.ParseBase10(raw, emailE + 1, ptrout); // when ptr = ptrout.value; if (emailE + 1 == ptr) { return(-1); } if (ptr == raw.Length || raw[ptr] != ' ') { return(-1); } RawParseUtils.ParseBase10(raw, ptr + 1, ptrout); // tz offset if (ptr + 1 == ptrout.value) { return(-1); } return(ptrout.value); }
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; }
internal virtual int ParseGitHeaders(int ptr, int end) { while (ptr < end) { int eol = RawParseUtils.NextLF(buf, ptr); if (IsHunkHdr(buf, ptr, eol) >= 1) { // First hunk header; break out and parse them later. break; } else { if (RawParseUtils.Match(buf, ptr, OLD_NAME) >= 0) { ParseOldName(ptr, eol); } else { if (RawParseUtils.Match(buf, ptr, NEW_NAME) >= 0) { ParseNewName(ptr, eol); } else { if (RawParseUtils.Match(buf, ptr, OLD_MODE) >= 0) { oldMode = ParseFileMode(ptr + OLD_MODE.Length, eol); } else { if (RawParseUtils.Match(buf, ptr, NEW_MODE) >= 0) { newMode = ParseFileMode(ptr + NEW_MODE.Length, eol); } else { if (RawParseUtils.Match(buf, ptr, DELETED_FILE_MODE) >= 0) { oldMode = ParseFileMode(ptr + DELETED_FILE_MODE.Length, eol); newMode = FileMode.MISSING; changeType = DiffEntry.ChangeType.DELETE; } else { if (RawParseUtils.Match(buf, ptr, NEW_FILE_MODE) >= 0) { ParseNewFileMode(ptr, eol); } else { if (RawParseUtils.Match(buf, ptr, COPY_FROM) >= 0) { oldPath = ParseName(oldPath, ptr + COPY_FROM.Length, eol); changeType = DiffEntry.ChangeType.COPY; } else { if (RawParseUtils.Match(buf, ptr, COPY_TO) >= 0) { newPath = ParseName(newPath, ptr + COPY_TO.Length, eol); changeType = DiffEntry.ChangeType.COPY; } else { if (RawParseUtils.Match(buf, ptr, RENAME_OLD) >= 0) { oldPath = ParseName(oldPath, ptr + RENAME_OLD.Length, eol); changeType = DiffEntry.ChangeType.RENAME; } else { if (RawParseUtils.Match(buf, ptr, RENAME_NEW) >= 0) { newPath = ParseName(newPath, ptr + RENAME_NEW.Length, eol); changeType = DiffEntry.ChangeType.RENAME; } else { if (RawParseUtils.Match(buf, ptr, RENAME_FROM) >= 0) { oldPath = ParseName(oldPath, ptr + RENAME_FROM.Length, eol); changeType = DiffEntry.ChangeType.RENAME; } else { if (RawParseUtils.Match(buf, ptr, RENAME_TO) >= 0) { newPath = ParseName(newPath, ptr + RENAME_TO.Length, eol); changeType = DiffEntry.ChangeType.RENAME; } else { if (RawParseUtils.Match(buf, ptr, SIMILARITY_INDEX) >= 0) { score = RawParseUtils.ParseBase10(buf, ptr + SIMILARITY_INDEX.Length, null); } else { if (RawParseUtils.Match(buf, ptr, DISSIMILARITY_INDEX) >= 0) { score = RawParseUtils.ParseBase10(buf, ptr + DISSIMILARITY_INDEX.Length, null); } else { if (RawParseUtils.Match(buf, ptr, INDEX) >= 0) { ParseIndexLine(ptr + INDEX.Length, eol); } else { // Probably an empty patch (stat dirty). break; } } } } } } } } } } } } } } } } ptr = eol; } return(ptr); }