List of usage examples for org.eclipse.jgit.patch FileHeader getStartOffset
public int getStartOffset()
From source file:com.google.gerrit.server.patch.PatchListEntry.java
License:Apache License
private static byte[] compact(final FileHeader h) { final int end = end(h); if (h.getStartOffset() == 0 && end == h.getBuffer().length) { return h.getBuffer(); }/* w w w .j a v a 2 s .co m*/ final byte[] buf = new byte[end - h.getStartOffset()]; System.arraycopy(h.getBuffer(), h.getStartOffset(), buf, 0, buf.length); return buf; }
From source file:com.google.gerrit.server.patch.PatchListEntry.java
License:Apache License
private static PatchType toPatchType(final FileHeader hdr) { PatchType pt;/* w w w . j a va 2 s . c om*/ switch (hdr.getPatchType()) { case UNIFIED: pt = Patch.PatchType.UNIFIED; break; case GIT_BINARY: case BINARY: pt = Patch.PatchType.BINARY; break; default: throw new IllegalArgumentException("Unsupported type " + hdr.getPatchType()); } if (pt != PatchType.BINARY) { final byte[] buf = hdr.getBuffer(); for (int ptr = hdr.getStartOffset(); ptr < hdr.getEndOffset(); ptr++) { if (buf[ptr] == '\0') { // Its really binary, but Git couldn't see the nul early enough // to realize its binary, and instead produced the diff. // // Force it to be a binary; it really should have been that. // pt = PatchType.BINARY; break; } } } return pt; }
From source file:com.google.gitiles.HtmlDiffFormatter.java
License:Open Source License
@Override public void format(FileHeader hdr, RawText a, RawText b) throws IOException { int start = hdr.getStartOffset(); int end = hdr.getEndOffset(); if (!hdr.getHunks().isEmpty()) { end = hdr.getHunks().get(0).getStartOffset(); }/*from ww w. j av a2s. com*/ renderHeader(RawParseUtils.decode(hdr.getBuffer(), start, end)); if (hdr.getPatchType() == PatchType.UNIFIED) { getOutputStream().write(DIFF_BEGIN); format(hdr.toEditList(), a, b); getOutputStream().write(DIFF_END); } }