/** * Get key name of this footer. * * @return key name of this footer; that is the text before the ":" on the * line footer's line. The text is decoded according to the commit's * specified (or assumed) character encoding. */ public String getKey() { return RawParseUtils.decode(enc, buffer, keyStart, keyEnd); }
/** * Parse the tagger identity from the raw buffer. * <p> * This method parses and returns the content of the tagger line, after * taking the tag's character set into account and decoding the tagger * 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. * * @return identity of the tagger (name, email) and the time the tag * was made by the tagger; null if no tagger line was found. */ public final PersonIdent getTaggerIdent() { final byte[] raw = buffer; final int nameB = RawParseUtils.tagger(raw, 0); if (nameB < 0) return null; return RawParseUtils.parsePersonIdent(raw, nameB); }
ptr--; final int msgB = RawParseUtils.commitMessage(raw, 0); final ArrayList<FooterLine> r = new ArrayList<>(4); final Charset enc = guessEncoding(); for (;;) { ptr = RawParseUtils.prevLF(raw, ptr); if (ptr <= msgB) break; // Don't parse commit headers as footer lines. break; // Stop at first paragraph break, no footers above it. final int keyEnd = RawParseUtils.endOfFooterLineKey(raw, keyStart); if (keyEnd < 0) continue; // Not a well formed footer line, skip it. int valEnd = RawParseUtils.nextLF(raw, valStart); if (raw[valEnd - 1] == '\n') valEnd--;
private static final int hexUInt32(final byte[] bs, int p, final int end) { if (8 <= end - p) return RawParseUtils.parseHexInt32(bs, p); int r = 0, n = 0; while (n < 8 && p < end) { r <<= 4; r |= RawParseUtils.parseHexInt4(bs[p++]); n++; } return r << (8 - n) * 4; }
/** * Parse the commit message and return the first "line" of it. * <p> * The first line is everything up to the first pair of LFs. This is the * "oneline" format, suitable for output in a single line display. * <p> * This method parses and returns the message portion of the commit buffer, * after taking the commit's character set into account and decoding the * buffer using that character set. This method is a fairly expensive * operation and produces a new string on each invocation. * * @return decoded commit message as a string. Never null. The returned * string does not contain any LFs, even if the first paragraph * spanned multiple lines. Embedded LFs are converted to spaces. */ public final String getShortMessage() { byte[] raw = buffer; int msgB = RawParseUtils.commitMessage(raw, 0); if (msgB < 0) { return ""; //$NON-NLS-1$ } int msgE = RawParseUtils.endOfParagraph(raw, msgB); String str = RawParseUtils.decode(guessEncoding(), raw, msgB, msgE); if (hasLF(raw, msgB, msgE)) { str = StringUtils.replaceLineBreaksWithSpace(str); } return str; }
/** * Parse the complete commit message and decode it to a string. * <p> * This method parses and returns the message portion of the commit buffer, * after taking the commit's character set into account and decoding the * buffer using that character set. This method is a fairly expensive * operation and produces a new string on each invocation. * * @return decoded commit message as a string. Never null. */ public final String getFullMessage() { byte[] raw = buffer; int msgB = RawParseUtils.commitMessage(raw, 0); if (msgB < 0) { return ""; //$NON-NLS-1$ } return RawParseUtils.decode(guessEncoding(), raw, msgB, raw.length); }
ReflogEntryImpl(byte[] raw, int pos) { oldId = ObjectId.fromString(raw, pos); pos += Constants.OBJECT_ID_STRING_LENGTH; if (raw[pos++] != ' ') throw new IllegalArgumentException( JGitText.get().rawLogMessageDoesNotParseAsLogEntry); newId = ObjectId.fromString(raw, pos); pos += Constants.OBJECT_ID_STRING_LENGTH; if (raw[pos++] != ' ') { throw new IllegalArgumentException( JGitText.get().rawLogMessageDoesNotParseAsLogEntry); } who = RawParseUtils.parsePersonIdentOnly(raw, pos); int p0 = RawParseUtils.next(raw, pos, '\t'); if (p0 >= raw.length) comment = ""; // personident has no \t, no comment present //$NON-NLS-1$ else { int p1 = RawParseUtils.nextLF(raw, p0); comment = p1 > p0 ? RawParseUtils.decode(raw, p0, p1 - 1) : ""; //$NON-NLS-1$ } }
/** * Parse the "encoding " header as a string. * <p> * Locates the "encoding " header (if present) and returns its value. * * @param b * buffer to scan. * @return the encoding header as specified in the commit; null if the * header was not present and should be assumed. * @since 4.2 */ @Nullable public static String parseEncodingName(byte[] b) { int enc = encoding(b, 0); if (enc < 0) { return null; } int lf = nextLF(b, enc); return decode(UTF_8, b, enc, lf - 1); }
ptr = RawParseUtils.committer(raw, ptr); if (ptr > 0) { ptr = RawParseUtils.nextLF(raw, ptr, '>'); commitTime = RawParseUtils.parseBase10(raw, ptr, null);
/** * Parse the author identity from the raw buffer. * <p> * This method parses and returns the content of the author line, after * taking the commit's character set into account and decoding the author * 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 * {@link org.eclipse.jgit.util.RawParseUtils} to scan the * {@link #getRawBuffer()} instead, as this will allow faster evaluation of * commits. * * @return identity of the author (name, email) and the time the commit was * made by the author; null if no author line was found. */ public final PersonIdent getAuthorIdent() { final byte[] raw = buffer; final int nameB = RawParseUtils.author(raw, 0); if (nameB < 0) return null; return RawParseUtils.parsePersonIdent(raw, nameB); }
/** * 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 * {@link org.eclipse.jgit.util.RawParseUtils} to scan the * {@link #getRawBuffer()} instead, as this will allow faster evaluation of * commits. * * @return identity of the committer (name, email) and the time the commit * was made by the committer; null if no committer line was found. */ public final PersonIdent getCommitterIdent() { final byte[] raw = buffer; final int nameB = RawParseUtils.committer(raw, 0); if (nameB < 0) return null; return RawParseUtils.parsePersonIdent(raw, nameB); }
private boolean isHex() { try { for (int i = pathOffset; i < pathLen; i++) parseHexInt4(path[i]); return true; } catch (ArrayIndexOutOfBoundsException fail) { return false; } } }
private void fromHexString(byte[] bs, int p) { try { w1 = RawParseUtils.parseHexInt32(bs, p); w2 = RawParseUtils.parseHexInt32(bs, p + 8); w3 = RawParseUtils.parseHexInt32(bs, p + 16); w4 = RawParseUtils.parseHexInt32(bs, p + 24); w5 = RawParseUtils.parseHexInt32(bs, p + 32); } catch (ArrayIndexOutOfBoundsException e1) { throw new InvalidObjectIdException(bs, p, Constants.OBJECT_ID_STRING_LENGTH); } }
void parseHeader() { // Parse "@@ -236,9 +236,9 @@ protected boolean" // final byte[] buf = file.buf; final MutableInteger ptr = new MutableInteger(); ptr.value = nextLF(buf, startOffset, ' '); old.startLine = -parseBase10(buf, ptr.value, ptr); if (buf[ptr.value] == ',') old.lineCount = parseBase10(buf, ptr.value + 1, ptr); else old.lineCount = 1; newStartLine = parseBase10(buf, ptr.value + 1, ptr); if (buf[ptr.value] == ',') newLineCount = parseBase10(buf, ptr.value + 1, ptr); else newLineCount = 1; }